django-rest-framework/index.html

245 lines
15 KiB
HTML
Raw Normal View History

2012-09-02 00:24:33 +04:00
<!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>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
2012-09-08 23:24:07 +04:00
<link href="http://tomchristie.github.com/django-rest-framework/css/prettify.css" rel="stylesheet">
2012-09-02 00:37:41 +04:00
<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">
2012-09-13 12:40:09 +04:00
<link href="http://tomchristie.github.com/django-rest-framework/css/default.css" rel="stylesheet">
2012-09-02 00:24:33 +04:00
<!-- 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">
2012-09-02 00:24:33 +04:00
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
2012-09-12 16:12:00 +04:00
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/restframework2">GitHub</a>
2012-09-02 00:24:33 +04:00
<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>
2012-09-02 00:37:41 +04:00
<a class="brand" href="http://tomchristie.github.com/django-rest-framework">Django REST framework</a>
2012-09-02 00:24:33 +04:00
<div class="nav-collapse collapse">
<ul class="nav">
2012-09-02 00:37:41 +04:00
<li><a href="http://tomchristie.github.com/django-rest-framework">Home</a></li>
2012-09-02 00:24:33 +04:00
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
<ul class="dropdown-menu">
2012-09-02 00:37:41 +04:00
<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>
2012-09-02 00:24:33 +04:00
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">API Guide <b class="caret"></b></a>
<ul class="dropdown-menu">
2012-09-02 00:37:41 +04:00
<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>
2012-09-12 13:14:01 +04:00
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/generic-views">Generic views</a></li>
2012-09-02 00:37:41 +04:00
<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/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>
2012-09-12 13:14:01 +04:00
<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>
2012-09-02 00:37:41 +04:00
<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>
2012-09-05 16:05:36 +04:00
<li><a href="http://tomchristie.github.com/django-rest-framework/api-guide/settings">Settings</a></li>
2012-09-02 00:24:33 +04:00
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Topics <b class="caret"></b></a>
<ul class="dropdown-menu">
2012-09-02 00:37:41 +04:00
<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/formoverloading">Browser based PUT, PATCH and DELETE</a></li>
2012-09-05 16:05:36 +04:00
<li><a href="http://tomchristie.github.com/django-rest-framework/topics/contributing">Contributing to REST framework</a></li>
2012-09-02 00:37:41 +04:00
<li><a href="http://tomchristie.github.com/django-rest-framework/topics/credits">Credits</a></li>
2012-09-02 00:24:33 +04:00
</ul>
</li>
</ul>
<ul class="nav pull-right">
<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>
2012-09-02 00:24:33 +04:00
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span3">
<div id="table-of-contents" class="well affix span3">
<ul class="nav nav-list side-nav">
<li class="main"><a href="#django-rest-framework">Django REST framework</a></li>
2012-09-02 00:24:33 +04:00
<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>
2012-09-02 00:37:41 +04:00
<li><a href="#development">Development</a></li>
2012-09-02 00:24:33 +04:00
<li><a href="#license">License</a></li>
</ul>
</div>
2012-09-02 00:24:33 +04:00
</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="Build Status" src="https://secure.travis-ci.org/tomchristie/django-rest-framework.png?branch=restframework2" /></a></p>
<h1 id="django-rest-framework">Django REST framework</h1>
2012-09-02 00:24:33 +04:00
<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>
<li><a href="https://github.com/zacharyvoase/urlobject">URLObject</a> (2.0.0+)</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>
2012-09-03 15:20:08 +04:00
<li><a href="http://pypi.python.org/pypi/PyYAML">PyYAML</a> (3.10+) - YAML content-type support.</li>
2012-09-02 00:24:33 +04:00
</ul>
<h2 id="installation">Installation</h2>
<p><strong>WARNING: These instructions will only become valid once this becomes the master version</strong></p>
2012-09-03 15:20:08 +04:00
<p>Install using <code>pip</code>, including any optional packages you want...</p>
2012-09-08 23:24:07 +04:00
<pre class="prettyprint lang-py"><code>pip install djangorestframework
2012-09-03 15:20:08 +04:00
pip install markdown # Recommended if using the browseable API.
pip install pyyaml # Required for yaml content-type support.
2012-09-02 00:24:33 +04:00
</code></pre>
<p>...or clone the project from github.</p>
2012-09-08 23:24:07 +04:00
<pre class="prettyprint lang-py"><code>git clone git@github.com:tomchristie/django-rest-framework.git
2012-09-03 15:20:08 +04:00
cd django-rest-framework
2012-09-02 00:24:33 +04:00
pip install -r requirements.txt
2012-09-03 15:20:08 +04:00
pip install -r optionals.txt
2012-09-02 00:24:33 +04:00
</code></pre>
<p>Add <code>djangorestframework</code> to your <code>INSTALLED_APPS</code>.</p>
2012-09-08 23:24:07 +04:00
<pre class="prettyprint lang-py"><code>INSTALLED_APPS = (
2012-09-02 00:24:33 +04:00
...
'djangorestframework',
)
</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>
2012-09-08 23:24:07 +04:00
<pre class="prettyprint lang-py"><code>urlpatterns = patterns('',
2012-09-02 00:24:33 +04:00
...
2012-09-05 16:05:36 +04:00
url(r'^api-auth/', include('djangorestframework.urls', namespace='djangorestframework'))
2012-09-02 00:24:33 +04:00
)
</code></pre>
<h2 id="quickstart">Quickstart</h2>
<p><strong>TODO</strong></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></li>
<li><a href="tutorial/6-resource-orientated-projects">6 - Resource orientated projects</a></li>
2012-09-02 00:24:33 +04:00
</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>
2012-09-12 13:14:01 +04:00
<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/authentication">Authentication</a></li>
<li><a href="api-guide/permissions">Permissions</a></li>
<li><a href="api-guide/throttling">Throttling</a></li>
2012-09-12 13:14:01 +04:00
<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>
2012-09-02 00:24:33 +04:00
</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/formoverloading">Form overloading</a></li>
<li><a href="topics/contributing">Contributing to REST framework</a></li>
<li><a href="topics/credits">Credits</a></li>
2012-09-02 00:24:33 +04:00
</ul>
2012-09-02 00:37:41 +04:00
<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>
2012-09-08 23:24:07 +04:00
<pre class="prettyprint lang-py"><code>./mkdocs.py
2012-09-02 00:37:41 +04:00
</code></pre>
<p>Run the tests:</p>
2012-09-08 23:24:07 +04:00
<pre class="prettyprint lang-py"><code>./djangorestframework/runtests/runtests.py
2012-09-02 00:37:41 +04:00
</code></pre>
2012-09-02 00:24:33 +04:00
<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-->
<!-- 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>
2012-09-08 23:24:07 +04:00
<script src="http://tomchristie.github.com/django-rest-framework/js/prettify.js"></script>
2012-09-02 00:37:41 +04:00
<script src="http://tomchristie.github.com/django-rest-framework/js/bootstrap-dropdown.js"></script>
<script src="http://tomchristie.github.com/django-rest-framework/js/bootstrap-scrollspy.js"></script>
<script src="http://tomchristie.github.com/django-rest-framework/js/bootstrap-collapse.js"></script>
2012-09-02 00:24:33 +04:00
<script>
//$('.side-nav').scrollspy()
var shiftWindow = function() { scrollBy(0, -50) };
if (location.hash) shiftWindow();
window.addEventListener("hashchange", shiftWindow);
2012-09-12 13:14:01 +04:00
$('.dropdown-menu').click(function(event) {
event.stopPropagation();
});
2012-09-02 00:24:33 +04:00
</script>
</body></html>