diff options
author | lxf <sng@luxagraf.net> | 2021-01-07 16:49:29 -0500 |
---|---|---|
committer | lxf <sng@luxagraf.net> | 2021-01-07 16:49:29 -0500 |
commit | e61f3d2c4537a2670c40b33eb02231a71dfb028a (patch) | |
tree | 587120b5a497c9e70d46e3eae7d1a219b5d4858b /app/posts/views/guide_views.py | |
parent | 534fcd39b1e8d24556d3bf110245a7373ee0eeb6 (diff) |
added a photograpy section by tweaking Category model and then adding
some urls
Diffstat (limited to 'app/posts/views/guide_views.py')
-rw-r--r-- | app/posts/views/guide_views.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/posts/views/guide_views.py b/app/posts/views/guide_views.py index 3d7ca86..d9503db 100644 --- a/app/posts/views/guide_views.py +++ b/app/posts/views/guide_views.py @@ -21,6 +21,21 @@ class GuideListView(PaginatedListView): queryset = super(GuideListView, self).get_queryset() return queryset.filter(status__exact=1).filter(post_type__in=[PostType.REVIEW,PostType.FIELD_TEST]).order_by('-pub_date').prefetch_related('location').prefetch_related('featured_image') +class GuideTopicListView(GuideListView): + """ + Return a list of Posts by topic in reverse chronological order + """ + template_name = "posts/guide_by_topic.html" + + def get_queryset(self): + queryset = super(GuideTopicListView, self).get_queryset() + topic = Category.objects.get(slug=self.kwargs['topic']) + return queryset.filter(status__exact=1).filter(topics__slug=topic).order_by('-pub_date').prefetch_related('featured_image') + + def get_context_data(self, **kwargs): + context = super(GuideTopicListView, self).get_context_data(**kwargs) + context['topic'] = Category.objects.get(slug=self.kwargs['topic']) + return context class ReviewsListView(GuideListView): template_name = "posts/post.html" |