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

Parametrizable viewset custom views reverse name #4821

Merged
merged 2 commits into from Jan 19, 2017
Merged

Parametrizable viewset custom views reverse name #4821

merged 2 commits into from Jan 19, 2017

Conversation

lzac
Copy link
Contributor

@lzac lzac commented Jan 17, 2017

Enabling custom reverse names on Viewsets detail_route and list_route using url_name parameter in decorator definition.

Example usage

@detail_route(methods=['post'], url_path='experimental/save-feedback', url_name='save-feedback')
def save_feedback(self, request, pk=None):
    pass

This allows us to retrieve our custom view using reverse utility by simply doing

reverse('<viewset-base-name>-save-feedback')

instead than

reverse('<viewset-base-name>-experimental/save-feedback')

and in general reverse name can be customized as desired.

@tomchristie
Copy link
Member

tomchristie commented Jan 18, 2017

Interesting, yup!

Copy link
Member

@tomchristie tomchristie left a comment

Needs documentation and a test adding too.

@tomchristie tomchristie added this to the 3.5.4 Release milestone Jan 19, 2017
@tomchristie tomchristie merged commit 635dc03 into encode:master Jan 19, 2017
3 checks passed
@tomchristie
Copy link
Member

tomchristie commented Jan 19, 2017

Ace!

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

Successfully merging this pull request may close these issues.

None yet

2 participants