diff options
| author | Tom Christie | 2013-04-30 14:34:42 +0100 | 
|---|---|---|
| committer | Tom Christie | 2013-04-30 14:34:42 +0100 | 
| commit | 7eba12fd28766971a25491a9360aaf0fda684a0f (patch) | |
| tree | 1ec07a0433a4b767e8ae3257641cee4047ec8747 /README.md | |
| parent | b65b065375796919a57f4bd6f1dd8187ef0eb165 (diff) | |
| download | django-rest-framework-7eba12fd28766971a25491a9360aaf0fda684a0f.tar.bz2 | |
More index docs tweaks
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 20 | 
1 files changed, 19 insertions, 1 deletions
| @@ -15,7 +15,7 @@ Some reasons you might want to use REST framework:  * The Web browseable API is a huge useability win for your developers.  * Authentication policies including OAuth1a and OAuth2 out of the box.  * Serialization that supports both ORM and non-ORM data sources. -* Customizable all the way down.  Just use regular function-based views if you don't need the more powerful features. +* Customizable all the way down - just use regular function-based views if you don't need the more powerful features.  * Extensive documentation, and great community support.  There is a live example API for testing purposes, [available here][sandbox]. @@ -57,6 +57,24 @@ 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. +Any global settings for a REST framework API are kept in a single configuration dictionary named `REST_FRAMEWORK`.  Start off by adding the following to your `settings.py` module: + +    REST_FRAMEWORK = { +        # Use hyperlinked styles by default. +        # Only used if the `serializer_class` attribute is not set on a view. +        'DEFAULT_MODEL_SERIALIZER_CLASS': +            'rest_framework.serializers.HyperlinkedModelSerializer', + +        # Use Django's standard `django.contrib.auth` permissions, +        # or allow read-only access for unauthenticated users. +        'DEFAULT_PERMISSION_CLASSES': [ +            'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' +        ] +    } + +Don't forget to make sure you've also added `rest_framework` to your `INSTALLED_APPS`. + +We're ready to create our API now.   Here's our project's root `urls.py` module:      from django.conf.urls.defaults import url, patterns, include | 
