On 19/10/10 17:16, shacker wrote: > If Django comments are attached to a record (like a news item) and > that item is deleted, the comment remains in the database. In other > words, comments don't get cascade delete treatment like foreign key > relationships do.
The django comments contrib uses the generic relation approach (part of the contenttypes contrib). So to get deletion behaviour you want, you need to define a reverse generic relation back to comment on your model for django's deletion cascade to follow the deletion in the generic case. On your own models, this is of course straightforward, but you may be stuck patching if you're commenting on models in third party apps. http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#reverse-generic-relations """ `comments = generic.GenericRelation(Comment, object_id_field="object_pk")` Note also, that if you delete an object that has a GenericRelation, any objects which have a GenericForeignKey pointing at it will be deleted as well. """ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.