2 21. Specifying 'choices' for a field
4 Most fields take a ``choices`` parameter, which should be a tuple of tuples
5 specifying which are the valid values for that field.
7 For each field that has ``choices``, a model instance gets a
8 ``get_fieldname_display()`` method, where ``fieldname`` is the name of the
9 field. This method returns the "human-readable" value of the field.
12 from django
.db
import models
20 class Person(models
.Model
):
21 name
= models
.CharField(max_length
=20)
22 gender
= models
.CharField(max_length
=1, choices
=GENDER_CHOICES
)
24 def __unicode__(self
):