Skip to content

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
Contributor

Thanks for the fix.

@lovelydinosaur lovelydinosaur added this to the 3.1.1 Release milestone Mar 13, 2015
@lovelydinosaur
Copy link
Contributor

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