from django.views.generic.detail import DetailView from utils.views import PaginatedListView from taggit.models import Tag from .models import Person class PersonListView(PaginatedListView): model = Person template_name = 'archives/people.html' def get_context_data(self, **kwargs): # Call the base implementation first to get a context context = super(PersonListView, self).get_context_data(**kwargs) context['tags'] = Person.tags.all() return context class PersonDetailView(DetailView): model = Person template_name = "details/person.html" slug_field = "slug" class PersonTagListView(PaginatedListView): model = Person template_name = 'archives/people.html' def get_queryset(self): print(self.kwargs['slug']) return Person.objects.filter(tags__slug=self.kwargs['slug']) def get_context_data(self, **kwargs): # Call the base implementation first to get a context context = super(PersonTagListView, self).get_context_data(**kwargs) context['tag'] = Tag.objects.get(slug__exact=self.kwargs['slug']) context['tags'] = Person.tags.all() return context