Answer the question
In order to leave comments, you need to log in
How to set HiddenInput value?
There is a model with posts and comments. Comments are linked to the post via foreignkey. respectively the post field.
I made a form from ModelForm, specified fields post, fio, body
.
In the view, I declare the worm like this:
post = get_object_or_404(Post, id=id)
form = AddComment()
return render(request, 'blog/detail.html', {'post': post, 'form': form})
form.post = post
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question