Django:错误:保存formset后,[u' ManagementForm数据丢失或被篡改]

时间:2016-10-10 18:30:46

标签: django django-forms formset formsets

按下保存的formset的提交按钮后,我收到此错误: " [u' ManagementForm数据丢失或被篡改']"

这是我的views.py

中的代码
MarcheFormSet = formset_factory(PrixMarcheForm1, extra=2)
if request.method == "POST":
    formset = MarcheFormSet(request.POST)
    if (formset.is_valid()):
        for form in formset:
            print form
            form.save()
            return redirect("/appartement/ajouter3/")
    else:
        print "nope"

和我的form.html(模板由views.py调用)

 {% if formset %}
        <form action="" method='POST'>{% csrf_token %}
            {{ formset.management_form }}
            {% for form in formset %}
              {{ form|crispy }}
            {% endfor %}
        <input type='submit' class='btn btn-default' value={{ outcome }}>
        </form>
    {% endif %}

我们将非常感谢您的想法