Пример #1
0
    def post(self, request, pk) :
        f = get_object_or_404(Star, id=pk)
        comment_form = CommentForm(request.POST)

        comment = Comment(text=request.POST['comment'], owner=request.user, star=f)
        comment.save()
        return redirect(reverse_lazy('star_detail', args=[pk]))
 def get(self, request, pk):
     star = Star.objects.get(id=pk)
     comments = Comment.objects.filter(star=star).order_by('-updated_at')
     comment_form = CommentForm()
     context = {
         'star': star,
         'comments': comments,
         'comment_form': comment_form
     }
     return render(request, self.template_name, context)