django-rest-framework/index.html
2012-10-17 13:50:08 +01:00

283 lines
18 KiB
HTML

<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Django REST framework</title>
<link href="http://tomchristie.github.com/django-rest-framework/img/favicon.ico" rel="icon" type="image/x-icon">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="http://tomchristie.github.com/django-rest-framework/css/prettify.css" rel="stylesheet">
<link href="http://tomchristie.github.com/django-rest-framework/css/bootstrap.css" rel="stylesheet">
<link href="http://tomchristie.github.com/django-rest-framework/css/bootstrap-responsive.css" rel="stylesheet">
<link href="http://tomchristie.github.com/django-rest-framework/css/default.css" rel="stylesheet">
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<body onload="prettyPrint()" class="index-page">
<div class="wrapper">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/restframework2">GitHub</a>
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="http://tomchristie.github.com/django-rest-framework">Django REST framework</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="http://tomchristie.github.com/django-rest-framework">Home</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="http://tomchristie.github.com/django-rest-framework/tutorial/quickstart">Quickstart</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/tutorial/1-serialization">1 - Serialization</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/tutorial/2-requests-and-responses">2 - Requests and responses</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/tutorial/3-class-based-views">3 - Class based views</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/tutorial/4-authentication-permissions-and-throttling">4 - Authentication, permissions and throttling</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships and hyperlinked APIs</a></li>
<!-- <li><a href="http://tomchristie.github.com/django-rest-framework/tutorial/6-resource-orientated-projects">6 - Resource orientated projects</a></li> -->
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">API Guide <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/requests">Requests</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/responses">Responses</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/views">Views</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/generic-views">Generic views</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/parsers">Parsers</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/renderers">Renderers</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/serializers">Serializers</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/fields">Serializer fields</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/authentication">Authentication</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/permissions">Permissions</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/throttling">Throttling</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/pagination">Pagination</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/content-negotiation">Content negotiation</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/format-suffixes">Format suffixes</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/reverse">Returning URLs</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/exceptions">Exceptions</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/status-codes">Status codes</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/settings">Settings</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Topics <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="http://tomchristie.github.com/django-rest-framework/topics/csrf">Working with AJAX and CSRF</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/topics/browser-enhancements">Browser enhancements</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/topics/browsable-api">The Browsable API</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/topics/rest-hypermedia-hateoas">REST, Hypermedia & HATEOAS</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/topics/contributing">Contributing to REST framework</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/topics/migration">2.0 Migration Guide</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/topics/release-notes">Release Notes</a></li>
<li><a href="http://tomchristie.github.com/django-rest-framework/topics/credits">Credits</a></li>
</ul>
</li>
</ul>
<ul class="nav pull-right">
<!-- TODO
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Version: 2.0.0 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Trunk</a></li>
<li><a href="#">2.0.0</a></li>
</ul>
</li>
-->
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="body-content">
<div class="container-fluid">
<div class="row-fluid">
<div class="span3">
<!-- TODO
<p style="margin-top: -12px">
<a class="btn btn-mini btn-primary" style="width: 60px">&laquo; previous</a>
<a class="btn btn-mini btn-primary" style="float: right; margin-right: 8px; width: 60px;">next &raquo;</a>
</p>
-->
<div id="table-of-contents">
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
<li class="main"><a href="#django-rest-framework">Django REST framework</a></li>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#quickstart">Quickstart</a></li>
<li><a href="#tutorial">Tutorial</a></li>
<li><a href="#api-guide">API Guide</a></li>
<li><a href="#topics">Topics</a></li>
<li><a href="#development">Development</a></li>
<li><a href="#support">Support</a></li>
<li><a href="#license">License</a></li>
</ul>
</div>
</div>
<div id="main-content" class="span9">
<iframe src="http://ghbtns.com/github-btn.html?user=tomchristie&amp;repo=django-rest-framework&amp;type=watch&amp;count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
<p><a href="http://travis-ci.org/tomchristie/django-rest-framework?branch=restframework2"><img alt="Travis build image" src="https://secure.travis-ci.org/tomchristie/django-rest-framework.png?branch=restframework2" /></a></p>
<h1 id="django-rest-framework">Django REST framework</h1>
<p><strong>A toolkit for building well-connected, self-describing Web APIs.</strong></p>
<p><strong>WARNING: This documentation is for the 2.0 redesign of REST framework. It is a work in progress.</strong></p>
<p>Django REST framework is a lightweight library that makes it easy to build Web APIs. It is designed as a modular and easy to customize architecture, based on Django's class based views.</p>
<p>Web APIs built using REST framework are fully self-describing and web browseable - a huge useability win for your developers. It also supports a wide range of media types, authentication and permission policies out of the box.</p>
<h2 id="requirements">Requirements</h2>
<p>REST framework requires the following:</p>
<ul>
<li>Python (2.6, 2.7)</li>
<li>Django (1.3, 1.4, 1.5)</li>
</ul>
<p>The following packages are optional:</p>
<ul>
<li><a href="http://pypi.python.org/pypi/Markdown/">Markdown</a> (2.1.0+) - Markdown support for the self describing API.</li>
<li><a href="http://pypi.python.org/pypi/PyYAML">PyYAML</a> (3.10+) - YAML content-type support.</li>
</ul>
<h2 id="installation">Installation</h2>
<p><strong>WARNING: These instructions will only become valid once this becomes the master version</strong></p>
<p>Install using <code>pip</code>, including any optional packages you want...</p>
<pre class="prettyprint lang-py"><code>pip install djangorestframework
pip install markdown # Recommended if using the browseable API.
pip install pyyaml # Required for yaml content-type support.
</code></pre>
<p>...or clone the project from github.</p>
<pre class="prettyprint lang-py"><code>git clone git@github.com:tomchristie/django-rest-framework.git
cd django-rest-framework
pip install -r requirements.txt
pip install -r optionals.txt
</code></pre>
<p>Add <code>rest_framework</code> to your <code>INSTALLED_APPS</code>.</p>
<pre class="prettyprint lang-py"><code>INSTALLED_APPS = (
...
'rest_framework',
)
</code></pre>
<p>If you're intending to use the browserable API you'll want to add REST framework's login and logout views. Add the following to your root <code>urls.py</code> file.</p>
<pre class="prettyprint lang-py"><code>urlpatterns = patterns('',
...
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
)
</code></pre>
<p>Note that the URL path can be whatever you want, but you must include <code>rest_framework.urls</code> with the <code>rest_framework</code> namespace.</p>
<h2 id="quickstart">Quickstart</h2>
<p>Can't wait to get started? The <a href="tutorial/quickstart">quickstart guide</a> is the fastest way to get up and running with REST framework.</p>
<h2 id="tutorial">Tutorial</h2>
<p>The tutorial will walk you through the building blocks that make up REST framework. It'll take a little while to get through, but it'll give you a comprehensive understanding of how everything fits together, and is highly recommended reading.</p>
<ul>
<li><a href="tutorial/1-serialization">1 - Serialization</a></li>
<li><a href="tutorial/2-requests-and-responses">2 - Requests &amp; Responses</a></li>
<li><a href="tutorial/3-class-based-views">3 - Class based views</a></li>
<li><a href="tutorial/4-authentication-permissions-and-throttling">4 - Authentication, permissions &amp; throttling</a></li>
<li><a href="tutorial/5-relationships-and-hyperlinked-apis">5 - Relationships &amp; hyperlinked APIs</a>
<!-- * <a href="tutorial/6-resource-orientated-projects">6 - Resource orientated projects</a>--></li>
</ul>
<h2 id="api-guide">API Guide</h2>
<p>The API guide is your complete reference manual to all the functionality provided by REST framework.</p>
<ul>
<li><a href="api-guide/requests">Requests</a></li>
<li><a href="api-guide/responses">Responses</a></li>
<li><a href="api-guide/views">Views</a></li>
<li><a href="api-guide/generic-views">Generic views</a></li>
<li><a href="api-guide/parsers">Parsers</a></li>
<li><a href="api-guide/renderers">Renderers</a></li>
<li><a href="api-guide/serializers">Serializers</a></li>
<li><a href="api-guide/fields">Serializer fields</a></li>
<li><a href="api-guide/authentication">Authentication</a></li>
<li><a href="api-guide/permissions">Permissions</a></li>
<li><a href="api-guide/throttling">Throttling</a></li>
<li><a href="api-guide/pagination">Pagination</a></li>
<li><a href="api-guide/content-negotiation">Content negotiation</a></li>
<li><a href="api-guide/format-suffixes">Format suffixes</a></li>
<li><a href="api-guide/reverse">Returning URLs</a></li>
<li><a href="api-guide/exceptions">Exceptions</a></li>
<li><a href="api-guide/status-codes">Status codes</a></li>
<li><a href="api-guide/settings">Settings</a></li>
</ul>
<h2 id="topics">Topics</h2>
<p>General guides to using REST framework.</p>
<ul>
<li><a href="topics/csrf">CSRF</a></li>
<li><a href="topics/browser-enhancements">Browser enhancements</a></li>
<li><a href="topics/browsable-api">The Browsable API</a></li>
<li><a href="topics/rest-hypermedia-hateoas">REST, Hypermedia &amp; HATEOAS</a></li>
<li><a href="topics/contributing">Contributing to REST framework</a></li>
<li><a href="topics/migration">2.0 Migration Guide</a></li>
<li><a href="topics/release-notes">Release Notes</a></li>
<li><a href="topics/credits">Credits</a></li>
</ul>
<h2 id="development">Development</h2>
<p>If you want to work on REST framework itself, clone the repository, then...</p>
<p>Build the docs:</p>
<pre class="prettyprint lang-py"><code>./mkdocs.py
</code></pre>
<p>Run the tests:</p>
<pre class="prettyprint lang-py"><code>./rest_framework/runtests/runtests.py
</code></pre>
<p>For more information see the <a href="topics/contributing">Contributing to REST framework</a> section.</p>
<h2 id="support">Support</h2>
<p>For support please see the <a href="https://groups.google.com/forum/?fromgroups#!forum/django-rest-framework">REST framework discussion group</a>, or try the <code>#restframework</code> channel on <code>irc.freenode.net</code>.</p>
<p>Paid support is also available from <a href="http://dabapps.com">DabApps</a>, and can include work on REST framework core, or support with building your REST framework API. Please contact <a href="mailto:tom@tomchristie.com">Tom Christie</a> if you'd like to discuss commercial support options.</p>
<h2 id="license">License</h2>
<p>Copyright (c) 2011-2012, Tom Christie
All rights reserved.</p>
<p>Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:</p>
<p>Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.</p>
<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
</div><!--/span-->
</div><!--/row-->
</div><!--/.fluid-container-->
</div><!--/.body content-->
<div id="push"></div>
</div><!--/.wrapper -->
<footer class="span12">
<p>Sponsored by <a href="http://dabapps.com/">DabApps</a>.</a></p>
</footer>
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://tomchristie.github.com/django-rest-framework/js/jquery-1.8.1-min.js"></script>
<script src="http://tomchristie.github.com/django-rest-framework/js/prettify-1.0.js"></script>
<script src="http://tomchristie.github.com/django-rest-framework/js/bootstrap-2.1.1-min.js"></script>
<script>
//$('.side-nav').scrollspy()
var shiftWindow = function() { scrollBy(0, -50) };
if (location.hash) shiftWindow();
window.addEventListener("hashchange", shiftWindow);
$('.dropdown-menu').on('click touchstart', function(event) {
event.stopPropagation();
});
</script>
</body></html>