1👍
✅
You should use string of model instead of model class itself to refer to the foreign key. It’s specially true when you have definition sequence problem. Quoting from django doc foreign key section:
If you need to create a relationship on a model that has not yet been
defined, you can use the name of the model, rather than the model
object itself:from django.db import models class Car(models.Model): manufacturer = models.ForeignKey( 'Manufacturer', on_delete=models.CASCADE, ) # ... class Manufacturer(models.Model): # ... pass
0👍
You’ll need to specify the TranslatorLanguage
model as a string, since it is defined later in models.py
, like this:
languages = models.ManyToManyField(Language, through='TranslatorLanguage')
- Creating a header image with bootstrap
- How do we tell where a django redirect comes from
- Django seems to work asyncroniously for some reason
Source:stackexchange.com