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

NestedHyperlinkedIdentityField with allowed lookup_field=None (OneToOne Relations) #210

Open
gretkierewicz opened this issue Feb 1, 2021 · 2 comments

Comments

@gretkierewicz
Copy link

Hi!

I would like to suggest some minor update for NestedHyperlinkedIdentityField in terms of OneToOne relations.

As there is no need of providing lookup_field in such scenario, allowing lookup_field=None field's kwarg could provide url just fine.

Example url patterns:
/basic_resource/
/basic_resource/{basic_resource_lookup}/
/basic_resource/{basic_resource_lookup}/nested_OneToOne_resource/

As parent_lookup_kwargs pointing basic_resource_lookup would be declared in nested serializer - it is just enough to get exact instance of nested resource for each basic_recource

@c17r
Copy link
Collaborator

c17r commented Feb 1, 2021

For that particular use case, it doesn't seem like you'd use nested routers because a OneToOne isn't nested.

@gretkierewicz
Copy link
Author

Not sure how would you pass OneToOne resource's parent lookup.
I'm building OneToOne relation in nested resource so it is even more complicated there.

Here is the pull request.
Update for allowing to pass lookup_field=None #211

It should be fully back-compatible.

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

2 participants