@@ -84,14 +84,25 @@ enum-properties_ which makes possible very rich enumeration fields.
8484 color = EnumField(Color)
8585
8686 instance = MyModel.objects.create(color = MyModel.Color(' FF0000' ))
87- assert instance.color == MyModel.Color(' Red' ) == MyModel.Color(' R' ) == MyModel.Color((1 , 0 , 0 ))
8887
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
9093 instance.color = ' FF0000'
9194 instance.full_clean()
9295 assert instance.color.hex == ' ff0000'
9396 instance.save()
9497
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
95106
96107 .. note ::
97108
@@ -125,8 +136,7 @@ Installation
125136 ``django-enum `` has several optional dependencies that are not pulled in
126137 by default. To utilize the
127138 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
130140 `pip install django-filter `.
131141
132142If features are utilized that require a missing optional dependency an
0 commit comments