7👍
✅
You can use a string with the class name to instantiate the first model before the other has been created:
class Images(models.Model):
job=models.OneToOneField('Jobs')
image=models.ImageField()
class Jobs(models.Model):
picture=models.ForeignKey(Images, null=True)
From the docs on models:
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.
Source:stackexchange.com