Added tagging to existing model, now how does its admin work?

Posted by Oli on Stack Overflow See other posts from Stack Overflow or by Oli
Published on 2010-04-01T12:24:00Z Indexed on 2010/04/10 16:53 UTC
Read the original article Hit count: 309

I wanted to add a StackOverflow-style tag input to a blog model of mine. This is a model that has a lot of data already in it.

class BlogPost(models.Model):
    # my blog fields

try:
    tagging.register(BlogPost)
except tagging.AlreadyRegistered:
    pass

I thought that was all I needed so I went through my old database of blog posts (this is a newly ported blog) and copied the tags in. It worked and I could display tags and filter by tag.

However, I just wrote a new BlogPost and realise there's no tag field there.

Reading the documentation (coincidentally, dry enough to be used as an antiperspirant), I found the TagField. Thinking this would just be a manager-style layer over the existing tagging register, I added it. It complained about there not being a Tag column.

I'd rather not denormalise on tags just to satisfy create an interface for inputting them. Is there a TagManager class that I can just set on the model?

    tags = TagManager() # or somesuch

© Stack Overflow or respective owner

Related posts about django

Related posts about django-tagging