Why do all products disappear when adding a foreign key?

models.py

class GoodImgBackend(models.Model): img=models.ImageField(upload_to='goods/backend/', blank=True) class Good(models.Model): ... это новый внешний ключ img_backend=models.ForeignKey(GoodImgBackend, blank=True) 

How do I fix that all the goods that were before adding a new foreign key?

    1 answer 1

    It was enough to add the foreign key in the ForeignKey field to null = True, i.e. as a result, the field should look like this:

     img_backend=ForeignKey(GoodImgBackend, blank=True, null=True)