Zach, You can always run custom delete operations if you want to work around the built in cascading. Take a look at the following example to see how you can do that: http://dpaste.com/92116/
Also, note that there is a ticket to add support for ON UPDATE and ON DELETE clauses to Django[1]. Working on fixing up tickets is nearly always encouraged. :) -Joey [1] http://code.djangoproject.com/ticket/7539 On Wed, Dec 10, 2008 at 07:25, AcidTonic <[EMAIL PROTECTED]> wrote: > > Currently the cascading delete functionality requires many users to > change how their app works slightly to accommodate this "feature". > > I'm curious how people are disabling or working around this aspect of > django. > > I've heard many people are implementing custom delete() methods on the > model class...... But after reading "http://docs.djangoproject.com/en/ > dev/topics/db/queries/#deleting-objects<http://docs.djangoproject.com/en/dev/topics/db/queries/#deleting-objects>" > I found a nice little gotcha. > > "Keep in mind that this will, whenever possible, be executed purely in > SQL, and so the delete() methods of individual object instances will > not necessarily be called during the process. If you've provided a > custom delete() method on a model class and want to ensure that it is > called, you will need to "manually" delete instances of that model > (e.g., by iterating over a QuerySet and calling delete() on each > object individually) rather than using the bulk delete() method of a > QuerySet." > > So before we had a bulk delete and now to get around functionality we > dont want, we have to lose bulk deletes and do them one at a time?!? > > I'm building an application to track IP addresses on many corporate > networks with a single subnet having around 65535 rows for IP > addresses..... Now this app has thousands of those subnets which means > I have millions of rows for IP addresses. > > Since they have relationships to the parent subnet, switchports, > devices, contacts, locations, applications etc. These relationships > need to be cleared before removing the IP, because nothing else is > supposed to get deleted. > > When before I could delete 5 subnets which removed a few hundred > thousand rows in a couple seconds, now to delete a single subnet takes > upwards of 5 minutes using the "for query in queryset: query.delete()" > method. > > So unless I'm missing something it would appear django is crippling > any application not wanting a cascading delete.... Since this is an > inventory style application any missing data is extremely bad. Waiting > 5 minutes for something that used to take a few seconds is also > unacceptable. > > I'm seeking all suggestions or ideas how to keep my other models from > getting deleted, without crippling my applications performance. > > Please advise, > Zach > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---