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

Fix lookup_url_kwarg handling in viewsets (Fixes #2591). #2685

Merged
merged 1 commit into from
Mar 13, 2015

Conversation

rbarrois
Copy link
Contributor

The lookup_url_kwarg is intended to set the name of a field in the
URL regexps when using custom lookup_field, but the routers ignore
it altogether.

When a ViewSet is defined with:

class ProfileViewSet(ViewSet):
    lookup_field = 'user__username'
    lookup_url_kwarg = 'username'

Then we should get an URL along the lines of /profiles/(?P<username>[^./]+)/.
However, we get /profiles/(?P<user__username>[^./]+)/...

This PR fixes the bug (reported as #2591), along with an inelegant test.

The ``lookup_url_kwarg`` is intended to set the name of a field in the
URL regexps when using custom ``lookup_field``, but the routers ignore
it altogether.
xordoquy added a commit that referenced this pull request Mar 13, 2015
Fix lookup_url_kwarg handling in viewsets (Fixes #2591).
@xordoquy xordoquy merged commit cc64e30 into encode:master Mar 13, 2015
@xordoquy
Copy link
Collaborator

Thanks for the fix.

@tomchristie tomchristie added this to the 3.1.1 Release milestone Mar 13, 2015
@tomchristie
Copy link
Member

Great!

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

Successfully merging this pull request may close these issues.

3 participants