diff options
| author | Tom Christie | 2013-04-30 08:24:33 +0100 |
|---|---|---|
| committer | Tom Christie | 2013-04-30 08:24:33 +0100 |
| commit | 21ae3a66917acf4ea57e8f7940ce1a6823a2ce92 (patch) | |
| tree | bd4cef8d397b6a51ca2eae044b0f042949c92acc /docs/index.md | |
| parent | 81c3b4f250e389c29bdaa7da07c4860e2175136d (diff) | |
| download | django-rest-framework-21ae3a66917acf4ea57e8f7940ce1a6823a2ce92.tar.bz2 | |
Drop out attribute
Diffstat (limited to 'docs/index.md')
| -rw-r--r-- | docs/index.md | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/docs/index.md b/docs/index.md index 931d6114..12e39153 100644 --- a/docs/index.md +++ b/docs/index.md @@ -79,34 +79,26 @@ Let's take a look at a quick example of using REST framework to build a simple m We'll create a read-write API for accessing users and groups. -Here's our `views.py` module: +Here's our project's root `urls.py` module: from django.conf.urls.defaults import url, patterns, include from django.contrib.auth.models import User, Group from rest_framework import viewsets, routers - # ViewSets define the view behavior. class UserViewSet(viewsets.ModelViewSet): - queryset = User.objects.all() - fields = ('url', 'email', 'is_staff', 'groups') - + model = User class GroupViewSet(viewsets.ModelViewSet): - queryset = Group.objects.all() - fields = ('url', 'name') - -And our `urls.py` setup: - - from django.conf.urls.defaults import url, patterns, include - from myapp import views - from rest_framework import routers - + model = Group + + # Routers provide an easy way of automatically determining the URL conf router = routers.DefaultRouter() router.register(r'users', views.UserViewSet, name='user') router.register(r'groups', views.GroupViewSet, name='group') + # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browseable API. urlpatterns = patterns('', |
