On Wed, Apr 29, 2009 at 03:06:37PM +0800, Vincent wrote: > The situation is, i have model A and model B, B has a foreignkey > point to A,. > > now i find that i wanna delete records of A without deleting > records of B which pointing to A.
You're trying to do something that a relational database management system is specifically designed to prevent you from doing. This would be a violation of referential integrity. If you delete the foreign key, then the records of B which refer to it would cease to be valid, destroying the integrity of your database, so the DBMS shouldn't allow you to do so. Typically, you'd configure your DBMS to disallow the deletion from A, cascade the deletion to B, or update the record in B to NULL or some default foreign key. See: <http://en.wikipedia.org/wiki/Foreign_key#Referential_Actions> This information is not specific to Django, but applies to all relational databases. Maybe someone else can tell you how to select one of the aforementioned options using Django's ORM. -- Phil Mocek --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---