我有一个形状我想用酥脆的形式呈现
形式
class MyForm(forms.ModelForm):
class Meta:
model = MyModel
excludes = ('user', 'created')
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_show_labels = False ## I only need the input field
self.helper.layout = layout.Layout(
layout.Field('name', css_class="form-control"),
layout.Field('objective', css_class="form-control"),
## ADD CLASS form-control TO THE FIELDS (This is the problem since the fields are not rendered with the class)
)
super(MyForm, self).__init__(*args, **kwargs)
模板
^{pr2}$字段不是用form-control
类呈现的。
标签是呈现的,我不需要他们,因为我有我的自定义标签。
任何关于如何用类呈现字段的帮助都将不胜感激。谢谢。在
如果手动渲染字段,可以按如下方式添加它们:
请注意,这将要求您手动呈现所有的
input
。在相关问题 更多 >
编程相关推荐