On Fri, Dec 5, 2008 at 8:50 AM, Thierry <[EMAIL PROTECTED]>wrote: > > I noticed that Django handles all the referential integrity issues for > delete statements at the Python/ORM level. > - Is this documented anywhere? >
http://docs.djangoproject.com/en/dev/topics/db/queries/#deleting-objects > > Furthermore I can't seem to find a switch to turn the whole ORM/python > level referential stuff off. Is there a setting for this somewhere? (I > prefer the database to handle it) > No. Search this list for CASCADE and you'll find other threads that mention why. > > Also, there is no support for different actions upon a delete. > Basically like this ticket sais: > http://code.djangoproject.com/ticket/2288 That ticket was closed wontfix with a mention that signals should be capable of handling whatever is required here. I see there's a follow-on signals ticket with patch that is still open. It isn't clear to me whether you don't feel that the signals approach will work for you or if you feel you need whatever is provided by the still-open follow-on ticket? > I have a logging table with relations to my production tables. They > are relations but no action would be more appropriate. The only way to > do this seems to be a IntegerField, instead of a ForeignKey. Is there > any alternative. > I'm assuming you are saying when you delete something from the referenced tables you do not want entries in the logging table to be deleted? Using the signals approach you could, before the delete, find the would-be affected logging entries and fix them up so they no longer reference the to-be-deleted object. Simply nulling the affected field would lose information, so at the same time you might want to store info in another field in the logging entry to record something about the referenced deleted object and when it was deleted. Or you could take the sometimes-used approach of never deleting records but rather using a field to indicate it has been deleted. Or you could use your IntegerField instead of ForeignKey approach. So there are alternatives....which one is best for you rather depends on your own needs. Karen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---