diff options
| author | Tom Christie | 2011-05-16 14:11:36 +0100 |
|---|---|---|
| committer | Tom Christie | 2011-05-16 14:11:36 +0100 |
| commit | 1e04790d505a1174f9e3c4481288982f9e7fd6c0 (patch) | |
| tree | 09c5b29acdc820dc3fc1108f3503cde03d725eb9 /examples/resourceexample/views.py | |
| parent | e92002ddde31fcc4ba3dee0f4a92a114c3c3a959 (diff) | |
| download | django-rest-framework-1e04790d505a1174f9e3c4481288982f9e7fd6c0.tar.bz2 | |
Fixing some of the last blocking issues
Diffstat (limited to 'examples/resourceexample/views.py')
| -rw-r--r-- | examples/resourceexample/views.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/examples/resourceexample/views.py b/examples/resourceexample/views.py index 911fd467..70d96891 100644 --- a/examples/resourceexample/views.py +++ b/examples/resourceexample/views.py @@ -1,20 +1,33 @@ from django.core.urlresolvers import reverse -from djangorestframework.resource import Resource +from djangorestframework.views import BaseView +from djangorestframework.resources import FormResource from djangorestframework.response import Response from djangorestframework import status from resourceexample.forms import MyForm -class ExampleResource(Resource): - """A basic read-only resource that points to 3 other resources.""" +class MyFormValidation(FormResource): + """ + A resource which applies form validation on the input. + """ + form = MyForm + + +class ExampleResource(BaseView): + """ + A basic read-only resource that points to 3 other resources. + """ def get(self, request): 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.""" - form = MyForm # Optional form validation on input (Applies in this case the POST method, but can also apply to PUT) + +class AnotherExampleResource(BaseView): + """ + A basic GET-able/POST-able resource. + """ + resource = MyFormValidation def get(self, request, num): """Handle GET requests""" |
