I have a model Article and a model Vote with a generic foreign key to
track user votes on articles.  When a vote is deleted, I have a
post_delete hook that updates the score field on the parent article.

My problem is when I delete an article, django sometimes deletes the
generically-related votes after it deletes the article, causing my
post_delete hook to re-save the deleted article.

A decent workaround is for my post_delete hook to pass
force_update=True and catch DatabaseError when saving the article, in
case it has already been deleted.  But I think it would be nice if
django just deleted the generically-related objects first so I didn't
have to worry about this.

I've opened a ticket and submitted a patch so generically-related
children are deleted before their parents:

http://code.djangoproject.com/ticket/13416

Does anyone see any problems this could cause?  Thanks.

Ryan

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to