Enum classes¶
-
class
enumchoicefield.enum.PrettyEnum¶ A
PrettyEnummakes defining nice, human-readable names for enum members easy. To use it, subclassPrettyEnumand declare the enum members with their human-readable name as their value:class Fruit(PrettyEnum): apple = "Apple" banana = "Banana" orange = "Orange"
The members’ values will be automatically set to ascending integers, starting at one. In the example above,
Fruit.apple.valueis1, andFruit.orange.valueis3.
-
class
enumchoicefield.enum.DeconstructableEnum¶ -
deconstruct()¶ a
DeconstructableEnumdefinesdeconstruct(), compatible with Django migrations. If you want to set a default for anEnumChoiceField, the enum must be deconstructable.
-
-
class
enumchoicefield.enum.ChoiceEnum¶ a
ChoiceEnumextends bothPrettyEnumandDeconstructableEnum. It is recommended to use aChoiceEnumsubclass withEnumChoiceField, but this is not required.