You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to report a weird action when I try to use filtering with DRF 3.4, django-filter 0.13 and django-enumfields 0.8.1, drf-enum-field 0.9.1
I made a request with url http://url/api/MyModels?test_type=a and the response said "['Select a valid choice. A is not one of the available choices.']".
It turns out that ChoiceField.valid_value() returns False because k, v in choices are both label instead of name and value so it keeps failing.
They should be name and value and tries to compare with query param which is 'a'.
This is my sample code
class TestType(Enum)
A = 'a'
class Labels:
A = 'a-label'
class MyModel(Model):
test_type = EnumField(TestType, max_length=MAX_TEST_TYPE_LENGTH)
I think EnumField should override valid_value() and makes sure overridden method called instead of ChoiceField.
The text was updated successfully, but these errors were encountered:
I would like to report a weird action when I try to use filtering with DRF 3.4, django-filter 0.13 and django-enumfields 0.8.1, drf-enum-field 0.9.1
I made a request with url http://url/api/MyModels?test_type=a and the response said "['Select a valid choice. A is not one of the available choices.']".
It turns out that ChoiceField.valid_value() returns False because k, v in choices are both label instead of name and value so it keeps failing.
They should be name and value and tries to compare with query param which is 'a'.
This is my sample code
I think EnumField should override valid_value() and makes sure overridden method called instead of ChoiceField.
The text was updated successfully, but these errors were encountered: