首页 > 解决方案 > Django 脆皮表单字段类型日期

问题描述

我正在尝试<input type="date">在下面的 django 清晰表单布局字段中获取日期选择器功能,例如 HTML。

Field('invoice_date', type='date'),

但是,它不起作用。完整片段如下:

def __init__(self, *args, **kwargs):
        super(InvoiceForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_tag = True
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-md-3 create-label'
        self.helper.field_class = 'col-md-9'

        self.helper.layout = Layout(
            Div(
                Field('customer'),
                Field('invoice_num'),
                Field('invoice_date', type='date'),
                Fieldset('Add detail', Formset('details')),
                HTML("<br>"),
                ButtonHolder(Submit('submit', 'save')),
                )
            )

标签: django-crispy-forms

解决方案


推荐阅读