Skip to content

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

@pbrenna

Description

@pbrenna

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNo assigned version

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions