#6108: send all_objects_to_be_deleted in the pre_delete signal
----------------------------------------------------------+-----------------
Reporter: Gábor Farkas <[email protected]> | Owner:
nobody
Status: new | Milestone:
Component: Core framework | Version: SVN
Resolution: | Keywords:
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
----------------------------------------------------------+-----------------
Comment (by gabor):
if anyone is planning to use above-mentioned code-snippet, please note,
that for django-1.0 it has to be changed slightly:
{{{
def delete(self):
from django.db.models.query import CollectedObjects
s = CollectedObjects()
self._collect_sub_objects(s)
#here s will contain all the objects that are planned to be deleted
if s.items() == [(type(u), { u.pk : u })]:
super(YourModel, self).delete()
else:
raise Exception("related objects found")
}}}
yes, this is a good example of why not to use private undocumented methods
(because they might change between versions...)
--
Ticket URL: <http://code.djangoproject.com/ticket/6108#comment:6>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---