summaryrefslogtreecommitdiff
path: root/app/posts
diff options
context:
space:
mode:
authorlxf <sng@luxagraf.net>2020-12-23 12:21:22 -0500
committerlxf <sng@luxagraf.net>2020-12-23 12:21:22 -0500
commitb57c0c23125c825f36d0e1c99d2a50d553dd4903 (patch)
treee71fdb22669404c571e72d499af636244c35fe9f /app/posts
parent233168576fcee317c068cd6e68a307682a109559 (diff)
added related images to src posts
Diffstat (limited to 'app/posts')
-rw-r--r--app/posts/templates/posts/src_detail.html3
-rw-r--r--app/posts/views/src_views.py9
2 files changed, 10 insertions, 2 deletions
diff --git a/app/posts/templates/posts/src_detail.html b/app/posts/templates/posts/src_detail.html
index 0257598..8e58b3b 100644
--- a/app/posts/templates/posts/src_detail.html
+++ b/app/posts/templates/posts/src_detail.html
@@ -83,11 +83,10 @@
</ul>
</nav>{%endwith%}{%endwith%}
{%endif%}
-
{% if object.related.all %}<div class="article-afterward related">
<div class="related-bottom">
<h6 class="hedtinycaps">You might also enjoy</h6>
- <ul class="article-card-list">{% for object in object.related.all %}
+ <ul class="article-card-list">{% for object in related %}
<li class="article-card-mini"><a href="{{object.get_absolute_url}}" title="{{object.title}}">
<div class="post-image post-mini-image">
{% if object.featured_image %}
diff --git a/app/posts/views/src_views.py b/app/posts/views/src_views.py
index 990088f..90c672c 100644
--- a/app/posts/views/src_views.py
+++ b/app/posts/views/src_views.py
@@ -1,5 +1,6 @@
from django.views.generic import ListView
from django.views.generic.detail import DetailView
+from django.apps import apps
from django.contrib.syndication.views import Feed
from django.urls import reverse
from django.conf import settings
@@ -31,6 +32,14 @@ class SrcDetailView(DetailView):
slug_field = "slug"
template_name="posts/src_detail.html"
+ def get_context_data(self, **kwargs):
+ context = super(SrcDetailView, 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 SrcDetailViewTXT(SrcDetailView):
template_name = "posts/jrnl_detail.txt"