blob: 7da3f01742d98c6cc687ca47536ab15203d250bb (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
 | Django REST framework
=====================
A lightweight REST framework for Django.
Features:
* Clean, simple, class-based views for Resources.
* Support for ModelResources with nice default implementations and input validation.
* Automatically provides a browse-able self-documenting API.
* Pluggable Emitters, Parsers and Authenticators - Easy to customise.
* Content type negotiation using Accept headers.
* Optional support for forms as input validation.
* Modular architecture - Easy to extend and modify.
Requirements
------------
* Python 2.6
* Django 1.2
.. note::
    Support for a wider range of Python & Django versions is planned, but right now django-rest-framework is only tested against these versions.
Installation & Setup
--------------------
The django-rest-framework project is hosted as a `mercurial repository on bitbucket <https://bitbucket.org/tomchristie/django-rest-framework>`_.
To get a local copy of the repository use mercurial::
    hg clone https://tomchristie@bitbucket.org/tomchristie/django-rest-framework
To add django-rest-framework to a django project:
* Copy or symlink the ``djangorestframework`` directory into python's ``site-packages`` directory, or otherwise ensure that the ``djangorestframework`` directory is on your ``PYTHONPATH``.
* Add ``djangorestframework`` to your ``INSTALLED_APPS``.
* Ensure the ``TEMPLATE_LOADERS`` setting contains the item ``'django.template.loaders.app_directories.Loader'``. (It will do by default, so you shouldn't normally need to do anything here.)
Getting Started
---------------
Often you'll want parts of your API to directly map to existing Models.
At it's simplest this looks something like this...
``urls.py``
.. include:: ../examples/simpleexample/urls.py
    :literal:
``views.py``
.. include:: ../examples/simpleexample/views.py
    :literal:
Examples
--------
There's a few real world examples included with django-rest-framework.
These demonstrate the following use cases:
#. Using :class:`.Resource` for resources that do not map to models.
#. Using :class:`.Resource` with forms for input validation.
#. Using :class:`.ModelResource` for resources that map directly to models.
All the examples are freely available for testing in the sandbox here: http://api.django-rest-framework.org
.. toctree::
  :maxdepth: 1
  examples/objectstore
  examples/pygments
  examples/blogpost
How Tos
-------
.. toctree::
  :maxdepth: 2
  howto/usingcurl
.. note::
    TODO
Library Reference
-----------------
.. toctree::
  :maxdepth: 2
  library/resource
  library/modelresource
  library/emitters
  library/parsers
  library/authenticators
  library/response
Indices and tables
------------------
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
 |