Skip to content

Commit 8b0d411

Browse files
Merge pull request encode#941 from FreakyDug/master
Fixed a couple of small problems I found when using the action decorator.
2 parents 2d5f7f2 + fa9f5fb commit 8b0d411

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

docs/api-guide/viewsets.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Let's define a simple viewset that can be used to list or retrieve all the users
2727
queryset = User.objects.all()
2828
serializer = UserSerializer(queryset, many=True)
2929
return Response(serializer.data)
30-
30+
3131
def retrieve(self, request, pk=None):
3232
queryset = User.objects.all()
3333
user = get_object_or_404(queryset, pk=pk)
@@ -69,7 +69,7 @@ The default routers included with REST framework will provide routes for a stand
6969
"""
7070
Example empty viewset demonstrating the standard
7171
actions that will be handled by a router class.
72-
72+
7373
If you're using format suffixes, make sure to also include
7474
the `format=None` keyword argument for each action.
7575
"""
@@ -103,12 +103,12 @@ For example:
103103

104104
class UserViewSet(viewsets.ModelViewSet):
105105
"""
106-
A viewset that provides the standard actions
106+
A viewset that provides the standard actions
107107
"""
108108
queryset = User.objects.all()
109109
serializer_class = UserSerializer
110-
111-
@action
110+
111+
@action()
112112
def set_password(self, request, pk=None):
113113
user = self.get_object()
114114
serializer = PasswordSerializer(data=request.DATA)
@@ -197,7 +197,7 @@ As with `ModelViewSet`, you'll normally need to provide at least the `queryset`
197197

198198
Again, as with `ModelViewSet`, you can use any of the standard attributes and method overrides available to `GenericAPIView`.
199199

200-
# Custom ViewSet base classes
200+
# Custom ViewSet base classes
201201

202202
You may need to provide custom `ViewSet` classes that do not have the full set of `ModelViewSet` actions, or that customize the behavior in some other way.
203203

@@ -211,7 +211,7 @@ To create a base viewset class that provides `create`, `list` and `retrieve` ope
211211
viewsets.GenericViewSet):
212212
"""
213213
A viewset that provides `retrieve`, `update`, and `list` actions.
214-
214+
215215
To use it, override the class and set the `.queryset` and
216216
`.serializer_class` attributes.
217217
"""

rest_framework/routers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def get_routes(self, viewset):
136136
attr = getattr(viewset, methodname)
137137
httpmethods = getattr(attr, 'bind_to_methods', None)
138138
if httpmethods:
139+
httpmethods = [method.lower() for method in httpmethods]
139140
dynamic_routes.append((httpmethods, methodname))
140141

141142
ret = []

0 commit comments

Comments
 (0)