diff options
| author | Tom Christie | 2011-06-02 15:22:14 +0100 |
|---|---|---|
| committer | Tom Christie | 2011-06-02 15:22:14 +0100 |
| commit | bf9ea978bca8928ba5726e4ec3d76e81d72aada8 (patch) | |
| tree | a752b60913ed733f76eb78cca983d249f47de702 /docs/index.rst | |
| parent | f78076b5ba916aea24a8cbfd2fc9c7830c7d6c5e (diff) | |
| download | django-rest-framework-bf9ea978bca8928ba5726e4ec3d76e81d72aada8.tar.bz2 | |
Updating docs for 0.2
Diffstat (limited to 'docs/index.rst')
| -rw-r--r-- | docs/index.rst | 28 |
1 files changed, 11 insertions, 17 deletions
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 <http://docs.djangoproject.com/en/dev/ref/models/instances/#get-absolute-url>`_ 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<pk>[^/]+)/$', 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<pk>[^/]+)/$', ModelResource.as_view(resource=MyResource)), + ) Django REST framework comes with two "getting started" examples. |
