Fix admin link for pages
This commit is contained in:
parent
644de9c72f
commit
49b1d0e9ca
1 changed files with 3 additions and 0 deletions
|
@ -35,6 +35,7 @@ class ArticleDetailView(generic.DetailView):
|
||||||
model = Article
|
model = Article
|
||||||
context_object_name = "article"
|
context_object_name = "article"
|
||||||
queryset = Article.with_pages.all()
|
queryset = Article.with_pages.all()
|
||||||
|
template_name = "articles/article_detail.html"
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
if self.request.user.is_authenticated:
|
if self.request.user.is_authenticated:
|
||||||
|
@ -43,6 +44,8 @@ class ArticleDetailView(generic.DetailView):
|
||||||
|
|
||||||
def get_object(self, queryset=None):
|
def get_object(self, queryset=None):
|
||||||
obj = super().get_object(queryset)
|
obj = super().get_object(queryset)
|
||||||
|
if hasattr(obj, "page"):
|
||||||
|
obj = obj.page
|
||||||
if not self.request.user.is_authenticated:
|
if not self.request.user.is_authenticated:
|
||||||
obj.views_count = F("views_count") + 1
|
obj.views_count = F("views_count") + 1
|
||||||
obj.save(update_fields=["views_count"])
|
obj.save(update_fields=["views_count"])
|
||||||
|
|
Reference in a new issue