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
|
||||
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"])
|
||||
|
|
Reference in a new issue