在我的 forms.py
中,我下面有一个返回 2 条记录的字段,但它在我的屏幕上显示 3 条记录。我不想要第一个“---------”
。
tipopagamento = forms.ModelChoiceField(widget=forms.RadioSelect(), queryset=tipopagamento.objects.all(), required=True)
我的屏幕显示:
最佳答案
设置empty_label
到无
。
tipopagamento = forms.ModelChoiceField(
widget=forms.RadioSelect(),
queryset=tipopagamento.objects.all(),
required=True,
empty_label=None,
)
关于python - 使用单选小部件从模型选择字段中删除 "---------",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50529839/