| 1 |
============================ |
|---|
| 2 |
The "django.contrib" add-ons |
|---|
| 3 |
============================ |
|---|
| 4 |
|
|---|
| 5 |
Django aims to follow Python's `"batteries included" philosophy`_. It ships |
|---|
| 6 |
with a variety of extra, optional tools that solve common Web-development |
|---|
| 7 |
problems. |
|---|
| 8 |
|
|---|
| 9 |
This code lives in ``django/contrib`` in the Django distribution. This document |
|---|
| 10 |
gives a rundown of the packages in ``contrib``, along with any dependencies |
|---|
| 11 |
those packages have. |
|---|
| 12 |
|
|---|
| 13 |
.. admonition:: Note |
|---|
| 14 |
|
|---|
| 15 |
For most of these add-ons -- specifically, the add-ons that include either |
|---|
| 16 |
models or template tags -- you'll need to add the package name (e.g., |
|---|
| 17 |
``'django.contrib.admin'``) to your ``INSTALLED_APPS`` setting and re-run |
|---|
| 18 |
``manage.py syncdb``. |
|---|
| 19 |
|
|---|
| 20 |
.. _"batteries included" philosophy: http://docs.python.org/tut/node12.html#batteries-included |
|---|
| 21 |
|
|---|
| 22 |
admin |
|---|
| 23 |
===== |
|---|
| 24 |
|
|---|
| 25 |
The automatic Django administrative interface. For more information, see |
|---|
| 26 |
`Tutorial 2`_. |
|---|
| 27 |
|
|---|
| 28 |
.. _Tutorial 2: ../tutorial02/ |
|---|
| 29 |
|
|---|
| 30 |
Requires the auth_ and contenttypes_ contrib packages to be installed. |
|---|
| 31 |
|
|---|
| 32 |
auth |
|---|
| 33 |
==== |
|---|
| 34 |
|
|---|
| 35 |
Django's authentication framework. |
|---|
| 36 |
|
|---|
| 37 |
See the `authentication documentation`_. |
|---|
| 38 |
|
|---|
| 39 |
.. _authentication documentation: ../authentication/ |
|---|
| 40 |
|
|---|
| 41 |
comments |
|---|
| 42 |
======== |
|---|
| 43 |
|
|---|
| 44 |
A simple yet flexible comments system. This is not yet documented. |
|---|
| 45 |
|
|---|
| 46 |
contenttypes |
|---|
| 47 |
============ |
|---|
| 48 |
|
|---|
| 49 |
A light framework for hooking into "types" of content, where each installed |
|---|
| 50 |
Django model is a separate content type. |
|---|
| 51 |
|
|---|
| 52 |
See the `contenttypes documentation`_. |
|---|
| 53 |
|
|---|
| 54 |
.. _contenttypes documentation: ../contenttypes/ |
|---|
| 55 |
|
|---|
| 56 |
csrf |
|---|
| 57 |
==== |
|---|
| 58 |
|
|---|
| 59 |
A middleware for preventing Cross Site Request Forgeries |
|---|
| 60 |
|
|---|
| 61 |
See the `csrf documentation`_. |
|---|
| 62 |
|
|---|
| 63 |
.. _csrf documentation: ../csrf/ |
|---|
| 64 |
|
|---|
| 65 |
flatpages |
|---|
| 66 |
========= |
|---|
| 67 |
|
|---|
| 68 |
A framework for managing simple "flat" HTML content in a database. |
|---|
| 69 |
|
|---|
| 70 |
See the `flatpages documentation`_. |
|---|
| 71 |
|
|---|
| 72 |
.. _flatpages documentation: ../flatpages/ |
|---|
| 73 |
|
|---|
| 74 |
Requires the sites_ contrib package to be installed as well. |
|---|
| 75 |
|
|---|
| 76 |
formtools |
|---|
| 77 |
========= |
|---|
| 78 |
|
|---|
| 79 |
A set of high-level abstractions for Django forms (django.newforms). |
|---|
| 80 |
|
|---|
| 81 |
django.contrib.formtools.preview |
|---|
| 82 |
-------------------------------- |
|---|
| 83 |
|
|---|
| 84 |
An abstraction of the following workflow: |
|---|
| 85 |
|
|---|
| 86 |
"Display an HTML form, force a preview, then do something with the submission." |
|---|
| 87 |
|
|---|
| 88 |
See the `form preview documentation`_. |
|---|
| 89 |
|
|---|
| 90 |
.. _form preview documentation: ../form_preview/ |
|---|
| 91 |
|
|---|
| 92 |
humanize |
|---|
| 93 |
======== |
|---|
| 94 |
|
|---|
| 95 |
A set of Django template filters useful for adding a "human touch" to data. |
|---|
| 96 |
To activate these filters, add ``'django.contrib.humanize'`` to your |
|---|
| 97 |
``INSTALLED_APPS`` setting. Once you've done that, use ``{% load humanize %}`` |
|---|
| 98 |
in a template, and you'll have access to these filters: |
|---|
| 99 |
|
|---|
| 100 |
apnumber |
|---|
| 101 |
-------- |
|---|
| 102 |
|
|---|
| 103 |
For numbers 1-9, returns the number spelled out. Otherwise, returns the |
|---|
| 104 |
number. This follows Associated Press style. |
|---|
| 105 |
|
|---|
| 106 |
Examples: |
|---|
| 107 |
|
|---|
| 108 |
* ``1`` becomes ``'one'``. |
|---|
| 109 |
* ``2`` becomes ``'two'``. |
|---|
| 110 |
* ``10`` becomes ``10``. |
|---|
| 111 |
|
|---|
| 112 |
You can pass in either an integer or a string representation of an integer. |
|---|
| 113 |
|
|---|
| 114 |
intcomma |
|---|
| 115 |
-------- |
|---|
| 116 |
|
|---|
| 117 |
Converts an integer to a string containing commas every three digits. |
|---|
| 118 |
|
|---|
| 119 |
Examples: |
|---|
| 120 |
|
|---|
| 121 |
* ``4500`` becomes ``'4,500'``. |
|---|
| 122 |
* ``45000`` becomes ``'45,000'``. |
|---|
| 123 |
* ``450000`` becomes ``'450,000'``. |
|---|
| 124 |
* ``4500000`` becomes ``'4,500,000'``. |
|---|
| 125 |
|
|---|
| 126 |
You can pass in either an integer or a string representation of an integer. |
|---|
| 127 |
|
|---|
| 128 |
intword |
|---|
| 129 |
------- |
|---|
| 130 |
|
|---|
| 131 |
Converts a large integer to a friendly text representation. Works best for |
|---|
| 132 |
numbers over 1 million. |
|---|
| 133 |
|
|---|
| 134 |
Examples: |
|---|
| 135 |
|
|---|
| 136 |
* ``1000000`` becomes ``'1.0 million'``. |
|---|
| 137 |
* ``1200000`` becomes ``'1.2 million'``. |
|---|
| 138 |
* ``1200000000`` becomes ``'1.2 billion'``. |
|---|
| 139 |
|
|---|
| 140 |
Values up to 1000000000000000 (one quadrillion) are supported. |
|---|
| 141 |
|
|---|
| 142 |
You can pass in either an integer or a string representation of an integer. |
|---|
| 143 |
|
|---|
| 144 |
ordinal |
|---|
| 145 |
------- |
|---|
| 146 |
|
|---|
| 147 |
Converts an integer to its ordinal as a string. |
|---|
| 148 |
|
|---|
| 149 |
Examples: |
|---|
| 150 |
|
|---|
| 151 |
* ``1`` becomes ``'1st'``. |
|---|
| 152 |
* ``2`` becomes ``'2nd'``. |
|---|
| 153 |
* ``3`` becomes ``'3rd'``. |
|---|
| 154 |
|
|---|
| 155 |
You can pass in either an integer or a string representation of an integer. |
|---|
| 156 |
|
|---|
| 157 |
naturalday |
|---|
| 158 |
---------- |
|---|
| 159 |
|
|---|
| 160 |
**New in Django development version** |
|---|
| 161 |
|
|---|
| 162 |
For dates that are the current day or within one day, return "today", |
|---|
| 163 |
"tomorrow" or "yesterday", as appropriate. Otherwise, format the date using |
|---|
| 164 |
the passed in format string. |
|---|
| 165 |
|
|---|
| 166 |
**Argument:** Date formatting string as described in default tag now_. |
|---|
| 167 |
|
|---|
| 168 |
.. _now: ../templates/#now |
|---|
| 169 |
|
|---|
| 170 |
Examples (when 'today' is 17 Feb 2007): |
|---|
| 171 |
|
|---|
| 172 |
* ``16 Feb 2007`` becomes ``yesterday``. |
|---|
| 173 |
* ``17 Feb 2007`` becomes ``today``. |
|---|
| 174 |
* ``18 Feb 2007`` becomes ``tomorrow``. |
|---|
| 175 |
* Any other day is formatted according to given argument or the |
|---|
| 176 |
`DATE_FORMAT`_ setting if no argument is given. |
|---|
| 177 |
|
|---|
| 178 |
.. _DATE_FORMAT: ../settings/#date_format |
|---|
| 179 |
|
|---|
| 180 |
localflavor |
|---|
| 181 |
=========== |
|---|
| 182 |
|
|---|
| 183 |
A collection of various Django snippets that are useful only for a particular |
|---|
| 184 |
country or culture. For example, ``django.contrib.localflavor.us.forms`` |
|---|
| 185 |
contains a ``USZipCodeField`` that you can use to validate U.S. zip codes. |
|---|
| 186 |
|
|---|
| 187 |
See the `localflavor documentation`_. |
|---|
| 188 |
|
|---|
| 189 |
.. _localflavor documentation: ../localflavor/ |
|---|
| 190 |
|
|---|
| 191 |
markup |
|---|
| 192 |
====== |
|---|
| 193 |
|
|---|
| 194 |
A collection of template filters that implement common markup languages: |
|---|
| 195 |
|
|---|
| 196 |
* ``textile`` -- implements `Textile`_ |
|---|
| 197 |
* ``markdown`` -- implements `Markdown`_ |
|---|
| 198 |
* ``restructuredtext`` -- implements `ReST (ReStructured Text)`_ |
|---|
| 199 |
|
|---|
| 200 |
In each case, the filter expects formatted markup as a string and returns a |
|---|
| 201 |
string representing the marked-up text. For example, the ``textile`` filter |
|---|
| 202 |
converts text that is marked-up in Textile format to HTML. |
|---|
| 203 |
|
|---|
| 204 |
To activate these filters, add ``'django.contrib.markup'`` to your |
|---|
| 205 |
``INSTALLED_APPS`` setting. Once you've done that, use ``{% load markup %}`` in |
|---|
| 206 |
a template, and you'll have access to these filters. For more documentation, |
|---|
| 207 |
read the source code in django/contrib/markup/templatetags/markup.py. |
|---|
| 208 |
|
|---|
| 209 |
.. _Textile: http://en.wikipedia.org/wiki/Textile_%28markup_language%29 |
|---|
| 210 |
.. _Markdown: http://en.wikipedia.org/wiki/Markdown |
|---|
| 211 |
.. _ReST (ReStructured Text): http://en.wikipedia.org/wiki/ReStructuredText |
|---|
| 212 |
|
|---|
| 213 |
redirects |
|---|
| 214 |
========= |
|---|
| 215 |
|
|---|
| 216 |
A framework for managing redirects. |
|---|
| 217 |
|
|---|
| 218 |
See the `redirects documentation`_. |
|---|
| 219 |
|
|---|
| 220 |
.. _redirects documentation: ../redirects/ |
|---|
| 221 |
|
|---|
| 222 |
sessions |
|---|
| 223 |
======== |
|---|
| 224 |
|
|---|
| 225 |
A framework for storing data in anonymous sessions. |
|---|
| 226 |
|
|---|
| 227 |
See the `sessions documentation`_. |
|---|
| 228 |
|
|---|
| 229 |
.. _sessions documentation: ../sessions/ |
|---|
| 230 |
|
|---|
| 231 |
sites |
|---|
| 232 |
===== |
|---|
| 233 |
|
|---|
| 234 |
A light framework that lets you operate multiple Web sites off of the same |
|---|
| 235 |
database and Django installation. It gives you hooks for associating objects to |
|---|
| 236 |
one or more sites. |
|---|
| 237 |
|
|---|
| 238 |
See the `sites documentation`_. |
|---|
| 239 |
|
|---|
| 240 |
.. _sites documentation: ../sites/ |
|---|
| 241 |
|
|---|
| 242 |
sitemaps |
|---|
| 243 |
======== |
|---|
| 244 |
|
|---|
| 245 |
A framework for generating Google sitemap XML files. |
|---|
| 246 |
|
|---|
| 247 |
See the `sitemaps documentation`_. |
|---|
| 248 |
|
|---|
| 249 |
.. _sitemaps documentation: ../sitemaps/ |
|---|
| 250 |
|
|---|
| 251 |
syndication |
|---|
| 252 |
=========== |
|---|
| 253 |
|
|---|
| 254 |
A framework for generating syndication feeds, in RSS and Atom, quite easily. |
|---|
| 255 |
|
|---|
| 256 |
See the `syndication documentation`_. |
|---|
| 257 |
|
|---|
| 258 |
.. _syndication documentation: ../syndication_feeds/ |
|---|
| 259 |
|
|---|
| 260 |
webdesign |
|---|
| 261 |
========= |
|---|
| 262 |
|
|---|
| 263 |
Helpers and utilties targeted primarily at Web *designers* rather than |
|---|
| 264 |
Web *developers*. |
|---|
| 265 |
|
|---|
| 266 |
See the `Web design helpers documentation`_. |
|---|
| 267 |
|
|---|
| 268 |
.. _Web design helpers documentation: ../webdesign/ |
|---|
| 269 |
|
|---|
| 270 |
Other add-ons |
|---|
| 271 |
============= |
|---|
| 272 |
|
|---|
| 273 |
If you have an idea for functionality to include in ``contrib``, let us know! |
|---|
| 274 |
Code it up, and post it to the `django-users mailing list`_. |
|---|
| 275 |
|
|---|
| 276 |
.. _django-users mailing list: http://groups.google.com/group/django-users |
|---|