diff options
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('', |
