Django models: mutual references between two classes and impossibility to use forward declaration in python
You can find the solution in the docs:
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:
class Car(models.Model): manufacturer = models.ForeignKey('Manufacturer') # ...class Manufacturer(models.Model): # ...