在django-crispy形式内连接两个字段而不是其他横向? [英] get two fields inline in django-crispy forms but not others horizontal?

查看:224
本文介绍了在django-crispy形式内连接两个字段而不是其他横向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要有两个字段对应于下一个旁边的复选框(不在其他下方),就像我在图像中显示的那样。

I want to have two fields corresponding to check boxes next to next (not one below other) like I have shown in the image.

我的表单从 models.Form 继承,并有其他字段,我已经在这里留下了。有可能使用脆性表格来获得这个?对于其余的字段,

my form inherits from models.Form and has other fields, which I have left out here. is it possible to get this using crispy-forms? For rest of the fields,

我使用 self.helper.form_class ='form-horizo​​ntal',我想保持其他表单域的完整性

I use self.helper.form_class='form-horizontal', which I want to keep intact for other form fields

谢谢

推荐答案

这是未经测试的,但我认为这将工作。

This is untested but I think this will work.

self.helper.layout = Layout(
    Div(
        Div('inlineField1',css_class='col-md-6',),
        Div('inlineField2',css_class='col-md-6',),
        css_class='row',
    ),
    'other_fields',
    ...,

    FormActions(
        Submit('submit', 'Submit'),
    ),
)

这篇关于在django-crispy形式内连接两个字段而不是其他横向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆