[Django]-Django One to One – Don't want delete related model

7👍

You need to set the on_delete parameter.

In your case :

information = models.ForeignKey(RefereeLevel,related_name='information',blank=False,null=True,default=1, on_delete=models.SET_NULL

1👍

What you can do is to set on_delete param like

information = models.ForeignKey(RefereeLevel,related_name='information',blank=False,null=True,default=1, on_delete=models.SET_NULL)

on_delete=models.SET_NULL will set the foreign key value to null

Leave a comment