Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Respect serializer's id field. #576

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

Conversation

amw
Copy link
Contributor

@amw amw commented Feb 18, 2019
edited
Loading

Description of the Change

Until now the renderer ignored id field provided by the serializer. This prevented API author from using separate values for internal database key (pk) and for user facing resource ID. One reason for using separate values like this is if the pk has to be small for use by foreign keys and external id can be longer, for example a human readable string.

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

Copy link
Member

sliverc commented Feb 19, 2019

This PR seems to be related to issue #155

For complete support to overwrite primary key of a resource it also needs to be possible to reference such in relationships. How would you go about this with your approach?
Other question is also how the view would need to look like for custom primary key lookup?

Copy link

What is the recommended workaround for this, for the time being?

Glad this is being worked on!

@amw amw force-pushed the dont-ignore-serializer-id-during-render branch from 38c2ab0 to 7e3c2da Compare August 6, 2019 11:37
Copy link

codecov bot commented Aug 6, 2019
edited
Loading

Codecov Report

Merging #576 into master will decrease coverage by 0.47%.
The diff coverage is 95%.

Impacted file tree graph

@@ Coverage Diff @@
## master #576 +/- ##
==========================================
- Coverage 96.11% 95.64% -0.48% 
==========================================
 Files 56 55 -1 
 Lines 2859 2870 +11 
==========================================
- Hits 2748 2745 -3 
- Misses 111 125 +14
Impacted Files Coverage Δ
rest_framework_json_api/renderers.py 87.45% <100%> (+0.66%) ⬆️
example/tests/unit/test_renderer_class_methods.py 98.83% <94.11%> (-1.17%) ⬇️
rest_framework_json_api/metadata.py 25% <0%> (-23.34%) ⬇️
example/tests/test_filters.py 100% <0%> (ø) ⬆️
example/settings/dev.py 100% <0%> (ø) ⬆️
example/tests/integration/test_pagination.py 100% <0%> (ø) ⬆️
example/tests/integration/test_polymorphism.py 100% <0%> (ø) ⬆️
example/models.py 100% <0%> (ø) ⬆️
example/tests/test_serializers.py 100% <0%> (ø) ⬆️
rest_framework_json_api/django_filters/backends.py 100% <0%> (ø) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5650bd1...7e3c2da. Read the comment docs.

Copy link
Member

sliverc commented Oct 2, 2019

Closing this PR as there hasn't been any progress and I don't quite see how this approach will work with relationships.

Please feel free to comment also in #155 for any suggestions how to move forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /