I've now had to learn this the hard way by having real live data
deleted from my database on two production projects and it pisses me
off big time every time.

I can accept that NOT nullable foreign relations cascade the delete
but not if they have null=True on them. Example:

class Survey(Models):
    ...

class Analysis(Models):
    survey = ForeignKey(Survey, null=True)

Just looking at that it's to be fairly obvious that on deleting a
Survey instance it should nullify the foreign key relation on the
Analysis model. Not delete it!


On a perhaps unrelated note is it a bug that I can't prevent this with
signals? This doesn't work:

def disconnect(sender, instance, **kwargs):
    for each in Analysis.objects.filter(survey=instance):
        each.survey = None
        each.save()

pre_delete.connect(disconnect, sender=Survey)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to