Use lazy evaluated ForeignKey references to prevent future problems#155
Conversation
Starting with Django 1.7 there have been multiple people hitting #django with problems that eventually could be solved using lazy references to related models instead of class references. Teaching it this ways seems to be a good way to prevent future issues.
|
I'm just curious about this issue, could you provide some more details about this problem? Also is still the same using settings.AUTH_USER_MODEL? |
|
The problem, as far as I understand it, is that under some, relatively rare, conditions models are imported twice which screws up some internal references in Django, even though the new app loading in 1.7 should prevent that.
Last but not least, the string representation in the form class ModelA(models.Model):
fk = models.ForeignKey('someapp.ModelB')
class ModelB(models.Model):
fk = models.ForeignKey('someapp.ModelA')The foreign key definition in |
|
Thanks Markus! ❤️ |
Use lazy evaluated ForeignKey references to prevent future problems
Starting with Django 1.7 there have been multiple people hitting #django
with problems that eventually could be solved using lazy references to
related models instead of class references. Teaching it this ways seems
to be a good way to prevent future issues.