Answer the question
In order to leave comments, you need to log in
How to pass a variable from a form to a view?
Need to pass a variable from form
{% for i in good %}
<p>{{ i.results }}</p>
<form action="/comment/" method="post" enctype="multipart/form-data">{% csrf_token %}
<label for="com">Комментарий:</label>
<input type="text" name="com" value="">
<input type='hidden' value="{{ i.id }}" name="index">
<input type="submit" value="Ок">
</form>
{% endfor %}
<a href="/" class="btn btn-outline-secondary">Перейти на главную</a>
{% endif %}
{% endblock %}
class Comment(forms.Form):
com = forms.CharField(label='Комментарий:', max_length=100)
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