We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In Django 5.0 field choices seem to be always lists, even when defined as Choices. In Django 4.3.9 it seems to be working as expected.
from model_utils import Choices class MyClass my_field = models.CharField( choices=Choices(("M", "Male", "MALE"), ("F", "Female", "FEMALE")) )
Django 4.2.11
from models import MyModel type(MyModel._meta.get_field("my_field").choices)
<class 'model_utils.choices.Choices'>
MyModel._meta.get_field("my_field").choices
Choices(("M", "Male", "MALE"), ("F", "Female", "FEMALE"))
Django 5.0
<class 'list'>
[("M", "MALE"), ("F", "FEMALE")]
This raises an error
TypeError: list indices must be integers or slices, not str
when trying to
MyModel._meta.get_field("my_field").choices["M"]
The text was updated successfully, but these errors were encountered:
Can you provide a PR with a failing testcase?
Sorry, something went wrong.
No branches or pull requests
Problem
In Django 5.0 field choices seem to be always lists, even when defined as Choices. In Django 4.3.9 it seems to be working as expected.
Environment
Code examples
Django 4.2.11
<class 'model_utils.choices.Choices'>
Choices(("M", "Male", "MALE"), ("F", "Female", "FEMALE"))
Django 5.0
<class 'list'>
[("M", "MALE"), ("F", "FEMALE")]
This raises an error
TypeError: list indices must be integers or slices, not str
when trying to
The text was updated successfully, but these errors were encountered: