2011-02-19 13:26:27 +03:00
""" The root view for the examples provided with Django REST framework """
2012-02-20 14:28:50 +04:00
from djangorestframework . utils import reverse
2011-05-24 13:27:24 +04:00
from djangorestframework . views import View
2011-02-19 13:26:27 +03:00
2011-05-24 13:27:24 +04:00
class Sandbox ( View ) :
2011-02-19 13:26:27 +03:00
""" This is the sandbox for the examples provided with [Django REST framework](http://django-rest-framework.org).
2011-12-13 01:20:09 +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
All the example APIs allow anonymous access , and can be navigated either through the browser or from the command line . . .
2011-04-28 22:54:30 +04:00
bash : curl - X GET http : / / api . django - rest - framework . org / # (Use default renderer)
bash : curl - X GET http : / / api . django - rest - framework . org / - H ' Accept: text/plain ' # (Use plaintext documentation renderer)
2011-02-19 13:26:27 +03:00
2011-12-29 17:31:12 +04:00
The examples provided :
2011-02-19 13:26:27 +03:00
1. A basic example using the [ Resource ] ( http : / / django - rest - framework . org / library / resource . html ) class .
2. A basic example using the [ ModelResource ] ( http : / / django - rest - framework . org / library / modelresource . html ) class .
2011-04-28 22:54:30 +04:00
3. An basic example using Django 1.3 ' s [class based views](http://docs.djangoproject.com/en/dev/topics/class-based-views/) and djangorestframework ' s [ RendererMixin ] ( http : / / django - rest - framework . org / library / renderers . html ) .
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 .
2011-02-19 13:26:27 +03:00
Please feel free to browse , create , edit and delete the resources in these examples . """
2011-04-27 21:07:28 +04:00
def get ( self , request ) :
2012-02-20 14:28:50 +04:00
return [ { ' name ' : ' Simple Resource example ' , ' url ' : reverse ( ' example-resource ' , request ) } ,
{ ' name ' : ' Simple ModelResource example ' , ' url ' : reverse ( ' model-resource-root ' , request ) } ,
{ ' name ' : ' Simple Mixin-only example ' , ' url ' : reverse ( ' mixin-view ' , request ) } ,
{ ' name ' : ' Object store API ' , ' url ' : reverse ( ' object-store-root ' , request ) } ,
{ ' name ' : ' Code highlighting API ' , ' url ' : reverse ( ' pygments-root ' , request ) } ,
{ ' name ' : ' Blog posts API ' , ' url ' : reverse ( ' blog-posts-root ' , request ) } ,
{ ' name ' : ' Permissions example ' , ' url ' : reverse ( ' permissions-example ' , request ) }
2011-06-20 03:10:25 +04:00
]