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

NestedSimplerRouter with nested>0 doesn't allow for no prefix in the url parameter #212

Open
adamf opened this issue Feb 15, 2021 · 1 comment

Comments

@adamf
Copy link

adamf commented Feb 15, 2021

If I have a URL path such as:
/api/users/{username}

When I nest this with some child element, I get the the lookup value given toNestedSimpleRouter prepended:
routers.NestedSimpleRouter(router, api_path_users, lookup="username")

/api/users/{username_username}/books/

Is there a way to not have this prepend happen? I've tried working with parent_lookup_kwargs and so on, but to no avail. Any ideas how to make it so the url would be /api/users/{username}/books/?

Thanks!

@gretkierewicz
Copy link

If I have a URL path such as:
/api/users/{username}

When I nest this with some child element, I get the the lookup value given toNestedSimpleRouter prepended:
routers.NestedSimpleRouter(router, api_path_users, lookup="username")

/api/users/{username_username}/books/

Is there a way to not have this prepend happen? I've tried working with parent_lookup_kwargs and so on, but to no avail. Any ideas how to make it so the url would be /api/users/{username}/books/?

Thanks!

Hi,

I think there is no such possibility.

lookup parameter in the NestedSimpleRouter ensures that every URL kwarg will be unique.
So if you have many lookups named 'slug' you will end up with 'username_slug' and 'book_slug'.

I guess it would be better to have a lookups named 'name' or 'slug' for username as 'username' is an instance and 'name' or 'slug' could be his lookups.
Then 'username_name' or 'username_slug' would be much more readable.

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