Reputation: 645
I'm trying to integrate django-shop with a simple django installation but it gives my following error :
django.core.exceptions.ImproperlyConfigured: Deferred foreign key 'OrderPayment.order' has not been mapped
I even tried creating the OrderPayment model as referred in docs as below but still I got no luck.
class OrderPayment(models.Model):
id = models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')
order = models.ForeignKey(on_delete=models.deletion.CASCADE, to=Order, verbose_name='Order')
class Meta():
verbose_name = "Order Payment"
Upvotes: 0
Views: 503
Reputation: 21
You either have to implement your materialized models first or to import the defaults models in your shop implementation. See this link: http://django-shop.readthedocs.io/en/latest/reference/deferred-models.html
Edit: The defaults models are located in the shop/models/defaults directory. You can either import them in your shop implementation or copy them and modify them to fit your project needs.
shop/models/defaults/__init__.py says:
The models in directory default have been added as a pure convenience and for demonstration purpose. Whenever there is a need to use a modified version, copy one of these models into the projects model directory and adopt it to your needs. Otherwise just import the model into your own models.py file without using it. The latter is important to materialize the model.
Each model is declared in its own file. This is to prevent model validation errors on related fields if a file containing this definition is imported without using the model.
Upvotes: 2