aboutsummaryrefslogtreecommitdiffstats
path: root/examples/resourceexample/views.py
diff options
context:
space:
mode:
authorSébastien Piquemal2012-02-23 09:01:33 +0200
committerSébastien Piquemal2012-02-23 09:01:33 +0200
commit9da1ae81dc9a056db94ea07f35478ed003fea598 (patch)
tree2557ce0fe8be2b7febb184c3bb3da7b5289fbbe1 /examples/resourceexample/views.py
parent242327d339fe1193a45c64cb20a2ba4c56044c3b (diff)
parent5fd4c639d7c64572dd07dc31dcd627bed9469b05 (diff)
downloaddjango-rest-framework-9da1ae81dc9a056db94ea07f35478ed003fea598.tar.bz2
merged + fixed broken test
Diffstat (limited to 'examples/resourceexample/views.py')
-rw-r--r--examples/resourceexample/views.py14
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)))