Fix a bug in options related to read-only RelatedField#2981
Merged
xordoquy merged 1 commit intoencode:masterfrom Jun 2, 2015
Merged
Fix a bug in options related to read-only RelatedField#2981xordoquy merged 1 commit intoencode:masterfrom
RelatedField#2981xordoquy merged 1 commit intoencode:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Can we instead do if not field_info.get('read_only'): ...?
8fd2585 to
9b22f43
Compare
Contributor
There was a problem hiding this comment.
In theory can't these two be combined?
if not field_info.get('read_only') and hasattr(field, 'choices'):9b22f43 to
a97c989
Compare
Contributor
|
Looks good to me. Thanks !! |
xordoquy
added a commit
that referenced
this pull request
Jun 2, 2015
Read-Only RelatedField Metadata Failure Test and Fix
RelatedField in OPTIONS
RelatedField in OPTIONSRelatedField
This was referenced Mar 9, 2017
This was referenced Oct 16, 2017
This was referenced Nov 6, 2017
This was referenced Nov 14, 2017
This was referenced Dec 10, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #2811
Problem
The issue was discovered when an
OPTIONSrequest to an endpoint blew up with the following error:Tracing the problem, I found that
iterableisNonebecause the queryset from which it derives isNonebecause thePrimaryKeyRelatedFieldfrom which it derives is read-only.Solution
It is expected that the
OPTIONSrequest should succeed and simply not list choices for read-only fields since, a user cannot submit data to them anyway.This pull request contains both a test that fails on existing code and a fix in
SimpleMetaData.get_field_infothat checks if a field is read-only before attempting to get choices