Wie alle Optionen von dem Formular in Django eingereicht, das ist das Formular, das ich verwendet habe.So erhalten Sie alle Optionen von Formular gesendet
{% extends 'quiz/base.html' %}
{% block content%}
<h1>You are at quiz page</h1>
<form action="{% url 'quiz:process_data' %}" method="post">
{% csrf_token %}
{% for question in question_set %}
<h3>{{question.id}}.{{question.question_text }}</h3>
{% for option in question.options_set.all %}
<input type="radio" name="choice{{question.id}}" value="{{ option.options}}" > {{option.options}}<br>
{% endfor %}
{% endfor %}
<input type="Submit" name="Submit">
</form>
{% endblock%}
Ich versuchte selected_choice=request.POST
, aber das csrfmiddlewaretokenchoice1Submitchoice3
als Ausgabe zu bekommen. Wie kann ich das lösen? Danke
Request.POST ist ein Wörterbuch. Also einfach 'request.POST.get ('form_field_name')' –
Bitte posten Sie Ihre form.py. –