Add `'rest_framework'` to your `INSTALLED_APPS` setting.
...
...
@@ -69,20 +55,42 @@ If you're intending to use the browseable API you'll probably also want to add R
Note that the URL path can be whatever you want, but you must include `'rest_framework.urls'` with the `'rest_framework'` namespace.
# Development
# Example
Let's take a look at a quick example of using REST framework to build a simple model-backed API.
To build the docs.
We'll create a read-write API for accessing users and groups.
./mkdocs.py
Here's our project's root `urls.py` module:
To run the tests.
from django.conf.urls.defaults import url, patterns, include
from django.contrib.auth.models import User, Group
from rest_framework import viewsets, routers
./rest_framework/runtests/runtests.py
# ViewSets define the view behavior.
class UserViewSet(viewsets.ModelViewSet):
model = User
To run the tests against all supported configurations, first install [the tox testing tool][tox] globally, using `pip install tox`, then simply run `tox`:
class GroupViewSet(viewsets.ModelViewSet):
model = Group
# Routers provide an easy way of automatically determining the URL conf
Django REST framework is a flexible, powerful Web API toolkit. It is designed as a modular and easy to customize architecture, based on Django's class based views.
Django REST framework is a flexible and powerful Web API toolkit. It is designed as a modular and easy to customize architecture, based on Django's class based views.
APIs built using REST framework are fully self-describing and web browseable - a huge useability win for your developers. It also supports a wide range of media types, authentication and permission policies out of the box.
...
...
@@ -47,7 +47,6 @@ Install using `pip`, including any optional packages you want...
pip install djangorestframework
pip install markdown # Markdown support for the browseable API.