@@ -69,12 +69,14 @@ simple declarative syntax are possible with ``EnumField``. See
69
69
External Enum Types
70
70
###################
71
71
72
- Externally defined, that is ``Enum `` classes defined externally to your code
73
- base or enum classes that otherwise do not inherit from Django's Choices type,
74
- are supported. When no choices are present on an ``Enum `` type, ``EnumField ``
75
- will attempt to use the ``label `` member on each enumeration value if it is
76
- present, otherwise the labels will be based off the enumeration name. Choices
77
- can also be overridden at the ``EnumField `` declaration.
72
+ ``Enum `` classes defined externally to your code base or enum classes that
73
+ otherwise do not inherit from Django's ``Choices `` type, are supported. When no
74
+ choices are present on an ``Enum `` type, ``EnumField `` will attempt to use the
75
+ ``label `` member on each enumeration value if it is present, otherwise the
76
+ labels will be based off the enumeration name. Choices can also be overridden
77
+ at the ``EnumField `` declaration.
78
+
79
+ In short, ``EnumField `` should work with any subclass of ``Enum ``.
78
80
79
81
.. code :: python
80
82
@@ -94,6 +96,17 @@ can also be overridden at the ``EnumField`` declaration.
94
96
95
97
The above code will produce a choices set like ``[(' V0' , ' VALUE0' ), ...]``.
96
98
99
+ .. warning ::
100
+
101
+ One nice feature of Django' s ``Choices`` type is that it disables
102
+ `` auto()`` on `` Enum`` fields. `` auto()`` can be dangerous because the
103
+ values assigned depend on the order of declaration. This means that if the
104
+ order changes existing database values will no longer align with the
105
+ enumeration values. When using `` Enums`` where control over the values is
106
+ not certain it is a good idea to add integration tests that look for value
107
+ changes.
108
+
109
+
97
110
Parameters
98
111
# #########
99
112
0 commit comments