def get(self, request, poet_id, slug_id, id):
try:
poem = Poem.objects.get(id=id, author_id=poet_id)
if poem.is_shown == 0 and (not request.user or request.user.id != poem.added_user_id):
raise Http404('Page not found')
except Poem.DoesNotExist:
raise Http404('Page not found')
view, created = View.objects.get_or_create(poem_id=poem.id)
view.views_count = view.views_count + 1
view.save()
poet = Poet.objects.get(id=poet_id)
return render(request, self.template_name, {
'poem': poem,
'poet': poet,
})
评论列表
文章目录