2011-02-19 13:26:27 +03:00
|
|
|
"""The root view for the examples provided with Django REST framework"""
|
|
|
|
|
2012-02-22 00:57:36 +04:00
|
|
|
from djangorestframework.reverse import reverse
|
2011-05-24 13:27:24 +04:00
|
|
|
from djangorestframework.views import View
|
2012-02-07 18:52:15 +04:00
|
|
|
from djangorestframework.response import Response
|
2011-02-19 13:26:27 +03:00
|
|
|
|
|
|
|
|
2011-05-24 13:27:24 +04:00
|
|
|
class Sandbox(View):
|
2012-02-22 00:12:14 +04:00
|
|
|
"""
|
|
|
|
This is the sandbox for the examples provided with
|
|
|
|
[Django REST framework][1].
|
2011-02-19 13:26:27 +03:00
|
|
|
|
2012-02-22 00:12:14 +04:00
|
|
|
These examples are provided to help you get a better idea of some of the
|
|
|
|
features of RESTful APIs created using the framework.
|
2011-02-19 13:26:27 +03:00
|
|
|
|
2012-02-22 00:12:14 +04:00
|
|
|
All the example APIs allow anonymous access, and can be navigated either
|
|
|
|
through the browser or from the command line.
|
2011-02-19 13:26:27 +03:00
|
|
|
|
2012-02-22 00:12:14 +04:00
|
|
|
For example, to get the default representation using curl:
|
|
|
|
|
|
|
|
bash: curl -X GET http://rest.ep.io/
|
2012-02-25 22:45:17 +04:00
|
|
|
|
2012-02-22 00:12:14 +04:00
|
|
|
Or, to get the plaintext documentation represention:
|
|
|
|
|
|
|
|
bash: curl -X GET http://rest.ep.io/ -H 'Accept: text/plain'
|
2011-02-19 13:26:27 +03:00
|
|
|
|
2011-12-29 17:31:12 +04:00
|
|
|
The examples provided:
|
|
|
|
|
2012-02-22 00:12:14 +04:00
|
|
|
1. A basic example using the [Resource][2] class.
|
|
|
|
2. A basic example using the [ModelResource][3] class.
|
|
|
|
3. An basic example using Django 1.3's [class based views][4] and
|
|
|
|
djangorestframework's [RendererMixin][5].
|
2011-02-19 13:26:27 +03:00
|
|
|
4. A generic object store API.
|
|
|
|
5. A code highlighting API.
|
|
|
|
6. A blog posts and comments API.
|
2011-06-26 03:38:56 +04:00
|
|
|
7. A basic example using permissions.
|
2012-01-25 02:11:54 +04:00
|
|
|
8. A basic example using enhanced request.
|
2011-02-19 13:26:27 +03:00
|
|
|
|
2012-02-22 00:12:14 +04:00
|
|
|
Please feel free to browse, create, edit and delete the resources in
|
|
|
|
these examples.
|
|
|
|
|
|
|
|
[1]: http://django-rest-framework.org
|
|
|
|
[2]: http://django-rest-framework.org/library/resource.html
|
|
|
|
[3]: http://django-rest-framework.org/library/modelresource.html
|
|
|
|
[4]: http://docs.djangoproject.com/en/dev/topics/class-based-views/
|
|
|
|
[5]: http://django-rest-framework.org/library/renderers.html
|
|
|
|
"""
|
2011-02-19 13:26:27 +03:00
|
|
|
|
2011-04-27 21:07:28 +04:00
|
|
|
def get(self, request):
|
2012-02-22 00:12:14 +04:00
|
|
|
return Response([
|
|
|
|
{'name': 'Simple Resource example',
|
2012-02-25 22:45:17 +04:00
|
|
|
'url': reverse('example-resource', request=request)},
|
2012-02-22 00:12:14 +04:00
|
|
|
{'name': 'Simple ModelResource example',
|
2012-02-25 22:45:17 +04:00
|
|
|
'url': reverse('model-resource-root', request=request)},
|
2012-02-22 00:12:14 +04:00
|
|
|
{'name': 'Simple Mixin-only example',
|
2012-02-25 22:45:17 +04:00
|
|
|
'url': reverse('mixin-view', request=request)},
|
|
|
|
{'name': 'Object store API',
|
|
|
|
'url': reverse('object-store-root', request=request)},
|
2012-02-22 00:12:14 +04:00
|
|
|
{'name': 'Code highlighting API',
|
2012-02-25 22:45:17 +04:00
|
|
|
'url': reverse('pygments-root', request=request)},
|
2012-02-22 00:12:14 +04:00
|
|
|
{'name': 'Blog posts API',
|
2012-02-25 22:45:17 +04:00
|
|
|
'url': reverse('blog-posts-root', request=request)},
|
2012-02-22 00:12:14 +04:00
|
|
|
{'name': 'Permissions example',
|
2012-02-25 22:45:17 +04:00
|
|
|
'url': reverse('permissions-example', request=request)},
|
2012-02-22 00:12:14 +04:00
|
|
|
])
|