如何从django中删除---------选择小部件

时间:2018-05-29 18:32:45

标签: django forms widget

如何删除我的django ModelForm widgts中的-----? 文档说使用empty_label但它适用于SelectDateWidget

我的表格

class ProjectForm(forms.ModelForm):

    class Meta:
        model = Project
        exclude = ('copy', 'created', 'researcher', 'keywords', 'application_area', 'predominant_area')

        widgets = {
            'title':forms.TextInput(attrs={
                'class':'form-control',
                'placeholder': 'Titulo da oportunidade'
            }),
            'conclusion_date':forms.TextInput(attrs={
                'class': 'form-control',
                'type':'text',
                'placeholder':'Data de conclusão'
        }),
            'category': forms.RadioSelect(attrs={
                'class':'form-control'
        }),
            'result':forms.Select(attrs={
                'class':'form-control'
        }),
     }

1 个答案:

答案 0 :(得分:2)

您可以为您的选择输入添加默认值,然后它将最初显示默认值。

供进一步参考:

https://docs.djangoproject.com/en/2.0/topics/forms/

https://docs.djangoproject.com/en/2.0/ref/forms/fields/