I had a post on this recently that you would probably find relevant, see: http://groups.google.com/group/django-users/browse_frm/thread/582f21486c1073eb/8af00e9c0577a5e6?lnk=gst&q=margie#8af00e9c0577a5e6
Or search for "deletion of distant related objects" in this group. I'm still somewhat confused on how to deal with this at a high level, in an environment where one has apps that are written separately from each other. For example, suppose developer A writes an app called "BookStore" that contains a Book model. Now suppose developer B integrates BookStore into his/her own "Book Club", and has a Reader model that references the Book model through a foreign key. It seems to me that if the BookStore app provides a ui for deleting books, that this has the very negative consequence of deleting Readers, which probably isn't what the Book Club developer wants. In my other post Malcolm gave me some pointers for finding all of the fields that reference a particular key. IE, if the the BookStore app wants to provide a ui for deleting Books, it could find all fields that reference Books through a foreign key, and set those foreign keys to null prior to deleting the Books. This would work, however it makes certain very nice parts of Django unusable - namely the formsets. Suppose I have a formet of books and want to use the Delete funcionality of the formset. It's not clear to me if/how I can set all fields that reference Books through a foreign key to null, prior to the automatic delete getting called. Perhaps I just have to sacrifice the automatic delete and have my own delete checkbox in the formset forms, and when I see that I set all the foreign keys to null. I am just now going into production with my app, and trying to figure out what model to present to my users. Currently I have a bunch of formsets but have told my users "Don't use Delete!" (Of course I can remove the Delete checkbox - and I will). But I'm curious what the plan going forward is for all of this. I have seen disucssion on the developers group about it but it is not clear to me if there is a plan or if it has been tabled or if it is still in discussion. Would love to hear a summary of where this might be going from any developers! I realize it is a tough problem - not complaining here. Just trying to get a grip on what do do in my own app and whether there are any changes coming and if so, what they would be and what the timeframe might be. Margie On Apr 28, 10:57 pm, Vincent <pho...@gmail.com> wrote: > Hi, > I got a problem like this: > > class A(models.Model): > id = models.AutoField(primary_key=True) > field1 = models.TextField() > > class B(models.Model): > a = models.ForeignKey(A) > field1 = models.TextField() > > then there are some records of A/B, > how can i delete records of A and do not delete records of B which have > foreignkey on A > > Maybe i could change 'a = models.ForeignKey(A)' to ' a = > models.IntegerField("A") '. > > Is it a suitable way for this problem? > > Thanks for your suggestion. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---