Always list all years in archive views

This commit is contained in:
Alexandre Iooss 2022-04-17 09:39:30 +02:00
parent 3afbc2b7e1
commit f29719ef78
3 changed files with 30 additions and 19 deletions

View file

@ -37,6 +37,12 @@ class GalleryDateView(LoginRequiredMixin):
else:
return qs.filter(photos__is_public=True).distinct()
def get_context_data(self, **kwargs):
"""Always show all years in archive"""
context = super().get_context_data(**kwargs)
context['date_list'] = self.get_queryset().dates(self.date_field, 'year', 'DESC')
return context
class GalleryArchiveIndexView(GalleryDateView, ArchiveIndexView):
pass