On Dec 11, 6:36 am, "Jeremy Dunck" <jdu...@gmail.com> wrote:
> I'd like to make sure I understand what we're talking about here.
>
> model_instance.delete() nulls any instances with nullable FKs to the
> deleted instance, right?
>
> The problem AFAICS, is that QuerySet.delete is not so careful, and
> deletes all FK records, even if they are nullable?
>
> And was it always so, or was this introduced in QuerySet-refactor, or
> at some other time?  I don't see a mention on
> BackwardsIncompatibleChanges and friends.

As of r8165 of Django (post qs-refactor), model_instance.delete() does
*not* null out instances with nullable foreign keys that point to the
about-to-be deleted instance.  It deletes them instead.  We have a
special field called NullableForeignKey that we use on models where we
want the field to be nulled out when the object pointed to is
deleted.  I've pasted the impl. here: http://dpaste.com/98186/ , along
with some tests to show how to use it.

I'm not sure if Django has made changes internally to fix this post
r8165 -- we're going to make the 1.0 jump in the next few weeks, and
I'll take a look at it at that point.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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