Table Of Contents

Previous topic

Returning URIs from your Web APIs

Next topic

Using CURL with django-rest-framework

This Page

Setup

Templates

Django REST framework uses a few templates for the HTML and plain text documenting renderers. You’ll need to ensure TEMPLATE_LOADERS setting contains 'django.template.loaders.app_directories.Loader'. This will already be the case by default.

You may customize the templates by creating a new template called djangorestframework/api.html in your project, which should extend djangorestframework/base.html and override the appropriate block tags. For example:

{% extends "djangorestframework/base.html" %}

{% block title %}My API{% endblock %}

{% block branding %}
<h1 id="site-name">My API</h1>
{% endblock %}

Styling

Django REST framework requires django.contrib.staticfiles to serve it’s css. If you’re using Django 1.2 you’ll need to use the seperate django-staticfiles package instead.

You can override the styling by creating a file in your top-level static directory named djangorestframework/css/style.css

Markdown

Python markdown is not required but comes recommended.

If markdown is installed your Resource descriptions can include markdown formatting which will be rendered by the self-documenting API.

YAML

YAML support is optional, and requires PyYAML.

Login / Logout

Django REST framework includes login and logout views that are needed if you’re using the self-documenting API.

Make sure you include the following in your urlconf:

from django.conf.urls.defaults import patterns, url

urlpatterns = patterns('',
    ...
    url(r'^restframework', include('djangorestframework.urls', namespace='djangorestframework'))
)