Answers for "django choicefield empty label"

0

django choicefield empty label

### 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)
Posted by: Guest on August-10-2020

Code answers related to "django choicefield empty label"

Python Answers by Framework

Browse Popular Code Answers by Language