Skip to content

Commit

Permalink
[Bug 778118] Add migration to remove document tags
Browse files Browse the repository at this point in the history
This deletes all tags that point at a document.
  • Loading branch information
mythmon committed Oct 5, 2012
1 parent d756e15 commit 32f8d04
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions migrations/174-remove-tags-from-documents.py
@@ -0,0 +1,16 @@
from django.contrib.contenttypes.models import ContentType

from taggit.models import TaggedItem

from wiki.models import Document


def run():
# Get content_type_id for Document.
content_type = ContentType.objects.get_for_model(Document)
# Get all instances of tags that point at a Document
tags = TaggedItem.objects.filter(content_type=content_type)

print 'Deleting %d tags.' % tags.count()
tags.delete()
print 'Done!'

0 comments on commit 32f8d04

Please sign in to comment.