我正在使用Django formttools來創建一個多步驟向導。在其中一個表單中,我有一個問題選項,用戶需要根據需要添加盡可能多的問題。我已經通過Django Dynamic Formset實現了動態表單集,但是盡管我的模板中有{%csrf_token%},但我仍然遇到CSRF問題。這是我的模板: {% block content %} <p>Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p> <form action="" method="post" enctype="multipart/form-data" id="job-question">{% csrf_token %} <table> {{ wizard.management_form }}{% if wizard.form.forms %} {{ wizard.form.management_form }} {% for form in wizard.form.forms %} {{ form }} {% endfor %}{% else %} {{ wizard.form }}{% endif %}</table>{% if wizard.steps.prev %}<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %}</button><button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %}</button>{% endif %}<input type="submit" value="{% trans "submit" %}"/></form><script type="text/javascript" src="{% static 'js/jquery-min.3.4.1..js' %}"></script><script type="text/javascript" src="{% static 'js/jquery.formset.js' %}"></script><script type="text/javascript"> $(function() { $('#job-question').formset(); })</script>{% endblock %}
添加回答
舉報
0/150
提交
取消