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

Load polymorphic relation serializers from string #405

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

Copy link

@peakwinter peakwinter commented Jan 24, 2018

This PR mimics the functionality of included_serializers and allows polymorphic serializers passed to PolymorphicResourceRelatedField to be dotted string paths, in addition to references to actual Serializer objects. In this way, a PolymorphicResourceRelatedField can support circular references to serializers defined in the same module.

Copy link

Codecov Report

Merging #405 into master will decrease coverage by 0.02%.
The diff coverage is 80%.

Impacted file tree graph

@@ Coverage Diff @@
## master #405 +/- ##
=========================================
- Coverage 91.93% 91.9% -0.03% 
=========================================
 Files 55 55 
 Lines 2925 2929 +4 
=========================================
+ Hits 2689 2692 +3 
- Misses 236 237 +1
Impacted Files Coverage Δ
rest_framework_json_api/relations.py 82.77% <80%> (-0.18%) ⬇️

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 1bbf6fa...7257bc1. Read the comment docs.

@sliverc sliverc self-requested a review May 1, 2018 11:17
Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution.

I do not think this fix is in the right place as get_polymorphic_types is also used in other modules.

Better is to do the string import in PolymorphicSerializerMetaclass.__new__. This way it will also only be done once and not over and over again. What do you think?

Could you also add a test case and some example for the documentation?

Thanks.

auvipy reacted with thumbs up emoji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@sliverc sliverc sliverc requested changes

+1 more reviewer

@subhaminion subhaminion subhaminion approved these changes

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

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