Add detail page for tags
This commit is contained in:
parent
7d700bea36
commit
d59fb154b6
6 changed files with 48 additions and 2 deletions
|
|
@ -0,0 +1,21 @@
|
|||
# Copyright (C) 2021 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.views.generic import DetailView
|
||||
from taggit.models import Tag
|
||||
from photologue.models import Gallery
|
||||
|
||||
|
||||
class TagDetail(LoginRequiredMixin, DetailView):
|
||||
model = Tag
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""
|
||||
Insert the single object into the context dict.
|
||||
"""
|
||||
current_tag = self.get_object().slug
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['galleries'] = Gallery.objects.on_site().is_public() \
|
||||
.filter(extended__tags__name=current_tag)
|
||||
return context
|
||||
Loading…
Add table
Add a link
Reference in a new issue