Yes, Django always cascades deletes. There's talk about providing more options in a future release, but for now it's kind of a problem. I generally find this behavior potentially catastrophic, so I wrote an intermediate model base class that clears all nullable foreign keys before deleting an object:
http://www.djangosnippets.org/snippets/1231/ Note that this probably won't stop the admin app from warning about the anticipated cascade. On Oct 7, 2009, at 6:37 AM, x_O wrote: > > Hi > > My question that I'm getting right that situation. I've two models: > > class First(db.models): > second_item = models.ForeignKey('Second',null=True) > ... > > class Second(db.models): > ... > > I've both models registered in admin.py as AdminModels. > > Why when I'm trying to delete some object created from "Second" class > which is RELATED to other one created from "First" class, admin is > telling me that will remove also that "First" object (relation in > ForeignKey is null). I understand that when there is null=False > attribute should remove it, by why when it is null=True? > > In my interpretation of that should just leave First object with > 'second_item' = None. > > x_O > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---