Reputation: 1081
I am little new to django and trying to find best ways to do things instead of writing everything myself. I am working on a model where I need multiple types of tags to be associated with a model and then I want to retrieve the objects using multiple filtering criteria. I see that in django-tagging tags are stored per model so I think its not possible to have multiple tags per model. Ex:
class Place( model ):
category = TagField() # fun, play, learn, relax
sport = TagField() # boating, hunting, fishing
Is it possible to do this using django-tagging ? Am I missing something since this looks pretty common usecase to me.
Upvotes: 2
Views: 601
Reputation: 34142
Seems like you're talking about so-called machine tags. These are tags with namespaces and/or values. (Flickr uses this approach: it allows us to tag photo with, say, upcoming:event=81334
, and will display this tag as a link to Upcoming event.)
There is an issue for django-tagging, filed back in 2007: see code.google.com/p/django-tagging/issues/detail?id=14.
No comments by core maintainers, unfortunately. However, there's a ‘machinetags’ branch mantained by Gregor Müllegger here: https://code.launchpad.net/~gregor-muellegger/django-tagging/machinetags/.
It's mostly in sync with the django-tagging trunk (the latest commit a number of commits is missing though). I remember myself working on some project using that branch about a year ago; it worked fine. Read the documentation on branch and comments on the issue for more details.
Upvotes: 1
Reputation: 16377
I'm not experienced in django-tagging, but looking at its models:
http://code.google.com/p/django-tagging/source/browse/trunk/tagging/models.py#456
it's obvious that you can only attach tags to models but there are no multiple tag groups per model. Writing this, you might be successfull in tagging tags themselves, although this is not the best design one could imagine :)
Upvotes: 1