aboutsummaryrefslogtreecommitdiffstats
path: root/examples/resourceexample
diff options
context:
space:
mode:
Diffstat (limited to 'examples/resourceexample')
-rw-r--r--examples/resourceexample/urls.py7
-rw-r--r--examples/resourceexample/views.py5
2 files changed, 7 insertions, 5 deletions
diff --git a/examples/resourceexample/urls.py b/examples/resourceexample/urls.py
index 828caef2..cb6435bb 100644
--- a/examples/resourceexample/urls.py
+++ b/examples/resourceexample/urls.py
@@ -1,6 +1,7 @@
from django.conf.urls.defaults import patterns, url
+from resourceexample.views import ExampleResource, AnotherExampleResource
-urlpatterns = patterns('resourceexample.views',
- url(r'^$', 'ExampleResource'),
- url(r'^(?P<num>[0-9]+)/$', 'AnotherExampleResource'),
+urlpatterns = patterns('',
+ url(r'^$', ExampleResource.as_view(), name='example-resource'),
+ url(r'^(?P<num>[0-9]+)/$', AnotherExampleResource.as_view(), name='another-example-resource'),
)
diff --git a/examples/resourceexample/views.py b/examples/resourceexample/views.py
index e5bb5efa..c4462ee2 100644
--- a/examples/resourceexample/views.py
+++ b/examples/resourceexample/views.py
@@ -1,13 +1,14 @@
+from django.core.urlresolvers import reverse
from djangorestframework.resource import Resource
from djangorestframework.response import Response, status
from resourceexample.forms import MyForm
class ExampleResource(Resource):
- """A basic read only resource that points to 3 other resources."""
+ """A basic read-only resource that points to 3 other resources."""
allowed_methods = anon_allowed_methods = ('GET',)
def get(self, request, auth):
- return {"Some other resources": [self.reverse(AnotherExampleResource, num=num) for num in range(3)]}
+ return {"Some other resources": [reverse('another-example-resource', kwargs={'num':num}) for num in range(3)]}
class AnotherExampleResource(Resource):
"""A basic GET-able/POST-able resource."""