@@ -84,14 +84,25 @@ enum-properties_ which makes possible very rich enumeration fields.
84
84
color = EnumField(Color)
85
85
86
86
instance = MyModel.objects.create(color = MyModel.Color(' FF0000' ))
87
- assert instance.color == MyModel.Color(' Red' ) == MyModel.Color(' R' ) == MyModel.Color((1 , 0 , 0 ))
88
87
89
- # save back by any symmetric value
88
+ assert instance.color == TextChoicesExample.Color(' Red' )
89
+ assert instance.color == TextChoicesExample.Color(' R' )
90
+ assert instance.color == TextChoicesExample.Color((1 , 0 , 0 ))
91
+
92
+ # save by any symmetric value or enum type instance
90
93
instance.color = ' FF0000'
91
94
instance.full_clean()
92
95
assert instance.color.hex == ' ff0000'
93
96
instance.save()
94
97
98
+ # filtering works by any symmetric value or enum type instance
99
+ assert TextChoicesExample.objects.filter(
100
+ color = TextChoicesExample.Color.RED
101
+ ).first() == instance
102
+
103
+ assert TextChoicesExample.objects.filter(color = (1 , 0 , 0 )).first() == instance
104
+
105
+ assert TextChoicesExample.objects.filter(color = ' FF0000' ).first() == instance
95
106
96
107
.. note ::
97
108
@@ -125,8 +136,7 @@ Installation
125
136
``django-enum `` has several optional dependencies that are not pulled in
126
137
by default. To utilize the
127
138
enum-properties _ choice types you must `pip install enum-properties ` and
128
- to use the ``EnumFilter `` type for
129
- `django-filter <https://pypi.org/project/django-filter/ >`_ you must
139
+ to use the ``EnumFilter `` type for django-filter _ you must
130
140
`pip install django-filter `.
131
141
132
142
If features are utilized that require a missing optional dependency an
0 commit comments