我在尝试使用下面的脆弱表单标签时收到错误
模板评论期间出错
代码{% crispy form form.helper %}
模板html文件如下
{% load crispy_forms_tags %}
...
{% crispy form form.helper %}
...
Forms.py包含类似这样的内容
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
import floppyforms as forms
class SampleForm(forms.Form):
...
答案 0 :(得分:1)
不用尝试。
{% crispy form helper %}
答案 1 :(得分:-1)
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
class ExampleForm(forms.Form):
[...]
def __init__(self, *args, **kwargs):
super(ExampleForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'id-exampleForm'
self.helper.form_class = 'blueForms'
self.helper.form_method = 'post'
self.helper.form_action = 'submit_survey'
self.helper.add_input(Submit('submit', 'Submit'))
然后:
{% load crispy_forms_tags %}
{% crispy example_form example_form.helper %}