Hi, I'm trying to figure out the way django deletes models so that I
can clear the correct references that I need to prior to deleting. So
I have models set up with overrided delete functions so that I can do
clears before the actual delete. However, it appears the delete
functions in a model don't get called in the cascade of deletes so not
each child model gets to do it's clear of linked data before
deleting.
def model1(models.Model):
def delete(self):
self.related_model.clear()
super(model1, self).delete()
def model2(models.Model):
model2 = models.ForeignKey(model2)
def delete(self):
self.another_related_model.clear()
super(model2, self).delete()
So if I do model1.delete() then it will do it's clear but it appears
it won't do the clear from model2? Am I getting this behaviour right
or am I doing something wrong here?
The model class seems like the best place to put delete logic in so
that when it's deleted it clears any data it needs to first.
- Tom
--
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en.