2007-03-22 04:52:17 +01:00
|
|
|
============================
|
|
|
|
The "django.contrib" add-ons
|
|
|
|
============================
|
2005-11-22 20:21:51 +01:00
|
|
|
|
2006-08-01 22:48:26 +02:00
|
|
|
Django aims to follow Python's `"batteries included" philosophy`_. It ships
|
|
|
|
with a variety of extra, optional tools that solve common Web-development
|
|
|
|
problems.
|
2005-11-22 20:21:51 +01:00
|
|
|
|
2007-06-07 19:50:53 +02:00
|
|
|
This code lives in ``django/contrib`` in the Django distribution. This document
|
2007-06-07 23:41:41 +02:00
|
|
|
gives a rundown of the packages in ``contrib``, along with any dependencies
|
2007-06-07 19:50:53 +02:00
|
|
|
those packages have.
|
2005-11-22 20:21:51 +01:00
|
|
|
|
2007-03-28 00:18:52 +02:00
|
|
|
.. admonition:: Note
|
|
|
|
|
|
|
|
For most of these add-ons -- specifically, the add-ons that include either
|
|
|
|
models or template tags -- you'll need to add the package name (e.g.,
|
|
|
|
``'django.contrib.admin'``) to your ``INSTALLED_APPS`` setting and re-run
|
|
|
|
``manage.py syncdb``.
|
|
|
|
|
2006-08-01 22:48:26 +02:00
|
|
|
.. _"batteries included" philosophy: http://docs.python.org/tut/node12.html#batteries-included
|
|
|
|
|
2005-11-22 20:21:51 +01:00
|
|
|
admin
|
|
|
|
=====
|
|
|
|
|
|
|
|
The automatic Django administrative interface. For more information, see
|
2008-07-21 19:12:15 +02:00
|
|
|
`Tutorial 2`_ and the `admin documentation`_.
|
2005-11-22 20:21:51 +01:00
|
|
|
|
2007-04-20 11:15:30 +02:00
|
|
|
.. _Tutorial 2: ../tutorial02/
|
2008-07-21 19:12:15 +02:00
|
|
|
.. _admin documentation: ../admin/
|
2005-11-22 20:21:51 +01:00
|
|
|
|
2007-06-07 19:50:53 +02:00
|
|
|
Requires the auth_ and contenttypes_ contrib packages to be installed.
|
|
|
|
|
2006-05-22 05:14:33 +02:00
|
|
|
auth
|
|
|
|
====
|
|
|
|
|
|
|
|
Django's authentication framework.
|
|
|
|
|
|
|
|
See the `authentication documentation`_.
|
|
|
|
|
2007-01-24 21:08:47 +01:00
|
|
|
.. _authentication documentation: ../authentication/
|
2006-05-22 05:14:33 +02:00
|
|
|
|
2005-11-22 20:21:51 +01:00
|
|
|
comments
|
|
|
|
========
|
|
|
|
|
|
|
|
A simple yet flexible comments system. This is not yet documented.
|
|
|
|
|
2006-05-22 05:14:33 +02:00
|
|
|
contenttypes
|
|
|
|
============
|
|
|
|
|
|
|
|
A light framework for hooking into "types" of content, where each installed
|
2007-12-17 08:39:24 +01:00
|
|
|
Django model is a separate content type.
|
|
|
|
|
|
|
|
See the `contenttypes documentation`_.
|
|
|
|
|
|
|
|
.. _contenttypes documentation: ../contenttypes/
|
2006-05-22 05:14:33 +02:00
|
|
|
|
|
|
|
csrf
|
|
|
|
====
|
|
|
|
|
|
|
|
A middleware for preventing Cross Site Request Forgeries
|
|
|
|
|
|
|
|
See the `csrf documentation`_.
|
|
|
|
|
2007-01-24 21:08:47 +01:00
|
|
|
.. _csrf documentation: ../csrf/
|
2006-05-22 05:14:33 +02:00
|
|
|
|
2007-12-01 18:07:32 +01:00
|
|
|
flatpages
|
|
|
|
=========
|
|
|
|
|
|
|
|
A framework for managing simple "flat" HTML content in a database.
|
|
|
|
|
|
|
|
See the `flatpages documentation`_.
|
|
|
|
|
|
|
|
.. _flatpages documentation: ../flatpages/
|
|
|
|
|
|
|
|
Requires the sites_ contrib package to be installed as well.
|
|
|
|
|
2006-12-05 21:51:25 +01:00
|
|
|
formtools
|
|
|
|
=========
|
|
|
|
|
2008-07-21 18:38:54 +02:00
|
|
|
A set of high-level abstractions for Django forms (django.forms).
|
2006-12-05 21:51:25 +01:00
|
|
|
|
|
|
|
django.contrib.formtools.preview
|
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
An abstraction of the following workflow:
|
|
|
|
|
|
|
|
"Display an HTML form, force a preview, then do something with the submission."
|
|
|
|
|
2007-09-15 01:15:40 +02:00
|
|
|
See the `form preview documentation`_.
|
|
|
|
|
|
|
|
.. _form preview documentation: ../form_preview/
|
2006-12-05 21:51:25 +01:00
|
|
|
|
2006-06-04 02:58:39 +02:00
|
|
|
humanize
|
|
|
|
========
|
|
|
|
|
|
|
|
A set of Django template filters useful for adding a "human touch" to data.
|
2006-06-08 05:03:19 +02:00
|
|
|
To activate these filters, add ``'django.contrib.humanize'`` to your
|
|
|
|
``INSTALLED_APPS`` setting. Once you've done that, use ``{% load humanize %}``
|
2006-06-04 02:58:39 +02:00
|
|
|
in a template, and you'll have access to these filters:
|
|
|
|
|
2006-06-04 03:03:48 +02:00
|
|
|
apnumber
|
|
|
|
--------
|
2006-06-04 02:58:39 +02:00
|
|
|
|
2006-06-04 03:03:48 +02:00
|
|
|
For numbers 1-9, returns the number spelled out. Otherwise, returns the
|
|
|
|
number. This follows Associated Press style.
|
2006-06-04 02:58:39 +02:00
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
2006-06-04 03:03:48 +02:00
|
|
|
* ``1`` becomes ``'one'``.
|
|
|
|
* ``2`` becomes ``'two'``.
|
|
|
|
* ``10`` becomes ``10``.
|
2006-06-04 02:58:39 +02:00
|
|
|
|
|
|
|
You can pass in either an integer or a string representation of an integer.
|
|
|
|
|
|
|
|
intcomma
|
|
|
|
--------
|
|
|
|
|
|
|
|
Converts an integer to a string containing commas every three digits.
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
* ``4500`` becomes ``'4,500'``.
|
|
|
|
* ``45000`` becomes ``'45,000'``.
|
|
|
|
* ``450000`` becomes ``'450,000'``.
|
|
|
|
* ``4500000`` becomes ``'4,500,000'``.
|
|
|
|
|
|
|
|
You can pass in either an integer or a string representation of an integer.
|
|
|
|
|
|
|
|
intword
|
|
|
|
-------
|
|
|
|
|
|
|
|
Converts a large integer to a friendly text representation. Works best for
|
|
|
|
numbers over 1 million.
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
* ``1000000`` becomes ``'1.0 million'``.
|
|
|
|
* ``1200000`` becomes ``'1.2 million'``.
|
|
|
|
* ``1200000000`` becomes ``'1.2 billion'``.
|
|
|
|
|
|
|
|
Values up to 1000000000000000 (one quadrillion) are supported.
|
|
|
|
|
|
|
|
You can pass in either an integer or a string representation of an integer.
|
|
|
|
|
2006-06-04 03:03:48 +02:00
|
|
|
ordinal
|
|
|
|
-------
|
|
|
|
|
|
|
|
Converts an integer to its ordinal as a string.
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
* ``1`` becomes ``'1st'``.
|
|
|
|
* ``2`` becomes ``'2nd'``.
|
|
|
|
* ``3`` becomes ``'3rd'``.
|
|
|
|
|
|
|
|
You can pass in either an integer or a string representation of an integer.
|
|
|
|
|
2007-08-20 10:50:08 +02:00
|
|
|
naturalday
|
|
|
|
----------
|
|
|
|
|
|
|
|
**New in Django development version**
|
|
|
|
|
|
|
|
For dates that are the current day or within one day, return "today",
|
|
|
|
"tomorrow" or "yesterday", as appropriate. Otherwise, format the date using
|
|
|
|
the passed in format string.
|
|
|
|
|
|
|
|
**Argument:** Date formatting string as described in default tag now_.
|
|
|
|
|
|
|
|
.. _now: ../templates/#now
|
|
|
|
|
|
|
|
Examples (when 'today' is 17 Feb 2007):
|
|
|
|
|
|
|
|
* ``16 Feb 2007`` becomes ``yesterday``.
|
|
|
|
* ``17 Feb 2007`` becomes ``today``.
|
|
|
|
* ``18 Feb 2007`` becomes ``tomorrow``.
|
|
|
|
* Any other day is formatted according to given argument or the
|
|
|
|
`DATE_FORMAT`_ setting if no argument is given.
|
|
|
|
|
|
|
|
.. _DATE_FORMAT: ../settings/#date_format
|
|
|
|
|
2007-02-15 06:53:44 +01:00
|
|
|
localflavor
|
|
|
|
===========
|
|
|
|
|
|
|
|
A collection of various Django snippets that are useful only for a particular
|
2007-12-17 09:58:29 +01:00
|
|
|
country or culture. For example, ``django.contrib.localflavor.us.forms``
|
2007-02-15 06:53:44 +01:00
|
|
|
contains a ``USZipCodeField`` that you can use to validate U.S. zip codes.
|
|
|
|
|
2007-12-17 09:58:29 +01:00
|
|
|
See the `localflavor documentation`_.
|
|
|
|
|
|
|
|
.. _localflavor documentation: ../localflavor/
|
|
|
|
|
2005-11-22 20:21:51 +01:00
|
|
|
markup
|
|
|
|
======
|
|
|
|
|
2007-03-28 00:18:52 +02:00
|
|
|
A collection of template filters that implement common markup languages:
|
|
|
|
|
|
|
|
* ``textile`` -- implements `Textile`_
|
|
|
|
* ``markdown`` -- implements `Markdown`_
|
|
|
|
* ``restructuredtext`` -- implements `ReST (ReStructured Text)`_
|
2005-11-22 20:21:51 +01:00
|
|
|
|
2007-03-28 00:18:52 +02:00
|
|
|
In each case, the filter expects formatted markup as a string and returns a
|
|
|
|
string representing the marked-up text. For example, the ``textile`` filter
|
|
|
|
converts text that is marked-up in Textile format to HTML.
|
2005-11-22 20:21:51 +01:00
|
|
|
|
2007-03-28 00:18:52 +02:00
|
|
|
To activate these filters, add ``'django.contrib.markup'`` to your
|
|
|
|
``INSTALLED_APPS`` setting. Once you've done that, use ``{% load markup %}`` in
|
|
|
|
a template, and you'll have access to these filters. For more documentation,
|
|
|
|
read the source code in django/contrib/markup/templatetags/markup.py.
|
2006-07-01 05:25:48 +02:00
|
|
|
|
2007-03-22 04:52:17 +01:00
|
|
|
.. _Textile: http://en.wikipedia.org/wiki/Textile_%28markup_language%29
|
|
|
|
.. _Markdown: http://en.wikipedia.org/wiki/Markdown
|
|
|
|
.. _ReST (ReStructured Text): http://en.wikipedia.org/wiki/ReStructuredText
|
|
|
|
|
2005-11-22 20:21:51 +01:00
|
|
|
redirects
|
|
|
|
=========
|
|
|
|
|
|
|
|
A framework for managing redirects.
|
|
|
|
|
|
|
|
See the `redirects documentation`_.
|
|
|
|
|
2007-01-24 21:08:47 +01:00
|
|
|
.. _redirects documentation: ../redirects/
|
2005-11-22 20:21:51 +01:00
|
|
|
|
2007-12-01 18:07:32 +01:00
|
|
|
sessions
|
|
|
|
========
|
|
|
|
|
|
|
|
A framework for storing data in anonymous sessions.
|
|
|
|
|
|
|
|
See the `sessions documentation`_.
|
|
|
|
|
|
|
|
.. _sessions documentation: ../sessions/
|
|
|
|
|
2006-05-22 05:14:33 +02:00
|
|
|
sites
|
|
|
|
=====
|
|
|
|
|
|
|
|
A light framework that lets you operate multiple Web sites off of the same
|
|
|
|
database and Django installation. It gives you hooks for associating objects to
|
2006-05-22 06:48:44 +02:00
|
|
|
one or more sites.
|
|
|
|
|
|
|
|
See the `sites documentation`_.
|
|
|
|
|
2007-01-24 21:08:47 +01:00
|
|
|
.. _sites documentation: ../sites/
|
2006-05-22 05:14:33 +02:00
|
|
|
|
2006-09-01 01:19:53 +02:00
|
|
|
sitemaps
|
|
|
|
========
|
|
|
|
|
|
|
|
A framework for generating Google sitemap XML files.
|
|
|
|
|
|
|
|
See the `sitemaps documentation`_.
|
|
|
|
|
2007-01-24 21:08:47 +01:00
|
|
|
.. _sitemaps documentation: ../sitemaps/
|
2006-09-01 01:19:53 +02:00
|
|
|
|
2005-11-22 20:21:51 +01:00
|
|
|
syndication
|
|
|
|
===========
|
|
|
|
|
|
|
|
A framework for generating syndication feeds, in RSS and Atom, quite easily.
|
|
|
|
|
|
|
|
See the `syndication documentation`_.
|
|
|
|
|
2007-08-04 05:19:14 +02:00
|
|
|
.. _syndication documentation: ../syndication_feeds/
|
2005-11-22 20:21:51 +01:00
|
|
|
|
2007-12-01 18:07:32 +01:00
|
|
|
webdesign
|
|
|
|
=========
|
|
|
|
|
2007-12-04 07:05:28 +01:00
|
|
|
Helpers and utilties targeted primarily at Web *designers* rather than
|
|
|
|
Web *developers*.
|
2007-12-01 18:07:32 +01:00
|
|
|
|
2007-12-04 07:05:28 +01:00
|
|
|
See the `Web design helpers documentation`_.
|
2007-12-01 18:07:32 +01:00
|
|
|
|
2007-12-04 07:05:28 +01:00
|
|
|
.. _Web design helpers documentation: ../webdesign/
|
2007-12-01 18:07:32 +01:00
|
|
|
|
2005-11-22 20:21:51 +01:00
|
|
|
Other add-ons
|
|
|
|
=============
|
|
|
|
|
|
|
|
If you have an idea for functionality to include in ``contrib``, let us know!
|
|
|
|
Code it up, and post it to the `django-users mailing list`_.
|
|
|
|
|
|
|
|
.. _django-users mailing list: http://groups.google.com/group/django-users
|