From 49b1d0e9cab332ee8378d8da4dc813f94ab8ccd2 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Mon, 17 Aug 2020 13:17:23 +0200 Subject: [PATCH] Fix admin link for pages --- articles/views/html.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/articles/views/html.py b/articles/views/html.py index e32a706..d05d4bb 100644 --- a/articles/views/html.py +++ b/articles/views/html.py @@ -35,6 +35,7 @@ class ArticleDetailView(generic.DetailView): model = Article context_object_name = "article" queryset = Article.with_pages.all() + template_name = "articles/article_detail.html" def get_queryset(self): if self.request.user.is_authenticated: @@ -43,6 +44,8 @@ class ArticleDetailView(generic.DetailView): def get_object(self, queryset=None): obj = super().get_object(queryset) + if hasattr(obj, "page"): + obj = obj.page if not self.request.user.is_authenticated: obj.views_count = F("views_count") + 1 obj.save(update_fields=["views_count"])