mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 08:14:16 +03:00
Fixed code example.
This commit is contained in:
parent
1bd8fe4152
commit
ab4be47379
|
@ -42,13 +42,16 @@ The example above would generate the following URL patterns:
|
||||||
Any methods on the viewset decorated with `@detail_route` or `@list_route` will also be routed.
|
Any methods on the viewset decorated with `@detail_route` or `@list_route` will also be routed.
|
||||||
For example, given a method like this on the `UserViewSet` class:
|
For example, given a method like this on the `UserViewSet` class:
|
||||||
|
|
||||||
from myapp.permissions import IsAdminOrIsSelf
|
from myapp.permissions import IsAdminOrIsSelf
|
||||||
from rest_framework.decorators import detail_route
|
from rest_framework.decorators import detail_route
|
||||||
|
|
||||||
@detail_route(methods=['post'], permission_classes=[IsAdminOrIsSelf])
|
class UserViewSet(ModelViewSet):
|
||||||
def set_password(self, request, pk=None):
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@detail_route(methods=['post'], permission_classes=[IsAdminOrIsSelf])
|
||||||
|
def set_password(self, request, pk=None):
|
||||||
|
...
|
||||||
|
|
||||||
The following URL pattern would additionally be generated:
|
The following URL pattern would additionally be generated:
|
||||||
|
|
||||||
* URL pattern: `^users/{pk}/set_password/$` Name: `'user-set-password'`
|
* URL pattern: `^users/{pk}/set_password/$` Name: `'user-set-password'`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user