-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fix None UUID ForeignKey serialization #3915
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
Closed
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ab3f9cf
Fix None UUID ForeignKey serialization
50782ec
Remove EOL Django 1.7
665f434
Update release notes.
14e52ca
Test deserialising data including `None` fk
363bc4f
Skip UUID tests for Django 1.7
793d03a
Revert "Remove EOL Django 1.7"
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Fix None UUID ForeignKey serialization
- Loading branch information
There are no files selected for viewing
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Nonecase is handled as part of the regular serialization machinery - shouldn't need to be handling them on a per-field basis. (Tho perhaps something else wonky in this case?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the first commit here: carltongibson@ab3f9cf
(Before getting distracted with 1.7)
The test fails without this change. If this is the wrong fix, then where should it go? (I'm happy to dig but you probably Just Know™)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here
PrimaryKeyRelatedFieldcallsself.pk_field.to_representation(value.pk).When that's a
UUIDFieldwe hit this block:When
valueisNone, without the fix, that's equivalent to:which is the observed output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related: https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/serializers.py#L461-L472
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question is why that's not catching the
Nonecase. Are we always failing to do so for related fields, or is there something different in this case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Good link. I see it.
I'll have a look later.
(Do you have any thoughts on keeping/dropping Django 1.7 here? Happy to keep it but not sure how, since the
if ...VERSIONfixes didn't work...?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with the 3.4 line dropping the 1.7.
I would feel better if that was part of a different PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to make the tests pass... — I could do the 1.7 one first...