表單集創建在views.py:ManagementForm數據丟失錯誤而表單集驗證
ffact = formset_factory(Form,extra=somenum]))
fset = ffact(prefix='pfix')
驗證在views.py:
ffact = formset_factory(Form,extra=3))
fset = ffact(request.POST)
if fset_is.valid():
blah blah
這導致異常類型:ValidationError在/應用程序/索引/ 例外值:[u'ManagementForm數據丟失或被篡改'] django-docs 確實提到過這一點。我不知道如何提供管理數據。我想是這樣this,
try:
fset = ffact(request.POST)
except ValidationError:
fset = None
if fset and fset.is_valid():
blah blah
但我仍然會得到相同的error.Any想法?謝謝。
您提供的Django文檔鏈接已過時。以下是兩種替代方案: https://docs.djangoproject.com/zh/1.10/topics/forms/formsets/#understanding-the-managementform 和 https://docs.djangoproject.com/zh/1.10/topics/forms/modelforms /#using-the-formset-in-the-template – 2016-11-29 19:26:13