Skip to content

Serializer mutation choice field creation fails with django-rest-framework 3.15.0 #1507

New issue

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

Closed
MrThearMan opened this issue Mar 17, 2024 · 6 comments · Fixed by #1506
Closed
Labels

Comments

@MrThearMan
Copy link

What is the current behavior?

See title. This is due to an isinstance check in converters.get_choices that changes the iterable if the choices are an OrderedDict. Django REST Framework 3.15.0 changed from OrderedDicts to regular dicts, so this check no longer converts the iterable, meaning the loop now tries to iterate the dict by keys, but unpack it to two variables, which is not possible.

I've created an example repo reproducing the issue: https://github.com/MrThearMan/graphene-django-bug. The repo contains the exact traceback for the error.

What is the expected behavior?

I should be able to use serializer mutations with choice fields in DRF 3.15.0.

Changing the isinstance check to isinstance(choices, dict) should solve the issue without any breaking anything for older versions of DRF, as OrderedDicts are subclasses of dicts.

MrThearMan added a commit to MrThearMan/graphene-django that referenced this issue Mar 17, 2024
@MrThearMan
Copy link
Author

Seems like there is already a pull request for this: #1506. Should've checked those first 😄

@kiendang kiendang linked a pull request Mar 18, 2024 that will close this issue
@kiendang
Copy link
Collaborator

@MrThearMan #1506 has been merged. Please check if that fixes the issue. Feel free to reopen the issue if that's not the case.

@MrThearMan
Copy link
Author

Thanks, works like a charm! A patch release for this would be much appreciated!

@MrThearMan
Copy link
Author

@kiendang Would you be able to release a v3.2.1 with this fix to PyPI?

@kiendang
Copy link
Collaborator

Pinging @firaskafri. When you have time could you look at making a patch release v3.2.1? Thanks!

@MrThearMan
Copy link
Author

@kiendang @firaskafri Any updates on the PyPI?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants