KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a fairly simple model that uses Django Taggit for tagging. Everything works great, but now I'd like to expand some functionality and I'm a little confused. What I want is two views. One that shows all my tags in the system. One that shows all the content from my app with a specific tag. What makes sense to me is to do the following for each view. in views.py for myapp All Tags from myapp.models import App from taggit.models import Tag class TagList(ListView): """ Get all the tags in the db """ queryset = Tag.objects.all() template_name = "myapp/TagList.html" paginate_by = 10 All content for a Tag from myapp.models import App from taggit.models import Tag class TaggedList(ListView): """ Get all the contet for a tag """ template_name = "myapp/TaggedList.html" def get_object(self): return get_list_or_404(App, tag__iexact=self.kwargs['tag']) Have I lost my mind or is it really that easy? BTW, I'm using generic class views. Thanks for the help. Dave
Tags (comma-separated)
Save Edits
Cancel