related posts added to post show

This commit is contained in:
2020-06-12 21:23:15 +00:00
parent 02c6875d63
commit 38c63e0e74

View File

@@ -43,7 +43,8 @@ def show(request,id=None):
p=Post.objects.get(id=int(id)) p=Post.objects.get(id=int(id))
elif id != ""and not id is None: elif id != ""and not id is None:
p=Post.objects.get(slug=(id)) p=Post.objects.get(slug=(id))
return render(request, 'posts/show.html', {"post":p,"next":get_next_dict().get(p.slug,None)}) similar_posts = p.tags.similar_objects()
return render(request, 'posts/show.html', {"post":p,"next":get_next_dict().get(p.slug,None), "related_posts": similar_posts})
# Ajax function that is called to calculate a slug from the title # Ajax function that is called to calculate a slug from the title
def slug_calc(request): def slug_calc(request):