Forward Class Declaration In Python
I have two classes in order: class A(models): ... class B(models): a = models.ManyToManyField(A) Now I have to change my model to one below: class A(models): b = mode
Solution 1:
At least SQLAlchemy allows you to use a string instead of a class. Try if django-orm allows that, too.
a = models.ManyToManyField('A')
# ...b = models.ManyToManyField('B')
Update: According to Django/Python Circular model reference that's exactly the way to go.
Post a Comment for "Forward Class Declaration In Python"