mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-04-25 19:43:47 +03:00
Update docs
This commit is contained in:
parent
9fb7793861
commit
6c5fb56257
|
@ -3,35 +3,18 @@
|
||||||
Setup
|
Setup
|
||||||
=====
|
=====
|
||||||
|
|
||||||
Installing into site-packages
|
Templates
|
||||||
-----------------------------
|
---------
|
||||||
|
|
||||||
If you need to manually install Django REST framework to your ``site-packages`` directory, run the ``setup.py`` script::
|
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.
|
||||||
|
|
||||||
python setup.py install
|
You may customize the templates by creating a new template called
|
||||||
|
``djangorestframework/api.html`` in your project, which should extend
|
||||||
Template Loaders
|
``djangorestframework/base.html`` and override the appropriate
|
||||||
----------------
|
block tags. For example::
|
||||||
|
|
||||||
Django REST framework uses a few templates for the HTML and plain text documenting renderers.
|
|
||||||
|
|
||||||
* Ensure ``TEMPLATE_LOADERS`` setting contains ``'django.template.loaders.app_directories.Loader'``.
|
|
||||||
|
|
||||||
This will be the case by default so you shouldn't normally need to do anything here.
|
|
||||||
|
|
||||||
Admin Styling
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Django REST framework uses the admin media for styling. When running using Django's testserver this is automatically served for you,
|
|
||||||
but once you move onto a production server, you'll want to make sure you serve the admin media separately, exactly as you would do
|
|
||||||
`if using the Django admin <https://docs.djangoproject.com/en/dev/howto/deployment/modpython/#serving-the-admin-files>`_.
|
|
||||||
|
|
||||||
* Ensure that the ``ADMIN_MEDIA_PREFIX`` is set appropriately and that you are serving the admin media.
|
|
||||||
(Django's testserver will automatically serve the admin media for you)
|
|
||||||
|
|
||||||
You may customize the templates by creating a new template called ``djangorestframework/api.html``
|
|
||||||
in your project, extend ``djangorestframework/base.html`` and override the
|
|
||||||
appropriate ``{% block tags %}``. For example::
|
|
||||||
|
|
||||||
{% extends "djangorestframework/base.html" %}
|
{% extends "djangorestframework/base.html" %}
|
||||||
|
|
||||||
|
@ -42,19 +25,36 @@ appropriate ``{% block tags %}``. For example::
|
||||||
{% endblock %}
|
{% 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
|
Markdown
|
||||||
--------
|
--------
|
||||||
|
|
||||||
The Python `markdown library <http://www.freewisdom.org/projects/python-markdown/>`_ is not required but comes recommended.
|
`Python markdown`_ is not required but comes recommended.
|
||||||
|
|
||||||
If markdown is installed your :class:`.Resource` descriptions can include `markdown style formatting
|
If markdown is installed your :class:`.Resource` descriptions can include
|
||||||
<http://daringfireball.net/projects/markdown/syntax>`_ which will be rendered by the HTML documenting renderer.
|
`markdown formatting`_ which will be rendered by the self-documenting API.
|
||||||
|
|
||||||
login/logout
|
YAML
|
||||||
---------------------------------
|
----
|
||||||
|
|
||||||
Django REST framework comes with a few views that can be useful including an api
|
YAML support is optional, and requires `PyYAML`_.
|
||||||
login and logout views::
|
|
||||||
|
|
||||||
|
Login / Logout
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Django REST framework includes login and logout views that are useful if
|
||||||
|
you're using the self-documenting API::
|
||||||
|
|
||||||
from django.conf.urls.defaults import patterns
|
from django.conf.urls.defaults import patterns
|
||||||
|
|
||||||
|
@ -64,3 +64,9 @@ login and logout views::
|
||||||
(r'^accounts/logout/$', 'api_logout'),
|
(r'^accounts/logout/$', 'api_logout'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
.. _django.contrib.staticfiles: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/
|
||||||
|
.. _django-staticfiles: http://pypi.python.org/pypi/django-staticfiles/
|
||||||
|
.. _URLObject: http://pypi.python.org/pypi/URLObject/
|
||||||
|
.. _Python markdown: http://www.freewisdom.org/projects/python-markdown/
|
||||||
|
.. _markdown formatting: http://daringfireball.net/projects/markdown/syntax
|
||||||
|
.. _PyYAML: http://pypi.python.org/pypi/PyYAML
|
|
@ -40,8 +40,11 @@ Requirements
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* Python (2.5, 2.6, 2.7 supported)
|
* Python (2.5, 2.6, 2.7 supported)
|
||||||
* Django (1.2, 1.3, 1.4-alpha supported)
|
* Django (1.2, 1.3, 1.4 supported)
|
||||||
|
* `django.contrib.staticfiles`_ (or `django-staticfiles`_ for Django 1.2)
|
||||||
|
* `URLObject`_ >= 2.0.0
|
||||||
|
* `Markdown`_ >= 2.1.0 (Optional)
|
||||||
|
* `PyYAML`_ >= 3.10 (Optional)
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
@ -54,8 +57,6 @@ Or get the latest development version using git::
|
||||||
|
|
||||||
git clone git@github.com:tomchristie/django-rest-framework.git
|
git clone git@github.com:tomchristie/django-rest-framework.git
|
||||||
|
|
||||||
Or you can `download the current release <http://pypi.python.org/pypi/djangorestframework>`_.
|
|
||||||
|
|
||||||
Setup
|
Setup
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -114,3 +115,8 @@ Indices and tables
|
||||||
* :ref:`modindex`
|
* :ref:`modindex`
|
||||||
* :ref:`search`
|
* :ref:`search`
|
||||||
|
|
||||||
|
.. _django.contrib.staticfiles: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/
|
||||||
|
.. _django-staticfiles: http://pypi.python.org/pypi/django-staticfiles/
|
||||||
|
.. _URLObject: http://pypi.python.org/pypi/URLObject/
|
||||||
|
.. _Markdown: http://pypi.python.org/pypi/Markdown/
|
||||||
|
.. _PyYAML: http://pypi.python.org/pypi/PyYAML
|
||||||
|
|
Loading…
Reference in New Issue
Block a user