In the views why have you used templane_name while you not using class
based views...try and change that to render the template using request
On Mar 30, 2020 11:55, "Jeff Waters" <water...@gmail.com> wrote:

> Sure. It's as follows:
>
> @login_required
> def add_comment(request, image_id):
>     template_name = 'add_comment.html'
>     image = get_object_or_404(Picture, id=image_id)
>     comments = image.comments.filter(active=True)
>     new_comment = None
>     # Comment posted
>     if request.method == 'POST':
>         comment_form = CommentForm(data=request.POST)
>         if comment_form.is_valid():
>             # Create Comment object and don't save to database yet
>             new_comment = comment_form.save(commit=False)
>             # Assign the current post to the comment
>             new_comment.post = post
>             # Save the comment to the database
>             new_comment.save()
>     else:
>         comment_form = CommentForm()
>
>     return render(request, template_name, {'image': image,
>                                            'comments': comments,
>                                            'new_comment': new_comment,
>                                            'comment_form': comment_form})
>
>
>
> Thanks
>
> Jeff
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/8e0f5a28-7a48-4037-aba5-ea591a81d397%40googlegroups.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPsfuofgALu7-qZFeVyxxr4LJLtAwnsFhnYvsOSD6QMBmH17bw%40mail.gmail.com.

Reply via email to