-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Use OrderedDict for RelatedField.choices. #2408
Comments
Sure, don't see why not. |
This breaks all my unit tests! Should this be documented somewhere? http://share.aidanlister.com/ayni |
@aidanlister dict comparisons against ordered dict still return true if the elements match. Any chance you've missed something unexpected (eg some of the values are subtly different, or you're needlessly performing a comparison of the repr() of the compared items or something) |
IIRC the comparison display is not really usefull with Python 2.7. With Python3 I think it appears as a dict |
Ah @tomchristie I think you're right, the change is how the dates are presented in DRF3.
I'll see what I can work out |
The order of choices is useful when returning metadata. For ChoiceFields DRF uses an OrderedDict but for RelatedFields everything is put into a regular dict which loses order.
https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/relations.py#L106
The text was updated successfully, but these errors were encountered: