django-crispy-form内联div

时间:2014-12-04 19:06:31

标签: django django-crispy-forms

我想使用酥脆的形式获得三个内联div(我很接近),但我不确定如何。这就是我到目前为止所做的:

self.helper.layout = Layout(
    Div(
        Div(
            'mothers_id','date','date_collector',
            css_class="form-inline", #this is the line I can't get just right (I think)
        ),
        Div(        
            'q_1a',
            'q_1b',
            'q_1c',
        ),
    )
)

1 个答案:

答案 0 :(得分:1)

示例(坐标):

    self.helper_coordinate = FormHelper()
    self.helper_coordinate.layout = Layout(
        Div(
            HTML(u'<div class="col-xs-2" style="line-height:35px;"><strong>Latitude:</strong></div>'),
            Div(AppendedText('lat_deg', '°'), css_class='col-xs-3'),
            Div(AppendedText('lat_min', '\''), css_class='col-xs-3'),
            Div(AppendedText('lat_sec', '"'), css_class='col-xs-4'),
            css_class='row-fluid'  # here you can add some custom class, for example 'row-fluid margin-top-15'
        ),
        Div(
            HTML(u'<div class="col-xs-2" style="line-height:35px;"><strong>Longitude:</strong></div>'),
            Div(AppendedText('lon_deg', '°'), css_class='col-xs-3'),
            Div(AppendedText('lon_min', '\''), css_class='col-xs-3'),
            Div(AppendedText('lon_sec', '"'), css_class='col-xs-4'),
            css_class='row-fluid'
        ),
    )