How to get django-taggit custom tags in view

I am trying to get two categories of tags to work using django-taggit on one model. Everything seems to be working right in the admin but I can't figure out how to write a view that will let me use two categories of tags.

class Photo(models.Model):
    title = models.CharField(max_length=64)
    description = models.CharField(max_length=255)
    created = models.DateTimeField(auto_now_add=True)
    image = models.ImageField(upload_to='photos/')
    submitter = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
    year = models.ManyToManyField(Year, blank=True)
    people = TaggableManager(through=TaggedPeople, verbose_name='People')
    tags = TaggableManager(through=TaggedGeneric, verbose_name='Tags')

    def __str__(self):
        return self.title

Then in my view I have

class PhotoListView(ListView):
    model = Photo
    template_name = 'photoapp/list.html'
    context_object_name = 'photos'

class PhotoTagListView(PhotoListView):
    template_name = 'photoapp/taglist.html'

    def get_tag(self):
        return self.kwargs.get('tag')

    def get_queryset(self):
        return self.model.objects.filter(tags__slug=self.get_tag())

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context["tag"] = self.get_tag()
        context["tags"] = GenericTag.objects.all().order_by('name')
        context["people"] = PeopleTag.objects.all().order_by('name')
        return context

The "tag" tag is working correctly. How do I get the "people tag" to work with a template to display all the photos with a certain person?

Back to Top