-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
ManyRelatedField.choices tries to iterate over None #2811
Comments
I'm not sure where the best place to fix this is. A simple fix for my direct issue would be to catch the |
I went into similar issue a few days ago. I got this when making an OPTIONS request and it seems the response tries to iterate over field choices, even if field is I fixed this by adding (file: relations.py, line:380) iterable = queryset.all() if (hasattr(queryset, 'all')) else queryset
+ if not iterable:
+ return { } This is perhaps a bad behaviour of the OPTION request that could check if field is not read_only before calling Best regards. |
I've just run into this as well. I think the solution is definitely to change the behavior of the metadata so that it checks if the field is read_only. After all, there is no point in iterating over the choices for a read_only field. I'll submit a PR shortly |
ManyRelatedField.choices
is aproperty
which iterates overself.child_relation.queryset
. This can beNone
ifself.child_relation
is read-only.I found this when
SimpleMetadata.get_field_info
tried to check iffield.choices
exists and raisedTypeError
.The text was updated successfully, but these errors were encountered: