diff options
| author | Tom Christie | 2012-02-21 20:12:14 +0000 |
|---|---|---|
| committer | Tom Christie | 2012-02-21 20:12:14 +0000 |
| commit | af9e4f69d732cc643d6ec7ae13d4a19ac0332d44 (patch) | |
| tree | 9d3fb9a8aebc520716e7f83075ef83e8102b5952 /examples/resourceexample/views.py | |
| parent | 21fcd3a90631e96e3fa210dd526abab9571ad6e1 (diff) | |
| download | django-rest-framework-af9e4f69d732cc643d6ec7ae13d4a19ac0332d44.tar.bz2 | |
Merging master into develop
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..f2a7a08a 100644 --- a/examples/resourceexample/views.py +++ b/examples/resourceexample/views.py @@ -1,5 +1,4 @@ -from django.core.urlresolvers import reverse - +from djangorestframework.utils 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))) |
