【发布时间】:2019-12-18 00:52:03
【问题描述】:
我正在使用django-crispy-forms,并且我有一个包含许多字段的表单。我只想自定义其中的几个字段,例如:
class ExampleForm(forms.ModelForm):
model = ExampleModel
fields = "__all__" # tons of fields
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Field('readonlyfield', readonly=True),
# Add rest of fields here without explicitly typing them all out
)
如果我呈现此表单,它将只有一个字段。如何使用默认布局值/设置添加其余部分?
【问题讨论】: