Open GoogleCodeExporter opened 9 years ago
Original comment by jonathan.buchanan
on 30 Oct 2008 at 2:44
I would like this also!
Original comment by phoebebr...@gmail.com
on 11 Aug 2009 at 12:47
Here's the handler to do it for all models. Since it deletes TaggedItems for
ALL deleted model instances (with an integer primary key, since those are the
only model types you can tag), it's pretty heavy handed. But you only have to
write this handler once and connect it once.
from django.contrib.contenttypes.models import ContentType
from django.db.models import signals
from tagging.models import TaggedItem
def taggeditem_delete(sender, **kwargs):
deleted = kwargs['instance']
try:
id = int(deleted.pk)
except ValueError:
return
ctype = ContentType.objects.get_for_model(deleted)
item_tags = TaggedItem.objects.filter(
content_type=ctype,
object_id=id,
)
item_tags.delete()
signals.post_delete.connect(taggeditem_delete)
Original comment by john.kur...@gmail.com
on 9 Oct 2010 at 1:10
Original issue reported on code.google.com by
n.le...@gmail.com
on 17 Sep 2008 at 12:52