diff options
Diffstat (limited to 'examples/resourceexample/views.py')
| -rw-r--r-- | examples/resourceexample/views.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/resourceexample/views.py b/examples/resourceexample/views.py index 44c4176a..8e7be302 100644 --- a/examples/resourceexample/views.py +++ b/examples/resourceexample/views.py @@ -1,5 +1,4 @@ -from django.core.urlresolvers import reverse - +from djangorestframework.reverse import reverse from djangorestframework.views import View from djangorestframework.response import Response from djangorestframework import status @@ -14,9 +13,12 @@ class ExampleView(View): def get(self, request): """ - Handle GET requests, returning a list of URLs pointing to 3 other views. + Handle GET requests, returning a list of URLs pointing to + three other views. """ - return Response({"Some other resources": [reverse('another-example', kwargs={'num':num}) for num in range(3)]}) + urls = [reverse('another-example', request, kwargs={'num': num}) + for num in range(3)] + return Response({"Some other resources": urls}) class AnotherExampleView(View): @@ -32,7 +34,7 @@ class AnotherExampleView(View): Returns a simple string indicating which view the GET request was for. """ if int(num) > 2: - return Response(status.HTTP_404_NOT_FOUND) + return Response(status=status.HTTP_404_NOT_FOUND) return Response("GET request to AnotherExampleResource %s" % num) def post(self, request, num): @@ -41,5 +43,5 @@ class AnotherExampleView(View): Returns a simple string indicating what content was supplied. """ if int(num) > 2: - return Response(status.HTTP_404_NOT_FOUND) + return Response(status=status.HTTP_404_NOT_FOUND) return Response("POST request to AnotherExampleResource %s, with content: %s" % (num, repr(self.CONTENT))) |
