Django 表单,空行

问题描述 投票:0回答:1

在我的 Django 表单中,当我查看我的选择时,有一个空行 (_____),如何解决此问题?

尝试删除此行

这是代码

special_occasion = models.CharField(max_length=11, choices=[('None', 'None'), ('anniversary', 'Anniversary'), ('date', 'Date'), ('business', 'Business')])
django django-forms
1个回答
0
投票

考虑在表单中明确指定此字段:

class CustomForm(forms.Form):
    ...
    special_occasion = forms.ChoiceField(choices=[('None', 'None'), ('anniversary', 'Anniversary'), ('date', 'Date'), ('business', 'Business')])
© www.soinside.com 2019 - 2024. All rights reserved.