django form choices code example
Example: field.choices django
Will create a select box for this in the model form. Use can select from the
options.The first element in each tuple is the actual value to be set on the model,
and the second element is the human-readable name. For example:
YEAR_IN_SCHOOL_CHOICES = [
(FRESHMAN, 'Freshman'),
(SOPHOMORE, 'Sophomore'),
(JUNIOR, 'Junior'),
(SENIOR, 'Senior'),
(GRADUATE, 'Graduate'),
]
year_in_school = models.CharField(
max_length=2,
choices=YEAR_IN_SCHOOL_CHOICES,
default=FRESHMAN,
)