📜  django choicefield 空标签 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:49.412000             🧑  作者: Mango

代码示例1
### forms.py
from django.forms import Form, ChoiceField

CHOICE_LIST = [
    ('', '----'), # replace the value '----' with whatever you want, it won't matter
    (1, 'Rock'),
    (2, 'Hard Place')
]

class SomeForm (Form):

    some_choice = ChoiceField(choices=CHOICE_LIST, required=False)