From f79cf2bc02bb560cc0d6cee4688366960ed7c5a1 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Fri, 2 Apr 2021 09:22:29 -0400 Subject: posts: added related to range detail pages --- app/posts/templates/posts/range_detail.html | 42 ++++++++++++++--------------- app/posts/views/range_views.py | 8 ++++++ 2 files changed, 28 insertions(+), 22 deletions(-) (limited to 'app/posts') diff --git a/app/posts/templates/posts/range_detail.html b/app/posts/templates/posts/range_detail.html index 008a572..15b4cd5 100644 --- a/app/posts/templates/posts/range_detail.html +++ b/app/posts/templates/posts/range_detail.html @@ -150,30 +150,28 @@ {% if object.related.all %}
-
{%endif%} diff --git a/app/posts/views/range_views.py b/app/posts/views/range_views.py index 0a3a564..0a808b8 100644 --- a/app/posts/views/range_views.py +++ b/app/posts/views/range_views.py @@ -22,6 +22,14 @@ class RangeDetailView(LuxDetailView): slug_field = "slug" template_name = "posts/range_detail.html" + def get_context_data(self, **kwargs): + context = super(RangeDetailView, self).get_context_data(**kwargs) + related = [] + for obj in self.object.related.all(): + model = apps.get_model(obj.model_name.app_label, obj.model_name.model) + related.append(model.objects.get(slug=obj.slug, pub_date=obj.pub_date)) + context['related'] = related + return context class RangeListView(PaginatedListView): """ -- cgit v1.2.3-70-g09d2