From 70bae74c82c2bece323dbb83794c6f0c79ef604d Mon Sep 17 00:00:00 2001 From: luxagraf Date: Wed, 20 Dec 2023 10:06:03 -0500 Subject: guides: fixed view code to show related --- app/posts/views/guide_views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/posts/views') diff --git a/app/posts/views/guide_views.py b/app/posts/views/guide_views.py index a4ff873..641da66 100644 --- a/app/posts/views/guide_views.py +++ b/app/posts/views/guide_views.py @@ -56,7 +56,11 @@ class GuideDetailView(LuxDetailView): def get_context_data(self, **kwargs): context = super(GuideDetailView, self).get_context_data(**kwargs) - print(self.kwargs['topic']) + 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 topic = Category.objects.get(slug=self.kwargs['topic']) context['topic'] = topic context['breadcrumbs'] = ('Guides', topic.name ) -- cgit v1.2.3-70-g09d2