From bf9ea978bca8928ba5726e4ec3d76e81d72aada8 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 2 Jun 2011 15:22:14 +0100 Subject: Updating docs for 0.2 --- docs/examples/modelresources.rst | 7 ------- docs/index.rst | 28 +++++++++++----------------- 2 files changed, 11 insertions(+), 24 deletions(-) (limited to 'docs') diff --git a/docs/examples/modelresources.rst b/docs/examples/modelresources.rst index 676656a7..375e4a8d 100644 --- a/docs/examples/modelresources.rst +++ b/docs/examples/modelresources.rst @@ -32,13 +32,6 @@ Here's the models we're working from in this example. It's usually a good idea .. include:: ../../examples/modelresourceexample/models.py :literal: -Now that we've got some models and a urlconf, there's very little code to write. We'll create a :class:`.ModelResource` to map to instances of our models, and a top level :class:`.RootModelResource` to list the existing instances and to create new instances. - -``views.py`` - -.. include:: ../../examples/modelresourceexample/views.py - :literal: - And we're done. We've now got a fully browseable API, which supports multiple input and output media types, and has all the nice automatic field validation that Django gives us for free. We can visit the API in our browser: diff --git a/docs/index.rst b/docs/index.rst index 88c3bac2..866ad444 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -70,28 +70,22 @@ For more information on settings take a look at the :ref:`setup` section. Getting Started --------------- -Using Django REST framework can be as simple as adding a few lines to your urlconf and adding a `permalink `_ to your model. +Using Django REST framework can be as simple as adding a few lines to your urlconf. -`urls.py`:: +``urls.py``:: from django.conf.urls.defaults import patterns, url - from djangorestframework import ModelResource, RootModelResource - from models import MyModel + from djangorestframework.resources import ModelResource + from djangorestframework.views import ListOrCreateModelView, InstanceModelView + from myapp.models import MyModel + + class MyResource(ModelResource): + model = MyModel urlpatterns = patterns('', - url(r'^$', RootModelResource.as_view(model=MyModel)), - url(r'^(?P[^/]+)/$', ModelResource.as_view(model=MyModel), name='my-model'), - ) - -`models.py`:: - - class MyModel(models.Model): - - # (Rest of model definition...) - - @models.permalink - def get_absolute_url(self): - return ('my-model', (self.pk,)) + url(r'^$', RootModelResource.as_view(resource=MyResource)), + url(r'^(?P[^/]+)/$', ModelResource.as_view(resource=MyResource)), + ) Django REST framework comes with two "getting started" examples. -- cgit v1.2.3