This is probably a stupid question but I downloaded Django-taggit
and the docs mentioned adding a TaggableManager
manager to the each model I want to associate. This is fine, but what about models from external apps I "pip-ed"? What's the best way to use taggit with these models?
Asked
Active
Viewed 714 times
3

goh
- 27,631
- 28
- 89
- 151
3 Answers
2
You could subclass the model in the external app in one of your own apps, that would probably be a reasonable solution, i.e.
from someapp.models import SomeModel
from taggit.managers import TaggableManager
class SomeModelTagged(SomeModel):
tags = TaggableManager()
Then in the views where you used SomeModel from the external app you would have to use your new model instead.

Marc-Olivier Titeux
- 1,209
- 3
- 13
- 24

tijs
- 797
- 7
- 24
2
You can easily register model from any of your external apps with taggit. Assume the name of the model is Item.
from taggit.managers import TaggableManager
from external_app.models import Item
Item.add_to_class('tags', TaggableManager())
And then you can use taggit in usual way.
i = Item.objects.get(pk=1)
i.tags.add("wassup")
i.tags.all()

Akshar Raaj
- 14,231
- 7
- 51
- 45
0
You could have pip install the editable version with (-e VCS+REPOS_URL[@REV]#egg=PACKAGE) and add the django-taggable integration yourself.

RyanBrady
- 6,633
- 4
- 27
- 32
-
I'm guessing he wants to avoid just that. With django-taggi*ng* you can register the model but I haven't tested whether you can do the registering outside of the app to be registered. – kaleissin Dec 28 '11 at 21:10