Potentially unplanned regression regarding ChoiceField and Enums #9388
Replies: 3 comments 4 replies
-
We just got hit by the exact same issue and end up with the same question of what is actually the expectation here. To make the matter worst, in our case the enum value is a callable, thus it's impossible to change our FE to send that value, we do need to send the key so that we get the related enum instance back. |
Beta Was this translation helpful? Give feedback.
-
It would be great if you can come with a proper fix to get rid of the regression! |
Beta Was this translation helpful? Give feedback.
-
Add me to the list of people thinking that this is a regression and a breaking change. We have a subclass of the ChoiceField, defined as:
We also have an enum with string values:
In djangorestframework 3.14, this returned "Field not compatible with cross-fields"
On djangorestframework 3.15, the same code raises a KeyError (
Surely this can't be the intended behavior. |
Beta Was this translation helpful? Give feedback.
-
We're upgrading from 3.12.4 to 3.15.1 as part of a Django 3.2 to 4.2 upgrade. I believe there was a regression caused by this PR https://github.com/encode/django-rest-framework/pull/8955/files but I'm not sure if it is known/expected.
We have the following approximate setup:
The integers are the keys used internally, but the client passed the key of the enum to the view (
{"status": "unverified"}
). Previously this was working but the PR above broke it in favor of the opposite (passing thechoice.value
instead of thestr(choice)
). There seemed to be some concern around regressions and testing that didn't look like they were addressed in the PR, so I'm wondering if this regression is expected or if this is something that should be fixed.Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions