Skip to content
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

Foreign key pointing to one2one field is indicated as a string #559

Open
pbrenna opened this issue Mar 18, 2020 · 0 comments
Open

Foreign key pointing to one2one field is indicated as a string #559

pbrenna opened this issue Mar 18, 2020 · 0 comments

Comments

@pbrenna
Copy link

pbrenna commented Mar 18, 2020

This is different but complementary to issue #481 : when a serializers.PrimaryKeyRelatedField's queryset points to a one2one related field (such as when using django polymorphic) one should resolve recursively the type of the field, and not as a string.

Rationale: django polymorphic models inheritance by having a one2one relation between the child model's pk and its parent's pk.
Such inheritance chains can be arbitrarily long, so the only solution I could find was writing a recursive implementation (but maybe the base type can be extracted without recursion?) which I will send as a PR hoping it is useful.
Edit: PR #560

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant