Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前正在使用crispy-forms在django中构建一个webapp,我想知道,有没有办法使用字段名称的字符串列表为表单创建布局?谢谢你。
你可以这样做:
list_of_field_names = ['field1', 'field2'] self.helper = FormHelper() self.helper.layout = Layout( Fieldset( 'first arg is the legend of the fieldset', *list_of_field_names ), ... )