Agree with Jordan. When you talk about CASCADE Delete to SET_NULL, those will matter when the parent table is deleted.
For Example: User Field Type UserID INT Username VARCHAR Employee Field Type Relationship … some fields User INT Foreignkey(User, Userid) In this case: 1. If you delete Employee with a related User, you don’t have to worry about cascading on User. 2. But if you delete a User, the User is already referred in multiple places in other tables. Deleting that user will create a dangling reference. Which will affect the integrity constraints. So here you set a policy to DELETE on cascade or SET_NULL on related fields. Hope this helps Regards, Parth Joshi > On 09-Nov-2019, at 7:16 PM, Nijo Joseph <[email protected]> wrote: > > Since you are deleting the child model object none of these matters. But if > you are deleting the parent model object on_delete matters. > > On Sat, 9 Nov 2019, 6:35 pm Jordan Micle, <[email protected] > <mailto:[email protected]>> wrote: > when you use foreingkey you will set these options > here, change like this > on_delete=models.SET_NULL > user = models.ForeignKey(User, null=True, on_delete=models.SET_NULL) > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/2ea6ad8b-022e-4db1-adf0-9642565eb608%40googlegroups.com > > <https://groups.google.com/d/msgid/django-users/2ea6ad8b-022e-4db1-adf0-9642565eb608%40googlegroups.com?utm_medium=email&utm_source=footer>. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAFFcXKLZaGmfBZF4rtXeKa64D%2B9QgQFW%3D_sabmsEvr5pjabLGA%40mail.gmail.com > > <https://groups.google.com/d/msgid/django-users/CAFFcXKLZaGmfBZF4rtXeKa64D%2B9QgQFW%3D_sabmsEvr5pjabLGA%40mail.gmail.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/537C2694-DD19-4CFD-AEA9-7CE219F07736%40gmail.com.

