私は自分のプロジェクトで jinja2 と wtforms を組み合わせて使用しています。ここでは、FieldList で FormField を使用する必要があります。次のコードは機能しませんが、例外がスローされます。
class FormTranslations(object):
def gettext(self, string):
return gettext(string)
def ngettext(self, singular, plural, n):
return ngettext(singular, plural, n)
class BaseForm(Form):
def __init__(self, request_handler):
super(BaseForm, self).__init__(request_handler.request.POST)
def _get_translations(self):
return FormTranslations()
class SubForm(BaseForm):
name = fields.StringField()
qty = fields.IntegerField()
class MainForm(BaseForm):
value = fields.IntegerField()
items = fields.FieldList(fields.FormField(SubForm), min_entries=2)
#Instantiate and initialize the MainForm:
f = MainForm(self)
Exception:
…
…
…
File "/src/external/wtforms/form.py", line 178, in __call__
return type.__call__(cls, *args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'formdata'
ある時はそうですformdata
。場合によっては、それがキーワードである、obj
またはprefix
そのように思われることもあります。unexpected
コードの何が問題になっていますか?