On Fri, Sep 19, 2008 at 1:51 PM, dbee <[EMAIL PROTECTED]> wrote: > > I'm trying to delete a user from my admin panel. The system tells me > that it causes an integrity error by violating a foreign key > constraint ... > > What causes these kinds of errors ? > > IntegrityError at /admin/auth/user/28/delete/ > ERROR: update or delete on "mot1_campaigns" violates foreign key > constraint "$1" on "mobt1_response" DETAIL: Key (id)=(18) is still > referenced from table "mot1_response". DELETE FROM "mot1_campaigns" > WHERE "id" IN (18)
The row/object with id 18 in the "mot1_campaigns" is still stored in the table "mot1_response" where the the field is not set as null. What you could do is add an "ON DELETE CASCADE" on the foreign key in "mot1_response", if you sql-server supports that. Then when you delete, the row/object in "mot1_response" will be automatically deleted also. You can't set this from inside Django though so it's time to read the fine sql manual. If your server does not support ON DELETE CASCADE you need to delete all dependent rows/objects manually before you delete the user. HM --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---