This is unlikely to be expected in choices for a The use of enum.unique() is enforced to ensure that values cannot beĭefined multiple times.choicesĪs a suitable value to pass to choices in a field definition. To access lists of those separate parts of the enumeration. A number of custom properties are added to the enumeration classes –.label property is added on values, to return the human-readable name. String, the label is automatically generated from the member name. If a tuple is not provided, or the last item is not a (lazy) Of subclassing choices using a more complexĭata type. Value will be a (value, label) two-tuple. Of this tuple to be used as the human-readable name, or label. Django supports adding an extra string value to the end Enum member values are a tuple of arguments to use when constructing theĬoncrete data type.These work similar to enum from Python’s standard library, but with some FRESHMAN, ) def is_upperclass ( self ): return self. CharField ( max_length = 2, choices = YearInSchool. TextChoices ): FRESHMAN = 'FR', _ ( 'Freshman' ) SOPHOMORE = 'SO', _ ( 'Sophomore' ) JUNIOR = 'JR', _ ( 'Junior' ) SENIOR = 'SR', _ ( 'Senior' ) GRADUATE = 'GR', _ ( 'Graduate' ) year_in_school = models. From import gettext_lazy as _ class Student ( models.