如何在具有松散形式的div中包装selectdatewidget select

时间:2013-09-17 15:12:21

标签: django django-forms django-crispy-forms

我使用crispy表单和bootstrap3,我想在同一行显示selectdatewidget选项,如下所示:

<div class="form-group">
    <label for="id_startdate_day" class="control-label col-lg-2">
       Startdate
    </label>

    <div class="col-lg-10">
        <div class="row">
            <div class="col-lg-3">
                <select class="form-control" id="id_startdate_day" name="startdate_day">
                <option value="1">1</option><option value="2">2</option>
                </select>
            </div>
            <div class="col-lg-3">
                <select class="form-control" id="id_startdate_month" name="startdate_month">
                <option value="1">jan</option><option value="2">feb</option>
                </select>
            </div>
            <div class="col-lg-3">
                <select class="form-control" id="id_startdate_year" name="startdate_year">
                <option value="2013" selected="selected">2013</option><option value="2014">2014</option>
                </select>
            </div>
        </div>
    </div>
</div>

我试图为该字段制作自己的模板,但我似乎无法“分裂”{% crispy_field field %}

我已尝试{% crispy_field field.1 %} {% crispy_field field.2 %} {% crispy_field field.3 %}但我收到此错误:Failed lookup for key [1]

任何人都知道如何“拆分”crispy_field字段?还是有另一种解决方案吗?

0 个答案:

没有答案