summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2012-10-26 08:41:13 +0100
committerAndrew Godwin <andrew@aeracode.org>2012-10-26 08:41:13 +0100
commit6a632e04578776e877adc5e2dc53f008c890a0d4 (patch)
treeaa47200fb63adf44609066a45601bd3b8768ec1c /docs/ref
parenta589fdff81ab36c57ff0a1003e60ee0dd55f3a88 (diff)
parentfabe9c9e5f0a437b5389faaf469ce53091abd3cf (diff)
Merge branch 'master' into schema-alteration
Conflicts: django/db/backends/__init__.py django/db/models/fields/related.py django/db/models/options.py
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/class-based-views/generic-date-based.txt8
-rw-r--r--docs/ref/class-based-views/mixins-date-based.txt12
-rw-r--r--docs/ref/contrib/admin/_images/raw_id_fields.pngbin0 -> 1871 bytes
-rw-r--r--docs/ref/contrib/admin/index.txt82
-rw-r--r--docs/ref/contrib/comments/example.txt21
-rw-r--r--docs/ref/contrib/comments/index.txt50
-rw-r--r--docs/ref/contrib/comments/moderation.txt4
-rw-r--r--docs/ref/contrib/contenttypes.txt2
-rw-r--r--docs/ref/contrib/csrf.txt6
-rw-r--r--docs/ref/contrib/flatpages.txt6
-rw-r--r--docs/ref/contrib/formtools/form-wizard.txt2
-rw-r--r--docs/ref/contrib/gis/admin.txt2
-rw-r--r--docs/ref/contrib/gis/db-api.txt2
-rw-r--r--docs/ref/contrib/gis/geoip.txt8
-rw-r--r--docs/ref/contrib/gis/geoquerysets.txt2
-rw-r--r--docs/ref/contrib/gis/geos.txt54
-rw-r--r--docs/ref/contrib/gis/index.txt2
-rw-r--r--docs/ref/contrib/gis/install.txt1267
-rwxr-xr-xdocs/ref/contrib/gis/install/create_template_postgis-1.3.sh (renamed from docs/ref/contrib/gis/create_template_postgis-1.3.sh)0
-rwxr-xr-xdocs/ref/contrib/gis/install/create_template_postgis-1.4.sh (renamed from docs/ref/contrib/gis/create_template_postgis-1.4.sh)0
-rwxr-xr-xdocs/ref/contrib/gis/install/create_template_postgis-1.5.sh (renamed from docs/ref/contrib/gis/create_template_postgis-1.5.sh)0
-rwxr-xr-xdocs/ref/contrib/gis/install/create_template_postgis-debian.sh (renamed from docs/ref/contrib/gis/create_template_postgis-debian.sh)0
-rw-r--r--docs/ref/contrib/gis/install/geodjango_setup.bat (renamed from docs/ref/contrib/gis/geodjango_setup.bat)0
-rw-r--r--docs/ref/contrib/gis/install/geolibs.txt282
-rw-r--r--docs/ref/contrib/gis/install/index.txt535
-rw-r--r--docs/ref/contrib/gis/install/postgis.txt175
-rw-r--r--docs/ref/contrib/gis/install/spatialite.txt222
-rw-r--r--docs/ref/contrib/gis/testing.txt2
-rw-r--r--docs/ref/contrib/localflavor.txt1466
-rw-r--r--docs/ref/contrib/sitemaps.txt2
-rw-r--r--docs/ref/contrib/sites.txt59
-rw-r--r--docs/ref/contrib/staticfiles.txt2
-rw-r--r--docs/ref/contrib/syndication.txt4
-rw-r--r--docs/ref/databases.txt10
-rw-r--r--docs/ref/django-admin.txt35
-rw-r--r--docs/ref/files/storage.txt12
-rw-r--r--docs/ref/forms/api.txt12
-rw-r--r--docs/ref/forms/fields.txt18
-rw-r--r--docs/ref/forms/validation.txt4
-rw-r--r--docs/ref/forms/widgets.txt7
-rw-r--r--docs/ref/index.txt4
-rw-r--r--docs/ref/middleware.txt10
-rw-r--r--docs/ref/models/fields.txt16
-rw-r--r--docs/ref/models/instances.txt21
-rw-r--r--docs/ref/models/querysets.txt48
-rw-r--r--docs/ref/request-response.txt136
-rw-r--r--docs/ref/settings.txt53
-rw-r--r--docs/ref/signals.txt25
-rw-r--r--docs/ref/template-response.txt2
-rw-r--r--docs/ref/templates/api.txt14
-rw-r--r--docs/ref/templates/builtins.txt16
-rw-r--r--docs/ref/urlresolvers.txt202
-rw-r--r--docs/ref/urls.txt156
-rw-r--r--docs/ref/utils.txt31
54 files changed, 2168 insertions, 2943 deletions
diff --git a/docs/ref/class-based-views/generic-date-based.txt b/docs/ref/class-based-views/generic-date-based.txt
index 64b269f514..c6af23e421 100644
--- a/docs/ref/class-based-views/generic-date-based.txt
+++ b/docs/ref/class-based-views/generic-date-based.txt
@@ -87,16 +87,24 @@ YearArchiveView
* ``year``: A :class:`~datetime.date` object
representing the given year.
+ .. versionchanged:: 1.5
+
+ Previously, this returned a string.
+
* ``next_year``: A :class:`~datetime.date` object
representing the first day of the next year, according to
:attr:`~BaseDateListView.allow_empty` and
:attr:`~DateMixin.allow_future`.
+ .. versionadded:: 1.5
+
* ``previous_year``: A :class:`~datetime.date` object
representing the first day of the previous year, according to
:attr:`~BaseDateListView.allow_empty` and
:attr:`~DateMixin.allow_future`.
+ .. versionadded:: 1.5
+
**Notes**
* Uses a default ``template_name_suffix`` of ``_archive_year``.
diff --git a/docs/ref/class-based-views/mixins-date-based.txt b/docs/ref/class-based-views/mixins-date-based.txt
index 01181ebb6c..561e525e70 100644
--- a/docs/ref/class-based-views/mixins-date-based.txt
+++ b/docs/ref/class-based-views/mixins-date-based.txt
@@ -318,12 +318,16 @@ BaseDateListView
Returns the aggregation period for ``date_list``. Returns
:attr:`~BaseDateListView.date_list_period` by default.
- .. method:: get_date_list(queryset, date_type=None)
+ .. method:: get_date_list(queryset, date_type=None, ordering='ASC')
Returns the list of dates of type ``date_type`` for which ``queryset``
contains entries. For example, ``get_date_list(qs, 'year')`` will
return the list of years for which ``qs`` has entries. If
``date_type`` isn't provided, the result of
- :meth:`BaseDateListView.get_date_list_period` is used. See
- :meth:`~django.db.models.query.QuerySet.dates()` for the ways that the
- ``date_type`` argument can be used.
+ :meth:`~BaseDateListView.get_date_list_period` is used. ``date_type``
+ and ``ordering`` are simply passed to
+ :meth:`QuerySet.dates()<django.db.models.query.QuerySet.dates>`.
+
+ .. versionchanged:: 1.5
+ The ``ordering`` parameter was added, and the default order was
+ changed to ascending.
diff --git a/docs/ref/contrib/admin/_images/raw_id_fields.png b/docs/ref/contrib/admin/_images/raw_id_fields.png
new file mode 100644
index 0000000000..0774c40469
--- /dev/null
+++ b/docs/ref/contrib/admin/_images/raw_id_fields.png
Binary files differ
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index 66a5a2cc4f..6ed929cb7d 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -60,6 +60,8 @@ Other topics
For information about serving the static files (images, JavaScript, and
CSS) associated with the admin in production, see :ref:`serving-files`.
+ Having problems? Try :doc:`/faq/admin`.
+
``ModelAdmin`` objects
======================
@@ -129,8 +131,6 @@ subclass::
date_hierarchy = 'pub_date'
- .. versionadded:: 1.3
-
This will intelligently populate itself based on available data,
e.g. if all the dates are in one month, it'll show the day-level
drill-down only.
@@ -307,7 +307,9 @@ subclass::
By default a ``ModelForm`` is dynamically created for your model. It is
used to create the form presented on both the add/change pages. You can
easily provide your own ``ModelForm`` to override any default form behavior
- on the add/change pages.
+ on the add/change pages. Alternatively, you can customize the default
+ form rather than specifying an entirely new one by using the
+ :meth:`ModelAdmin.get_form` method.
For an example see the section `Adding custom validation to the admin`_.
@@ -373,7 +375,8 @@ subclass::
.. attribute:: ModelAdmin.inlines
- See :class:`InlineModelAdmin` objects below.
+ See :class:`InlineModelAdmin` objects below as well as
+ :meth:`ModelAdmin.get_formsets`.
.. attribute:: ModelAdmin.list_display
@@ -576,8 +579,6 @@ subclass::
class PersonAdmin(ModelAdmin):
list_filter = ('is_staff', 'company')
- .. versionadded:: 1.3
-
Field names in ``list_filter`` can also span relations
using the ``__`` lookup, for example::
@@ -748,8 +749,6 @@ subclass::
.. attribute:: ModelAdmin.paginator
- .. versionadded:: 1.3
-
The paginator class to be used for pagination. By default,
:class:`django.core.paginator.Paginator` is used. If the custom paginator
class doesn't have the same constructor interface as
@@ -804,6 +803,14 @@ subclass::
class ArticleAdmin(admin.ModelAdmin):
raw_id_fields = ("newspaper",)
+ The ``raw_id_fields`` ``Input`` widget should contain a primary key if the
+ field is a ``ForeignKey`` or a comma separated list of values if the field
+ is a ``ManyToManyField``. The ``raw_id_fields`` widget shows a magnifying
+ glass button next to the field which allows users to search for and select
+ a value:
+
+ .. image:: _images/raw_id_fields.png
+
.. attribute:: ModelAdmin.readonly_fields
By default the admin shows all fields as editable. Any fields in this
@@ -966,8 +973,6 @@ templates used by the :class:`ModelAdmin` views:
.. method:: ModelAdmin.delete_model(self, request, obj)
- .. versionadded:: 1.3
-
The ``delete_model`` method is given the ``HttpRequest`` and a model
instance. Use this method to do pre- or post-delete operations.
@@ -1049,6 +1054,16 @@ templates used by the :class:`ModelAdmin` views:
changelist that will be linked to the change view, as described in the
:attr:`ModelAdmin.list_display_links` section.
+.. method:: ModelAdmin.get_inline_instances(self, request, obj=None)
+
+ .. versionadded:: 1.5
+
+ The ``get_inline_instances`` method is given the ``HttpRequest`` and the
+ ``obj`` being edited (or ``None`` on an add form) and is expected to return
+ a ``list`` or ``tuple`` of :class:`~django.contrib.admin.InlineModelAdmin`
+ objects, as described below in the :class:`~django.contrib.admin.InlineModelAdmin`
+ section.
+
.. method:: ModelAdmin.get_urls(self)
The ``get_urls`` method on a ``ModelAdmin`` returns the URLs to be used for
@@ -1115,6 +1130,38 @@ templates used by the :class:`ModelAdmin` views:
(r'^my_view/$', self.admin_site.admin_view(self.my_view, cacheable=True))
+.. method:: ModelAdmin.get_form(self, request, obj=None, **kwargs)
+
+ Returns a :class:`~django.forms.ModelForm` class for use in the admin add
+ and change views, see :meth:`add_view` and :meth:`change_view`.
+
+ If you wanted to hide a field from non-superusers, for example, you could
+ override ``get_form`` as follows::
+
+ class MyModelAdmin(admin.ModelAdmin):
+ def get_form(self, request, obj=None, **kwargs):
+ self.exclude = []
+ if not request.user.is_superuser:
+ self.exclude.append('field_to_hide')
+ return super(MyModelAdmin, self).get_form(request, obj, **kwargs)
+
+.. method:: ModelAdmin.get_formsets(self, request, obj=None)
+
+ Yields :class:`InlineModelAdmin`\s for use in admin add and change views.
+
+ For example if you wanted to display a particular inline only in the change
+ view, you could override ``get_formsets`` as follows::
+
+ class MyModelAdmin(admin.ModelAdmin):
+ inlines = [MyInline, SomeOtherInline]
+
+ def get_formsets(self, request, obj=None):
+ for inline in self.get_inline_instances(request, obj):
+ # hide MyInline in the add view
+ if isinstance(inline, MyInline) and obj is None:
+ continue
+ yield inline.get_formset(request, obj)
+
.. method:: ModelAdmin.formfield_for_foreignkey(self, db_field, request, **kwargs)
The ``formfield_for_foreignkey`` method on a ``ModelAdmin`` allows you to
@@ -1213,8 +1260,6 @@ templates used by the :class:`ModelAdmin` views:
.. method:: ModelAdmin.get_paginator(queryset, per_page, orphans=0, allow_empty_first_page=True)
- .. versionadded:: 1.3
-
Returns an instance of the paginator to use for this view. By default,
instantiates an instance of :attr:`paginator`.
@@ -1295,8 +1340,6 @@ on your ``ModelAdmin``::
}
js = ("my_code.js",)
-.. versionchanged:: 1.3
-
The :doc:`staticfiles app </ref/contrib/staticfiles>` prepends
:setting:`STATIC_URL` (or :setting:`MEDIA_URL` if :setting:`STATIC_URL` is
``None``) to any media paths. The same rules apply as :ref:`regular media
@@ -1394,18 +1437,15 @@ adds some of its own (the shared features are actually defined in the
- :attr:`~ModelAdmin.exclude`
- :attr:`~ModelAdmin.filter_horizontal`
- :attr:`~ModelAdmin.filter_vertical`
+- :attr:`~ModelAdmin.ordering`
- :attr:`~ModelAdmin.prepopulated_fields`
+- :meth:`~ModelAdmin.queryset`
- :attr:`~ModelAdmin.radio_fields`
- :attr:`~ModelAdmin.readonly_fields`
- :attr:`~InlineModelAdmin.raw_id_fields`
- :meth:`~ModelAdmin.formfield_for_foreignkey`
- :meth:`~ModelAdmin.formfield_for_manytomany`
-.. versionadded:: 1.3
-
-- :attr:`~ModelAdmin.ordering`
-- :meth:`~ModelAdmin.queryset`
-
.. versionadded:: 1.4
- :meth:`~ModelAdmin.has_add_permission`
@@ -1436,8 +1476,6 @@ The ``InlineModelAdmin`` class adds:
through to ``inlineformset_factory`` when creating the formset for this
inline.
- .. _ref-contrib-admin-inline-extra:
-
.. attribute:: InlineModelAdmin.extra
This controls the number of extra forms the formset will display in
@@ -1813,8 +1851,6 @@ Templates can override or extend base admin templates as described in
.. attribute:: AdminSite.login_form
- .. versionadded:: 1.3
-
Subclass of :class:`~django.contrib.auth.forms.AuthenticationForm` that
will be used by the admin site login view.
diff --git a/docs/ref/contrib/comments/example.txt b/docs/ref/contrib/comments/example.txt
index e78d83c35d..2bff778c2f 100644
--- a/docs/ref/contrib/comments/example.txt
+++ b/docs/ref/contrib/comments/example.txt
@@ -152,27 +152,6 @@ enable it in your project's ``urls.py``:
Now you should have the latest comment feeds being served off ``/feeds/latest/``.
-.. versionchanged:: 1.3
-
-Prior to Django 1.3, the LatestCommentFeed was deployed using the
-syndication feed view:
-
-.. code-block:: python
-
- from django.conf.urls import patterns
- from django.contrib.comments.feeds import LatestCommentFeed
-
- feeds = {
- 'latest': LatestCommentFeed,
- }
-
- urlpatterns = patterns('',
- # ...
- (r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
- {'feed_dict': feeds}),
- # ...
- )
-
Moderation
==========
diff --git a/docs/ref/contrib/comments/index.txt b/docs/ref/contrib/comments/index.txt
index 4b1dd96280..1c6ff7c7ed 100644
--- a/docs/ref/contrib/comments/index.txt
+++ b/docs/ref/contrib/comments/index.txt
@@ -254,6 +254,56 @@ you can include a hidden form input called ``next`` in your comment form. For ex
<input type="hidden" name="next" value="{% url 'my_comment_was_posted' %}" />
+Providing a comment form for authenticated users
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If a user is already authenticated, it makes little sense to display the name,
+email, and URL fields, since these can already be retrieved from their login
+data and profile. In addition, some sites will only accept comments from
+authenticated users.
+
+To provide a comment form for authenticated users, you can manually provide the
+additional fields expected by the Django comments framework. For example,
+assuming comments are attached to the model "object"::
+
+ {% if user.is_authenticated %}
+ {% get_comment_form for object as form %}
+ <form action="{% comment_form_target %}" method="POST">
+ {% csrf_token %}
+ {{ form.comment }}
+ {{ form.honeypot }}
+ {{ form.content_type }}
+ {{ form.object_pk }}
+ {{ form.timestamp }}
+ {{ form.security_hash }}
+ <input type="hidden" name="next" value="{% url 'object_detail_view' object.id %}" />
+ <input type="submit" value="Add comment" id="id_submit" />
+ </form>
+ {% else %}
+ <p>Please <a href="{% url 'auth_login' %}">log in</a> to leave a comment.</p>
+ {% endif %}
+
+The honeypot, content_type, object_pk, timestamp, and security_hash fields are
+fields that would have been created automatically if you had simply used
+``{{ form }}`` in your template, and are referred to in `Notes on the comment
+form`_ below.
+
+Note that we do not need to specify the user to be associated with comments
+submitted by authenticated users. This is possible because the :doc:`Built-in
+Comment Models</ref/contrib/comments/models>` that come with Django associate
+comments with authenticated users by default.
+
+In this example, the honeypot field will still be visible to the user; you'll
+need to hide that field in your CSS::
+
+ #id_honeypot {
+ display: none;
+ }
+
+If you want to accept either anonymous or authenticated comments, replace the
+contents of the "else" clause above with a standard comment form and the right
+thing will happen whether a user is logged in or not.
+
.. _notes-on-the-comment-form:
Notes on the comment form
diff --git a/docs/ref/contrib/comments/moderation.txt b/docs/ref/contrib/comments/moderation.txt
index f03c7fda0d..39b3ea7913 100644
--- a/docs/ref/contrib/comments/moderation.txt
+++ b/docs/ref/contrib/comments/moderation.txt
@@ -136,10 +136,6 @@ Simply subclassing :class:`CommentModerator` and changing the values of these
options will automatically enable the various moderation methods for any
models registered using the subclass.
-.. versionchanged:: 1.3
-
-``moderate_after`` and ``close_after`` now accept 0 as a valid value.
-
Adding custom moderation methods
--------------------------------
diff --git a/docs/ref/contrib/contenttypes.txt b/docs/ref/contrib/contenttypes.txt
index e98da6e429..dfbeabc302 100644
--- a/docs/ref/contrib/contenttypes.txt
+++ b/docs/ref/contrib/contenttypes.txt
@@ -423,8 +423,6 @@ pointing at it will be deleted as well. In the example above, this means that
if a ``Bookmark`` object were deleted, any ``TaggedItem`` objects pointing at
it would be deleted at the same time.
-.. versionadded:: 1.3
-
Unlike :class:`~django.db.models.ForeignKey`,
:class:`~django.contrib.contenttypes.generic.GenericForeignKey` does not accept
an :attr:`~django.db.models.ForeignKey.on_delete` argument to customize this
diff --git a/docs/ref/contrib/csrf.txt b/docs/ref/contrib/csrf.txt
index 8d352ff8b2..32d8a705bc 100644
--- a/docs/ref/contrib/csrf.txt
+++ b/docs/ref/contrib/csrf.txt
@@ -72,9 +72,9 @@ To enable CSRF protection for your views, follow these steps:
:func:`~django.shortcuts.render_to_response()` wrapper that takes care
of this step for you.
-The utility script ``extras/csrf_migration_helper.py`` can help to automate the
-finding of code and templates that may need these steps. It contains full help
-on how to use it.
+The utility script ``extras/csrf_migration_helper.py`` (located in the Django
+distribution, but not installed) can help to automate the finding of code and
+templates that may need these steps. It contains full help on how to use it.
.. _csrf-ajax:
diff --git a/docs/ref/contrib/flatpages.txt b/docs/ref/contrib/flatpages.txt
index 3de449708f..7ff9165642 100644
--- a/docs/ref/contrib/flatpages.txt
+++ b/docs/ref/contrib/flatpages.txt
@@ -158,9 +158,7 @@ For more on middleware, read the :doc:`middleware docs
:class:`~django.contrib.flatpages.middleware.FlatpageFallbackMiddleware`
only steps in once another view has successfully produced a 404 response.
If another view or middleware class attempts to produce a 404 but ends up
- raising an exception instead (such as a ``TemplateDoesNotExist``
- exception if your site does not have an appropriate template to
- use for HTTP 404 responses), the response will become an HTTP 500
+ raising an exception instead, the response will become an HTTP 500
("Internal Server Error") and the
:class:`~django.contrib.flatpages.middleware.FlatpageFallbackMiddleware`
will not attempt to serve a flat page.
@@ -239,8 +237,6 @@ template.
Getting a list of :class:`~django.contrib.flatpages.models.FlatPage` objects in your templates
==============================================================================================
-.. versionadded:: 1.3
-
The flatpages app provides a template tag that allows you to iterate
over all of the available flatpages on the :ref:`current site
<hooking-into-current-site-from-views>`.
diff --git a/docs/ref/contrib/formtools/form-wizard.txt b/docs/ref/contrib/formtools/form-wizard.txt
index d5231de3e5..0ced1bf155 100644
--- a/docs/ref/contrib/formtools/form-wizard.txt
+++ b/docs/ref/contrib/formtools/form-wizard.txt
@@ -226,7 +226,7 @@ Hooking the wizard into a URLconf
---------------------------------
Finally, we need to specify which forms to use in the wizard, and then
-deploy the new :class:`WizardView` object at an URL in the ``urls.py``. The
+deploy the new :class:`WizardView` object at a URL in the ``urls.py``. The
wizard's :meth:`as_view` method takes a list of your
:class:`~django.forms.Form` classes as an argument during instantiation::
diff --git a/docs/ref/contrib/gis/admin.txt b/docs/ref/contrib/gis/admin.txt
index aa6ba58630..d1a9fc1dcb 100644
--- a/docs/ref/contrib/gis/admin.txt
+++ b/docs/ref/contrib/gis/admin.txt
@@ -45,7 +45,7 @@ GeoDjango's admin site
.. attribute:: openlayers_url
Link to the URL of the OpenLayers JavaScript. Defaults to
- ``'http://openlayers.org/api/2.8/OpenLayers.js'``.
+ ``'http://openlayers.org/api/2.11/OpenLayers.js'``.
.. attribute:: modifiable
diff --git a/docs/ref/contrib/gis/db-api.txt b/docs/ref/contrib/gis/db-api.txt
index 318110ef04..519f79f0d4 100644
--- a/docs/ref/contrib/gis/db-api.txt
+++ b/docs/ref/contrib/gis/db-api.txt
@@ -282,7 +282,7 @@ Method PostGIS Oracle SpatiaLite
:meth:`GeoQuerySet.extent3d` X
:meth:`GeoQuerySet.force_rhr` X
:meth:`GeoQuerySet.geohash` X
-:meth:`GeoQuerySet.geojson` X
+:meth:`GeoQuerySet.geojson` X X
:meth:`GeoQuerySet.gml` X X X
:meth:`GeoQuerySet.intersection` X X X
:meth:`GeoQuerySet.kml` X X
diff --git a/docs/ref/contrib/gis/geoip.txt b/docs/ref/contrib/gis/geoip.txt
index a30573d860..e37c4c60b0 100644
--- a/docs/ref/contrib/gis/geoip.txt
+++ b/docs/ref/contrib/gis/geoip.txt
@@ -23,10 +23,10 @@ to the GPL-licensed `Python GeoIP`__ interface provided by MaxMind.
In order to perform IP-based geolocation, the :class:`GeoIP` object requires
the GeoIP C libary and either the GeoIP `Country`__ or `City`__
datasets in binary format (the CSV files will not work!). These datasets may be
-`downloaded from MaxMind`__. Grab the ``GeoIP.dat.gz`` and ``GeoLiteCity.dat.gz``
-and unzip them in a directory corresponding to what you set
-:setting:`GEOIP_PATH` with in your settings. See the example and reference below
-for more details.
+`downloaded from MaxMind`__. Grab the ``GeoLiteCountry/GeoIP.dat.gz`` and
+``GeoLiteCity.dat.gz`` files and unzip them in a directory corresponding to what
+you set :setting:`GEOIP_PATH` with in your settings. See the example and
+reference below for more details.
__ http://www.maxmind.com/app/c
__ http://www.maxmind.com/app/python
diff --git a/docs/ref/contrib/gis/geoquerysets.txt b/docs/ref/contrib/gis/geoquerysets.txt
index eeec2e2133..69280dc028 100644
--- a/docs/ref/contrib/gis/geoquerysets.txt
+++ b/docs/ref/contrib/gis/geoquerysets.txt
@@ -947,7 +947,7 @@ __ http://geohash.org/
.. method:: GeoQuerySet.geojson(**kwargs)
-*Availability*: PostGIS
+*Availability*: PostGIS, SpatiaLite
Attaches a ``geojson`` attribute to every model in the queryset that contains the
`GeoJSON`__ representation of the geometry.
diff --git a/docs/ref/contrib/gis/geos.txt b/docs/ref/contrib/gis/geos.txt
index f4e706d275..eb20b1f411 100644
--- a/docs/ref/contrib/gis/geos.txt
+++ b/docs/ref/contrib/gis/geos.txt
@@ -163,6 +163,11 @@ WKB / EWKB ``buffer``
GeoJSON ``str`` or ``unicode``
============= ======================
+.. note::
+
+ The new 3D/4D WKT notation with an intermediary Z or M (like
+ ``POINT Z (3, 4, 5)``) is only supported with GEOS 3.3.0 or later.
+
Properties
~~~~~~~~~~
@@ -232,8 +237,6 @@ Returns a boolean indicating whether the geometry is valid.
.. attribute:: GEOSGeometry.valid_reason
-.. versionadded:: 1.3
-
Returns a string describing the reason why a geometry is invalid.
.. attribute:: GEOSGeometry.srid
@@ -270,14 +273,18 @@ Essentially the SRID is prepended to the WKT representation, for example
.. attribute:: GEOSGeometry.hex
Returns the WKB of this Geometry in hexadecimal form. Please note
-that the SRID and Z values are not included in this representation
+that the SRID value is not included in this representation
because it is not a part of the OGC specification (use the
:attr:`GEOSGeometry.hexewkb` property instead).
+.. versionchanged:: 1.5
+
+ Prior to Django 1.5, the Z value of the geometry was dropped.
+
.. attribute:: GEOSGeometry.hexewkb
Returns the EWKB of this Geometry in hexadecimal form. This is an
-extension of the WKB specification that includes SRID and Z values
+extension of the WKB specification that includes the SRID value
that are a part of this geometry.
.. note::
@@ -316,16 +323,20 @@ correspondg to the GEOS geometry.
.. attribute:: GEOSGeometry.wkb
Returns the WKB (Well-Known Binary) representation of this Geometry
-as a Python buffer. SRID and Z values are not included, use the
+as a Python buffer. SRID value is not included, use the
:attr:`GEOSGeometry.ewkb` property instead.
+.. versionchanged:: 1.5
+
+ Prior to Django 1.5, the Z value of the geometry was dropped.
+
.. _ewkb:
.. attribute:: GEOSGeometry.ewkb
Return the EWKB representation of this Geometry as a Python buffer.
This is an extension of the WKB specification that includes any SRID
-and Z values that are a part of this geometry.
+value that are a part of this geometry.
.. note::
@@ -413,11 +424,36 @@ quarter circle (defaults is 8).
Returns a :class:`GEOSGeometry` representing the points making up this
geometry that do not make up other.
+.. method:: GEOSGeometry.interpolate(distance)
+.. method:: GEOSGeometry.interpolate_normalized(distance)
+
+.. versionadded:: 1.5
+
+Given a distance (float), returns the point (or closest point) within the
+geometry (:class:`LineString` or :class:`MultiLineString`) at that distance.
+The normalized version takes the distance as a float between 0 (origin) and 1
+(endpoint).
+
+Reverse of :meth:`GEOSGeometry.project`.
+
.. method:: GEOSGeometry:intersection(other)
Returns a :class:`GEOSGeometry` representing the points shared by this
geometry and other.
+.. method:: GEOSGeometry.project(point)
+.. method:: GEOSGeometry.project_normalized(point)
+
+.. versionadded:: 1.5
+
+Returns the distance (float) from the origin of the geometry
+(:class:`LineString` or :class:`MultiLineString`) to the point projected on the
+geometry (that is to a point of the line the closest to the given point).
+The normalized version returns the distance as a float between 0 (origin) and 1
+(endpoint).
+
+Reverse of :meth:`GEOSGeometry.interpolate`.
+
.. method:: GEOSGeometry.relate(other)
Returns the DE-9IM intersection matrix (a string) representing the
@@ -530,8 +566,6 @@ corresponding to the SRID of the geometry or ``None``.
.. method:: GEOSGeometry.transform(ct, clone=False)
-.. versionchanged:: 1.3
-
Transforms the geometry according to the given coordinate transformation paramter
(``ct``), which may be an integer SRID, spatial reference WKT string,
a PROJ.4 string, a :class:`~django.contrib.gis.gdal.SpatialReference` object, or a
@@ -796,7 +830,7 @@ Writer Objects
All writer objects have a ``write(geom)`` method that returns either the
WKB or WKT of the given geometry. In addition, :class:`WKBWriter` objects
also have properties that may be used to change the byte order, and or
-include the SRID and 3D values (in other words, EWKB).
+include the SRID value (in other words, EWKB).
.. class:: WKBWriter
@@ -858,7 +892,7 @@ so that the Z value is included in the WKB.
Outdim Value Description
============ ===========================
2 The default, output 2D WKB.
-3 Output 3D EWKB.
+3 Output 3D WKB.
============ ===========================
Example::
diff --git a/docs/ref/contrib/gis/index.txt b/docs/ref/contrib/gis/index.txt
index 1b1e7688d0..6a1402bfab 100644
--- a/docs/ref/contrib/gis/index.txt
+++ b/docs/ref/contrib/gis/index.txt
@@ -15,7 +15,7 @@ of spatially enabled data.
:maxdepth: 2
tutorial
- install
+ install/index
model-api
db-api
geoquerysets
diff --git a/docs/ref/contrib/gis/install.txt b/docs/ref/contrib/gis/install.txt
deleted file mode 100644
index b815973202..0000000000
--- a/docs/ref/contrib/gis/install.txt
+++ /dev/null
@@ -1,1267 +0,0 @@
-.. _ref-gis-install:
-
-======================
-GeoDjango Installation
-======================
-
-.. highlight:: console
-
-Overview
-========
-In general, GeoDjango installation requires:
-
-1. :ref:`Python and Django <django>`
-2. :ref:`spatial_database`
-3. :ref:`geospatial_libs`
-
-Details for each of the requirements and installation instructions
-are provided in the sections below. In addition, platform-specific
-instructions are available for:
-
-* :ref:`macosx`
-* :ref:`ubuntudebian`
-* :ref:`windows`
-
-.. admonition:: Use the Source
-
- Because GeoDjango takes advantage of the latest in the open source geospatial
- software technology, recent versions of the libraries are necessary.
- If binary packages aren't available for your platform,
- :ref:`installation from source <build_from_source>`
- may be required. When compiling the libraries from source, please follow the
- directions closely, especially if you're a beginner.
-
-Requirements
-============
-
-.. _django:
-
-Python and Django
------------------
-
-Because GeoDjango is included with Django, please refer to Django's
-:ref:`installation instructions <installing-official-release>` for details on
-how to install.
-
-
-.. _spatial_database:
-
-Spatial database
-----------------
-PostgreSQL (with PostGIS), MySQL, Oracle, and SQLite (with SpatiaLite) are
-the spatial databases currently supported.
-
-.. note::
-
- PostGIS is recommended, because it is the most mature and feature-rich
- open source spatial database.
-
-The geospatial libraries required for a GeoDjango installation depends
-on the spatial database used. The following lists the library requirements,
-supported versions, and any notes for each of the supported database backends:
-
-================== ============================== ================== =========================================
-Database Library Requirements Supported Versions Notes
-================== ============================== ================== =========================================
-PostgreSQL GEOS, PROJ.4, PostGIS 8.1+ Requires PostGIS.
-MySQL GEOS 5.x Not OGC-compliant; limited functionality.
-Oracle GEOS 10.2, 11 XE not supported; not tested with 9.
-SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.6.+ Requires SpatiaLite 2.3+, pysqlite2 2.5+
-================== ============================== ================== =========================================
-
-.. _geospatial_libs:
-
-Geospatial libraries
---------------------
-GeoDjango uses and/or provides interfaces for the following open source
-geospatial libraries:
-
-======================== ==================================== ================================ ==========================
-Program Description Required Supported Versions
-======================== ==================================== ================================ ==========================
-:ref:`GEOS <ref-geos>` Geometry Engine Open Source Yes 3.3, 3.2, 3.1, 3.0
-`PROJ.4`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 4.8, 4.7, 4.6, 4.5, 4.4
-:ref:`GDAL <ref-gdal>` Geospatial Data Abstraction Library No (but, required for SQLite) 1.9, 1.8, 1.7, 1.6, 1.5
-:ref:`GeoIP <ref-geoip>` IP-based geolocation library No 1.4
-`PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 1.5, 1.4, 1.3
-`SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 3.0, 2.4, 2.3
-======================== ==================================== ================================ ==========================
-
-.. admonition:: Install GDAL
-
- While :ref:`gdalbuild` is technically not required, it is *recommended*.
- Important features of GeoDjango (including the :ref:`ref-layermapping`,
- geometry reprojection, and the geographic admin) depend on its
- functionality.
-
-.. note::
-
- The GeoDjango interfaces to GEOS, GDAL, and GeoIP may be used
- independently of Django. In other words, no database or settings file
- required -- just import them as normal from :mod:`django.contrib.gis`.
-
-.. _PROJ.4: http://trac.osgeo.org/proj/
-__ http://postgis.refractions.net/
-__ http://www.gaia-gis.it/gaia-sins/
-
-.. _build_from_source:
-
-Building from source
-====================
-
-When installing from source on UNIX and GNU/Linux systems, please follow
-the installation instructions carefully, and install the libraries in the
-given order. If using MySQL or Oracle as the spatial database, only GEOS
-is required.
-
-.. note::
-
- On Linux platforms, it may be necessary to run the ``ldconfig``
- command after installing each library. For example::
-
- $ sudo make install
- $ sudo ldconfig
-
-.. note::
-
- OS X users are required to install `Apple Developer Tools`_ in order
- to compile software from source. This is typically included on your
- OS X installation DVDs.
-
-.. _Apple Developer Tools: https://developer.apple.com/technologies/tools/
-
-.. _geosbuild:
-
-GEOS
-----
-
-GEOS is a C++ library for performing geometric operations, and is the default
-internal geometry representation used by GeoDjango (it's behind the "lazy"
-geometries). Specifically, the C API library is called (e.g., ``libgeos_c.so``)
-directly from Python using ctypes.
-
-First, download GEOS 3.3.5 from the refractions Web site and untar the source
-archive::
-
- $ wget http://download.osgeo.org/geos/geos-3.3.5.tar.bz2
- $ tar xjf geos-3.3.5.tar.bz2
-
-Next, change into the directory where GEOS was unpacked, run the configure
-script, compile, and install::
-
- $ cd geos-3.3.5
- $ ./configure
- $ make
- $ sudo make install
- $ cd ..
-
-Troubleshooting
-^^^^^^^^^^^^^^^
-
-Can't find GEOS library
-~~~~~~~~~~~~~~~~~~~~~~~
-
-When GeoDjango can't find GEOS, this error is raised:
-
-.. code-block:: text
-
- ImportError: Could not find the GEOS library (tried "geos_c"). Try setting GEOS_LIBRARY_PATH in your settings.
-
-The most common solution is to properly configure your :ref:`libsettings` *or* set
-:ref:`geoslibrarypath` in your settings.
-
-If using a binary package of GEOS (e.g., on Ubuntu), you may need to :ref:`binutils`.
-
-.. _geoslibrarypath:
-
-``GEOS_LIBRARY_PATH``
-~~~~~~~~~~~~~~~~~~~~~
-
-If your GEOS library is in a non-standard location, or you don't want to
-modify the system's library path then the :setting:`GEOS_LIBRARY_PATH`
-setting may be added to your Django settings file with the full path to the
-GEOS C library. For example:
-
-.. code-block:: python
-
- GEOS_LIBRARY_PATH = '/home/bob/local/lib/libgeos_c.so'
-
-.. note::
-
- The setting must be the *full* path to the **C** shared library; in
- other words you want to use ``libgeos_c.so``, not ``libgeos.so``.
-
-See also :ref:`My logs are filled with GEOS-related errors <geos-exceptions-in-logfile>`.
-
-.. _proj4:
-
-PROJ.4
-------
-
-`PROJ.4`_ is a library for converting geospatial data to different coordinate
-reference systems.
-
-First, download the PROJ.4 source code and datum shifting files [#]_::
-
- $ wget http://download.osgeo.org/proj/proj-4.8.0.tar.gz
- $ wget http://download.osgeo.org/proj/proj-datumgrid-1.5.tar.gz
-
-Next, untar the source code archive, and extract the datum shifting files in the
-``nad`` subdirectory. This must be done *prior* to configuration::
-
- $ tar xzf proj-4.8.0.tar.gz
- $ cd proj-4.8.0/nad
- $ tar xzf ../../proj-datumgrid-1.5.tar.gz
- $ cd ..
-
-Finally, configure, make and install PROJ.4::
-
- $ ./configure
- $ make
- $ sudo make install
- $ cd ..
-
-.. _postgis:
-
-PostGIS
--------
-
-`PostGIS`__ adds geographic object support to PostgreSQL, turning it
-into a spatial database. :ref:`geosbuild` and :ref:`proj4` should be
-installed prior to building PostGIS.
-
-.. note::
-
- The `psycopg2`_ module is required for use as the database adaptor
- when using GeoDjango with PostGIS.
-
-.. _psycopg2: http://initd.org/psycopg/
-
-First download the source archive, and extract::
-
- $ wget http://postgis.refractions.net/download/postgis-1.5.5.tar.gz
- $ tar xzf postgis-1.5.5.tar.gz
- $ cd postgis-1.5.5
-
-Next, configure, make and install PostGIS::
-
- $ ./configure
-
-Finally, make and install::
-
- $ make
- $ sudo make install
- $ cd ..
-
-.. note::
-
- GeoDjango does not automatically create a spatial database. Please
- consult the section on :ref:`spatialdb_template` for more information.
-
-__ http://postgis.refractions.net/
-
-.. _gdalbuild:
-
-GDAL
-----
-
-`GDAL`__ is an excellent open source geospatial library that has support for
-reading most vector and raster spatial data formats. Currently, GeoDjango only
-supports :ref:`GDAL's vector data <ref-gdal>` capabilities [#]_.
-:ref:`geosbuild` and :ref:`proj4` should be installed prior to building GDAL.
-
-First download the latest GDAL release version and untar the archive::
-
- $ wget http://download.osgeo.org/gdal/gdal-1.9.1.tar.gz
- $ tar xzf gdal-1.9.1.tar.gz
- $ cd gdal-1.9.1
-
-Configure, make and install::
-
- $ ./configure
- $ make # Go get some coffee, this takes a while.
- $ sudo make install
- $ cd ..
-
-.. note::
-
- Because GeoDjango has it's own Python interface, the preceding instructions
- do not build GDAL's own Python bindings. The bindings may be built by
- adding the ``--with-python`` flag when running ``configure``. See
- `GDAL/OGR In Python`__ for more information on GDAL's bindings.
-
-If you have any problems, please see the troubleshooting section below for
-suggestions and solutions.
-
-__ http://trac.osgeo.org/gdal/
-__ http://trac.osgeo.org/gdal/wiki/GdalOgrInPython
-
-.. _gdaltrouble:
-
-Troubleshooting
-^^^^^^^^^^^^^^^
-
-Can't find GDAL library
-~~~~~~~~~~~~~~~~~~~~~~~
-
-When GeoDjango can't find the GDAL library, the ``HAS_GDAL`` flag
-will be false:
-
-.. code-block:: pycon
-
- >>> from django.contrib.gis import gdal
- >>> gdal.HAS_GDAL
- False
-
-The solution is to properly configure your :ref:`libsettings` *or* set
-:ref:`gdallibrarypath` in your settings.
-
-.. _gdallibrarypath:
-
-``GDAL_LIBRARY_PATH``
-~~~~~~~~~~~~~~~~~~~~~
-
-If your GDAL library is in a non-standard location, or you don't want to
-modify the system's library path then the :setting:`GDAL_LIBRARY_PATH`
-setting may be added to your Django settings file with the full path to
-the GDAL library. For example:
-
-.. code-block:: python
-
- GDAL_LIBRARY_PATH = '/home/sue/local/lib/libgdal.so'
-
-.. _gdaldata:
-
-Can't find GDAL data files (``GDAL_DATA``)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-When installed from source, GDAL versions 1.5.1 and below have an autoconf bug
-that places data in the wrong location. [#]_ This can lead to error messages
-like this:
-
-.. code-block:: text
-
- ERROR 4: Unable to open EPSG support file gcs.csv.
- ...
- OGRException: OGR failure.
-
-The solution is to set the ``GDAL_DATA`` environment variable to the location of the
-GDAL data files before invoking Python (typically ``/usr/local/share``; use
-``gdal-config --datadir`` to find out). For example::
-
- $ export GDAL_DATA=`gdal-config --datadir`
- $ python manage.py shell
-
-If using Apache, you may need to add this environment variable to your configuration
-file:
-
-.. code-block:: apache
-
- SetEnv GDAL_DATA /usr/local/share
-
-.. _spatialite:
-
-SpatiaLite
-----------
-
-.. note::
-
- Mac OS X users should follow the instructions in the :ref:`kyngchaos` section,
- as it is much easier than building from source.
-
-`SpatiaLite`__ adds spatial support to SQLite, turning it into a full-featured
-spatial database. Because SpatiaLite has special requirements, it typically
-requires SQLite and pysqlite2 (the Python SQLite DB-API adaptor) to be built from
-source. :ref:`geosbuild` and :ref:`proj4` should be installed prior to building
-SpatiaLite.
-
-After installation is complete, don't forget to read the post-installation
-docs on :ref:`create_spatialite_db`.
-
-__ http://www.gaia-gis.it/gaia-sins/
-
-.. _sqlite:
-
-SQLite
-^^^^^^
-
-Typically, SQLite packages are not compiled to include the `R*Tree module`__ --
-thus it must be compiled from source. First download the latest amalgamation
-source archive from the `SQLite download page`__, and extract::
-
- $ wget http://sqlite.org/sqlite-amalgamation-3.6.23.1.tar.gz
- $ tar xzf sqlite-amalgamation-3.6.23.1.tar.gz
- $ cd sqlite-3.6.23.1
-
-Next, run the ``configure`` script -- however the ``CFLAGS`` environment variable
-needs to be customized so that SQLite knows to build the R*Tree module::
-
- $ CFLAGS="-DSQLITE_ENABLE_RTREE=1" ./configure
- $ make
- $ sudo make install
- $ cd ..
-
-.. note::
-
- If using Ubuntu, installing a newer SQLite from source can be very difficult
- because it links to the existing ``libsqlite3.so`` in ``/usr/lib`` which
- many other packages depend on. Unfortunately, the best solution at this time
- is to overwrite the existing library by adding ``--prefix=/usr`` to the
- ``configure`` command.
-
-__ http://www.sqlite.org/rtree.html
-__ http://www.sqlite.org/download.html
-
-.. _spatialitebuild :
-
-SpatiaLite library (``libspatialite``) and tools (``spatialite``)
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-After SQLite has been built with the R*Tree module enabled, get the latest
-SpatiaLite library source and tools bundle from the `download page`__::
-
- $ wget http://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-amalgamation-2.3.1.tar.gz
- $ wget http://www.gaia-gis.it/gaia-sins/spatialite-tools-sources/spatialite-tools-2.3.1.tar.gz
- $ tar xzf libspatialite-amalgamation-2.3.1.tar.gz
- $ tar xzf spatialite-tools-2.3.1.tar.gz
-
-Prior to attempting to build, please read the important notes below to see if
-customization of the ``configure`` command is necessary. If not, then run the
-``configure`` script, make, and install for the SpatiaLite library::
-
- $ cd libspatialite-amalgamation-2.3.1
- $ ./configure # May need to modified, see notes below.
- $ make
- $ sudo make install
- $ cd ..
-
-Finally, do the same for the SpatiaLite tools::
-
- $ cd spatialite-tools-2.3.1
- $ ./configure # May need to modified, see notes below.
- $ make
- $ sudo make install
- $ cd ..
-
-.. note::
-
- If you've installed GEOS and PROJ.4 from binary packages, you will have to specify
- their paths when running the ``configure`` scripts for *both* the library and the
- tools (the configure scripts look, by default, in ``/usr/local``). For example,
- on Debian/Ubuntu distributions that have GEOS and PROJ.4 packages, the command would be::
-
- $ ./configure --with-proj-include=/usr/include --with-proj-lib=/usr/lib --with-geos-include=/usr/include --with-geos-lib=/usr/lib
-
-.. note::
-
- For Mac OS X users building from source, the SpatiaLite library *and* tools
- need to have their ``target`` configured::
-
- $ ./configure --target=macosx
-
-__ http://www.gaia-gis.it/gaia-sins/libspatialite-sources/
-
-.. _pysqlite2:
-
-pysqlite2
-^^^^^^^^^
-
-Because SpatiaLite must be loaded as an external extension, it requires the
-``enable_load_extension`` method, which is only available in versions 2.5+ of
-pysqlite2. Thus, download pysqlite2 2.6, and untar::
-
- $ wget http://pysqlite.googlecode.com/files/pysqlite-2.6.0.tar.gz
- $ tar xzf pysqlite-2.6.0.tar.gz
- $ cd pysqlite-2.6.0
-
-Next, use a text editor (e.g., ``emacs`` or ``vi``) to edit the ``setup.cfg`` file
-to look like the following:
-
-.. code-block:: ini
-
- [build_ext]
- #define=
- include_dirs=/usr/local/include
- library_dirs=/usr/local/lib
- libraries=sqlite3
- #define=SQLITE_OMIT_LOAD_EXTENSION
-
-.. note::
-
- The important thing here is to make sure you comment out the
- ``define=SQLITE_OMIT_LOAD_EXTENSION`` flag and that the ``include_dirs``
- and ``library_dirs`` settings are uncommented and set to the appropriate
- path if the SQLite header files and libraries are not in ``/usr/include``
- and ``/usr/lib``, respectively.
-
-After modifying ``setup.cfg`` appropriately, then run the ``setup.py`` script
-to build and install::
-
- $ sudo python setup.py install
-
-Post-installation
-=================
-
-.. _spatialdb_template:
-
-Creating a spatial database template for PostGIS
-------------------------------------------------
-
-Creating a spatial database with PostGIS is different than normal because
-additional SQL must be loaded to enable spatial functionality. Because of
-the steps in this process, it's better to create a database template that
-can be reused later.
-
-First, you need to be able to execute the commands as a privileged database
-user. For example, you can use the following to become the ``postgres`` user::
-
- $ sudo su - postgres
-
-.. note::
-
- The location *and* name of the PostGIS SQL files (e.g., from
- ``POSTGIS_SQL_PATH`` below) depends on the version of PostGIS.
- PostGIS versions 1.3 and below use ``<pg_sharedir>/contrib/lwpostgis.sql``;
- whereas version 1.4 uses ``<sharedir>/contrib/postgis.sql`` and
- version 1.5 uses ``<sharedir>/contrib/postgis-1.5/postgis.sql``.
-
- To complicate matters, :ref:`ubuntudebian` distributions have their
- own separate directory naming system that changes each release.
-
- The example below assumes PostGIS 1.5, thus you may need to modify
- ``POSTGIS_SQL_PATH`` and the name of the SQL file for the specific
- version of PostGIS you are using.
-
-Once you're a database super user, then you may execute the following commands
-to create a PostGIS spatial database template::
-
- $ POSTGIS_SQL_PATH=`pg_config --sharedir`/contrib/postgis-1.5
- # Creating the template spatial database.
- $ createdb -E UTF8 template_postgis
- $ createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
- # Allows non-superusers the ability to create from this template
- $ psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
- # Loading the PostGIS SQL routines
- $ psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql
- $ psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql
- # Enabling users to alter spatial tables.
- $ psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
- $ psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
- $ psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
-
-These commands may be placed in a shell script for later use; for convenience
-the following scripts are available:
-
-=============== =============================================
-PostGIS version Bash shell script
-=============== =============================================
-1.3 :download:`create_template_postgis-1.3.sh`
-1.4 :download:`create_template_postgis-1.4.sh`
-1.5 :download:`create_template_postgis-1.5.sh`
-Debian/Ubuntu :download:`create_template_postgis-debian.sh`
-=============== =============================================
-
-Afterwards, you may create a spatial database by simply specifying
-``template_postgis`` as the template to use (via the ``-T`` option)::
-
- $ createdb -T template_postgis <db name>
-
-.. note::
-
- While the ``createdb`` command does not require database super-user privileges,
- it must be executed by a database user that has permissions to create databases.
- You can create such a user with the following command::
-
- $ createuser --createdb <user>
-
-.. _create_spatialite_db:
-
-Creating a spatial database for SpatiaLite
-------------------------------------------
-
-After you've installed SpatiaLite, you'll need to create a number of spatial
-metadata tables in your database in order to perform spatial queries.
-
-If you're using SpatiaLite 2.4 or newer, use the ``spatialite`` utility to
-call the ``InitSpatialMetaData()`` function, like this::
-
- $ spatialite geodjango.db "SELECT InitSpatialMetaData();"
- the SPATIAL_REF_SYS table already contains some row(s)
- InitSpatiaMetaData ()error:"table spatial_ref_sys already exists"
- 0
-
-You can safely ignore the error messages shown. When you've done this, you can
-skip the rest of this section.
-
-If you're using SpatiaLite 2.3, you'll need to download a
-database-initialization file and execute its SQL queries in your database.
-
-First, get it from the `SpatiaLite Resources`__ page::
-
- $ wget http://www.gaia-gis.it/spatialite-2.3.1/init_spatialite-2.3.sql.gz
- $ gunzip init_spatialite-2.3.sql.gz
-
-Then, use the ``spatialite`` command to initialize a spatial database::
-
- $ spatialite geodjango.db < init_spatialite-2.3.sql
-
-.. note::
-
- The parameter ``geodjango.db`` is the *filename* of the SQLite database
- you want to use. Use the same in the :setting:`DATABASES` ``"name"`` key
- inside your ``settings.py``.
-
-__ http://www.gaia-gis.it/spatialite-2.3.1/resources.html
-
-Add ``django.contrib.gis`` to :setting:`INSTALLED_APPS`
--------------------------------------------------------
-
-Like other Django contrib applications, you will *only* need to add
-:mod:`django.contrib.gis` to :setting:`INSTALLED_APPS` in your settings.
-This is the so that ``gis`` templates can be located -- if not done, then
-features such as the geographic admin or KML sitemaps will not function properly.
-
-.. _addgoogleprojection:
-
-Add Google projection to ``spatial_ref_sys`` table
---------------------------------------------------
-
-.. note::
-
- If you're running PostGIS 1.4 or above, you can skip this step. The entry
- is already included in the default ``spatial_ref_sys`` table.
-
-In order to conduct database transformations to the so-called "Google"
-projection (a spherical mercator projection used by Google Maps),
-an entry must be added to your spatial database's ``spatial_ref_sys`` table.
-Invoke the Django shell from your project and execute the
-``add_srs_entry`` function:
-
-.. code-block:: pycon
-
- $ python manage shell
- >>> from django.contrib.gis.utils import add_srs_entry
- >>> add_srs_entry(900913)
-
-This adds an entry for the 900913 SRID to the ``spatial_ref_sys`` (or equivalent)
-table, making it possible for the spatial database to transform coordinates in
-this projection. You only need to execute this command *once* per spatial database.
-
-Troubleshooting
-===============
-
-If you can't find the solution to your problem here then participate in the
-community! You can:
-
-* Join the ``#geodjango`` IRC channel on FreeNode. Please be patient and polite
- -- while you may not get an immediate response, someone will attempt to answer
- your question as soon as they see it.
-* Ask your question on the `GeoDjango`__ mailing list.
-* File a ticket on the `Django trac`__ if you think there's a bug. Make
- sure to provide a complete description of the problem, versions used,
- and specify the component as "GIS".
-
-__ http://groups.google.com/group/geodjango
-__ https://code.djangoproject.com/newticket
-
-.. _libsettings:
-
-Library environment settings
-----------------------------
-
-By far, the most common problem when installing GeoDjango is that the
-external shared libraries (e.g., for GEOS and GDAL) cannot be located. [#]_
-Typically, the cause of this problem is that the operating system isn't aware
-of the directory where the libraries built from source were installed.
-
-In general, the library path may be set on a per-user basis by setting
-an environment variable, or by configuring the library path for the entire
-system.
-
-``LD_LIBRARY_PATH`` environment variable
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-A user may set this environment variable to customize the library paths
-they want to use. The typical library directory for software
-built from source is ``/usr/local/lib``. Thus, ``/usr/local/lib`` needs
-to be included in the ``LD_LIBRARY_PATH`` variable. For example, the user
-could place the following in their bash profile::
-
- export LD_LIBRARY_PATH=/usr/local/lib
-
-Setting system library path
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-On GNU/Linux systems, there is typically a file in ``/etc/ld.so.conf``, which may include
-additional paths from files in another directory, such as ``/etc/ld.so.conf.d``.
-As the root user, add the custom library path (like ``/usr/local/lib``) on a
-new line in ``ld.so.conf``. This is *one* example of how to do so::
-
- $ sudo echo /usr/local/lib >> /etc/ld.so.conf
- $ sudo ldconfig
-
-For OpenSolaris users, the system library path may be modified using the
-``crle`` utility. Run ``crle`` with no options to see the current configuration
-and use ``crle -l`` to set with the new library path. Be *very* careful when
-modifying the system library path::
-
- # crle -l $OLD_PATH:/usr/local/lib
-
-.. _binutils:
-
-Install ``binutils``
-^^^^^^^^^^^^^^^^^^^^
-
-GeoDjango uses the ``find_library`` function (from the ``ctypes.util`` Python
-module) to discover libraries. The ``find_library`` routine uses a program
-called ``objdump`` (part of the ``binutils`` package) to verify a shared
-library on GNU/Linux systems. Thus, if ``binutils`` is not installed on your
-Linux system then Python's ctypes may not be able to find your library even if
-your library path is set correctly and geospatial libraries were built perfectly.
-
-The ``binutils`` package may be installed on Debian and Ubuntu systems using the
-following command::
-
- $ sudo apt-get install binutils
-
-Similarly, on Red Hat and CentOS systems::
-
- $ sudo yum install binutils
-
-Platform-specific instructions
-==============================
-
-.. _macosx:
-
-Mac OS X
---------
-
-Because of the variety of packaging systems available for OS X, users have
-several different options for installing GeoDjango. These options are:
-
-* :ref:`homebrew`
-* :ref:`kyngchaos`
-* :ref:`fink`
-* :ref:`macports`
-* :ref:`build_from_source`
-
-.. note::
-
- Currently, the easiest and recommended approach for installing GeoDjango
- on OS X is to use the KyngChaos packages.
-
-This section also includes instructions for installing an upgraded version
-of :ref:`macosx_python` from packages provided by the Python Software
-Foundation, however, this is not required.
-
-.. _macosx_python:
-
-Python
-^^^^^^
-
-Although OS X comes with Python installed, users can use framework
-installers (`2.6`__ and `2.7`__ are available) provided by
-the Python Software Foundation. An advantage to using the installer is
-that OS X's Python will remain "pristine" for internal operating system
-use.
-
-__ http://python.org/ftp/python/2.6.6/python-2.6.6-macosx10.3.dmg
-__ http://python.org/ftp/python/2.7.3/
-
-.. note::
-
- You will need to modify the ``PATH`` environment variable in your
- ``.profile`` file so that the new version of Python is used when
- ``python`` is entered at the command-line::
-
- export PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH
-
-.. _homebrew:
-
-Homebrew
-^^^^^^^^
-
-`Homebrew`__ provides "recipes" for building binaries and packages from source.
-It provides recipes for the GeoDjango prerequisites on Macintosh computers
-running OS X. Because Homebrew still builds the software from source, the
-`Apple Developer Tools`_ are required.
-
-Summary::
-
- $ brew install postgresql
- $ brew install postgis
- $ brew install gdal
- $ brew install libgeoip
-
-__ http://mxcl.github.com/homebrew/
-
-.. _kyngchaos:
-
-KyngChaos packages
-^^^^^^^^^^^^^^^^^^
-
-William Kyngesburye provides a number of `geospatial library binary packages`__
-that make it simple to get GeoDjango installed on OS X without compiling
-them from source. However, the `Apple Developer Tools`_ are still necessary
-for compiling the Python database adapters :ref:`psycopg2_kyngchaos` (for PostGIS)
-and :ref:`pysqlite2_kyngchaos` (for SpatiaLite).
-
-.. note::
-
- SpatiaLite users should consult the :ref:`spatialite_kyngchaos` section
- after installing the packages for additional instructions.
-
-Download the framework packages for:
-
-* UnixImageIO
-* PROJ
-* GEOS
-* SQLite3 (includes the SpatiaLite library)
-* GDAL
-
-Install the packages in the order they are listed above, as the GDAL and SQLite
-packages require the packages listed before them.
-
-Afterwards, you can also install the KyngChaos binary packages for `PostgreSQL
-and PostGIS`__.
-
-After installing the binary packages, you'll want to add the following to
-your ``.profile`` to be able to run the package programs from the command-line::
-
- export PATH=/Library/Frameworks/UnixImageIO.framework/Programs:$PATH
- export PATH=/Library/Frameworks/PROJ.framework/Programs:$PATH
- export PATH=/Library/Frameworks/GEOS.framework/Programs:$PATH
- export PATH=/Library/Frameworks/SQLite3.framework/Programs:$PATH
- export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH
- export PATH=/usr/local/pgsql/bin:$PATH
-
-__ http://www.kyngchaos.com/software/frameworks
-__ http://www.kyngchaos.com/software/postgres
-
-.. _psycopg2_kyngchaos:
-
-psycopg2
-~~~~~~~~
-
-After you've installed the KyngChaos binaries and modified your ``PATH``, as
-described above, ``psycopg2`` may be installed using the following command::
-
- $ sudo pip install psycopg2
-
-.. note::
-
- If you don't have ``pip``, follow the the :ref:`installation instructions
- <installing-official-release>` to install it.
-
-.. _pysqlite2_kyngchaos:
-
-pysqlite2
-~~~~~~~~~
-
-Follow the :ref:`pysqlite2` source install instructions, however,
-when editing the ``setup.cfg`` use the following instead:
-
-.. code-block:: ini
-
- [build_ext]
- #define=
- include_dirs=/Library/Frameworks/SQLite3.framework/unix/include
- library_dirs=/Library/Frameworks/SQLite3.framework/unix/lib
- libraries=sqlite3
- #define=SQLITE_OMIT_LOAD_EXTENSION
-
-.. _spatialite_kyngchaos:
-
-SpatiaLite
-~~~~~~~~~~
-
-When :ref:`create_spatialite_db`, the ``spatialite`` program is required.
-However, instead of attempting to compile the SpatiaLite tools from source,
-download the `SpatiaLite Binaries`__ for OS X, and install ``spatialite`` in a
-location available in your ``PATH``. For example::
-
- $ curl -O http://www.gaia-gis.it/spatialite/spatialite-tools-osx-x86-2.3.1.tar.gz
- $ tar xzf spatialite-tools-osx-x86-2.3.1.tar.gz
- $ cd spatialite-tools-osx-x86-2.3.1/bin
- $ sudo cp spatialite /Library/Frameworks/SQLite3.framework/Programs
-
-Finally, for GeoDjango to be able to find the KyngChaos SpatiaLite library,
-add the following to your ``settings.py``:
-
-.. code-block:: python
-
- SPATIALITE_LIBRARY_PATH='/Library/Frameworks/SQLite3.framework/SQLite3'
-
-__ http://www.gaia-gis.it/spatialite-2.3.1/binaries.html
-
-.. _fink:
-
-Fink
-^^^^
-
-`Kurt Schwehr`__ has been gracious enough to create GeoDjango packages for users
-of the `Fink`__ package system. The following packages are available, depending
-on which version of Python you want to use:
-
-* ``django-gis-py26``
-* ``django-gis-py25``
-* ``django-gis-py24``
-
-__ http://schwehr.org/blog/
-__ http://www.finkproject.org/
-
-.. _macports:
-
-MacPorts
-^^^^^^^^
-
-`MacPorts`__ may be used to install GeoDjango prerequisites on Macintosh
-computers running OS X. Because MacPorts still builds the software from source,
-the `Apple Developer Tools`_ are required.
-
-Summary::
-
- $ sudo port install postgresql83-server
- $ sudo port install geos
- $ sudo port install proj
- $ sudo port install postgis
- $ sudo port install gdal +geos
- $ sudo port install libgeoip
-
-.. note::
-
- You will also have to modify the ``PATH`` in your ``.profile`` so
- that the MacPorts programs are accessible from the command-line::
-
- export PATH=/opt/local/bin:/opt/local/lib/postgresql83/bin
-
- In addition, add the ``DYLD_FALLBACK_LIBRARY_PATH`` setting so that
- the libraries can be found by Python::
-
- export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib:/opt/local/lib/postgresql83
-
-__ http://www.macports.org/
-
-.. _ubuntudebian:
-
-Ubuntu & Debian GNU/Linux
--------------------------
-
-.. note::
-
- The PostGIS SQL files are not placed in the PostgreSQL share directory in
- the Debian and Ubuntu packages. Instead, they're located in a special
- directory depending on the release. In this case, use the
- :download:`create_template_postgis-debian.sh` script
-
-.. _ubuntu:
-
-Ubuntu
-^^^^^^
-
-11.10 through 12.04
-~~~~~~~~~~~~~~~~~~~
-
-In Ubuntu 11.10, PostgreSQL was upgraded to 9.1. The installation command is:
-
-.. code-block:: bash
-
- $ sudo apt-get install binutils gdal-bin libproj-dev \
- postgresql-9.1-postgis postgresql-server-dev-9.1 python-psycopg2
-
-.. _ubuntu10:
-
-10.04 through 11.04
-~~~~~~~~~~~~~~~~~~~
-
-In Ubuntu 10.04, PostgreSQL was upgraded to 8.4 and GDAL was upgraded to 1.6.
-Ubuntu 10.04 uses PostGIS 1.4, while Ubuntu 10.10 uses PostGIS 1.5 (with
-geography support). The installation command is:
-
-.. code-block:: bash
-
- $ sudo apt-get install binutils gdal-bin libproj-dev postgresql-8.4-postgis \
- postgresql-server-dev-8.4 python-psycopg2
-
-.. _ibex:
-
-8.10
-~~~~
-
-Use the synaptic package manager to install the following packages:
-
-.. code-block:: bash
-
- $ sudo apt-get install binutils gdal-bin postgresql-8.3-postgis \
- postgresql-server-dev-8.3 python-psycopg2
-
-That's it! For the curious, the required binary prerequisites packages are:
-
-* ``binutils``: for ctypes to find libraries
-* ``postgresql-8.3``
-* ``postgresql-server-dev-8.3``: for ``pg_config``
-* ``postgresql-8.3-postgis``: for PostGIS 1.3.3
-* ``libgeos-3.0.0``, and ``libgeos-c1``: for GEOS 3.0.0
-* ``libgdal1-1.5.0``: for GDAL 1.5.0 library
-* ``proj``: for PROJ 4.6.0 -- but no datum shifting files, see note below
-* ``python-psycopg2``
-
-Optional packages to consider:
-
-* ``libgeoip1``: for :ref:`GeoIP <ref-geoip>` support
-* ``gdal-bin``: for GDAL command line programs like ``ogr2ogr``
-* ``python-gdal`` for GDAL's own Python bindings -- includes interfaces for raster manipulation
-
-.. note::
-
- On this version of Ubuntu the ``proj`` package does not come with the
- datum shifting files installed, which will cause problems with the
- geographic admin because the ``null`` datum grid is not available for
- transforming geometries to the spherical mercator projection. A solution
- is to download the datum-shifting files, create the grid file, and
- install it yourself:
-
- .. code-block:: bash
-
- $ wget http://download.osgeo.org/proj/proj-datumgrid-1.4.tar.gz
- $ mkdir nad
- $ cd nad
- $ tar xzf ../proj-datumgrid-1.4.tar.gz
- $ nad2bin null < null.lla
- $ sudo cp null /usr/share/proj
-
- Otherwise, the Ubuntu ``proj`` package is fine for general use as long as you
- do not plan on doing any database transformation of geometries to the
- Google projection (900913).
-
-.. _debian:
-
-Debian
-------
-
-.. _lenny:
-
-5.0 (Lenny)
-^^^^^^^^^^^
-
-This version is comparable to Ubuntu :ref:`ibex`, so the command
-is very similar:
-
-.. code-block:: bash
-
- $ sudo apt-get install binutils libgdal1-1.5.0 postgresql-8.3 \
- postgresql-8.3-postgis postgresql-server-dev-8.3 \
- python-psycopg2 python-setuptools
-
-This assumes that you are using PostgreSQL version 8.3. Else, replace ``8.3``
-in the above command with the appropriate PostgreSQL version.
-
-.. note::
-
- Please read the note in the Ubuntu :ref:`ibex` install documentation
- about the ``proj`` package -- it also applies here because the package does
- not include the datum shifting files.
-
-.. _post_install:
-
-Post-installation notes
-~~~~~~~~~~~~~~~~~~~~~~~
-
-If the PostgreSQL database cluster was not initiated after installing, then it
-can be created (and started) with the following command:
-
-.. code-block:: bash
-
- $ sudo pg_createcluster --start 8.3 main
-
-Afterwards, the ``/etc/init.d/postgresql-8.3`` script should be used to manage
-the starting and stopping of PostgreSQL.
-
-In addition, the SQL files for PostGIS are placed in a different location on
-Debian 5.0 . Thus when :ref:`spatialdb_template` either:
-
-* Create a symbolic link to these files:
-
- .. code-block:: bash
-
- $ sudo ln -s /usr/share/postgresql-8.3-postgis/{lwpostgis,spatial_ref_sys}.sql \
- /usr/share/postgresql/8.3
-
- If not running PostgreSQL 8.3, then replace ``8.3`` in the command above with
- the correct version.
-
-* Or use the :download:`create_template_postgis-debian.sh` to create the spatial database.
-
-.. _windows:
-
-Windows
--------
-
-Proceed through the following sections sequentially in order to install
-GeoDjango on Windows.
-
-.. note::
-
- These instructions assume that you are using 32-bit versions of
- all programs. While 64-bit versions of Python and PostgreSQL 9.0
- are available, 64-bit versions of spatial libraries, like
- GEOS and GDAL, are not yet provided by the :ref:`OSGeo4W` installer.
-
-Python
-^^^^^^
-
-First, download the latest `Python 2.7 installer`__ from the Python Web site.
-Next, run the installer and keep the defaults -- for example, keep
-'Install for all users' checked and the installation path set as
-``C:\Python27``.
-
-.. note::
-
- You may already have a version of Python installed in ``C:\python`` as ESRI
- products sometimes install a copy there. *You should still install a
- fresh version of Python 2.7.*
-
-__ http://python.org/download/
-
-PostgreSQL
-^^^^^^^^^^
-
-First, download the latest `PostgreSQL 9.0 installer`__ from the
-`EnterpriseDB`__ Web site. After downloading, simply run the installer,
-follow the on-screen directions, and keep the default options unless
-you know the consequences of changing them.
-
-.. note::
-
- The PostgreSQL installer creates both a new Windows user to be the
- 'postgres service account' and a ``postgres`` database superuser
- You will be prompted once to set the password for both accounts --
- make sure to remember it!
-
-When the installer completes, it will ask to launch the Application Stack
-Builder (ASB) on exit -- keep this checked, as it is necessary to
-install :ref:`postgisasb`.
-
-.. note::
-
- If installed successfully, the PostgreSQL server will run in the
- background each time the system as started as a Windows service.
- A :menuselection:`PostgreSQL 9.0` start menu group will created
- and contains shortcuts for the ASB as well as the 'SQL Shell',
- which will launch a ``psql`` command window.
-
-__ http://www.enterprisedb.com/products-services-training/pgdownload
-__ http://www.enterprisedb.com
-
-.. _postgisasb:
-
-PostGIS
-^^^^^^^
-
-From within the Application Stack Builder (to run outside of the installer,
-:menuselection:`Start --> Programs --> PostgreSQL 9.0`), select
-:menuselection:`PostgreSQL Database Server 9.0 on port 5432` from the drop down
-menu. Next, expand the :menuselection:`Categories --> Spatial Extensions` menu
-tree and select :menuselection:`PostGIS 1.5 for PostgreSQL 9.0`.
-
-After clicking next, you will be prompted to select your mirror, PostGIS
-will be downloaded, and the PostGIS installer will begin. Select only the
-default options during install (e.g., do not uncheck the option to create a
-default PostGIS database).
-
-.. note::
-
- You will be prompted to enter your ``postgres`` database superuser
- password in the 'Database Connection Information' dialog.
-
-psycopg2
-^^^^^^^^
-
-The ``psycopg2`` Python module provides the interface between Python and the
-PostgreSQL database. Download the latest `Windows installer`__ for your version
-of Python and PostgreSQL and run using the default settings. [#]_
-
-__ http://www.stickpeople.com/projects/python/win-psycopg/
-
-.. _osgeo4w:
-
-OSGeo4W
-^^^^^^^
-
-The `OSGeo4W installer`_ makes it simple to install the PROJ.4, GDAL, and GEOS
-libraries required by GeoDjango. First, download the `OSGeo4W installer`_,
-and run it. Select :menuselection:`Express Web-GIS Install` and click next.
-In the 'Select Packages' list, ensure that GDAL is selected; MapServer and
-Apache are also enabled by default, but are not required by GeoDjango and
-may be unchecked safely. After clicking next, the packages will be
-automatically downloaded and installed, after which you may exit the
-installer.
-
-.. _OSGeo4W installer: http://trac.osgeo.org/osgeo4w/
-
-Modify Windows environment
-^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-In order to use GeoDjango, you will need to add your Python and OSGeo4W
-directories to your Windows system ``Path``, as well as create ``GDAL_DATA``
-and ``PROJ_LIB`` environment variables. The following set of commands,
-executable with ``cmd.exe``, will set this up:
-
-.. code-block:: bat
-
- set OSGEO4W_ROOT=C:\OSGeo4W
- set PYTHON_ROOT=C:\Python27
- set GDAL_DATA=%OSGEO4W_ROOT%\share\gdal
- set PROJ_LIB=%OSGEO4W_ROOT%\share\proj
- set PATH=%PATH%;%PYTHON_ROOT%;%OSGEO4W_ROOT%\bin
- reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /f /d "%PATH%"
- reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v GDAL_DATA /t REG_EXPAND_SZ /f /d "%GDAL_DATA%"
- reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROJ_LIB /t REG_EXPAND_SZ /f /d "%PROJ_LIB%"
-
-For your convenience, these commands are available in the executable batch
-script, :download:`geodjango_setup.bat`.
-
-.. note::
-
- Administrator privileges are required to execute these commands.
- To do this, right-click on :download:`geodjango_setup.bat` and select
- :menuselection:`Run as administrator`. You need to log out and log back in again
- for the settings to take effect.
-
-.. note::
-
- If you customized the Python or OSGeo4W installation directories,
- then you will need to modify the ``OSGEO4W_ROOT`` and/or ``PYTHON_ROOT``
- variables accordingly.
-
-Install Django and set up database
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Finally, :ref:`install Django <installing-official-release>` on your system.
-You do not need to create a spatial database template, as one named
-``template_postgis`` is created for you when installing PostGIS.
-
-To administer the database, you can either use the pgAdmin III program
-(:menuselection:`Start --> PostgreSQL 9.0 --> pgAdmin III`) or the
-SQL Shell (:menuselection:`Start --> PostgreSQL 9.0 --> SQL Shell`).
-For example, to create a ``geodjango`` spatial database and user, the following
-may be executed from the SQL Shell as the ``postgres`` user::
-
- postgres# CREATE USER geodjango PASSWORD 'my_passwd';
- postgres# CREATE DATABASE geodjango OWNER geodjango TEMPLATE template_postgis ENCODING 'utf8';
-
-.. rubric:: Footnotes
-.. [#] The datum shifting files are needed for converting data to and from
- certain projections.
- For example, the PROJ.4 string for the `Google projection (900913 or 3857)
- <http://spatialreference.org/ref/sr-org/6864/prj/>`_ requires the
- ``null`` grid file only included in the extra datum shifting files.
- It is easier to install the shifting files now, then to have debug a
- problem caused by their absence later.
-.. [#] Specifically, GeoDjango provides support for the `OGR
- <http://gdal.org/ogr>`_ library, a component of GDAL.
-.. [#] See `GDAL ticket #2382 <http://trac.osgeo.org/gdal/ticket/2382>`_.
-.. [#] GeoDjango uses the :func:`~ctypes.util.find_library` routine from
- :mod:`ctypes.util` to locate shared libraries.
-.. [#] The ``psycopg2`` Windows installers are packaged and maintained by
- `Jason Erickson <http://www.stickpeople.com/projects/python/win-psycopg/>`_.
diff --git a/docs/ref/contrib/gis/create_template_postgis-1.3.sh b/docs/ref/contrib/gis/install/create_template_postgis-1.3.sh
index c9ab4fcebf..c9ab4fcebf 100755
--- a/docs/ref/contrib/gis/create_template_postgis-1.3.sh
+++ b/docs/ref/contrib/gis/install/create_template_postgis-1.3.sh
diff --git a/docs/ref/contrib/gis/create_template_postgis-1.4.sh b/docs/ref/contrib/gis/install/create_template_postgis-1.4.sh
index 57a1373f96..57a1373f96 100755
--- a/docs/ref/contrib/gis/create_template_postgis-1.4.sh
+++ b/docs/ref/contrib/gis/install/create_template_postgis-1.4.sh
diff --git a/docs/ref/contrib/gis/create_template_postgis-1.5.sh b/docs/ref/contrib/gis/install/create_template_postgis-1.5.sh
index 081b5f2656..081b5f2656 100755
--- a/docs/ref/contrib/gis/create_template_postgis-1.5.sh
+++ b/docs/ref/contrib/gis/install/create_template_postgis-1.5.sh
diff --git a/docs/ref/contrib/gis/create_template_postgis-debian.sh b/docs/ref/contrib/gis/install/create_template_postgis-debian.sh
index 3e621837fa..3e621837fa 100755
--- a/docs/ref/contrib/gis/create_template_postgis-debian.sh
+++ b/docs/ref/contrib/gis/install/create_template_postgis-debian.sh
diff --git a/docs/ref/contrib/gis/geodjango_setup.bat b/docs/ref/contrib/gis/install/geodjango_setup.bat
index b3e6cc6822..b3e6cc6822 100644
--- a/docs/ref/contrib/gis/geodjango_setup.bat
+++ b/docs/ref/contrib/gis/install/geodjango_setup.bat
diff --git a/docs/ref/contrib/gis/install/geolibs.txt b/docs/ref/contrib/gis/install/geolibs.txt
new file mode 100644
index 0000000000..c78f0c0e62
--- /dev/null
+++ b/docs/ref/contrib/gis/install/geolibs.txt
@@ -0,0 +1,282 @@
+.. _geospatial_libs:
+
+===============================
+Installing Geospatial libraries
+===============================
+
+GeoDjango uses and/or provides interfaces for the following open source
+geospatial libraries:
+
+======================== ==================================== ================================ ==========================
+Program Description Required Supported Versions
+======================== ==================================== ================================ ==========================
+:ref:`GEOS <ref-geos>` Geometry Engine Open Source Yes 3.3, 3.2, 3.1, 3.0
+`PROJ.4`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 4.8, 4.7, 4.6, 4.5, 4.4
+:ref:`GDAL <ref-gdal>` Geospatial Data Abstraction Library No (but, required for SQLite) 1.9, 1.8, 1.7, 1.6, 1.5
+:ref:`GeoIP <ref-geoip>` IP-based geolocation library No 1.4
+`PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 2.0, 1.5, 1.4, 1.3
+`SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 3.0, 2.4, 2.3
+======================== ==================================== ================================ ==========================
+
+.. admonition:: Install GDAL
+
+ While :ref:`gdalbuild` is technically not required, it is *recommended*.
+ Important features of GeoDjango (including the :ref:`ref-layermapping`,
+ geometry reprojection, and the geographic admin) depend on its
+ functionality.
+
+.. note::
+
+ The GeoDjango interfaces to GEOS, GDAL, and GeoIP may be used
+ independently of Django. In other words, no database or settings file
+ required -- just import them as normal from :mod:`django.contrib.gis`.
+
+.. _PROJ.4: http://trac.osgeo.org/proj/
+__ http://postgis.refractions.net/
+__ http://www.gaia-gis.it/gaia-sins/
+
+
+On Debian/Ubuntu, you are advised to install the following packages which will
+install, directly or by dependency, the required geospatial libraries:
+
+.. code-block:: bash
+
+ $ sudo apt-get install binutils libproj-dev gdal-bin
+
+Optional packages to consider:
+
+* ``libgeoip1``: for :ref:`GeoIP <ref-geoip>` support
+* ``gdal-bin``: for GDAL command line programs like ``ogr2ogr``
+* ``python-gdal`` for GDAL's own Python bindings -- includes interfaces for raster manipulation
+
+Please also consult platform-specific instructions if you are on :ref:`macosx`
+or :ref:`windows`.
+
+.. _build_from_source:
+
+Building from source
+====================
+
+When installing from source on UNIX and GNU/Linux systems, please follow
+the installation instructions carefully, and install the libraries in the
+given order. If using MySQL or Oracle as the spatial database, only GEOS
+is required.
+
+.. note::
+
+ On Linux platforms, it may be necessary to run the ``ldconfig``
+ command after installing each library. For example::
+
+ $ sudo make install
+ $ sudo ldconfig
+
+.. note::
+
+ OS X users are required to install `Apple Developer Tools`_ in order
+ to compile software from source. This is typically included on your
+ OS X installation DVDs.
+
+.. _Apple Developer Tools: https://developer.apple.com/technologies/tools/
+
+.. _geosbuild:
+
+GEOS
+----
+
+GEOS is a C++ library for performing geometric operations, and is the default
+internal geometry representation used by GeoDjango (it's behind the "lazy"
+geometries). Specifically, the C API library is called (e.g., ``libgeos_c.so``)
+directly from Python using ctypes.
+
+First, download GEOS 3.3.5 from the refractions Web site and untar the source
+archive::
+
+ $ wget http://download.osgeo.org/geos/geos-3.3.5.tar.bz2
+ $ tar xjf geos-3.3.5.tar.bz2
+
+Next, change into the directory where GEOS was unpacked, run the configure
+script, compile, and install::
+
+ $ cd geos-3.3.5
+ $ ./configure
+ $ make
+ $ sudo make install
+ $ cd ..
+
+Troubleshooting
+^^^^^^^^^^^^^^^
+
+Can't find GEOS library
+~~~~~~~~~~~~~~~~~~~~~~~
+
+When GeoDjango can't find GEOS, this error is raised:
+
+.. code-block:: text
+
+ ImportError: Could not find the GEOS library (tried "geos_c"). Try setting GEOS_LIBRARY_PATH in your settings.
+
+The most common solution is to properly configure your :ref:`libsettings` *or* set
+:ref:`geoslibrarypath` in your settings.
+
+If using a binary package of GEOS (e.g., on Ubuntu), you may need to :ref:`binutils`.
+
+.. _geoslibrarypath:
+
+``GEOS_LIBRARY_PATH``
+~~~~~~~~~~~~~~~~~~~~~
+
+If your GEOS library is in a non-standard location, or you don't want to
+modify the system's library path then the :setting:`GEOS_LIBRARY_PATH`
+setting may be added to your Django settings file with the full path to the
+GEOS C library. For example:
+
+.. code-block:: python
+
+ GEOS_LIBRARY_PATH = '/home/bob/local/lib/libgeos_c.so'
+
+.. note::
+
+ The setting must be the *full* path to the **C** shared library; in
+ other words you want to use ``libgeos_c.so``, not ``libgeos.so``.
+
+See also :ref:`My logs are filled with GEOS-related errors <geos-exceptions-in-logfile>`.
+
+.. _proj4:
+
+PROJ.4
+------
+
+`PROJ.4`_ is a library for converting geospatial data to different coordinate
+reference systems.
+
+First, download the PROJ.4 source code and datum shifting files [#]_::
+
+ $ wget http://download.osgeo.org/proj/proj-4.8.0.tar.gz
+ $ wget http://download.osgeo.org/proj/proj-datumgrid-1.5.tar.gz
+
+Next, untar the source code archive, and extract the datum shifting files in the
+``nad`` subdirectory. This must be done *prior* to configuration::
+
+ $ tar xzf proj-4.8.0.tar.gz
+ $ cd proj-4.8.0/nad
+ $ tar xzf ../../proj-datumgrid-1.5.tar.gz
+ $ cd ..
+
+Finally, configure, make and install PROJ.4::
+
+ $ ./configure
+ $ make
+ $ sudo make install
+ $ cd ..
+
+.. _gdalbuild:
+
+GDAL
+----
+
+`GDAL`__ is an excellent open source geospatial library that has support for
+reading most vector and raster spatial data formats. Currently, GeoDjango only
+supports :ref:`GDAL's vector data <ref-gdal>` capabilities [#]_.
+:ref:`geosbuild` and :ref:`proj4` should be installed prior to building GDAL.
+
+First download the latest GDAL release version and untar the archive::
+
+ $ wget http://download.osgeo.org/gdal/gdal-1.9.1.tar.gz
+ $ tar xzf gdal-1.9.1.tar.gz
+ $ cd gdal-1.9.1
+
+Configure, make and install::
+
+ $ ./configure
+ $ make # Go get some coffee, this takes a while.
+ $ sudo make install
+ $ cd ..
+
+.. note::
+
+ Because GeoDjango has it's own Python interface, the preceding instructions
+ do not build GDAL's own Python bindings. The bindings may be built by
+ adding the ``--with-python`` flag when running ``configure``. See
+ `GDAL/OGR In Python`__ for more information on GDAL's bindings.
+
+If you have any problems, please see the troubleshooting section below for
+suggestions and solutions.
+
+__ http://trac.osgeo.org/gdal/
+__ http://trac.osgeo.org/gdal/wiki/GdalOgrInPython
+
+.. _gdaltrouble:
+
+Troubleshooting
+^^^^^^^^^^^^^^^
+
+Can't find GDAL library
+~~~~~~~~~~~~~~~~~~~~~~~
+
+When GeoDjango can't find the GDAL library, the ``HAS_GDAL`` flag
+will be false:
+
+.. code-block:: pycon
+
+ >>> from django.contrib.gis import gdal
+ >>> gdal.HAS_GDAL
+ False
+
+The solution is to properly configure your :ref:`libsettings` *or* set
+:ref:`gdallibrarypath` in your settings.
+
+.. _gdallibrarypath:
+
+``GDAL_LIBRARY_PATH``
+~~~~~~~~~~~~~~~~~~~~~
+
+If your GDAL library is in a non-standard location, or you don't want to
+modify the system's library path then the :setting:`GDAL_LIBRARY_PATH`
+setting may be added to your Django settings file with the full path to
+the GDAL library. For example:
+
+.. code-block:: python
+
+ GDAL_LIBRARY_PATH = '/home/sue/local/lib/libgdal.so'
+
+.. _gdaldata:
+
+Can't find GDAL data files (``GDAL_DATA``)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+When installed from source, GDAL versions 1.5.1 and below have an autoconf bug
+that places data in the wrong location. [#]_ This can lead to error messages
+like this:
+
+.. code-block:: text
+
+ ERROR 4: Unable to open EPSG support file gcs.csv.
+ ...
+ OGRException: OGR failure.
+
+The solution is to set the ``GDAL_DATA`` environment variable to the location of the
+GDAL data files before invoking Python (typically ``/usr/local/share``; use
+``gdal-config --datadir`` to find out). For example::
+
+ $ export GDAL_DATA=`gdal-config --datadir`
+ $ python manage.py shell
+
+If using Apache, you may need to add this environment variable to your configuration
+file:
+
+.. code-block:: apache
+
+ SetEnv GDAL_DATA /usr/local/share
+
+.. rubric:: Footnotes
+.. [#] The datum shifting files are needed for converting data to and from
+ certain projections.
+ For example, the PROJ.4 string for the `Google projection (900913 or 3857)
+ <http://spatialreference.org/ref/sr-org/6864/prj/>`_ requires the
+ ``null`` grid file only included in the extra datum shifting files.
+ It is easier to install the shifting files now, then to have debug a
+ problem caused by their absence later.
+.. [#] Specifically, GeoDjango provides support for the `OGR
+ <http://gdal.org/ogr>`_ library, a component of GDAL.
+.. [#] See `GDAL ticket #2382 <http://trac.osgeo.org/gdal/ticket/2382>`_.
+
diff --git a/docs/ref/contrib/gis/install/index.txt b/docs/ref/contrib/gis/install/index.txt
new file mode 100644
index 0000000000..c710866813
--- /dev/null
+++ b/docs/ref/contrib/gis/install/index.txt
@@ -0,0 +1,535 @@
+.. _ref-gis-install:
+
+======================
+GeoDjango Installation
+======================
+
+.. highlight:: console
+
+Overview
+========
+In general, GeoDjango installation requires:
+
+1. :ref:`Python and Django <django>`
+2. :ref:`spatial_database`
+3. :ref:`geospatial_libs`
+
+Details for each of the requirements and installation instructions
+are provided in the sections below. In addition, platform-specific
+instructions are available for:
+
+* :ref:`macosx`
+* :ref:`windows`
+
+.. admonition:: Use the Source
+
+ Because GeoDjango takes advantage of the latest in the open source geospatial
+ software technology, recent versions of the libraries are necessary.
+ If binary packages aren't available for your platform, installation from
+ source may be required. When compiling the libraries from source, please
+ follow the directions closely, especially if you're a beginner.
+
+Requirements
+============
+
+.. _django:
+
+Python and Django
+-----------------
+
+Because GeoDjango is included with Django, please refer to Django's
+:ref:`installation instructions <installing-official-release>` for details on
+how to install.
+
+
+.. _spatial_database:
+
+Spatial database
+----------------
+PostgreSQL (with PostGIS), MySQL, Oracle, and SQLite (with SpatiaLite) are
+the spatial databases currently supported.
+
+.. note::
+
+ PostGIS is recommended, because it is the most mature and feature-rich
+ open source spatial database.
+
+The geospatial libraries required for a GeoDjango installation depends
+on the spatial database used. The following lists the library requirements,
+supported versions, and any notes for each of the supported database backends:
+
+================== ============================== ================== =========================================
+Database Library Requirements Supported Versions Notes
+================== ============================== ================== =========================================
+PostgreSQL GEOS, PROJ.4, PostGIS 8.2+ Requires PostGIS.
+MySQL GEOS 5.x Not OGC-compliant; limited functionality.
+Oracle GEOS 10.2, 11 XE not supported; not tested with 9.
+SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.6.+ Requires SpatiaLite 2.3+, pysqlite2 2.5+
+================== ============================== ================== =========================================
+
+See also `this comparison matrix`__ on the OSGeo Wiki for
+PostgreSQL/PostGIS/GEOS/GDAL possible combinations.
+
+__ http://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS
+
+Installation
+============
+
+Geospatial libraries
+--------------------
+
+.. toctree::
+ :maxdepth: 1
+
+ geolibs
+
+Database installation
+---------------------
+
+.. toctree::
+ :maxdepth: 1
+
+ postgis
+ spatialite
+
+Add ``django.contrib.gis`` to :setting:`INSTALLED_APPS`
+-------------------------------------------------------
+
+Like other Django contrib applications, you will *only* need to add
+:mod:`django.contrib.gis` to :setting:`INSTALLED_APPS` in your settings.
+This is the so that ``gis`` templates can be located -- if not done, then
+features such as the geographic admin or KML sitemaps will not function properly.
+
+.. _addgoogleprojection:
+
+Add Google projection to ``spatial_ref_sys`` table
+--------------------------------------------------
+
+.. note::
+
+ If you're running PostGIS 1.4 or above, you can skip this step. The entry
+ is already included in the default ``spatial_ref_sys`` table.
+
+In order to conduct database transformations to the so-called "Google"
+projection (a spherical mercator projection used by Google Maps),
+an entry must be added to your spatial database's ``spatial_ref_sys`` table.
+Invoke the Django shell from your project and execute the
+``add_srs_entry`` function:
+
+.. code-block:: pycon
+
+ $ python manage shell
+ >>> from django.contrib.gis.utils import add_srs_entry
+ >>> add_srs_entry(900913)
+
+This adds an entry for the 900913 SRID to the ``spatial_ref_sys`` (or equivalent)
+table, making it possible for the spatial database to transform coordinates in
+this projection. You only need to execute this command *once* per spatial database.
+
+Troubleshooting
+===============
+
+If you can't find the solution to your problem here then participate in the
+community! You can:
+
+* Join the ``#geodjango`` IRC channel on FreeNode. Please be patient and polite
+ -- while you may not get an immediate response, someone will attempt to answer
+ your question as soon as they see it.
+* Ask your question on the `GeoDjango`__ mailing list.
+* File a ticket on the `Django trac`__ if you think there's a bug. Make
+ sure to provide a complete description of the problem, versions used,
+ and specify the component as "GIS".
+
+__ http://groups.google.com/group/geodjango
+__ https://code.djangoproject.com/newticket
+
+.. _libsettings:
+
+Library environment settings
+----------------------------
+
+By far, the most common problem when installing GeoDjango is that the
+external shared libraries (e.g., for GEOS and GDAL) cannot be located. [#]_
+Typically, the cause of this problem is that the operating system isn't aware
+of the directory where the libraries built from source were installed.
+
+In general, the library path may be set on a per-user basis by setting
+an environment variable, or by configuring the library path for the entire
+system.
+
+``LD_LIBRARY_PATH`` environment variable
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+A user may set this environment variable to customize the library paths
+they want to use. The typical library directory for software
+built from source is ``/usr/local/lib``. Thus, ``/usr/local/lib`` needs
+to be included in the ``LD_LIBRARY_PATH`` variable. For example, the user
+could place the following in their bash profile::
+
+ export LD_LIBRARY_PATH=/usr/local/lib
+
+Setting system library path
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+On GNU/Linux systems, there is typically a file in ``/etc/ld.so.conf``, which may include
+additional paths from files in another directory, such as ``/etc/ld.so.conf.d``.
+As the root user, add the custom library path (like ``/usr/local/lib``) on a
+new line in ``ld.so.conf``. This is *one* example of how to do so::
+
+ $ sudo echo /usr/local/lib >> /etc/ld.so.conf
+ $ sudo ldconfig
+
+For OpenSolaris users, the system library path may be modified using the
+``crle`` utility. Run ``crle`` with no options to see the current configuration
+and use ``crle -l`` to set with the new library path. Be *very* careful when
+modifying the system library path::
+
+ # crle -l $OLD_PATH:/usr/local/lib
+
+.. _binutils:
+
+Install ``binutils``
+^^^^^^^^^^^^^^^^^^^^
+
+GeoDjango uses the ``find_library`` function (from the ``ctypes.util`` Python
+module) to discover libraries. The ``find_library`` routine uses a program
+called ``objdump`` (part of the ``binutils`` package) to verify a shared
+library on GNU/Linux systems. Thus, if ``binutils`` is not installed on your
+Linux system then Python's ctypes may not be able to find your library even if
+your library path is set correctly and geospatial libraries were built perfectly.
+
+The ``binutils`` package may be installed on Debian and Ubuntu systems using the
+following command::
+
+ $ sudo apt-get install binutils
+
+Similarly, on Red Hat and CentOS systems::
+
+ $ sudo yum install binutils
+
+Platform-specific instructions
+==============================
+
+.. _macosx:
+
+Mac OS X
+--------
+
+Because of the variety of packaging systems available for OS X, users have
+several different options for installing GeoDjango. These options are:
+
+* :ref:`homebrew`
+* :ref:`kyngchaos`
+* :ref:`fink`
+* :ref:`macports`
+* :ref:`build_from_source`
+
+.. note::
+
+ Currently, the easiest and recommended approach for installing GeoDjango
+ on OS X is to use the KyngChaos packages.
+
+This section also includes instructions for installing an upgraded version
+of :ref:`macosx_python` from packages provided by the Python Software
+Foundation, however, this is not required.
+
+.. _macosx_python:
+
+Python
+^^^^^^
+
+Although OS X comes with Python installed, users can use framework
+installers (`2.6`__ and `2.7`__ are available) provided by
+the Python Software Foundation. An advantage to using the installer is
+that OS X's Python will remain "pristine" for internal operating system
+use.
+
+__ http://python.org/ftp/python/2.6.6/python-2.6.6-macosx10.3.dmg
+__ http://python.org/ftp/python/2.7.3/
+
+.. note::
+
+ You will need to modify the ``PATH`` environment variable in your
+ ``.profile`` file so that the new version of Python is used when
+ ``python`` is entered at the command-line::
+
+ export PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH
+
+.. _homebrew:
+
+Homebrew
+^^^^^^^^
+
+`Homebrew`__ provides "recipes" for building binaries and packages from source.
+It provides recipes for the GeoDjango prerequisites on Macintosh computers
+running OS X. Because Homebrew still builds the software from source, the
+`Apple Developer Tools`_ are required.
+
+Summary::
+
+ $ brew install postgresql
+ $ brew install postgis
+ $ brew install gdal
+ $ brew install libgeoip
+
+__ http://mxcl.github.com/homebrew/
+.. _Apple Developer Tools: https://developer.apple.com/technologies/tools/
+
+.. _kyngchaos:
+
+KyngChaos packages
+^^^^^^^^^^^^^^^^^^
+
+William Kyngesburye provides a number of `geospatial library binary packages`__
+that make it simple to get GeoDjango installed on OS X without compiling
+them from source. However, the `Apple Developer Tools`_ are still necessary
+for compiling the Python database adapters :ref:`psycopg2_kyngchaos` (for PostGIS)
+and :ref:`pysqlite2` (for SpatiaLite).
+
+.. note::
+
+ SpatiaLite users should consult the :ref:`spatialite_macosx` section
+ after installing the packages for additional instructions.
+
+Download the framework packages for:
+
+* UnixImageIO
+* PROJ
+* GEOS
+* SQLite3 (includes the SpatiaLite library)
+* GDAL
+
+Install the packages in the order they are listed above, as the GDAL and SQLite
+packages require the packages listed before them.
+
+Afterwards, you can also install the KyngChaos binary packages for `PostgreSQL
+and PostGIS`__.
+
+After installing the binary packages, you'll want to add the following to
+your ``.profile`` to be able to run the package programs from the command-line::
+
+ export PATH=/Library/Frameworks/UnixImageIO.framework/Programs:$PATH
+ export PATH=/Library/Frameworks/PROJ.framework/Programs:$PATH
+ export PATH=/Library/Frameworks/GEOS.framework/Programs:$PATH
+ export PATH=/Library/Frameworks/SQLite3.framework/Programs:$PATH
+ export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH
+ export PATH=/usr/local/pgsql/bin:$PATH
+
+__ http://www.kyngchaos.com/software/frameworks
+__ http://www.kyngchaos.com/software/postgres
+
+.. _psycopg2_kyngchaos:
+
+psycopg2
+~~~~~~~~
+
+After you've installed the KyngChaos binaries and modified your ``PATH``, as
+described above, ``psycopg2`` may be installed using the following command::
+
+ $ sudo pip install psycopg2
+
+.. note::
+
+ If you don't have ``pip``, follow the the :ref:`installation instructions
+ <installing-official-release>` to install it.
+
+.. _fink:
+
+Fink
+^^^^
+
+`Kurt Schwehr`__ has been gracious enough to create GeoDjango packages for users
+of the `Fink`__ package system. The following packages are available, depending
+on which version of Python you want to use:
+
+* ``django-gis-py26``
+* ``django-gis-py25``
+* ``django-gis-py24``
+
+__ http://schwehr.org/blog/
+__ http://www.finkproject.org/
+
+.. _macports:
+
+MacPorts
+^^^^^^^^
+
+`MacPorts`__ may be used to install GeoDjango prerequisites on Macintosh
+computers running OS X. Because MacPorts still builds the software from source,
+the `Apple Developer Tools`_ are required.
+
+Summary::
+
+ $ sudo port install postgresql83-server
+ $ sudo port install geos
+ $ sudo port install proj
+ $ sudo port install postgis
+ $ sudo port install gdal +geos
+ $ sudo port install libgeoip
+
+.. note::
+
+ You will also have to modify the ``PATH`` in your ``.profile`` so
+ that the MacPorts programs are accessible from the command-line::
+
+ export PATH=/opt/local/bin:/opt/local/lib/postgresql83/bin
+
+ In addition, add the ``DYLD_FALLBACK_LIBRARY_PATH`` setting so that
+ the libraries can be found by Python::
+
+ export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib:/opt/local/lib/postgresql83
+
+__ http://www.macports.org/
+
+.. _windows:
+
+Windows
+-------
+
+Proceed through the following sections sequentially in order to install
+GeoDjango on Windows.
+
+.. note::
+
+ These instructions assume that you are using 32-bit versions of
+ all programs. While 64-bit versions of Python and PostgreSQL 9.0
+ are available, 64-bit versions of spatial libraries, like
+ GEOS and GDAL, are not yet provided by the :ref:`OSGeo4W` installer.
+
+Python
+^^^^^^
+
+First, download the latest `Python 2.7 installer`__ from the Python Web site.
+Next, run the installer and keep the defaults -- for example, keep
+'Install for all users' checked and the installation path set as
+``C:\Python27``.
+
+.. note::
+
+ You may already have a version of Python installed in ``C:\python`` as ESRI
+ products sometimes install a copy there. *You should still install a
+ fresh version of Python 2.7.*
+
+__ http://python.org/download/
+
+PostgreSQL
+^^^^^^^^^^
+
+First, download the latest `PostgreSQL 9.0 installer`__ from the
+`EnterpriseDB`__ Web site. After downloading, simply run the installer,
+follow the on-screen directions, and keep the default options unless
+you know the consequences of changing them.
+
+.. note::
+
+ The PostgreSQL installer creates both a new Windows user to be the
+ 'postgres service account' and a ``postgres`` database superuser
+ You will be prompted once to set the password for both accounts --
+ make sure to remember it!
+
+When the installer completes, it will ask to launch the Application Stack
+Builder (ASB) on exit -- keep this checked, as it is necessary to
+install :ref:`postgisasb`.
+
+.. note::
+
+ If installed successfully, the PostgreSQL server will run in the
+ background each time the system as started as a Windows service.
+ A :menuselection:`PostgreSQL 9.0` start menu group will created
+ and contains shortcuts for the ASB as well as the 'SQL Shell',
+ which will launch a ``psql`` command window.
+
+__ http://www.enterprisedb.com/products-services-training/pgdownload
+__ http://www.enterprisedb.com
+
+.. _postgisasb:
+
+PostGIS
+^^^^^^^
+
+From within the Application Stack Builder (to run outside of the installer,
+:menuselection:`Start --> Programs --> PostgreSQL 9.0`), select
+:menuselection:`PostgreSQL Database Server 9.0 on port 5432` from the drop down
+menu. Next, expand the :menuselection:`Categories --> Spatial Extensions` menu
+tree and select :menuselection:`PostGIS 1.5 for PostgreSQL 9.0`.
+
+After clicking next, you will be prompted to select your mirror, PostGIS
+will be downloaded, and the PostGIS installer will begin. Select only the
+default options during install (e.g., do not uncheck the option to create a
+default PostGIS database).
+
+.. note::
+
+ You will be prompted to enter your ``postgres`` database superuser
+ password in the 'Database Connection Information' dialog.
+
+psycopg2
+^^^^^^^^
+
+The ``psycopg2`` Python module provides the interface between Python and the
+PostgreSQL database. Download the latest `Windows installer`__ for your version
+of Python and PostgreSQL and run using the default settings. [#]_
+
+__ http://www.stickpeople.com/projects/python/win-psycopg/
+
+.. _osgeo4w:
+
+OSGeo4W
+^^^^^^^
+
+The `OSGeo4W installer`_ makes it simple to install the PROJ.4, GDAL, and GEOS
+libraries required by GeoDjango. First, download the `OSGeo4W installer`_,
+and run it. Select :menuselection:`Express Web-GIS Install` and click next.
+In the 'Select Packages' list, ensure that GDAL is selected; MapServer and
+Apache are also enabled by default, but are not required by GeoDjango and
+may be unchecked safely. After clicking next, the packages will be
+automatically downloaded and installed, after which you may exit the
+installer.
+
+.. _OSGeo4W installer: http://trac.osgeo.org/osgeo4w/
+
+Modify Windows environment
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+In order to use GeoDjango, you will need to add your Python and OSGeo4W
+directories to your Windows system ``Path``, as well as create ``GDAL_DATA``
+and ``PROJ_LIB`` environment variables. The following set of commands,
+executable with ``cmd.exe``, will set this up:
+
+.. code-block:: bat
+
+ set OSGEO4W_ROOT=C:\OSGeo4W
+ set PYTHON_ROOT=C:\Python27
+ set GDAL_DATA=%OSGEO4W_ROOT%\share\gdal
+ set PROJ_LIB=%OSGEO4W_ROOT%\share\proj
+ set PATH=%PATH%;%PYTHON_ROOT%;%OSGEO4W_ROOT%\bin
+ reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /f /d "%PATH%"
+ reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v GDAL_DATA /t REG_EXPAND_SZ /f /d "%GDAL_DATA%"
+ reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROJ_LIB /t REG_EXPAND_SZ /f /d "%PROJ_LIB%"
+
+For your convenience, these commands are available in the executable batch
+script, :download:`geodjango_setup.bat`.
+
+.. note::
+
+ Administrator privileges are required to execute these commands.
+ To do this, right-click on :download:`geodjango_setup.bat` and select
+ :menuselection:`Run as administrator`. You need to log out and log back in again
+ for the settings to take effect.
+
+.. note::
+
+ If you customized the Python or OSGeo4W installation directories,
+ then you will need to modify the ``OSGEO4W_ROOT`` and/or ``PYTHON_ROOT``
+ variables accordingly.
+
+Install Django and set up database
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Finally, :ref:`install Django <installing-official-release>` on your system.
+
+.. rubric:: Footnotes
+.. [#] GeoDjango uses the :func:`~ctypes.util.find_library` routine from
+ :mod:`ctypes.util` to locate shared libraries.
+.. [#] The ``psycopg2`` Windows installers are packaged and maintained by
+ `Jason Erickson <http://www.stickpeople.com/projects/python/win-psycopg/>`_.
diff --git a/docs/ref/contrib/gis/install/postgis.txt b/docs/ref/contrib/gis/install/postgis.txt
new file mode 100644
index 0000000000..6d7fe88203
--- /dev/null
+++ b/docs/ref/contrib/gis/install/postgis.txt
@@ -0,0 +1,175 @@
+.. _postgis:
+
+==================
+Installing PostGIS
+==================
+
+`PostGIS`__ adds geographic object support to PostgreSQL, turning it
+into a spatial database. :ref:`geosbuild`, :ref:`proj4` and
+:ref:`gdalbuild` should be installed prior to building PostGIS. You
+might also need additional libraries, see `PostGIS requirements`_.
+
+.. note::
+
+ The `psycopg2`_ module is required for use as the database adaptor
+ when using GeoDjango with PostGIS.
+
+.. _psycopg2: http://initd.org/psycopg/
+.. _PostGIS requirements: http://www.postgis.org/documentation/manual-2.0/postgis_installation.html#id2711662
+
+On Debian/Ubuntu, you are advised to install the following packages:
+postgresql-x.x, postgresql-x.x-postgis, postgresql-server-dev-x.x,
+python-psycopg2 (x.x matching the PostgreSQL version you want to install).
+Please also consult platform-specific instructions if you are on :ref:`macosx`
+or :ref:`windows`.
+
+Building from source
+====================
+
+First download the source archive, and extract::
+
+ $ wget http://postgis.refractions.net/download/postgis-2.0.1.tar.gz
+ $ tar xzf postgis-2.0.1.tar.gz
+ $ cd postgis-2.0.1
+
+Next, configure, make and install PostGIS::
+
+ $ ./configure
+
+Finally, make and install::
+
+ $ make
+ $ sudo make install
+ $ cd ..
+
+.. note::
+
+ GeoDjango does not automatically create a spatial database. Please consult
+ the section on :ref:`spatialdb_template91` or
+ :ref:`spatialdb_template_earlier` for more information.
+
+__ http://postgis.refractions.net/
+
+Post-installation
+=================
+
+.. _spatialdb_template:
+.. _spatialdb_template91:
+
+Creating a spatial database with PostGIS 2.0 and PostgreSQL 9.1
+---------------------------------------------------------------
+
+PostGIS 2 includes an extension for Postgres 9.1 that can be used to enable
+spatial functionality::
+
+ $ createdb <db name>
+ $ psql <db name>
+ > CREATE EXTENSION postgis;
+ > CREATE EXTENSION postgis_topology;
+
+No PostGIS topology functionalities are yet available from GeoDjango, so the
+creation of the ``postgis_topology`` extension is entirely optional.
+
+.. _spatialdb_template_earlier:
+
+Creating a spatial database template for earlier versions
+---------------------------------------------------------
+
+If you have an earlier version of PostGIS or PostgreSQL, the CREATE
+EXTENSION isn't available and you need to create the spatial database
+using the following instructions.
+
+Creating a spatial database with PostGIS is different than normal because
+additional SQL must be loaded to enable spatial functionality. Because of
+the steps in this process, it's better to create a database template that
+can be reused later.
+
+First, you need to be able to execute the commands as a privileged database
+user. For example, you can use the following to become the ``postgres`` user::
+
+ $ sudo su - postgres
+
+.. note::
+
+ The location *and* name of the PostGIS SQL files (e.g., from
+ ``POSTGIS_SQL_PATH`` below) depends on the version of PostGIS.
+ PostGIS versions 1.3 and below use ``<pg_sharedir>/contrib/lwpostgis.sql``;
+ whereas version 1.4 uses ``<sharedir>/contrib/postgis.sql`` and
+ version 1.5 uses ``<sharedir>/contrib/postgis-1.5/postgis.sql``.
+
+ To complicate matters, Debian/Ubuntu distributions have their own separate
+ directory naming system that might change with time. In this case, use the
+ :download:`create_template_postgis-debian.sh` script.
+
+ The example below assumes PostGIS 1.5, thus you may need to modify
+ ``POSTGIS_SQL_PATH`` and the name of the SQL file for the specific
+ version of PostGIS you are using.
+
+Once you're a database super user, then you may execute the following commands
+to create a PostGIS spatial database template::
+
+ $ POSTGIS_SQL_PATH=`pg_config --sharedir`/contrib/postgis-2.0
+ # Creating the template spatial database.
+ $ createdb -E UTF8 template_postgis
+ $ createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
+ # Allows non-superusers the ability to create from this template
+ $ psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
+ # Loading the PostGIS SQL routines
+ $ psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql
+ $ psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql
+ # Enabling users to alter spatial tables.
+ $ psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
+ $ psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
+ $ psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
+
+These commands may be placed in a shell script for later use; for convenience
+the following scripts are available:
+
+=============== =============================================
+PostGIS version Bash shell script
+=============== =============================================
+1.3 :download:`create_template_postgis-1.3.sh`
+1.4 :download:`create_template_postgis-1.4.sh`
+1.5 :download:`create_template_postgis-1.5.sh`
+Debian/Ubuntu :download:`create_template_postgis-debian.sh`
+=============== =============================================
+
+Afterwards, you may create a spatial database by simply specifying
+``template_postgis`` as the template to use (via the ``-T`` option)::
+
+ $ createdb -T template_postgis <db name>
+
+.. note::
+
+ While the ``createdb`` command does not require database super-user privileges,
+ it must be executed by a database user that has permissions to create databases.
+ You can create such a user with the following command::
+
+ $ createuser --createdb <user>
+
+PostgreSQL's createdb fails
+---------------------------
+
+When the PostgreSQL cluster uses a non-UTF8 encoding, the
+:file:`create_template_postgis-*.sh` script will fail when executing
+``createdb``::
+
+ createdb: database creation failed: ERROR: new encoding (UTF8) is incompatible
+ with the encoding of the template database (SQL_ASCII)
+
+The `current workaround`__ is to re-create the cluster using UTF8 (back up any
+databases before dropping the cluster).
+
+__ http://jacobian.org/writing/pg-encoding-ubuntu/
+
+Managing the database
+---------------------
+
+To administer the database, you can either use the pgAdmin III program
+(:menuselection:`Start --> PostgreSQL 9.0 --> pgAdmin III`) or the
+SQL Shell (:menuselection:`Start --> PostgreSQL 9.0 --> SQL Shell`).
+For example, to create a ``geodjango`` spatial database and user, the following
+may be executed from the SQL Shell as the ``postgres`` user::
+
+ postgres# CREATE USER geodjango PASSWORD 'my_passwd';
+ postgres# CREATE DATABASE geodjango OWNER geodjango TEMPLATE template_postgis ENCODING 'utf8';
diff --git a/docs/ref/contrib/gis/install/spatialite.txt b/docs/ref/contrib/gis/install/spatialite.txt
new file mode 100644
index 0000000000..941d559272
--- /dev/null
+++ b/docs/ref/contrib/gis/install/spatialite.txt
@@ -0,0 +1,222 @@
+.. _spatialite:
+
+=====================
+Installing Spatialite
+=====================
+
+`SpatiaLite`__ adds spatial support to SQLite, turning it into a full-featured
+spatial database.
+
+Check first if you can install Spatialite from system packages or binaries. For
+example, on Debian-based distributions, try to install the ``spatialite-bin``
+package. For Mac OS X, follow the
+:ref:`specific instructions below<spatialite_macosx>`. For Windows, you may
+find binaries on `Gaia-SINS`__ home page. In any case, you should always
+be able to :ref:`install from source<spatialite_source>`.
+
+When you are done with the installation process, skip to :ref:`create_spatialite_db`.
+
+__ https://www.gaia-gis.it/fossil/libspatialite
+__ http://www.gaia-gis.it/gaia-sins/
+
+.. _spatialite_source:
+
+Installing from source
+~~~~~~~~~~~~~~~~~~~~~~
+
+:ref:`GEOS and PROJ.4<geospatial_libs>` should be installed prior to building
+SpatiaLite.
+
+SQLite
+^^^^^^
+
+Check first if SQLite is compiled with the `R*Tree module`__. Run the sqlite3
+command line interface and enter the following query::
+
+ sqlite> CREATE VIRTUAL TABLE testrtree USING rtree(id,minX,maxX,minY,maxY);
+
+If you obtain an error, you will have to recompile SQLite from source. Otherwise,
+just skip this section.
+
+To install from sources, download the latest amalgamation source archive from
+the `SQLite download page`__, and extract::
+
+ $ wget http://sqlite.org/sqlite-amalgamation-3.6.23.1.tar.gz
+ $ tar xzf sqlite-amalgamation-3.6.23.1.tar.gz
+ $ cd sqlite-3.6.23.1
+
+Next, run the ``configure`` script -- however the ``CFLAGS`` environment variable
+needs to be customized so that SQLite knows to build the R*Tree module::
+
+ $ CFLAGS="-DSQLITE_ENABLE_RTREE=1" ./configure
+ $ make
+ $ sudo make install
+ $ cd ..
+
+__ http://www.sqlite.org/rtree.html
+__ http://www.sqlite.org/download.html
+
+.. _spatialitebuild :
+
+SpatiaLite library (``libspatialite``) and tools (``spatialite``)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Get the latest SpatiaLite library source and tools bundle from the
+`download page`__::
+
+ $ wget http://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-amalgamation-2.4.0-5.tar.gz
+ $ wget http://www.gaia-gis.it/gaia-sins/spatialite-tools-sources/spatialite-tools-2.4.0-5.tar.gz
+ $ tar xzf libspatialite-amalgamation-2.4.0-5.tar.gz
+ $ tar xzf spatialite-tools-2.4.0-5.tar.gz
+
+Prior to attempting to build, please read the important notes below to see if
+customization of the ``configure`` command is necessary. If not, then run the
+``configure`` script, make, and install for the SpatiaLite library::
+
+ $ cd libspatialite-amalgamation-2.3.1
+ $ ./configure # May need to modified, see notes below.
+ $ make
+ $ sudo make install
+ $ cd .... _spatialite
+
+Finally, do the same for the SpatiaLite tools::
+
+ $ cd spatialite-tools-2.3.1
+ $ ./configure # May need to modified, see notes below.
+ $ make
+ $ sudo make install
+ $ cd ..
+
+.. note::
+
+ If you've installed GEOS and PROJ.4 from binary packages, you will have to specify
+ their paths when running the ``configure`` scripts for *both* the library and the
+ tools (the configure scripts look, by default, in ``/usr/local``). For example,
+ on Debian/Ubuntu distributions that have GEOS and PROJ.4 packages, the command would be::
+
+ $ ./configure --with-proj-include=/usr/include --with-proj-lib=/usr/lib --with-geos-include=/usr/include --with-geos-lib=/usr/lib
+
+.. note::
+
+ For Mac OS X users building from source, the SpatiaLite library *and* tools
+ need to have their ``target`` configured::
+
+ $ ./configure --target=macosx
+
+__ http://www.gaia-gis.it/gaia-sins/libspatialite-sources/
+
+.. _pysqlite2:
+
+pysqlite2
+^^^^^^^^^
+
+If you are on Python 2.6, you will also have to compile pysqlite2, because
+``SpatiaLite`` must be loaded as an external extension, and the required
+``enable_load_extension`` method is only available in versions 2.5+ of
+pysqlite2. Thus, download pysqlite2 2.6, and untar::
+
+ $ wget http://pysqlite.googlecode.com/files/pysqlite-2.6.3.tar.gz
+ $ tar xzf pysqlite-2.6.3.tar.gz
+ $ cd pysqlite-2.6.3
+
+Next, use a text editor (e.g., ``emacs`` or ``vi``) to edit the ``setup.cfg`` file
+to look like the following:
+
+.. code-block:: ini
+
+ [build_ext]
+ #define=
+ include_dirs=/usr/local/include
+ library_dirs=/usr/local/lib
+ libraries=sqlite3
+ #define=SQLITE_OMIT_LOAD_EXTENSION
+
+or if you are on Mac OS X:
+
+.. code-block:: ini
+
+ [build_ext]
+ #define=
+ include_dirs=/Library/Frameworks/SQLite3.framework/unix/include
+ library_dirs=/Library/Frameworks/SQLite3.framework/unix/lib
+ libraries=sqlite3
+ #define=SQLITE_OMIT_LOAD_EXTENSION
+
+.. note::
+
+ The important thing here is to make sure you comment out the
+ ``define=SQLITE_OMIT_LOAD_EXTENSION`` flag and that the ``include_dirs``
+ and ``library_dirs`` settings are uncommented and set to the appropriate
+ path if the SQLite header files and libraries are not in ``/usr/include``
+ and ``/usr/lib``, respectively.
+
+After modifying ``setup.cfg`` appropriately, then run the ``setup.py`` script
+to build and install::
+
+ $ sudo python setup.py install
+
+.. _spatialite_macosx:
+
+Mac OS X-specific instructions
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Mac OS X users should follow the instructions in the :ref:`kyngchaos` section,
+as it is much easier than building from source.
+
+When :ref:`create_spatialite_db`, the ``spatialite`` program is required.
+However, instead of attempting to compile the SpatiaLite tools from source,
+download the `SpatiaLite Binaries`__ for OS X, and install ``spatialite`` in a
+location available in your ``PATH``. For example::
+
+ $ curl -O http://www.gaia-gis.it/spatialite/spatialite-tools-osx-x86-2.3.1.tar.gz
+ $ tar xzf spatialite-tools-osx-x86-2.3.1.tar.gz
+ $ cd spatialite-tools-osx-x86-2.3.1/bin
+ $ sudo cp spatialite /Library/Frameworks/SQLite3.framework/Programs
+
+Finally, for GeoDjango to be able to find the KyngChaos SpatiaLite library,
+add the following to your ``settings.py``:
+
+.. code-block:: python
+
+ SPATIALITE_LIBRARY_PATH='/Library/Frameworks/SQLite3.framework/SQLite3'
+
+__ http://www.gaia-gis.it/spatialite-2.3.1/binaries.html
+
+.. _create_spatialite_db:
+
+Creating a spatial database for SpatiaLite
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+After you've installed SpatiaLite, you'll need to create a number of spatial
+metadata tables in your database in order to perform spatial queries.
+
+If you're using SpatiaLite 2.4 or newer, use the ``spatialite`` utility to
+call the ``InitSpatialMetaData()`` function, like this::
+
+ $ spatialite geodjango.db "SELECT InitSpatialMetaData();"
+ the SPATIAL_REF_SYS table already contains some row(s)
+ InitSpatiaMetaData ()error:"table spatial_ref_sys already exists"
+ 0
+
+You can safely ignore the error messages shown. When you've done this, you can
+skip the rest of this section.
+
+If you're using SpatiaLite 2.3, you'll need to download a
+database-initialization file and execute its SQL queries in your database.
+
+First, get it from the `SpatiaLite Resources`__ page::
+
+ $ wget http://www.gaia-gis.it/spatialite-2.3.1/init_spatialite-2.3.sql.gz
+ $ gunzip init_spatialite-2.3.sql.gz
+
+Then, use the ``spatialite`` command to initialize a spatial database::
+
+ $ spatialite geodjango.db < init_spatialite-2.3.sql
+
+.. note::
+
+ The parameter ``geodjango.db`` is the *filename* of the SQLite database
+ you want to use. Use the same in the :setting:`DATABASES` ``"name"`` key
+ inside your ``settings.py``.
+
+__ http://www.gaia-gis.it/spatialite-2.3.1/resources.html
diff --git a/docs/ref/contrib/gis/testing.txt b/docs/ref/contrib/gis/testing.txt
index d12c884a1b..86979f0308 100644
--- a/docs/ref/contrib/gis/testing.txt
+++ b/docs/ref/contrib/gis/testing.txt
@@ -134,8 +134,6 @@ your settings::
GeoDjango tests
===============
-.. versionchanged:: 1.3
-
GeoDjango's test suite may be run in one of two ways, either by itself or
with the rest of :ref:`Django's unit tests <running-unit-tests>`.
diff --git a/docs/ref/contrib/localflavor.txt b/docs/ref/contrib/localflavor.txt
index 4595f51d9e..9bb27e6e74 100644
--- a/docs/ref/contrib/localflavor.txt
+++ b/docs/ref/contrib/localflavor.txt
@@ -6,1403 +6,143 @@ The "local flavor" add-ons
:synopsis: A collection of various Django snippets that are useful only for
a particular country or culture.
-Following its "batteries included" philosophy, Django comes with assorted
-pieces of code that are useful for particular countries or cultures. These are
-called the "local flavor" add-ons and live in the
-:mod:`django.contrib.localflavor` package.
+Historically, Django has shipped with ``django.contrib.localflavor`` --
+assorted pieces of code that are useful for particular countries or cultures.
+Starting with Django 1.5, we've started the process of moving the code to
+outside packages (i.e., packages distributed separately from Django), for
+easier maintenance and to trim the size of Django's codebase.
-Inside that package, country- or culture-specific code is organized into
-subpackages, named using `ISO 3166 country codes`_.
+The localflavor packages are named ``django-localflavor-*``, where the asterisk
+is an `ISO 3166 country code`_. For example: ``django-localflavor-us`` is the
+localflavor package for the U.S.A.
-Most of the ``localflavor`` add-ons are localized form components deriving
-from the :doc:`forms </topics/forms/index>` framework -- for example, a
-:class:`~django.contrib.localflavor.us.forms.USStateField` that knows how to
-validate U.S. state abbreviations, and a
-:class:`~django.contrib.localflavor.fi.forms.FISocialSecurityNumber` that
-knows how to validate Finnish social security numbers.
+Most of these ``localflavor`` add-ons are country-specific fields for the
+:doc:`forms </topics/forms/index>` framework -- for example, a
+``USStateField`` that knows how to validate U.S. state abbreviations and a
+``FISocialSecurityNumber`` that knows how to validate Finnish social security
+numbers.
To use one of these localized components, just import the relevant subpackage.
For example, here's how you can create a form with a field representing a
French telephone number::
from django import forms
- from django.contrib.localflavor.fr.forms import FRPhoneNumberField
+ from django_localflavor_fr.forms import FRPhoneNumberField
class MyForm(forms.Form):
my_french_phone_no = FRPhoneNumberField()
-Supported countries
-===================
-
-Countries currently supported by :mod:`~django.contrib.localflavor` are:
-
-* Argentina_
-* Australia_
-* Austria_
-* Belgium_
-* Brazil_
-* Canada_
-* Chile_
-* China_
-* Colombia_
-* Croatia_
-* Czech_
-* Ecuador_
-* Finland_
-* France_
-* Germany_
-* `Hong Kong`_
-* Iceland_
-* India_
-* Indonesia_
-* Ireland_
-* Israel_
-* Italy_
-* Japan_
-* Kuwait_
-* Macedonia_
-* Mexico_
-* `The Netherlands`_
-* Norway_
-* Peru_
-* Poland_
-* Portugal_
-* Paraguay_
-* Romania_
-* Russia_
-* Slovakia_
-* Slovenia_
-* `South Africa`_
-* Spain_
-* Sweden_
-* Switzerland_
-* Turkey_
-* `United Kingdom`_
-* `United States of America`_
-* Uruguay_
-
-The ``django.contrib.localflavor`` package also includes a ``generic`` subpackage,
-containing useful code that is not specific to one particular country or culture.
-Currently, it defines date, datetime and split datetime input fields based on
-those from :doc:`forms </topics/forms/index>`, but with non-US default formats.
-Here's an example of how to use them::
-
- from django import forms
- from django.contrib.localflavor import generic
-
- class MyForm(forms.Form):
- my_date_field = generic.forms.DateField()
-
-.. _ISO 3166 country codes: http://www.iso.org/iso/country_codes.htm
-.. _Argentina: `Argentina (ar)`_
-.. _Australia: `Australia (au)`_
-.. _Austria: `Austria (at)`_
-.. _Belgium: `Belgium (be)`_
-.. _Brazil: `Brazil (br)`_
-.. _Canada: `Canada (ca)`_
-.. _Chile: `Chile (cl)`_
-.. _China: `China (cn)`_
-.. _Colombia: `Colombia (co)`_
-.. _Croatia: `Croatia (hr)`_
-.. _Czech: `Czech (cz)`_
-.. _Ecuador: `Ecuador (ec)`_
-.. _Finland: `Finland (fi)`_
-.. _France: `France (fr)`_
-.. _Germany: `Germany (de)`_
-.. _Hong Kong: `Hong Kong (hk)`_
-.. _The Netherlands: `The Netherlands (nl)`_
-.. _Iceland: `Iceland (is\_)`_
-.. _India: `India (in\_)`_
-.. _Indonesia: `Indonesia (id)`_
-.. _Ireland: `Ireland (ie)`_
-.. _Israel: `Israel (il)`_
-.. _Italy: `Italy (it)`_
-.. _Japan: `Japan (jp)`_
-.. _Kuwait: `Kuwait (kw)`_
-.. _Macedonia: `Macedonia (mk)`_
-.. _Mexico: `Mexico (mx)`_
-.. _Norway: `Norway (no)`_
-.. _Paraguay: `Paraguay (py)`_
-.. _Peru: `Peru (pe)`_
-.. _Poland: `Poland (pl)`_
-.. _Portugal: `Portugal (pt)`_
-.. _Romania: `Romania (ro)`_
-.. _Russia: `Russia (ru)`_
-.. _Slovakia: `Slovakia (sk)`_
-.. _Slovenia: `Slovenia (si)`_
-.. _South Africa: `South Africa (za)`_
-.. _Spain: `Spain (es)`_
-.. _Sweden: `Sweden (se)`_
-.. _Switzerland: `Switzerland (ch)`_
-.. _Turkey: `Turkey (tr)`_
-.. _United Kingdom: `United Kingdom (gb)`_
-.. _United States of America: `United States of America (us)`_
-.. _Uruguay: `Uruguay (uy)`_
-
-Internationalization of localflavor
-===================================
-
-Localflavor has its own catalog of translations, in the directory
-``django/contrib/localflavor/locale``, and it's not loaded automatically like
-Django's general catalog in ``django/conf/locale``. If you want localflavor's
-texts to be translated, like form fields error messages, you must include
-:mod:`django.contrib.localflavor` in the :setting:`INSTALLED_APPS` setting, so
-the internationalization system can find the catalog, as explained in
-:ref:`how-django-discovers-translations`.
-
-Adding flavors
-==============
-
-We'd love to add more of these to Django, so please `create a ticket`_ with
-any code you'd like to contribute. One thing we ask is that you please use
-Unicode objects (``u'mystring'``) for strings, rather than setting the encoding
-in the file. See any of the existing flavors for examples.
-
-.. _create a ticket: https://code.djangoproject.com/newticket
-
-Localflavor and backwards compatibility
-=======================================
-
-As documented in our :ref:`API stability
-<misc-api-stability-localflavor>` policy, Django will always attempt
-to make :mod:`django.contrib.localflavor` reflect the officially
-gazetted policies of the appropriate local government authority. For
-example, if a government body makes a change to add, alter, or remove
-a province (or state, or county), that change will be reflected in
-Django's localflavor in the next stable Django release.
-
-When a backwards-incompatible change is made (for example, the removal
-or renaming of a province) the localflavor in question will raise a
-warning when that localflavor is imported. This provides a runtime
-indication that something may require attention.
-
-However, once you have addressed the backwards compatibility (for
-example, auditing your code to see if any data migration is required),
-the warning serves no purpose. The warning can then be supressed.
-For example, to suppress the warnings raised by the Indonesian
-localflavor you would use the following code::
-
- import warnings
- warnings.filterwarnings('ignore',
- category=RuntimeWarning,
- module='django.contrib.localflavor.id')
- from django.contrib.localflavor.id import forms as id_forms
-
-
-Argentina (``ar``)
-=============================================
-
-.. class:: ar.forms.ARPostalCodeField
-
- A form field that validates input as either a classic four-digit Argentinian
- postal code or a CPA_.
-
-.. _CPA: http://www.correoargentino.com.ar/consulta_cpa/home.php
-
-.. class:: ar.forms.ARDNIField
-
- A form field that validates input as a Documento Nacional de Identidad (DNI)
- number.
-
-.. class:: ar.forms.ARCUITField
-
- A form field that validates input as a Codigo Unico de Identificacion
- Tributaria (CUIT) number.
-
-.. class:: ar.forms.ARProvinceSelect
-
- A ``Select`` widget that uses a list of Argentina's provinces and autonomous
- cities as its choices.
-
-Australia (``au``)
-=============================================
-
-.. versionadded:: 1.4
-
-.. class:: au.forms.AUPostCodeField
-
- A form field that validates input as an Australian postcode.
-
-.. class:: au.forms.AUPhoneNumberField
-
- A form field that validates input as an Australian phone number. Valid numbers
- have ten digits.
-
-.. class:: au.forms.AUStateSelect
-
- A ``Select`` widget that uses a list of Australian states/territories as its
- choices.
-
-.. class:: au.models.AUPhoneNumberField
-
- A model field that checks that the value is a valid Australian phone
- number (ten digits).
-
-.. class:: au.models.AUStateField
-
- A model field that forms represent as a ``forms.AUStateField`` field and
- stores the three-letter Australian state abbreviation in the database.
-
-.. class:: au.models.AUPostCodeField
-
- A model field that forms represent as a ``forms.AUPostCodeField`` field
- and stores the four-digit Australian postcode in the database.
-
-Austria (``at``)
-================
-
-.. class:: at.forms.ATZipCodeField
-
- A form field that validates its input as an Austrian zip code, with the
- format XXXX (first digit must be greater than 0).
-
-.. class:: at.forms.ATStateSelect
-
- A ``Select`` widget that uses a list of Austrian states as its choices.
-
-.. class:: at.forms.ATSocialSecurityNumberField
-
- A form field that validates its input as an Austrian social security number.
-
-Belgium (``be``)
-================
-
-.. versionadded:: 1.3
-
-.. class:: be.forms.BEPhoneNumberField
-
- A form field that validates input as a Belgium phone number, with one of
- the formats 0x xxx xx xx, 0xx xx xx xx, 04xx xx xx xx, 0x/xxx.xx.xx,
- 0xx/xx.xx.xx, 04xx/xx.xx.xx, 0x.xxx.xx.xx, 0xx.xx.xx.xx, 04xx.xx.xx.xx,
- 0xxxxxxxx or 04xxxxxxxx.
-
-.. class:: be.forms.BEPostalCodeField
-
- A form field that validates input as a Belgium postal code, in the range
- and format 1XXX-9XXX.
-
-.. class:: be.forms.BEProvinceSelect
-
- A ``Select`` widget that uses a list of Belgium provinces as its
- choices.
-
-.. class:: be.forms.BERegionSelect
-
- A ``Select`` widget that uses a list of Belgium regions as its
- choices.
-
-Brazil (``br``)
-===============
-
-.. class:: br.forms.BRPhoneNumberField
-
- A form field that validates input as a Brazilian phone number, with the format
- XX-XXXX-XXXX.
-
-.. class:: br.forms.BRZipCodeField
-
- A form field that validates input as a Brazilian zip code, with the format
- XXXXX-XXX.
-
-.. class:: br.forms.BRStateSelect
-
- A ``Select`` widget that uses a list of Brazilian states/territories as its
- choices.
-
-.. class:: br.forms.BRCPFField
-
- A form field that validates input as `Brazilian CPF`_.
-
- Input can either be of the format XXX.XXX.XXX-VD or be a group of 11 digits.
-
-.. _Brazilian CPF: http://en.wikipedia.org/wiki/Cadastro_de_Pessoas_F%C3%ADsicas
-
-.. class:: br.forms.BRCNPJField
-
- A form field that validates input as `Brazilian CNPJ`_.
-
- Input can either be of the format XX.XXX.XXX/XXXX-XX or be a group of 14
- digits.
-
-.. _Brazilian CNPJ: http://en.wikipedia.org/wiki/National_identification_number#Brazil
-
-Canada (``ca``)
-===============
-
-.. class:: ca.forms.CAPhoneNumberField
-
- A form field that validates input as a Canadian phone number, with the format
- XXX-XXX-XXXX.
-
-.. class:: ca.forms.CAPostalCodeField
-
- A form field that validates input as a Canadian postal code, with the format
- XXX XXX.
-
-.. class:: ca.forms.CAProvinceField
-
- A form field that validates input as a Canadian province name or abbreviation.
-
-.. class:: ca.forms.CASocialInsuranceNumberField
-
- A form field that validates input as a Canadian Social Insurance Number (SIN).
- A valid number must have the format XXX-XXX-XXX and pass a `Luhn mod-10
- checksum`_.
-
-.. _Luhn mod-10 checksum: http://en.wikipedia.org/wiki/Luhn_algorithm
-
-.. class:: ca.forms.CAProvinceSelect
-
- A ``Select`` widget that uses a list of Canadian provinces and territories as
- its choices.
-
-Chile (``cl``)
-==============
-
-.. class:: cl.forms.CLRutField
-
- A form field that validates input as a Chilean national identification number
- ('Rol Unico Tributario' or RUT). The valid format is XX.XXX.XXX-X.
-
-.. class:: cl.forms.CLRegionSelect
-
- A ``Select`` widget that uses a list of Chilean regions (Regiones) as its
- choices.
-
-China (``cn``)
-==============
-
-.. versionadded:: 1.4
-
-.. class:: cn.forms.CNProvinceSelect
-
- A ``Select`` widget that uses a list of Chinese regions as its choices.
-
-.. class:: cn.forms.CNPostCodeField
-
- A form field that validates input as a Chinese post code.
- Valid formats are XXXXXX where X is digit.
-
-.. class:: cn.forms.CNIDCardField
-
- A form field that validates input as a Chinese Identification Card Number.
- Both 1st and 2nd generation ID Card Number are validated.
-
-.. class:: cn.forms.CNPhoneNumberField
-
- A form field that validates input as a Chinese phone number.
- Valid formats are 0XX-XXXXXXXX, composed of 3 or 4 digits of region code
- and 7 or 8 digits of phone number.
-
-.. class:: cn.forms.CNCellNumberField
-
- A form field that validates input as a Chinese mobile phone number.
- Valid formats are like 1XXXXXXXXXX, where X is digit.
- The second digit could only be 3, 5 and 8.
-
-Colombia (``co``)
-=================
-
-.. versionadded:: 1.4
-
-.. class:: co.forms.CoDepartmentSelect
-
- A ``Select`` widget that uses a list of Colombian departments
- as its choices.
-
-Croatia (``hr``)
-================
-
-.. versionadded:: 1.4
+For documentation on a given country's localflavor helpers, see its README
+file.
-.. class:: hr.forms.HRCountySelect
+.. _ISO 3166 country code: http://www.iso.org/iso/country_codes.htm
- A ``Select`` widget that uses a list of counties of Croatia as its choices.
-
-.. class:: hr.forms.HRPhoneNumberPrefixSelect
-
- A ``Select`` widget that uses a list of phone number prefixes of Croatia as
- its choices.
-
-.. class:: hr.forms.HRLicensePlatePrefixSelect
-
- A ``Select`` widget that uses a list of vehicle license plate prefixes of
- Croatia as its choices.
-
-.. class:: hr.forms.HRPhoneNumberField
-
- A form field that validates input as a phone number of Croatia.
- A valid format is a country code or a leading zero, area code prefix, 6 or 7
- digit number; e.g. +385XXXXXXXX or 0XXXXXXXX
- Validates fixed, mobile and FGSM numbers. Normalizes to a full number with
- country code (+385 prefix).
-
-.. class:: hr.forms.HRLicensePlateField
-
- A form field that validates input as a vehicle license plate of Croatia.
- Normalizes to the specific format XX YYYY-XX where X is a letter and Y a
- digit. There can be three or four digits.
- Suffix is constructed from the shared letters of the Croatian and English
- alphabets.
- It is used for standardized license plates only. Special cases like license
- plates for oldtimers, temporary license plates, government institution
- license plates and customized license plates are not covered by this field.
-
-.. class:: hr.forms.HRPostalCodeField
-
- A form field that validates input as a postal code of Croatia.
- It consists of exactly five digits ranging from 10000 to 59999 inclusive.
-
-.. class:: hr.forms.HROIBField
-
- A form field that validates input as a Personal Identification Number (OIB)
- of Croatia.
- It consists of exactly eleven digits.
-
-.. class:: hr.forms.HRJMBGField
-
- A form field that validates input as a Unique Master Citizen Number (JMBG).
- The number is still in use in Croatia, but it is being replaced by OIB.
- This field works for other ex-Yugoslavia countries as well where the JMBG is
- still in use.
- The area segment of the JMBG is not validated because the citizens might
- have emigrated to another ex-Yugoslavia country.
- The number consists of exactly thirteen digits.
-
-.. class:: hr.forms.HRJMBAGField
-
- A form field that validates input as a Unique Master Academic Citizen Number
- (JMBAG) of Croatia.
- This number is used by college students and professors in Croatia.
- The number consists of exactly nineteen digits.
-
-Czech (``cz``)
+How to migrate
==============
-.. class:: cz.forms.CZPostalCodeField
-
- A form field that validates input as a Czech postal code. Valid formats
- are XXXXX or XXX XX, where X is a digit.
-
-.. class:: cz.forms.CZBirthNumberField
-
- A form field that validates input as a Czech Birth Number.
- A valid number must be in format XXXXXX/XXXX (slash is optional).
-
-.. class:: cz.forms.CZICNumberField
-
- A form field that validates input as a Czech IC number field.
-
-.. class:: cz.forms.CZRegionSelect
-
- A ``Select`` widget that uses a list of Czech regions as its choices.
-
-Ecuador (``ec``)
-================
-
-.. versionadded:: 1.4
-
-.. class:: ec.forms.EcProvinceSelect
-
- A ``Select`` widget that uses a list of Ecuatorian provinces as
- its choices.
-
-Finland (``fi``)
-================
-
-.. class:: fi.forms.FISocialSecurityNumber
-
- A form field that validates input as a Finnish social security number.
-
-.. class:: fi.forms.FIZipCodeField
-
- A form field that validates input as a Finnish zip code. Valid codes
- consist of five digits.
-
-.. class:: fi.forms.FIMunicipalitySelect
-
- A ``Select`` widget that uses a list of Finnish municipalities as its
- choices.
-
-France (``fr``)
-===============
-
-.. class:: fr.forms.FRPhoneNumberField
-
- A form field that validates input as a French local phone number. The
- correct format is 0X XX XX XX XX. 0X.XX.XX.XX.XX and 0XXXXXXXXX validate
- but are corrected to 0X XX XX XX XX.
-
-.. class:: fr.forms.FRZipCodeField
-
- A form field that validates input as a French zip code. Valid codes
- consist of five digits.
-
-.. class:: fr.forms.FRDepartmentSelect
-
- A ``Select`` widget that uses a list of French departments as its choices.
-
-Germany (``de``)
-================
-
-.. class:: de.forms.DEIdentityCardNumberField
-
- A form field that validates input as a German identity card number
- (Personalausweis_). Valid numbers have the format
- XXXXXXXXXXX-XXXXXXX-XXXXXXX-X, with no group consisting entirely of zeroes.
-
-.. _Personalausweis: http://de.wikipedia.org/wiki/Personalausweis
-
-.. class:: de.forms.DEZipCodeField
-
- A form field that validates input as a German zip code. Valid codes
- consist of five digits.
-
-.. class:: de.forms.DEStateSelect
-
- A ``Select`` widget that uses a list of German states as its choices.
-
-Hong Kong (``hk``)
-==================
-
-.. class:: hk.forms.HKPhoneNumberField
-
- A form field that validates input as a Hong Kong phone number.
-
-
-The Netherlands (``nl``)
-========================
-
-.. class:: nl.forms.NLPhoneNumberField
-
- A form field that validates input as a Dutch telephone number.
-
-.. class:: nl.forms.NLSofiNumberField
-
- A form field that validates input as a Dutch social security number
- (SoFI/BSN).
-
-.. class:: nl.forms.NLZipCodeField
-
- A form field that validates input as a Dutch zip code.
-
-.. class:: nl.forms.NLProvinceSelect
+If you've used the old ``django.contrib.localflavor`` package, follow these two
+easy steps to update your code:
- A ``Select`` widget that uses a list of Dutch provinces as its list of
- choices.
+1. Install the appropriate third-party ``django-localflavor-*`` package(s).
+ Go to https://github.com/django/ and find the package for your country.
-Iceland (``is_``)
-=================
+2. Change your app's import statements to reference the new packages.
-.. class:: is_.forms.ISIdNumberField
+ For example, change this::
- A form field that validates input as an Icelandic identification number
- (kennitala). The format is XXXXXX-XXXX.
+ from django.contrib.localflavor.fr.forms import FRPhoneNumberField
-.. class:: is_.forms.ISPhoneNumberField
+ ...to this::
- A form field that validates input as an Icelandtic phone number (seven
- digits with an optional hyphen or space after the first three digits).
+ from django_localflavor_fr.forms import FRPhoneNumberField
-.. class:: is_.forms.ISPostalCodeSelect
+The code in the new packages is the same (it was copied directly from Django),
+so you don't have to worry about backwards compatibility in terms of
+functionality. Only the imports have changed.
- A ``Select`` widget that uses a list of Icelandic postal codes as its
- choices.
-
-India (``in_``)
-===============
-
-.. class:: in_.forms.INStateField
-
- A form field that validates input as an Indian state/territory name or
- abbreviation. Input is normalized to the standard two-letter vehicle
- registration abbreviation for the given state or territory.
-
-.. class:: in_.forms.INZipCodeField
-
- A form field that validates input as an Indian zip code, with the
- format XXXXXXX.
-
-.. class:: in_.forms.INStateSelect
-
- A ``Select`` widget that uses a list of Indian states/territories as its
- choices.
-
-.. versionadded:: 1.4
-
-.. class:: in_.forms.INPhoneNumberField
-
- A form field that validates that the data is a valid Indian phone number,
- including the STD code. It's normalised to 0XXX-XXXXXXX or 0XXX XXXXXXX
- format. The first string is the STD code which is a '0' followed by 2-4
- digits. The second string is 8 digits if the STD code is 3 digits, 7
- digits if the STD code is 4 digits and 6 digits if the STD code is 5
- digits. The second string will start with numbers between 1 and 6. The
- separator is either a space or a hyphen.
-
-Ireland (``ie``)
-================
-
-.. class:: ie.forms.IECountySelect
-
- A ``Select`` widget that uses a list of Irish Counties as its choices.
-
-Indonesia (``id``)
+Deprecation policy
==================
-.. class:: id.forms.IDPostCodeField
-
- A form field that validates input as an Indonesian post code field.
-
-.. class:: id.forms.IDProvinceSelect
-
- A ``Select`` widget that uses a list of Indonesian provinces as its choices.
-
-.. versionchanged:: 1.3
- The province "Nanggroe Aceh Darussalam (NAD)" has been removed
- from the province list in favor of the new official designation
- "Aceh (ACE)".
-
-.. class:: id.forms.IDPhoneNumberField
-
- A form field that validates input as an Indonesian telephone number.
-
-.. class:: id.forms.IDLicensePlatePrefixSelect
-
- A ``Select`` widget that uses a list of Indonesian license plate
- prefix code as its choices.
-
-.. class:: id.forms.IDLicensePlateField
-
- A form field that validates input as an Indonesian vehicle license plate.
-
-.. class:: id.forms.IDNationalIdentityNumberField
-
- A form field that validates input as an Indonesian national identity
- number (`NIK`_/KTP). The output will be in the format of
- 'XX.XXXX.DDMMYY.XXXX'. Dots or spaces can be used in the input to break
- down the numbers.
-
-.. _NIK: http://en.wikipedia.org/wiki/Indonesian_identity_card
-
-Israel (``il``)
-===============
-
-.. class:: il.forms.ILPostalCodeField
-
- A form field that validates its input as an Israeli five-digit postal code.
-
-.. class:: il.forms.ILIDNumberField
-
- A form field that validates its input as an `Israeli identification number`_.
- The output will be in the format of a 2-9 digit number, consisting of a
- 1-8 digit ID number followed by a single checksum digit, calculated using
- the `Luhn algorithm`_.
+In Django 1.5, importing from ``django.contrib.localflavor`` will result in a
+``DeprecationWarning``. This means your code will still work, but you should
+change it as soon as possible.
- Input may contain an optional hyphen separating the ID number from the checksum
- digit.
+In Django 1.6, importing from ``django.contrib.localflavor`` will no longer
+work.
-.. _Israeli identification number: http://he.wikipedia.org/wiki/%D7%9E%D7%A1%D7%A4%D7%A8_%D7%96%D7%94%D7%95%D7%AA_(%D7%99%D7%A9%D7%A8%D7%90%D7%9C)
-.. _Luhn algorithm: http://en.wikipedia.org/wiki/Luhn_algorithm
-
-Italy (``it``)
-==============
-
-.. class:: it.forms.ITSocialSecurityNumberField
-
- A form field that validates input as an Italian social security number
- (`codice fiscale`_).
-
-.. _codice fiscale: http://www.agenziaentrate.gov.it/wps/content/Nsilib/Nsi/Home/CosaDeviFare/Richiedere/Codice+fiscale+e+tessera+sanitaria/Richiesta+TS_CF/SchedaI/Informazioni+codificazione+pf/
-
-.. class:: it.forms.ITVatNumberField
-
- A form field that validates Italian VAT numbers (partita IVA).
-
-.. class:: it.forms.ITZipCodeField
-
- A form field that validates input as an Italian zip code. Valid codes
- must have five digits.
-
-.. class:: it.forms.ITProvinceSelect
-
- A ``Select`` widget that uses a list of Italian provinces as its choices.
-
-.. class:: it.forms.ITRegionSelect
-
- A ``Select`` widget that uses a list of Italian regions as its choices.
-
-Japan (``jp``)
-==============
-
-.. class:: jp.forms.JPPostalCodeField
-
- A form field that validates input as a Japanese postcode. It accepts seven
- digits, with or without a hyphen.
-
-.. class:: jp.forms.JPPrefectureSelect
-
- A ``Select`` widget that uses a list of Japanese prefectures as its choices.
-
-Kuwait (``kw``)
-===============
-
-.. class:: kw.forms.KWCivilIDNumberField
-
- A form field that validates input as a Kuwaiti Civil ID number. A valid
- Civil ID number must obey the following rules:
-
- * The number consist of 12 digits.
- * The birthdate of the person is a valid date.
- * The calculated checksum equals to the last digit of the Civil ID.
-
-Macedonia (``mk``)
+Supported countries
===================
-.. versionadded:: 1.4
-
-.. class:: mk.forms.MKIdentityCardNumberField
-
- A form field that validates input as a Macedonian identity card number.
- Both old and new identity card numbers are supported.
-
-
-.. class:: mk.forms.MKMunicipalitySelect
-
- A form ``Select`` widget that uses a list of Macedonian municipalities as
- choices.
-
+The following countries have django-localflavor- packages.
-.. class:: mk.forms.UMCNField
+* Argentina: https://github.com/django/django-localflavor-ar
+* Australia: https://github.com/django/django-localflavor-au
+* Austria: https://github.com/django/django-localflavor-at
+* Belgium: https://github.com/django/django-localflavor-be
+* Brazil: https://github.com/django/django-localflavor-br
+* Canada: https://github.com/django/django-localflavor-ca
+* Chile: https://github.com/django/django-localflavor-cl
+* China: https://github.com/django/django-localflavor-cn
+* Colombia: https://github.com/django/django-localflavor-co
+* Croatia: https://github.com/django/django-localflavor-cr
+* Czech Republic: https://github.com/django/django-localflavor-cz
+* Ecuador: https://github.com/django/django-localflavor-ec
+* Finland: https://github.com/django/django-localflavor-fi
+* France: https://github.com/django/django-localflavor-fr
+* Germany: https://github.com/django/django-localflavor-de
+* Hong Kong: https://github.com/django/django-localflavor-hk
+* Iceland: https://github.com/django/django-localflavor-is
+* India: https://github.com/django/django-localflavor-in
+* Indonesia: https://github.com/django/django-localflavor-id
+* Ireland: https://github.com/django/django-localflavor-ie
+* Israel: https://github.com/django/django-localflavor-il
+* Italy: https://github.com/django/django-localflavor-it
+* Japan: https://github.com/django/django-localflavor-jp
+* Kuwait: https://github.com/django/django-localflavor-kw
+* Lithuania: https://github.com/simukis/django-localflavor-lt
+* Macedonia: https://github.com/django/django-localflavor-mk
+* Mexico: https://github.com/django/django-localflavor-mx
+* The Netherlands: https://github.com/django/django-localflavor-nl
+* Norway: https://github.com/django/django-localflavor-no
+* Peru: https://github.com/django/django-localflavor-pe
+* Poland: https://github.com/django/django-localflavor-pl
+* Portugal: https://github.com/django/django-localflavor-pt
+* Paraguay: https://github.com/django/django-localflavor-py
+* Romania: https://github.com/django/django-localflavor-ro
+* Russia: https://github.com/django/django-localflavor-ru
+* Slovakia: https://github.com/django/django-localflavor-sk
+* Slovenia: https://github.com/django/django-localflavor-si
+* South Africa: https://github.com/django/django-localflavor-za
+* Spain: https://github.com/django/django-localflavor-es
+* Sweden: https://github.com/django/django-localflavor-se
+* Switzerland: https://github.com/django/django-localflavor-ch
+* Turkey: https://github.com/django/django-localflavor-tr
+* United Kingdom: https://github.com/django/django-localflavor-gb
+* United States of America: https://github.com/django/django-localflavor-us
+* Uruguay: https://github.com/django/django-localflavor-uy
- A form field that validates input as a unique master citizen
- number.
+django.contrib.localflavor.generic
+==================================
- The format of the unique master citizen number is not unique
- to Macedonia. For more information see:
- https://secure.wikimedia.org/wikipedia/en/wiki/Unique_Master_Citizen_Number
+The ``django.contrib.localflavor.generic`` package, which hasn't been removed from
+Django yet, contains useful code that is not specific to one particular country
+or culture. Currently, it defines date, datetime and split datetime input
+fields based on those from :doc:`forms </topics/forms/index>`, but with non-US
+default formats. Here's an example of how to use them::
- A value will pass validation if it complies to the following rules:
-
- * Consists of exactly 13 digits
- * The first 7 digits represent a valid past date in the format DDMMYYY
- * The last digit of the UMCN passes a checksum test
-
-
-.. class:: mk.models.MKIdentityCardNumberField
-
- A model field that forms represent as a
- ``forms.MKIdentityCardNumberField`` field.
-
-
-.. class:: mk.models.MKMunicipalityField
-
- A model field that forms represent as a
- ``forms.MKMunicipalitySelect`` and stores the 2 character code of the
- municipality in the database.
-
-
-.. class:: mk.models.UMCNField
-
- A model field that forms represent as a ``forms.UMCNField`` field.
-
-
-Mexico (``mx``)
-===============
-
-.. class:: mx.forms.MXZipCodeField
-
- .. versionadded:: 1.4
-
- A form field that accepts a Mexican Zip Code.
-
- More info about this: List of postal codes in Mexico (zipcodes_)
-
-.. _zipcodes: http://en.wikipedia.org/wiki/List_of_postal_codes_in_Mexico
-
-.. class:: mx.forms.MXRFCField
-
- .. versionadded:: 1.4
-
- A form field that validates a Mexican *Registro Federal de Contribuyentes* for
- either **Persona fĂ­sica** or **Persona moral**. This field accepts RFC strings
- whether or not it contains a *homoclave*.
-
- More info about this: Registro Federal de Contribuyentes (rfc_)
-
-.. _rfc: http://es.wikipedia.org/wiki/Registro_Federal_de_Contribuyentes_(M%C3%A9xico)
-
-.. class:: mx.forms.MXCURPField
-
- .. versionadded:: 1.4
-
- A field that validates a Mexican *Clave Ăšnica de Registro de PoblaciĂłn*.
-
- More info about this: Clave Unica de Registro de Poblacion (curp_)
-
-.. _curp: http://www.condusef.gob.mx/index.php/clave-unica-de-registro-de-poblacion-curp
-
-.. class:: mx.forms.MXStateSelect
-
- A ``Select`` widget that uses a list of Mexican states as its choices.
-
-.. class:: mx.models.MXStateField
-
- .. versionadded:: 1.4
-
- A model field that stores the three-letter Mexican state abbreviation in the
- database.
-
-.. class:: mx.models.MXZipCodeField
-
- .. versionadded:: 1.4
-
- A model field that forms represent as a ``forms.MXZipCodeField`` field and
- stores the five-digit Mexican zip code.
-
-.. class:: mx.models.MXRFCField
-
- .. versionadded:: 1.4
-
- A model field that forms represent as a ``forms.MXRFCField`` field and
- stores the value of a valid Mexican RFC.
-
-.. class:: mx.models.MXCURPField
-
- .. versionadded:: 1.4
-
- A model field that forms represent as a ``forms.MXCURPField`` field and
- stores the value of a valid Mexican CURP.
-
-Additionally, a choice tuple is provided in ``django.contrib.localflavor.mx.mx_states``,
-allowing customized model and form fields, and form presentations, for subsets of
-Mexican states abbreviations:
-
-.. data:: mx.mx_states.STATE_CHOICES
-
- A tuple of choices of the states abbreviations for all 31 Mexican states,
- plus the `Distrito Federal`.
-
-Norway (``no``)
-===============
-
-.. class:: no.forms.NOSocialSecurityNumber
-
- A form field that validates input as a Norwegian social security number
- (personnummer_).
-
-.. _personnummer: http://no.wikipedia.org/wiki/Personnummer
-
-.. class:: no.forms.NOZipCodeField
-
- A form field that validates input as a Norwegian zip code. Valid codes
- have four digits.
-
-.. class:: no.forms.NOMunicipalitySelect
-
- A ``Select`` widget that uses a list of Norwegian municipalities (fylker) as
- its choices.
-
-Paraguay (``py``)
-=================
-
-.. versionadded:: 1.4
-
-.. class:: py.forms.PyDepartmentSelect
-
- A ``Select`` widget with a list of Paraguayan departments as choices.
-
-.. class:: py.forms.PyNumberedDepartmentSelect
-
- A ``Select`` widget with a roman numbered list of Paraguayan departments as choices.
-
-Peru (``pe``)
-=============
-
-.. class:: pe.forms.PEDNIField
-
- A form field that validates input as a DNI (Peruvian national identity)
- number.
-
-.. class:: pe.forms.PERUCField
-
- A form field that validates input as an RUC (Registro Unico de
- Contribuyentes) number. Valid RUC numbers have 11 digits.
-
-.. class:: pe.forms.PEDepartmentSelect
-
- A ``Select`` widget that uses a list of Peruvian Departments as its choices.
-
-Poland (``pl``)
-===============
-
-.. class:: pl.forms.PLPESELField
-
- A form field that validates input as a Polish national identification number
- (PESEL_).
-
-.. _PESEL: http://en.wikipedia.org/wiki/PESEL
-
-.. versionadded:: 1.4
-
-.. class:: pl.forms.PLNationalIDCardNumberField
-
- A form field that validates input as a Polish National ID Card number. The
- valid format is AAAXXXXXX, where A is letter (A-Z), X is digit and left-most
- digit is checksum digit. More information about checksum calculation algorithm
- see `Polish identity card`_.
-
-.. _`Polish identity card`: http://en.wikipedia.org/wiki/Polish_identity_card
-
-.. class:: pl.forms.PLREGONField
-
- A form field that validates input as a Polish National Official Business
- Register Number (REGON_), having either seven or nine digits. The checksum
- algorithm used for REGONs is documented at
- http://wipos.p.lodz.pl/zylla/ut/nip-rego.html.
-
-.. _REGON: http://www.stat.gov.pl/bip/regon_ENG_HTML.htm
-
-.. class:: pl.forms.PLPostalCodeField
-
- A form field that validates input as a Polish postal code. The valid format
- is XX-XXX, where X is a digit.
-
-.. class:: pl.forms.PLNIPField
-
- A form field that validates input as a Polish Tax Number (NIP). Valid formats
- are XXX-XXX-XX-XX, XXX-XX-XX-XXX or XXXXXXXXXX. The checksum algorithm used
- for NIPs is documented at http://wipos.p.lodz.pl/zylla/ut/nip-rego.html.
-
-.. class:: pl.forms.PLCountySelect
-
- A ``Select`` widget that uses a list of Polish administrative units as its
- choices.
-
-.. class:: pl.forms.PLProvinceSelect
-
- A ``Select`` widget that uses a list of Polish voivodeships (administrative
- provinces) as its choices.
-
-Portugal (``pt``)
-=================
-
-.. class:: pt.forms.PTZipCodeField
-
- A form field that validates input as a Portuguese zip code.
-
-.. class:: pt.forms.PTPhoneNumberField
-
- A form field that validates input as a Portuguese phone number.
- Valid numbers have 9 digits (may include spaces) or start by 00
- or + (international).
-
-Romania (``ro``)
-================
-
-.. class:: ro.forms.ROCIFField
-
- A form field that validates Romanian fiscal identification codes (CIF). The
- return value strips the leading RO, if given.
-
-.. class:: ro.forms.ROCNPField
-
- A form field that validates Romanian personal numeric codes (CNP).
-
-.. class:: ro.forms.ROCountyField
-
- A form field that validates its input as a Romanian county (judet) name or
- abbreviation. It normalizes the input to the standard vehicle registration
- abbreviation for the given county. This field will only accept names written
- with diacritics; consider using ROCountySelect as an alternative.
-
-.. class:: ro.forms.ROCountySelect
-
- A ``Select`` widget that uses a list of Romanian counties (judete) as its
- choices.
-
-.. class:: ro.forms.ROIBANField
-
- A form field that validates its input as a Romanian International Bank
- Account Number (IBAN). The valid format is ROXX-XXXX-XXXX-XXXX-XXXX-XXXX,
- with or without hyphens.
-
-.. class:: ro.forms.ROPhoneNumberField
-
- A form field that validates Romanian phone numbers, short special numbers
- excluded.
-
-.. class:: ro.forms.ROPostalCodeField
-
- A form field that validates Romanian postal codes.
-
-Russia (``ru``)
-===============
-
-.. versionadded:: 1.4
-
-.. class:: ru.forms.RUPostalCodeField
-
- Russian Postal code field. The valid format is XXXXXX, where X is any
- digit and the first digit is not zero.
-
-.. class:: ru.forms.RUCountySelect
-
- A ``Select`` widget that uses a list of Russian Counties as its choices.
-
-.. class:: ru.forms.RURegionSelect
-
- A ``Select`` widget that uses a list of Russian Regions as its choices.
-
-.. class:: ru.forms.RUPassportNumberField
-
- Russian internal passport number. The valid format is XXXX XXXXXX, where X
- is any digit.
-
-.. class:: ru.forms.RUAlienPassportNumberField
-
- Russian alien's passport number. The valid format is XX XXXXXXX, where X
- is any digit.
-
-Slovakia (``sk``)
-=================
-
-.. class:: sk.forms.SKPostalCodeField
-
- A form field that validates input as a Slovak postal code. Valid formats
- are XXXXX or XXX XX, where X is a digit.
-
-.. class:: sk.forms.SKDistrictSelect
-
- A ``Select`` widget that uses a list of Slovak districts as its choices.
-
-.. class:: sk.forms.SKRegionSelect
-
- A ``Select`` widget that uses a list of Slovak regions as its choices.
-
-Slovenia (``si``)
-=================
-
-.. class:: si.forms.SIEMSOField
-
- A form field that validates input as Slovenian personal identification
- number and stores gender and birthday to self.info dictionary.
-
-.. class:: si.forms.SITaxNumberField
-
- A form field that validates input as a Slovenian tax number. Valid input
- is SIXXXXXXXX or XXXXXXXX.
-
-.. class:: si.forms.SIPhoneNumberField
-
- A form field that validates input as a Slovenian phone number. Phone
- number must contain at least local area code with optional country code.
-
-.. class:: si.forms.SIPostalCodeField
-
- A form field that provides a choice field of major Slovenian postal
- codes.
-
-.. class:: si.forms.SIPostalCodeSelect
-
- A ``Select`` widget that uses a list of major Slovenian postal codes as
- its choices.
-
-
-South Africa (``za``)
-=====================
-
-.. class:: za.forms.ZAIDField
-
- A form field that validates input as a South African ID number. Validation
- uses the Luhn checksum and a simplistic (i.e., not entirely accurate) check
- for birth date.
-
-.. class:: za.forms.ZAPostCodeField
-
- A form field that validates input as a South African postcode. Valid
- postcodes must have four digits.
-
-Spain (``es``)
-==============
-
-.. class:: es.forms.ESIdentityCardNumberField
-
- A form field that validates input as a Spanish NIF/NIE/CIF (Fiscal
- Identification Number) code.
-
-.. class:: es.forms.ESCCCField
-
- A form field that validates input as a Spanish bank account number (Codigo
- Cuenta Cliente or CCC). A valid CCC number has the format
- EEEE-OOOO-CC-AAAAAAAAAA, where the E, O, C and A digits denote the entity,
- office, checksum and account, respectively. The first checksum digit
- validates the entity and office. The second checksum digit validates the
- account. It is also valid to use a space as a delimiter, or to use no
- delimiter.
-
-.. class:: es.forms.ESPhoneNumberField
-
- A form field that validates input as a Spanish phone number. Valid numbers
- have nine digits, the first of which is 6, 8 or 9.
-
-.. class:: es.forms.ESPostalCodeField
-
- A form field that validates input as a Spanish postal code. Valid codes
- have five digits, the first two being in the range 01 to 52, representing
- the province.
-
-.. class:: es.forms.ESProvinceSelect
-
- A ``Select`` widget that uses a list of Spanish provinces as its choices.
-
-.. class:: es.forms.ESRegionSelect
-
- A ``Select`` widget that uses a list of Spanish regions as its choices.
-
-Sweden (``se``)
-===============
-
-.. class:: se.forms.SECountySelect
-
- A Select form widget that uses a list of the Swedish counties (län) as its
- choices.
-
- The cleaned value is the official county code -- see
- http://en.wikipedia.org/wiki/Counties_of_Sweden for a list.
-
-.. class:: se.forms.SEOrganisationNumber
-
- A form field that validates input as a Swedish organisation number
- (organisationsnummer).
-
- It accepts the same input as SEPersonalIdentityField (for sole
- proprietorships (enskild firma). However, co-ordination numbers are not
- accepted.
-
- It also accepts ordinary Swedish organisation numbers with the format
- NNNNNNNNNN.
-
- The return value will be YYYYMMDDXXXX for sole proprietors, and NNNNNNNNNN
- for other organisations.
-
-.. class:: se.forms.SEPersonalIdentityNumber
-
- A form field that validates input as a Swedish personal identity number
- (personnummer).
-
- The correct formats are YYYYMMDD-XXXX, YYYYMMDDXXXX, YYMMDD-XXXX,
- YYMMDDXXXX and YYMMDD+XXXX.
-
- A \+ indicates that the person is older than 100 years, which will be taken
- into consideration when the date is validated.
-
- The checksum will be calculated and checked. The birth date is checked
- to be a valid date.
-
- By default, co-ordination numbers (samordningsnummer) will be accepted. To
- only allow real personal identity numbers, pass the keyword argument
- coordination_number=False to the constructor.
-
- The cleaned value will always have the format YYYYMMDDXXXX.
-
-.. class:: se.forms.SEPostalCodeField
-
- A form field that validates input as a Swedish postal code (postnummer).
- Valid codes consist of five digits (XXXXX). The number can optionally be
- formatted with a space after the third digit (XXX XX).
-
- The cleaned value will never contain the space.
-
-Switzerland (``ch``)
-====================
-
-.. class:: ch.forms.CHIdentityCardNumberField
-
- A form field that validates input as a Swiss identity card number.
- A valid number must confirm to the X1234567<0 or 1234567890 format and
- have the correct checksums.
-
-.. class:: ch.forms.CHPhoneNumberField
-
- A form field that validates input as a Swiss phone number. The correct
- format is 0XX XXX XX XX. 0XX.XXX.XX.XX and 0XXXXXXXXX validate but are
- corrected to 0XX XXX XX XX.
-
-.. class:: ch.forms.CHZipCodeField
-
- A form field that validates input as a Swiss zip code. Valid codes
- consist of four digits.
-
-.. class:: ch.forms.CHStateSelect
-
- A ``Select`` widget that uses a list of Swiss states as its choices.
-
-Turkey (``tr``)
-===============
-
-.. class:: tr.forms.TRZipCodeField
-
- A form field that validates input as a Turkish zip code. Valid codes
- consist of five digits.
-
-.. class:: tr.forms.TRPhoneNumberField
-
- A form field that validates input as a Turkish phone number. The correct
- format is 0xxx xxx xxxx. +90xxx xxx xxxx and inputs without spaces also
- validates. The result is normalized to xxx xxx xxxx format.
-
-.. class:: tr.forms.TRIdentificationNumberField
-
- A form field that validates input as a TR identification number. A valid
- number must satisfy the following:
-
- * The number consist of 11 digits.
- * The first digit cannot be 0.
- * (sum(1st, 3rd, 5th, 7th, 9th)*7 - sum(2nd,4th,6th,8th)) % 10) must be
- equal to the 10th digit.
- * (sum(1st to 10th) % 10) must be equal to the 11th digit.
-
-.. class:: tr.forms.TRProvinceSelect
-
- A ``select`` widget that uses a list of Turkish provinces as its choices.
-
-United Kingdom (``gb``)
-=======================
-
-.. class:: gb.forms.GBPostcodeField
-
- A form field that validates input as a UK postcode. The regular
- expression used is sourced from the schema for British Standard BS7666
- address types at http://www.cabinetoffice.gov.uk/media/291293/bs7666-v2-0.xml.
-
-.. class:: gb.forms.GBCountySelect
-
- A ``Select`` widget that uses a list of UK counties/regions as its choices.
-
-.. class:: gb.forms.GBNationSelect
-
- A ``Select`` widget that uses a list of UK nations as its choices.
-
-United States of America (``us``)
-=================================
-
-.. class:: us.forms.USPhoneNumberField
-
- A form field that validates input as a U.S. phone number.
-
-.. class:: us.forms.USSocialSecurityNumberField
-
- A form field that validates input as a U.S. Social Security Number (SSN).
- A valid SSN must obey the following rules:
-
- * Format of XXX-XX-XXXX
- * No group of digits consisting entirely of zeroes
- * Leading group of digits cannot be 666
- * Number not in promotional block 987-65-4320 through 987-65-4329
- * Number not one known to be invalid due to widespread promotional
- use or distribution (e.g., the Woolworth's number or the 1962
- promotional number)
-
-.. class:: us.forms.USStateField
-
- A form field that validates input as a U.S. state name or abbreviation. It
- normalizes the input to the standard two-letter postal service abbreviation
- for the given state.
-
-.. class:: us.forms.USZipCodeField
-
- A form field that validates input as a U.S. ZIP code. Valid formats are
- XXXXX or XXXXX-XXXX.
-
-.. class:: us.forms.USStateSelect
-
- A form ``Select`` widget that uses a list of U.S. states/territories as its
- choices.
-
-.. class:: us.forms.USPSSelect
-
- A form ``Select`` widget that uses a list of U.S Postal Service
- state, territory and country abbreviations as its choices.
-
-.. class:: us.models.PhoneNumberField
-
- A :class:`CharField` that checks that the value is a valid U.S.A.-style phone
- number (in the format ``XXX-XXX-XXXX``).
-
-.. class:: us.models.USStateField
-
- A model field that forms represent as a ``forms.USStateField`` field and
- stores the two-letter U.S. state abbreviation in the database.
-
-.. class:: us.models.USPostalCodeField
-
- A model field that forms represent as a ``forms.USPSSelect`` field
- and stores the two-letter U.S Postal Service abbreviation in the
- database.
-
-Additionally, a variety of choice tuples are provided in
-``django.contrib.localflavor.us.us_states``, allowing customized model
-and form fields, and form presentations, for subsets of U.S states,
-territories and U.S Postal Service abbreviations:
-
-.. data:: us.us_states.CONTIGUOUS_STATES
-
- A tuple of choices of the postal abbreviations for the
- contiguous or "lower 48" states (i.e., all except Alaska and
- Hawaii), plus the District of Columbia.
-
-.. data:: us.us_states.US_STATES
-
- A tuple of choices of the postal abbreviations for all
- 50 U.S. states, plus the District of Columbia.
-
-.. data:: us.us_states.US_TERRITORIES
-
- A tuple of choices of the postal abbreviations for U.S
- territories: American Samoa, Guam, the Northern Mariana Islands,
- Puerto Rico and the U.S. Virgin Islands.
-
-.. data:: us.us_states.ARMED_FORCES_STATES
-
- A tuple of choices of the postal abbreviations of the three U.S
- military postal "states": Armed Forces Americas, Armed Forces
- Europe and Armed Forces Pacific.
-
-.. data:: us.us_states.COFA_STATES
-
- A tuple of choices of the postal abbreviations of the three
- independent nations which, under the Compact of Free Association,
- are served by the U.S. Postal Service: the Federated States of
- Micronesia, the Marshall Islands and Palau.
-
-.. data:: us.us_states.OBSOLETE_STATES
-
- A tuple of choices of obsolete U.S Postal Service state
- abbreviations: the former abbreviation for the Northern Mariana
- Islands, plus the Panama Canal Zone, the Philippines and the
- former Pacific trust territories.
-
-.. data:: us.us_states.STATE_CHOICES
-
- A tuple of choices of all postal abbreviations corresponding to U.S states or
- territories, and the District of Columbia..
-
-.. data:: us.us_states.USPS_CHOICES
-
- A tuple of choices of all postal abbreviations recognized by the
- U.S Postal Service (including all states and territories, the
- District of Columbia, armed forces "states" and independent
- nations serviced by USPS).
-
-Uruguay (``uy``)
-================
-
-.. class:: uy.forms.UYCIField
+ from django import forms
+ from django.contrib.localflavor import generic
- A field that validates Uruguayan 'Cedula de identidad' (CI) numbers.
+ class MyForm(forms.Form):
+ my_date_field = generic.forms.DateField()
-.. class:: uy.forms.UYDepartamentSelect
+Internationalization of localflavor
+===================================
- A ``Select`` widget that uses a list of Uruguayan departments as its
- choices.
+Localflavor has its own catalog of translations, in the directory
+``django/contrib/localflavor/locale``, and it's not loaded automatically like
+Django's general catalog in ``django/conf/locale``. If you want localflavor's
+texts to be translated, like form fields error messages, you must include
+:mod:`django.contrib.localflavor` in the :setting:`INSTALLED_APPS` setting, so
+the internationalization system can find the catalog, as explained in
+:ref:`how-django-discovers-translations`.
diff --git a/docs/ref/contrib/sitemaps.txt b/docs/ref/contrib/sitemaps.txt
index 2393a4a9a3..ef6c64dc61 100644
--- a/docs/ref/contrib/sitemaps.txt
+++ b/docs/ref/contrib/sitemaps.txt
@@ -330,8 +330,6 @@ with a caching decorator -- you must name your sitemap view and pass
Template customization
======================
-.. versionadded:: 1.3
-
If you wish to use a different template for each sitemap or sitemap index
available on your site, you may specify it by passing a ``template_name``
parameter to the ``sitemap`` and ``index`` views via the URLconf::
diff --git a/docs/ref/contrib/sites.txt b/docs/ref/contrib/sites.txt
index 8fc434ba9b..790e003453 100644
--- a/docs/ref/contrib/sites.txt
+++ b/docs/ref/contrib/sites.txt
@@ -80,11 +80,11 @@ This accomplishes several things quite nicely:
The view code that displays a given story just checks to make sure the
requested story is on the current site. It looks something like this::
- from django.conf import settings
+ from django.contrib.sites.models import get_current_site
def article_detail(request, article_id):
try:
- a = Article.objects.get(id=article_id, sites__id__exact=settings.SITE_ID)
+ a = Article.objects.get(id=article_id, sites__id__exact=get_current_site(request).id)
except Article.DoesNotExist:
raise Http404
# ...
@@ -131,53 +131,36 @@ For example::
# Do something else.
Of course, it's ugly to hard-code the site IDs like that. This sort of
-hard-coding is best for hackish fixes that you need done quickly. A slightly
+hard-coding is best for hackish fixes that you need done quickly. The
cleaner way of accomplishing the same thing is to check the current site's
domain::
- from django.conf import settings
- from django.contrib.sites.models import Site
+ from django.contrib.sites.models import get_current_site
def my_view(request):
- current_site = Site.objects.get(id=settings.SITE_ID)
+ current_site = get_current_site(request)
if current_site.domain == 'foo.com':
# Do something
else:
# Do something else.
-The idiom of retrieving the :class:`~django.contrib.sites.models.Site` object
-for the value of :setting:`settings.SITE_ID <SITE_ID>` is quite common, so
-the :class:`~django.contrib.sites.models.Site` model's manager has a
-``get_current()`` method. This example is equivalent to the previous one::
+This has also the advantage of checking if the sites framework is installed, and
+return a :class:`RequestSite` instance if it is not.
+
+If you don't have access to the request object, you can use the
+``get_current()`` method of the :class:`~django.contrib.sites.models.Site`
+model's manager. You should then ensure that your settings file does contain
+the :setting:`SITE_ID` setting. This example is equivalent to the previous one::
from django.contrib.sites.models import Site
- def my_view(request):
+ def my_function_without_request():
current_site = Site.objects.get_current()
if current_site.domain == 'foo.com':
# Do something
else:
# Do something else.
-.. versionchanged:: 1.3
-
-For code which relies on getting the current domain but cannot be certain
-that the sites framework will be installed for any given project, there is a
-utility function :func:`~django.contrib.sites.models.get_current_site` that
-takes a request object as an argument and returns either a Site instance (if
-the sites framework is installed) or a RequestSite instance (if it is not).
-This allows loose coupling with the sites framework and provides a usable
-fallback for cases where it is not installed.
-
-.. versionadded:: 1.3
-
-.. function:: get_current_site(request)
-
- Checks if contrib.sites is installed and returns either the current
- :class:`~django.contrib.sites.models.Site` object or a
- :class:`~django.contrib.sites.models.RequestSite` object based on
- the request.
-
Getting the current domain for display
--------------------------------------
@@ -196,14 +179,14 @@ current site's :attr:`~django.contrib.sites.models.Site.name` and
Here's an example of what the form-handling view looks like::
- from django.contrib.sites.models import Site
+ from django.contrib.sites.models import get_current_site
from django.core.mail import send_mail
def register_for_newsletter(request):
# Check form values, etc., and subscribe the user.
# ...
- current_site = Site.objects.get_current()
+ current_site = get_current_site(request)
send_mail('Thanks for subscribing to %s alerts' % current_site.name,
'Thanks for your subscription. We appreciate it.\n\n-The %s team.' % current_site.name,
'editor@%s' % current_site.domain,
@@ -374,19 +357,19 @@ Here's how Django uses the sites framework:
* In the :mod:`redirects framework <django.contrib.redirects>`, each
redirect object is associated with a particular site. When Django searches
- for a redirect, it takes into account the current :setting:`SITE_ID`.
+ for a redirect, it takes into account the current site.
* In the comments framework, each comment is associated with a particular
site. When a comment is posted, its
- :class:`~django.contrib.sites.models.Site` is set to the current
- :setting:`SITE_ID`, and when comments are listed via the appropriate
- template tag, only the comments for the current site are displayed.
+ :class:`~django.contrib.sites.models.Site` is set to the current site,
+ and when comments are listed via the appropriate template tag, only the
+ comments for the current site are displayed.
* In the :mod:`flatpages framework <django.contrib.flatpages>`, each
flatpage is associated with a particular site. When a flatpage is created,
you specify its :class:`~django.contrib.sites.models.Site`, and the
:class:`~django.contrib.flatpages.middleware.FlatpageFallbackMiddleware`
- checks the current :setting:`SITE_ID` in retrieving flatpages to display.
+ checks the current site in retrieving flatpages to display.
* In the :mod:`syndication framework <django.contrib.syndication>`, the
templates for ``title`` and ``description`` automatically have access to a
@@ -437,7 +420,7 @@ fallback when the database-backed sites framework is not available.
Sets the ``name`` and ``domain`` attributes to the value of
:meth:`~django.http.HttpRequest.get_host`.
-
+
A :class:`~django.contrib.sites.models.RequestSite` object has a similar
interface to a normal :class:`~django.contrib.sites.models.Site` object, except
diff --git a/docs/ref/contrib/staticfiles.txt b/docs/ref/contrib/staticfiles.txt
index cbe8ad54b8..3a74797145 100644
--- a/docs/ref/contrib/staticfiles.txt
+++ b/docs/ref/contrib/staticfiles.txt
@@ -5,8 +5,6 @@ The staticfiles app
.. module:: django.contrib.staticfiles
:synopsis: An app for handling static files.
-.. versionadded:: 1.3
-
``django.contrib.staticfiles`` collects static files from each of your
applications (and any other places you specify) into a single location that
can easily be served in production.
diff --git a/docs/ref/contrib/syndication.txt b/docs/ref/contrib/syndication.txt
index 5653397748..27b8fc0875 100644
--- a/docs/ref/contrib/syndication.txt
+++ b/docs/ref/contrib/syndication.txt
@@ -455,7 +455,7 @@ This example illustrates all possible attributes and methods for a
author_name = 'Sally Smith' # Hard-coded author name.
- # AUTHOR E-MAIL --One of the following three is optional. The framework
+ # AUTHOR EMAIL --One of the following three is optional. The framework
# looks for them in this order.
def author_email(self, obj):
@@ -635,7 +635,7 @@ This example illustrates all possible attributes and methods for a
item_author_name = 'Sally Smith' # Hard-coded author name.
- # ITEM AUTHOR E-MAIL --One of the following three is optional. The
+ # ITEM AUTHOR EMAIL --One of the following three is optional. The
# framework looks for them in this order.
#
# If you specify this, you must specify item_author_name.
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt
index 3e256e9d9e..3a52f838e7 100644
--- a/docs/ref/databases.txt
+++ b/docs/ref/databases.txt
@@ -158,6 +158,16 @@ Since MySQL 5.5.5, the default storage engine is InnoDB_. This engine is fully
transactional and supports foreign key references. It's probably the best
choice at this point.
+If you upgrade an existing project to MySQL 5.5.5 and subsequently add some
+tables, ensure that your tables are using the same storage engine (i.e. MyISAM
+vs. InnoDB). Specifically, if tables that have a ``ForeignKey`` between them
+use different storage engines, you may see an error like the following when
+running ``syncdb``::
+
+ _mysql_exceptions.OperationalError: (
+ 1005, "Can't create table '\\db_name\\.#sql-4a8_ab' (errno: 150)"
+ )
+
.. versionchanged:: 1.4
In previous versions of Django, fixtures with forward references (i.e.
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
index 5ff7ecba2c..7fa7539985 100644
--- a/docs/ref/django-admin.txt
+++ b/docs/ref/django-admin.txt
@@ -176,8 +176,6 @@ records to dump. If you're using a :ref:`custom manager <custom-managers>` as
the default manager and it filters some of the available records, not all of the
objects will be dumped.
-.. versionadded:: 1.3
-
The :djadminopt:`--all` option may be provided to specify that
``dumpdata`` should use Django's base manager, dumping records which
might otherwise be filtered or modified by a custom manager.
@@ -195,18 +193,10 @@ easy for humans to read, so you can use the ``--indent`` option to
pretty-print the output with a number of indentation spaces.
The :djadminopt:`--exclude` option may be provided to prevent specific
-applications from being dumped.
-
-.. versionadded:: 1.3
-
-The :djadminopt:`--exclude` option may also be provided to prevent specific
-models (specified as in the form of ``appname.ModelName``) from being dumped.
-
-In addition to specifying application names, you can provide a list of
-individual models, in the form of ``appname.Model``. If you specify a model
-name to ``dumpdata``, the dumped output will be restricted to that model,
-rather than the entire application. You can also mix application names and
-model names.
+applications or models (specified as in the form of ``appname.ModelName``) from
+being dumped. If you specify a model name to ``dumpdata``, the dumped output
+will be restricted to that model, rather than the entire application. You can
+also mix application names and model names.
The :djadminopt:`--database` option can be used to specify the database
from which data will be dumped.
@@ -299,6 +289,11 @@ Searches for and loads the contents of the named fixture into the database.
The :djadminopt:`--database` option can be used to specify the database
onto which the data will be loaded.
+.. versionadded:: 1.5
+
+The :djadminopt:`--ignorenonexistent` option can be used to ignore fields that
+may have been removed from models since the fixture was originally generated.
+
What's a "fixture"?
~~~~~~~~~~~~~~~~~~~
@@ -463,8 +458,6 @@ Use the ``--no-default-ignore`` option to disable the default values of
.. django-admin-option:: --no-wrap
-.. versionadded:: 1.3
-
Use the ``--no-wrap`` option to disable breaking long message lines into
several lines in language files.
@@ -640,18 +633,14 @@ machines on your network. To make your development server viewable to other
machines on the network, use its own IP address (e.g. ``192.168.2.1``) or
``0.0.0.0`` or ``::`` (with IPv6 enabled).
-.. versionchanged:: 1.3
-
You can provide an IPv6 address surrounded by brackets
(e.g. ``[200a::1]:8000``). This will automatically enable IPv6 support.
A hostname containing ASCII-only characters can also be used.
-.. versionchanged:: 1.3
-
If the :doc:`staticfiles</ref/contrib/staticfiles>` contrib app is enabled
(default in new projects) the :djadmin:`runserver` command will be overriden
-with an own :djadmin:`runserver<staticfiles-runserver>` command.
+with its own :ref:`runserver<staticfiles-runserver>` command.
.. django-admin-option:: --noreload
@@ -674,8 +663,6 @@ development server.
.. django-admin-option:: --ipv6, -6
-.. versionadded:: 1.3
-
Use the ``--ipv6`` (or shorter ``-6``) option to tell Django to use IPv6 for
the development server. This changes the default IP address from
``127.0.0.1`` to ``::1``.
@@ -1113,8 +1100,6 @@ To run on 1.2.3.4:7000 with a ``test`` fixture::
django-admin.py testserver --addrport 1.2.3.4:7000 test
-.. versionadded:: 1.3
-
The :djadminopt:`--noinput` option may be provided to suppress all user
prompts.
diff --git a/docs/ref/files/storage.txt b/docs/ref/files/storage.txt
index b3f8909847..f9bcf9b61e 100644
--- a/docs/ref/files/storage.txt
+++ b/docs/ref/files/storage.txt
@@ -18,7 +18,7 @@ Django provides two convenient ways to access the current storage class:
.. function:: get_storage_class([import_path=None])
Returns a class or module which implements the storage API.
-
+
When called without the ``import_path`` parameter ``get_storage_class``
will return the current default storage system as defined by
:setting:`DEFAULT_FILE_STORAGE`. If ``import_path`` is provided,
@@ -35,9 +35,9 @@ The FileSystemStorage Class
basic file storage on a local filesystem. It inherits from
:class:`~django.core.files.storage.Storage` and provides implementations
for all the public methods thereof.
-
+
.. note::
-
+
The :class:`FileSystemStorage.delete` method will not raise
raise an exception if the given file name does not exist.
@@ -53,16 +53,12 @@ The Storage Class
.. method:: accessed_time(name)
- .. versionadded:: 1.3
-
Returns a ``datetime`` object containing the last accessed time of the
file. For storage systems that aren't able to return the last accessed
time this will raise ``NotImplementedError`` instead.
.. method:: created_time(name)
- .. versionadded:: 1.3
-
Returns a ``datetime`` object containing the creation time of the file.
For storage systems that aren't able to return the creation time this
will raise ``NotImplementedError`` instead.
@@ -100,8 +96,6 @@ The Storage Class
.. method:: modified_time(name)
- .. versionadded:: 1.3
-
Returns a ``datetime`` object containing the last modified time. For
storage systems that aren't able to return the last modified time, this
will raise ``NotImplementedError`` instead.
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt
index 777d73e015..dffef314b7 100644
--- a/docs/ref/forms/api.txt
+++ b/docs/ref/forms/api.txt
@@ -105,7 +105,7 @@ Access the :attr:`~Form.errors` attribute to get a dictionary of error
messages::
>>> f.errors
- {'sender': [u'Enter a valid e-mail address.'], 'subject': [u'This field is required.']}
+ {'sender': [u'Enter a valid email address.'], 'subject': [u'This field is required.']}
In this dictionary, the keys are the field names, and the values are lists of
Unicode strings representing the error messages. The error messages are stored
@@ -538,18 +538,18 @@ method you're using::
>>> print(f.as_table())
<tr><th>Subject:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="subject" maxlength="100" /></td></tr>
<tr><th>Message:</th><td><input type="text" name="message" value="Hi there" /></td></tr>
- <tr><th>Sender:</th><td><ul class="errorlist"><li>Enter a valid e-mail address.</li></ul><input type="text" name="sender" value="invalid email address" /></td></tr>
+ <tr><th>Sender:</th><td><ul class="errorlist"><li>Enter a valid email address.</li></ul><input type="text" name="sender" value="invalid email address" /></td></tr>
<tr><th>Cc myself:</th><td><input checked="checked" type="checkbox" name="cc_myself" /></td></tr>
>>> print(f.as_ul())
<li><ul class="errorlist"><li>This field is required.</li></ul>Subject: <input type="text" name="subject" maxlength="100" /></li>
<li>Message: <input type="text" name="message" value="Hi there" /></li>
- <li><ul class="errorlist"><li>Enter a valid e-mail address.</li></ul>Sender: <input type="text" name="sender" value="invalid email address" /></li>
+ <li><ul class="errorlist"><li>Enter a valid email address.</li></ul>Sender: <input type="text" name="sender" value="invalid email address" /></li>
<li>Cc myself: <input checked="checked" type="checkbox" name="cc_myself" /></li>
>>> print(f.as_p())
<p><ul class="errorlist"><li>This field is required.</li></ul></p>
<p>Subject: <input type="text" name="subject" maxlength="100" /></p>
<p>Message: <input type="text" name="message" value="Hi there" /></p>
- <p><ul class="errorlist"><li>Enter a valid e-mail address.</li></ul></p>
+ <p><ul class="errorlist"><li>Enter a valid email address.</li></ul></p>
<p>Sender: <input type="text" name="sender" value="invalid email address" /></p>
<p>Cc myself: <input checked="checked" type="checkbox" name="cc_myself" /></p>
@@ -572,7 +572,7 @@ pass that in at construction time::
<div class="errorlist"><div class="error">This field is required.</div></div>
<p>Subject: <input type="text" name="subject" maxlength="100" /></p>
<p>Message: <input type="text" name="message" value="Hi there" /></p>
- <div class="errorlist"><div class="error">Enter a valid e-mail address.</div></div>
+ <div class="errorlist"><div class="error">Enter a valid email address.</div></div>
<p>Sender: <input type="text" name="sender" value="invalid email address" /></p>
<p>Cc myself: <input checked="checked" type="checkbox" name="cc_myself" /></p>
@@ -658,8 +658,6 @@ those classes as an argument::
.. method:: BoundField.value()
- .. versionadded:: 1.3
-
Use this method to render the raw value of this field as it would be rendered
by a ``Widget``::
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
index 7c06bf97ee..7c8d509031 100644
--- a/docs/ref/forms/fields.txt
+++ b/docs/ref/forms/fields.txt
@@ -28,7 +28,7 @@ exception or returns the clean value::
>>> f.clean('invalid email address')
Traceback (most recent call last):
...
- ValidationError: [u'Enter a valid e-mail address.']
+ ValidationError: [u'Enter a valid email address.']
Core field arguments
--------------------
@@ -405,7 +405,7 @@ For each field, we describe the default widget used if you don't specify
Additionally, if you specify :setting:`USE_L10N=False<USE_L10N>` in your settings, the
following will also be included in the default input formats::
- '%b %m %d', # 'Oct 25 2006'
+ '%b %d %Y', # 'Oct 25 2006'
'%b %d, %Y', # 'Oct 25, 2006'
'%d %b %Y', # '25 Oct 2006'
'%d %b, %Y', # '25 Oct, 2006'
@@ -414,6 +414,8 @@ For each field, we describe the default widget used if you don't specify
'%d %B %Y', # '25 October 2006'
'%d %B, %Y', # '25 October, 2006'
+ See also :ref:`format localization <format-localization>`.
+
``DateTimeField``
~~~~~~~~~~~~~~~~~
@@ -445,6 +447,8 @@ For each field, we describe the default widget used if you don't specify
'%m/%d/%y %H:%M', # '10/25/06 14:30'
'%m/%d/%y', # '10/25/06'
+ See also :ref:`format localization <format-localization>`.
+
``DecimalField``
~~~~~~~~~~~~~~~~
@@ -704,8 +708,6 @@ For each field, we describe the default widget used if you don't specify
``TypedMultipleChoiceField``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.. versionadded:: 1.3
-
.. class:: TypedMultipleChoiceField(**kwargs)
Just like a :class:`MultipleChoiceField`, except :class:`TypedMultipleChoiceField`
@@ -999,13 +1001,17 @@ objects (in the case of ``ModelMultipleChoiceField``) into the
.. class:: ModelMultipleChoiceField(**kwargs)
* Default widget: ``SelectMultiple``
- * Empty value: ``[]`` (an empty list)
- * Normalizes to: A list of model instances.
+ * Empty value: An empty ``QuerySet`` (self.queryset.none())
+ * Normalizes to: A ``QuerySet`` of model instances.
* Validates that every id in the given list of values exists in the
queryset.
* Error message keys: ``required``, ``list``, ``invalid_choice``,
``invalid_pk_value``
+ .. versionchanged:: 1.5
+ The empty and normalized values were changed to be consistently
+ ``QuerySets`` instead of ``[]`` and ``QuerySet`` respectively.
+
Allows the selection of one or more model objects, suitable for
representing a many-to-many relation. As with :class:`ModelChoiceField`,
you can use ``label_from_instance`` to customize the object
diff --git a/docs/ref/forms/validation.txt b/docs/ref/forms/validation.txt
index 1af32da875..e89bce748f 100644
--- a/docs/ref/forms/validation.txt
+++ b/docs/ref/forms/validation.txt
@@ -185,7 +185,7 @@ a look at Django's ``EmailField``::
class EmailField(CharField):
default_error_messages = {
- 'invalid': _('Enter a valid e-mail address.'),
+ 'invalid': _('Enter a valid email address.'),
}
default_validators = [validators.validate_email]
@@ -198,7 +198,7 @@ on field definition so::
is equivalent to::
email = forms.CharField(validators=[validators.validate_email],
- error_messages={'invalid': _('Enter a valid e-mail address.')})
+ error_messages={'invalid': _('Enter a valid email address.')})
Form field default cleaning
diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt
index 4724cbdec2..3c458930fa 100644
--- a/docs/ref/forms/widgets.txt
+++ b/docs/ref/forms/widgets.txt
@@ -294,11 +294,6 @@ These widgets make use of the HTML elements ``input`` and ``textarea``.
Determines whether the widget will have a value filled in when the
form is re-displayed after a validation error (default is ``False``).
- .. versionchanged:: 1.3
- The default value for
- :attr:`~PasswordInput.render_value` was
- changed from ``True`` to ``False``
-
``HiddenInput``
~~~~~~~~~~~~~~~
@@ -532,8 +527,6 @@ File upload widgets
.. class:: ClearableFileInput
- .. versionadded:: 1.3
-
File upload input: ``<input type='file' ...>``, with an additional checkbox
input to clear the field's value, if the field is not required and has
initial data.
diff --git a/docs/ref/index.txt b/docs/ref/index.txt
index 01a8ab22d1..e1959d44a6 100644
--- a/docs/ref/index.txt
+++ b/docs/ref/index.txt
@@ -6,7 +6,7 @@ API Reference
:maxdepth: 1
authbackends
- class-based-views/index
+ class-based-views/index
clickjacking
contrib/index
databases
@@ -22,5 +22,7 @@ API Reference
signals
templates/index
unicode
+ urlresolvers
+ urls
utils
validators
diff --git a/docs/ref/middleware.txt b/docs/ref/middleware.txt
index a6ea9a6c41..b542aee6e2 100644
--- a/docs/ref/middleware.txt
+++ b/docs/ref/middleware.txt
@@ -93,8 +93,8 @@ GZip middleware
Compresses content for browsers that understand GZip compression (all modern
browsers).
-It is suggested to place this first in the middleware list, so that the
-compression of the response content is the last thing that happens.
+This middleware should be placed before any other middleware that need to
+read or write the response body so that compression happens afterward.
It will NOT compress content if any of the following are true:
@@ -203,9 +203,9 @@ Transaction middleware
.. class:: TransactionMiddleware
-Binds commit and rollback to the request/response phase. If a view function
-runs successfully, a commit is done. If it fails with an exception, a rollback
-is done.
+Binds commit and rollback of the default database to the request/response
+phase. If a view function runs successfully, a commit is done. If it fails with
+an exception, a rollback is done.
The order of this middleware in the stack is important: middleware modules
running outside of it run with commit-on-save - the default Django behavior.
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 8b3c31f029..809d56eaf5 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -668,6 +668,11 @@ the field. Note: This method will close the file if it happens to be open when
The optional ``save`` argument controls whether or not the instance is saved
after the file has been deleted. Defaults to ``True``.
+Note that when a model is deleted, related files are not deleted. If you need
+to cleanup orphaned files, you'll need to handle it yourself (for instance,
+with a custom management command that can be run manually or scheduled to run
+periodically via e.g. cron).
+
``FilePathField``
-----------------
@@ -966,6 +971,12 @@ need to use::
This sort of reference can be useful when resolving circular import
dependencies between two applications.
+A database index is automatically created on the ``ForeignKey``. You can
+disable this by setting :attr:`~Field.db_index` to ``False``. You may want to
+avoid the overhead of an index if you are creating a foreign key for
+consistency rather than joins, or if you will be creating an alternative index
+like a partial or multiple column index.
+
Database Representation
~~~~~~~~~~~~~~~~~~~~~~~
@@ -1023,8 +1034,6 @@ define the details of how the relation works.
The field on the related object that the relation is to. By default, Django
uses the primary key of the related object.
-.. versionadded:: 1.3
-
.. attribute:: ForeignKey.on_delete
When an object referenced by a :class:`ForeignKey` is deleted, Django by
@@ -1081,6 +1090,9 @@ the model is related. This works exactly the same as it does for
:class:`ForeignKey`, including all the options regarding :ref:`recursive
<recursive-relationships>` and :ref:`lazy <lazy-relationships>` relationships.
+Related objects can be added, removed, or created with the field's
+:class:`~django.db.models.fields.related.RelatedManager`.
+
Database Representation
~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt
index 2fdc87df8c..1ba41148b0 100644
--- a/docs/ref/models/instances.txt
+++ b/docs/ref/models/instances.txt
@@ -387,10 +387,11 @@ perform an update on all fields.
Specifying ``update_fields`` will force an update.
When saving a model fetched through deferred model loading
-(:meth:`~Model.only()` or :meth:`~Model.defer()`) only the fields loaded from
-the DB will get updated. In effect there is an automatic ``update_fields`` in
-this case. If you assign or change any deferred field value, these fields will
-be added to the updated fields.
+(:meth:`~django.db.models.query.QuerySet.only()` or
+:meth:`~django.db.models.query.QuerySet.defer()`) only the fields loaded
+from the DB will get updated. In effect there is an automatic
+``update_fields`` in this case. If you assign or change any deferred field
+value, the field will be added to the updated fields.
Deleting objects
================
@@ -493,12 +494,16 @@ defined. If it makes sense for your model's instances to each have a unique
URL, you should define ``get_absolute_url()``.
It's good practice to use ``get_absolute_url()`` in templates, instead of
-hard-coding your objects' URLs. For example, this template code is bad::
+hard-coding your objects' URLs. For example, this template code is bad:
+
+.. code-block:: html+django
<!-- BAD template code. Avoid! -->
<a href="/people/{{ object.id }}/">{{ object.name }}</a>
-This template code is much better::
+This template code is much better:
+
+.. code-block:: html+django
<a href="{{ object.get_absolute_url }}">{{ object.name }}</a>
@@ -534,7 +539,9 @@ pattern name) and a list of position or keyword arguments and uses the URLconf
patterns to construct the correct, full URL. It returns a string for the
correct URL, with all parameters substituted in the correct positions.
-The ``permalink`` decorator is a Python-level equivalent to the :ttag:`url` template tag and a high-level wrapper for the :func:`django.core.urlresolvers.reverse()` function.
+The ``permalink`` decorator is a Python-level equivalent to the :ttag:`url`
+template tag and a high-level wrapper for the
+:func:`django.core.urlresolvers.reverse()` function.
An example should make it clear how to use ``permalink()``. Suppose your URLconf
contains a line such as::
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 8ec7cfc791..7138cd0e74 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -505,15 +505,8 @@ followed (optionally) by any output-affecting methods (such as ``values()``),
but it doesn't really matter. This is your chance to really flaunt your
individualism.
-.. versionchanged:: 1.3
-
-The ``values()`` method previously did not return anything for
-:class:`~django.db.models.ManyToManyField` attributes and would raise an error
-if you tried to pass this type of field to it.
-
-This restriction has been lifted, and you can now also refer to fields on
-related models with reverse relations through ``OneToOneField``, ``ForeignKey``
-and ``ManyToManyField`` attributes::
+You can also refer to fields on related models with reverse relations through
+``OneToOneField``, ``ForeignKey`` and ``ManyToManyField`` attributes::
Blog.objects.values('name', 'entry__headline')
[{'name': 'My blog', 'entry__headline': 'An entry'},
@@ -1463,6 +1456,16 @@ evaluated will force it to evaluate again, repeating the query.
Also, use of ``iterator()`` causes previous ``prefetch_related()`` calls to be
ignored since these two optimizations do not make sense together.
+.. warning::
+
+ Some Python database drivers like ``psycopg2`` perform caching if using
+ client side cursors (instantiated with ``connection.cursor()`` and what
+ Django's ORM uses). Using ``iterator()`` does not affect caching at the
+ database driver level. To disable this caching, look at `server side
+ cursors`_.
+
+.. _server side cursors: http://initd.org/psycopg/docs/usage.html#server-side-cursors
+
latest
~~~~~~
@@ -1571,7 +1574,8 @@ update
.. method:: update(**kwargs)
Performs an SQL update query for the specified fields, and returns
-the number of rows affected.
+the number of rows matched (which may not be equal to the number of rows
+updated if some rows already have the new value).
For example, to turn comments off for all blog entries published in 2010,
you could do this::
@@ -1631,7 +1635,7 @@ does not call any ``save()`` methods on your models, nor does it emit the
:attr:`~django.db.models.signals.post_save` signals (which are a consequence of
calling :meth:`Model.save() <~django.db.models.Model.save()>`). If you want to
update a bunch of records for a model that has a custom
-:meth:`~django.db.models.Model.save()`` method, loop over them and call
+:meth:`~django.db.models.Model.save()` method, loop over them and call
:meth:`~django.db.models.Model.save()`, like this::
for e in Entry.objects.filter(pub_date__year=2010):
@@ -1664,10 +1668,9 @@ For example::
# This will delete all Blogs and all of their Entry objects.
blogs.delete()
-.. versionadded:: 1.3
- This cascade behavior is customizable via the
- :attr:`~django.db.models.ForeignKey.on_delete` argument to the
- :class:`~django.db.models.ForeignKey`.
+This cascade behavior is customizable via the
+:attr:`~django.db.models.ForeignKey.on_delete` argument to the
+:class:`~django.db.models.ForeignKey`.
The ``delete()`` method does a bulk delete and does not call any ``delete()``
methods on your models. It does, however, emit the
@@ -1675,6 +1678,21 @@ methods on your models. It does, however, emit the
:data:`~django.db.models.signals.post_delete` signals for all deleted objects
(including cascaded deletions).
+.. versionadded:: 1.5
+ Allow fast-path deletion of objects
+
+Django needs to fetch objects into memory to send signals and handle cascades.
+However, if there are no cascades and no signals, then Django may take a
+fast-path and delete objects without fetching into memory. For large
+deletes this can result in significantly reduced memory usage. The amount of
+executed queries can be reduced, too.
+
+ForeignKeys which are set to :attr:`~django.db.models.ForeignKey.on_delete`
+DO_NOTHING do not prevent taking the fast-path in deletion.
+
+Note that the queries generated in object deletion is an implementation
+detail subject to change.
+
.. _field-lookups:
Field lookups
diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt
index 21e99de10d..c3ba99168d 100644
--- a/docs/ref/request-response.txt
+++ b/docs/ref/request-response.txt
@@ -16,7 +16,8 @@ passing the :class:`HttpRequest` as the first argument to the view function.
Each view is responsible for returning an :class:`HttpResponse` object.
This document explains the APIs for :class:`HttpRequest` and
-:class:`HttpResponse` objects.
+:class:`HttpResponse` objects, which are defined in the :mod:`django.http`
+module.
HttpRequest objects
===================
@@ -42,8 +43,6 @@ All attributes should be considered read-only, unless stated otherwise below.
data in different ways than conventional HTML forms: binary images,
XML payload etc. For processing conventional form data, use ``HttpRequest.POST``.
- .. versionadded:: 1.3
-
You can also read from an HttpRequest using a file-like interface. See
:meth:`HttpRequest.read()`.
@@ -93,8 +92,14 @@ All attributes should be considered read-only, unless stated otherwise below.
.. attribute:: HttpRequest.POST
- A dictionary-like object containing all given HTTP POST parameters. See the
- :class:`QueryDict` documentation below.
+ A dictionary-like object containing all given HTTP POST parameters,
+ providing that the request contains form data. See the
+ :class:`QueryDict` documentation below. If you need to access raw or
+ non-form data posted in the request, access this through the
+ :attr:`HttpRequest.body` attribute instead.
+
+ .. versionchanged:: 1.5
+ Before Django 1.5, HttpRequest.POST contained non-form data.
It's possible that a request can come in via POST with an empty ``POST``
dictionary -- if, say, a form is requested via the POST HTTP method but
@@ -192,6 +197,17 @@ All attributes should be considered read-only, unless stated otherwise below.
URLconf for the current request, overriding the :setting:`ROOT_URLCONF`
setting. See :ref:`how-django-processes-a-request` for details.
+.. attribute:: HttpRequest.resolver_match
+
+ .. versionadded:: 1.5
+
+ An instance of :class:`~django.core.urlresolvers.ResolverMatch` representing
+ the resolved url. This attribute is only set after url resolving took place,
+ which means it's available in all views but not in middleware methods which
+ are executed before url resolving takes place (like ``process_request``, you
+ can use ``process_view`` instead).
+
+
Methods
-------
@@ -305,8 +321,6 @@ Methods
.. method:: HttpRequest.xreadlines()
.. method:: HttpRequest.__iter__()
- .. versionadded:: 1.3
-
Methods implementing a file-like interface for reading from an
HttpRequest instance. This makes it possible to consume an incoming
request in a streaming fashion. A common use-case would be to process a
@@ -509,9 +523,6 @@ In addition, ``QueryDict`` has the following methods:
>>> q.urlencode()
'a=2&b=3&b=5'
- .. versionchanged:: 1.3
- The ``safe`` parameter was added.
-
Optionally, urlencode can be passed characters which
do not require encoding. For example::
@@ -555,13 +566,28 @@ file-like object::
Passing iterators
~~~~~~~~~~~~~~~~~
-Finally, you can pass ``HttpResponse`` an iterator rather than passing it
-hard-coded strings. If you use this technique, follow these guidelines:
+Finally, you can pass ``HttpResponse`` an iterator rather than strings. If you
+use this technique, the iterator should return strings.
+
+Passing an iterator as content to :class:`HttpResponse` creates a
+streaming response if (and only if) no middleware accesses the
+:attr:`HttpResponse.content` attribute before the response is returned.
+
+.. versionchanged:: 1.5
+
+This technique is fragile and was deprecated in Django 1.5. If you need the
+response to be streamed from the iterator to the client, you should use the
+:class:`StreamingHttpResponse` class instead.
-* The iterator should return strings.
-* If an :class:`HttpResponse` has been initialized with an iterator as its
- content, you can't use the :class:`HttpResponse` instance as a file-like
- object. Doing so will raise ``Exception``.
+As of Django 1.7, when :class:`HttpResponse` is instantiated with an
+iterator, it will consume it immediately, store the response content as a
+string, and discard the iterator.
+
+.. versionchanged:: 1.5
+
+You can now use :class:`HttpResponse` as a file-like object even if it was
+instantiated with an iterator. Django will consume and save the content of
+the iterator on first access.
Setting headers
~~~~~~~~~~~~~~~
@@ -586,7 +612,7 @@ To tell the browser to treat the response as a file attachment, use the
this is how you might return a Microsoft Excel spreadsheet::
>>> response = HttpResponse(my_data, content_type='application/vnd.ms-excel')
- >>> response['Content-Disposition'] = 'attachment; filename=foo.xls'
+ >>> response['Content-Disposition'] = 'attachment; filename="foo.xls"'
There's nothing Django-specific about the ``Content-Disposition`` header, but
it's easy to forget the syntax, so we've included it here.
@@ -603,6 +629,13 @@ Attributes
The `HTTP Status code`_ for the response.
+.. attribute:: HttpResponse.streaming
+
+ This is always ``False``.
+
+ This attribute exists so middleware can treat streaming responses
+ differently from regular responses.
+
Methods
-------
@@ -646,17 +679,7 @@ Methods
Returns ``True`` or ``False`` based on a case-insensitive check for a
header with the given name.
-.. method:: HttpResponse.set_cookie(key, value='', max_age=None, expires=None, path='/', domain=None, secure=None, httponly=True)
-
- .. versionchanged:: 1.3
-
- The possibility of specifying a ``datetime.datetime`` object in
- ``expires``, and the auto-calculation of ``max_age`` in such case
- was added. The ``httponly`` argument was also added.
-
- .. versionchanged:: 1.4
-
- The default value for httponly was changed from ``False`` to ``True``.
+.. method:: HttpResponse.set_cookie(key, value='', max_age=None, expires=None, path='/', domain=None, secure=None, httponly=False)
Sets a cookie. The parameters are the same as in the :class:`Cookie.Morsel`
object in the Python standard library.
@@ -780,3 +803,60 @@ types of HTTP responses. Like ``HttpResponse``, these subclasses live in
method, Django will treat it as emulating a
:class:`~django.template.response.SimpleTemplateResponse`, and the
``render`` method must itself return a valid response object.
+
+StreamingHttpResponse objects
+=============================
+
+.. versionadded:: 1.5
+
+.. class:: StreamingHttpResponse
+
+The :class:`StreamingHttpResponse` class is used to stream a response from
+Django to the browser. You might want to do this if generating the response
+takes too long or uses too much memory. For instance, it's useful for
+generating large CSV files.
+
+.. admonition:: Performance considerations
+
+ Django is designed for short-lived requests. Streaming responses will tie
+ a worker process and keep a database connection idle in transaction for
+ the entire duration of the response. This may result in poor performance.
+
+ Generally speaking, you should perform expensive tasks outside of the
+ request-response cycle, rather than resorting to a streamed response.
+
+The :class:`StreamingHttpResponse` is not a subclass of :class:`HttpResponse`,
+because it features a slightly different API. However, it is almost identical,
+with the following notable differences:
+
+* It should be given an iterator that yields strings as content.
+
+* You cannot access its content, except by iterating the response object
+ itself. This should only occur when the response is returned to the client.
+
+* It has no ``content`` attribute. Instead, it has a
+ :attr:`~StreamingHttpResponse.streaming_content` attribute.
+
+* You cannot use the file-like object ``tell()`` or ``write()`` methods.
+ Doing so will raise an exception.
+
+:class:`StreamingHttpResponse` should only be used in situations where it is
+absolutely required that the whole content isn't iterated before transferring
+the data to the client. Because the content can't be accessed, many
+middlewares can't function normally. For example the ``ETag`` and ``Content-
+Length`` headers can't be generated for streaming responses.
+
+Attributes
+----------
+
+.. attribute:: StreamingHttpResponse.streaming_content
+
+ An iterator of strings representing the content.
+
+.. attribute:: HttpResponse.status_code
+
+ The `HTTP Status code`_ for the response.
+
+.. attribute:: HttpResponse.streaming
+
+ This is always ``True``.
diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
index 16d067172d..a909c12665 100644
--- a/docs/ref/settings.txt
+++ b/docs/ref/settings.txt
@@ -110,23 +110,20 @@ A tuple of authentication backend classes (as strings) to use when attempting to
authenticate a user. See the :doc:`authentication backends documentation
</ref/authbackends>` for details.
-.. setting:: AUTH_PROFILE_MODULE
+.. setting:: AUTH_USER_MODEL
-AUTH_PROFILE_MODULE
--------------------
+AUTH_USER_MODEL
+---------------
-Default: Not defined
+Default: 'auth.User'
-The site-specific user profile model used by this site. See
-:ref:`auth-profiles`.
+The model to use to represent a User. See :ref:`auth-custom-user`.
.. setting:: CACHES
CACHES
------
-.. versionadded:: 1.3
-
Default::
{
@@ -167,12 +164,6 @@ backend class (i.e. ``mypackage.backends.whatever.WhateverCache``).
Writing a whole new cache backend from scratch is left as an exercise
to the reader; see the other backends for examples.
-.. note::
- Prior to Django 1.3, you could use a URI based version of the backend
- name to reference the built-in cache backends (e.g., you could use
- ``'db://tablename'`` to refer to the database backend). This format has
- been deprecated, and will be removed in Django 1.5.
-
.. setting:: CACHES-KEY_FUNCTION
KEY_FUNCTION
@@ -534,8 +525,6 @@ Only supported for the ``mysql`` backend (see the `MySQL manual`_ for details).
TEST_DEPENDENCIES
~~~~~~~~~~~~~~~~~
-.. versionadded:: 1.3
-
Default: ``['default']``, for all databases other than ``default``,
which has no dependencies.
@@ -1262,8 +1251,6 @@ the ``locale`` directory (i.e. ``'/path/to/locale'``).
LOGGING
-------
-.. versionadded:: 1.3
-
Default: A logging configuration dictionary.
A data structure containing configuration information. The contents of
@@ -1278,8 +1265,6 @@ email log handler; all other log messages are given to a NullHandler.
LOGGING_CONFIG
--------------
-.. versionadded:: 1.3
-
Default: ``'django.utils.log.dictConfig'``
A path to a callable that will be used to configure logging in the
@@ -1371,13 +1356,11 @@ MEDIA_URL
Default: ``''`` (Empty string)
URL that handles the media served from :setting:`MEDIA_ROOT`, used
-for :doc:`managing stored files </topics/files>`.
+for :doc:`managing stored files </topics/files>`. It must end in a slash if set
+to a non-empty value.
Example: ``"http://media.example.com/"``
-.. versionchanged:: 1.3
- It must end in a slash if set to a non-empty value.
-
MESSAGE_LEVEL
-------------
@@ -1896,10 +1879,6 @@ A tuple of callables that are used to populate the context in ``RequestContext``
These callables take a request object as their argument and return a dictionary
of items to be merged into the context.
-.. versionadded:: 1.3
- The ``django.core.context_processors.static`` context processor
- was added in this release.
-
.. versionadded:: 1.4
The ``django.core.context_processors.tz`` context processor
was added in this release.
@@ -2160,8 +2139,6 @@ See also :setting:`TIME_ZONE`, :setting:`USE_I18N` and :setting:`USE_L10N`.
USE_X_FORWARDED_HOST
--------------------
-.. versionadded:: 1.3.1
-
Default: ``False``
A boolean that specifies whether to use the X-Forwarded-Host header in
@@ -2231,6 +2208,22 @@ ADMIN_MEDIA_PREFIX
integration. See the :doc:`Django 1.4 release notes</releases/1.4>` for
more information.
+.. setting:: AUTH_PROFILE_MODULE
+
+AUTH_PROFILE_MODULE
+-------------------
+
+.. deprecated:: 1.5
+ With the introduction of :ref:`custom User models <auth-custom-user>`,
+ the use of :setting:`AUTH_PROFILE_MODULE` to define a single profile
+ model is no longer supported. See the
+ :doc:`Django 1.5 release notes</releases/1.5>` for more information.
+
+Default: Not defined
+
+The site-specific user profile model used by this site. See
+:ref:`auth-profiles`.
+
.. setting:: IGNORABLE_404_ENDS
IGNORABLE_404_ENDS
diff --git a/docs/ref/signals.txt b/docs/ref/signals.txt
index b2f2e85abc..0db540370d 100644
--- a/docs/ref/signals.txt
+++ b/docs/ref/signals.txt
@@ -46,7 +46,7 @@ pre_init
.. ^^^^^^^ this :module: hack keeps Sphinx from prepending the module.
-Whenever you instantiate a Django model,, this signal is sent at the beginning
+Whenever you instantiate a Django model, this signal is sent at the beginning
of the model's :meth:`~django.db.models.Model.__init__` method.
Arguments sent with this signal:
@@ -118,8 +118,6 @@ Arguments sent with this signal:
records in the database as the database might not be in a
consistent state yet.
-.. versionadded:: 1.3
-
``using``
The database alias being used.
@@ -155,8 +153,6 @@ Arguments sent with this signal:
records in the database as the database might not be in a
consistent state yet.
-.. versionadded:: 1.3
-
``using``
The database alias being used.
@@ -183,8 +179,6 @@ Arguments sent with this signal:
``instance``
The actual instance being deleted.
-.. versionadded:: 1.3
-
``using``
The database alias being used.
@@ -209,8 +203,6 @@ Arguments sent with this signal:
Note that the object will no longer be in the database, so be very
careful what you do with this instance.
-.. versionadded:: 1.3
-
``using``
The database alias being used.
@@ -271,8 +263,6 @@ Arguments sent with this signal:
For the ``pre_clear`` and ``post_clear`` actions, this is ``None``.
-.. versionadded:: 1.3
-
``using``
The database alias being used.
@@ -287,13 +277,22 @@ like this::
# ...
toppings = models.ManyToManyField(Topping)
-If we would do something like this:
+If we connected a handler like this::
+
+ def toppings_changed(sender, **kwargs):
+ # Do something
+ pass
+
+ m2m_changed.connect(toppings_changed, sender=Pizza.toppings.through)
+
+and then did something like this::
>>> p = Pizza.object.create(...)
>>> t = Topping.objects.create(...)
>>> p.toppings.add(t)
-the arguments sent to a :data:`m2m_changed` handler would be:
+the arguments sent to a :data:`m2m_changed` handler (``topppings_changed`` in
+the example above) would be:
============== ============================================================
Argument Value
diff --git a/docs/ref/template-response.txt b/docs/ref/template-response.txt
index 9e09077adc..d9b7130362 100644
--- a/docs/ref/template-response.txt
+++ b/docs/ref/template-response.txt
@@ -2,8 +2,6 @@
TemplateResponse and SimpleTemplateResponse
===========================================
-.. versionadded:: 1.3
-
.. module:: django.template.response
:synopsis: Classes dealing with lazy-rendered HTTP responses.
diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt
index 48bd346788..db57d2de96 100644
--- a/docs/ref/templates/api.txt
+++ b/docs/ref/templates/api.txt
@@ -160,11 +160,6 @@ it. Example::
>>> t.render(Context({"person": PersonClass2}))
"My name is Samantha."
-.. versionchanged:: 1.3
- Previously, only variables that originated with an attribute lookup would
- be called by the template system. This change was made for consistency
- across lookup types.
-
Callable variables are slightly more complex than variables which only require
straight lookups. Here are some things to keep in mind:
@@ -438,7 +433,7 @@ django.contrib.auth.context_processors.auth
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
-``RequestContext`` will contain these three variables:
+``RequestContext`` will contain these variables:
* ``user`` -- An ``auth.User`` instance representing the currently
logged-in user (or an ``AnonymousUser`` instance, if the client isn't
@@ -448,11 +443,6 @@ If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
``django.contrib.auth.context_processors.PermWrapper``, representing the
permissions that the currently logged-in user has.
-.. versionchanged:: 1.3
- Prior to version 1.3, ``PermWrapper`` was located in
- ``django.contrib.auth.context_processors``.
-
-
django.core.context_processors.debug
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -491,8 +481,6 @@ django.core.context_processors.static
.. function:: django.core.context_processors.static
-.. versionadded:: 1.3
-
If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
``RequestContext`` will contain a variable ``STATIC_URL``, providing the
value of the :setting:`STATIC_URL` setting.
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index 072eebf69f..3b8d058fb4 100644
--- a/docs/ref/templates/builtins.txt
+++ b/docs/ref/templates/builtins.txt
@@ -156,8 +156,6 @@ In this syntax, each value gets interpreted as a literal string, and there's no
way to specify variable values. Or literal commas. Or spaces. Did we mention
you shouldn't use this syntax in any new projects?
-.. versionadded:: 1.3
-
By default, when you use the ``as`` keyword with the cycle tag, the
usage of ``{% cycle %}`` that declares the cycle will itself output
the first value in the cycle. This could be a problem if you want to
@@ -676,9 +674,6 @@ including it. This example produces the output ``"Hello, John"``:
{{ greeting }}, {{ person|default:"friend" }}!
-.. versionchanged:: 1.3
- Additional context and exclusive context.
-
You can pass additional context to the template using keyword arguments::
{% include "name_snippet.html" with person="Jane" greeting="Hello" %}
@@ -710,8 +705,6 @@ registered in ``somelibrary`` and ``otherlibrary`` located in package
{% load somelibrary package.otherlibrary %}
-.. versionchanged:: 1.3
-
You can also selectively load individual filters or tags from a library, using
the ``from`` argument. In this example, the template tags/filters named ``foo``
and ``bar`` will be loaded from ``somelibrary``::
@@ -1004,7 +997,7 @@ refer to the name of the pattern in the ``url`` tag instead of using the
path to the view.
Note that if the URL you're reversing doesn't exist, you'll get an
-:exc:`^django.core.urlresolvers.NoReverseMatch` exception raised, which will
+:exc:`~django.core.urlresolvers.NoReverseMatch` exception raised, which will
cause your site to display an error page.
If you'd like to retrieve a URL without displaying it, you can use a slightly
@@ -1076,9 +1069,6 @@ which is rounded up to 88).
with
^^^^
-.. versionchanged:: 1.3
- New keyword argument format and multiple variable assignments.
-
Caches a complex variable under a simpler name. This is useful when accessing
an "expensive" method (e.g., one that hits the database) multiple times.
@@ -1261,7 +1251,7 @@ S English ordinal suffix for day of the ``'st'``, ``'nd'``,
month, 2 characters.
t Number of days in the given month. ``28`` to ``31``
T Time zone of this machine. ``'EST'``, ``'MDT'``
-u Microseconds. ``0`` to ``999999``
+u Microseconds. ``000000`` to ``999999``
U Seconds since the Unix Epoch
(January 1 1970 00:00:00 UTC).
w Day of the week, digits without ``'0'`` (Sunday) to ``'6'`` (Saturday)
@@ -2126,8 +2116,6 @@ For example::
If ``value`` is ``"http://www.example.org/foo?a=b&c=d"``, the output will be
``"http%3A//www.example.org/foo%3Fa%3Db%26c%3Dd"``.
-.. versionadded:: 1.3
-
An optional argument containing the characters which should not be escaped can
be provided.
diff --git a/docs/ref/urlresolvers.txt b/docs/ref/urlresolvers.txt
new file mode 100644
index 0000000000..1bb33c7ca1
--- /dev/null
+++ b/docs/ref/urlresolvers.txt
@@ -0,0 +1,202 @@
+==============================================
+``django.core.urlresolvers`` utility functions
+==============================================
+
+.. module:: django.core.urlresolvers
+
+reverse()
+---------
+
+If you need to use something similar to the :ttag:`url` template tag in
+your code, Django provides the following function:
+
+.. function:: reverse(viewname, [urlconf=None, args=None, kwargs=None, current_app=None])
+
+``viewname`` is either the function name (either a function reference, or the
+string version of the name, if you used that form in ``urlpatterns``) or the
+:ref:`URL pattern name <naming-url-patterns>`. Normally, you won't need to
+worry about the ``urlconf`` parameter and will only pass in the positional and
+keyword arguments to use in the URL matching. For example::
+
+ from django.core.urlresolvers import reverse
+
+ def myview(request):
+ return HttpResponseRedirect(reverse('arch-summary', args=[1945]))
+
+The ``reverse()`` function can reverse a large variety of regular expression
+patterns for URLs, but not every possible one. The main restriction at the
+moment is that the pattern cannot contain alternative choices using the
+vertical bar (``"|"``) character. You can quite happily use such patterns for
+matching against incoming URLs and sending them off to views, but you cannot
+reverse such patterns.
+
+The ``current_app`` argument allows you to provide a hint to the resolver
+indicating the application to which the currently executing view belongs.
+This ``current_app`` argument is used as a hint to resolve application
+namespaces into URLs on specific application instances, according to the
+:ref:`namespaced URL resolution strategy <topics-http-reversing-url-namespaces>`.
+
+You can use ``kwargs`` instead of ``args``. For example::
+
+ >>> reverse('admin:app_list', kwargs={'app_label': 'auth'})
+ '/admin/auth/'
+
+``args`` and ``kwargs`` cannot be passed to ``reverse()`` at the same time.
+
+.. admonition:: Make sure your views are all correct.
+
+ As part of working out which URL names map to which patterns, the
+ ``reverse()`` function has to import all of your URLconf files and examine
+ the name of each view. This involves importing each view function. If
+ there are *any* errors whilst importing any of your view functions, it
+ will cause ``reverse()`` to raise an error, even if that view function is
+ not the one you are trying to reverse.
+
+ Make sure that any views you reference in your URLconf files exist and can
+ be imported correctly. Do not include lines that reference views you
+ haven't written yet, because those views will not be importable.
+
+.. note::
+
+ The string returned by ``reverse()`` is already
+ :ref:`urlquoted <uri-and-iri-handling>`. For example::
+
+ >>> reverse('cities', args=[u'Orléans'])
+ '.../Orl%C3%A9ans/'
+
+ Applying further encoding (such as :meth:`~django.utils.http.urlquote` or
+ ``urllib.quote``) to the output of ``reverse()`` may produce undesirable
+ results.
+
+reverse_lazy()
+--------------
+
+.. versionadded:: 1.4
+
+A lazily evaluated version of `reverse()`_.
+
+.. function:: reverse_lazy(viewname, [urlconf=None, args=None, kwargs=None, current_app=None])
+
+It is useful for when you need to use a URL reversal before your project's
+URLConf is loaded. Some common cases where this function is necessary are:
+
+* providing a reversed URL as the ``url`` attribute of a generic class-based
+ view.
+
+* providing a reversed URL to a decorator (such as the ``login_url`` argument
+ for the :func:`django.contrib.auth.decorators.permission_required`
+ decorator).
+
+* providing a reversed URL as a default value for a parameter in a function's
+ signature.
+
+resolve()
+---------
+
+The ``resolve()`` function can be used for resolving URL paths to the
+corresponding view functions. It has the following signature:
+
+.. function:: resolve(path, urlconf=None)
+
+``path`` is the URL path you want to resolve. As with
+:func:`~django.core.urlresolvers.reverse`, you don't need to
+worry about the ``urlconf`` parameter. The function returns a
+:class:`ResolverMatch` object that allows you
+to access various meta-data about the resolved URL.
+
+If the URL does not resolve, the function raises an
+:class:`~django.http.Http404` exception.
+
+.. class:: ResolverMatch
+
+ .. attribute:: ResolverMatch.func
+
+ The view function that would be used to serve the URL
+
+ .. attribute:: ResolverMatch.args
+
+ The arguments that would be passed to the view function, as
+ parsed from the URL.
+
+ .. attribute:: ResolverMatch.kwargs
+
+ The keyword arguments that would be passed to the view
+ function, as parsed from the URL.
+
+ .. attribute:: ResolverMatch.url_name
+
+ The name of the URL pattern that matches the URL.
+
+ .. attribute:: ResolverMatch.app_name
+
+ The application namespace for the URL pattern that matches the
+ URL.
+
+ .. attribute:: ResolverMatch.namespace
+
+ The instance namespace for the URL pattern that matches the
+ URL.
+
+ .. attribute:: ResolverMatch.namespaces
+
+ The list of individual namespace components in the full
+ instance namespace for the URL pattern that matches the URL.
+ i.e., if the namespace is ``foo:bar``, then namespaces will be
+ ``['foo', 'bar']``.
+
+A :class:`ResolverMatch` object can then be interrogated to provide
+information about the URL pattern that matches a URL::
+
+ # Resolve a URL
+ match = resolve('/some/path/')
+ # Print the URL pattern that matches the URL
+ print(match.url_name)
+
+A :class:`ResolverMatch` object can also be assigned to a triple::
+
+ func, args, kwargs = resolve('/some/path/')
+
+One possible use of :func:`~django.core.urlresolvers.resolve` would be to test
+whether a view would raise a ``Http404`` error before redirecting to it::
+
+ from urlparse import urlparse
+ from django.core.urlresolvers import resolve
+ from django.http import HttpResponseRedirect, Http404
+
+ def myview(request):
+ next = request.META.get('HTTP_REFERER', None) or '/'
+ response = HttpResponseRedirect(next)
+
+ # modify the request and response as required, e.g. change locale
+ # and set corresponding locale cookie
+
+ view, args, kwargs = resolve(urlparse(next)[2])
+ kwargs['request'] = request
+ try:
+ view(*args, **kwargs)
+ except Http404:
+ return HttpResponseRedirect('/')
+ return response
+
+
+permalink()
+-----------
+
+The :func:`~django.db.models.permalink` decorator is useful for writing short
+methods that return a full URL path. For example, a model's
+``get_absolute_url()`` method. See :func:`django.db.models.permalink` for more.
+
+get_script_prefix()
+-------------------
+
+.. function:: get_script_prefix()
+
+Normally, you should always use :func:`~django.core.urlresolvers.reverse` or
+:func:`~django.db.models.permalink` to define URLs within your application.
+However, if your application constructs part of the URL hierarchy itself, you
+may occasionally need to generate URLs. In that case, you need to be able to
+find the base URL of the Django project within its Web server
+(normally, :func:`~django.core.urlresolvers.reverse` takes care of this for
+you). In that case, you can call ``get_script_prefix()``, which will return the
+script prefix portion of the URL for your Django project. If your Django
+project is at the root of its Web server, this is always ``"/"``.
diff --git a/docs/ref/urls.txt b/docs/ref/urls.txt
new file mode 100644
index 0000000000..b9a0199984
--- /dev/null
+++ b/docs/ref/urls.txt
@@ -0,0 +1,156 @@
+======================================
+``django.conf.urls`` utility functions
+======================================
+
+.. module:: django.conf.urls
+
+.. versionchanged:: 1.4
+ Starting with Django 1.4 functions ``patterns``, ``url``, ``include`` plus
+ the ``handler*`` symbols described below live in the ``django.conf.urls``
+ module.
+
+ Until Django 1.3 they were located in ``django.conf.urls.defaults``. You
+ still can import them from there but it will be removed in Django 1.6.
+
+patterns()
+----------
+
+.. function:: patterns(prefix, pattern_description, ...)
+
+A function that takes a prefix, and an arbitrary number of URL patterns, and
+returns a list of URL patterns in the format Django needs.
+
+The first argument to ``patterns()`` is a string ``prefix``. See
+:ref:`The view prefix <urlpatterns-view-prefix>`.
+
+The remaining arguments should be tuples in this format::
+
+ (regular expression, Python callback function [, optional_dictionary [, optional_name]])
+
+The ``optional_dictionary`` and ``optional_name`` parameters are described in
+:ref:`Passing extra options to view functions <views-extra-options>`.
+
+.. note::
+ Because `patterns()` is a function call, it accepts a maximum of 255
+ arguments (URL patterns, in this case). This is a limit for all Python
+ function calls. This is rarely a problem in practice, because you'll
+ typically structure your URL patterns modularly by using `include()`
+ sections. However, on the off-chance you do hit the 255-argument limit,
+ realize that `patterns()` returns a Python list, so you can split up the
+ construction of the list.
+
+ ::
+
+ urlpatterns = patterns('',
+ ...
+ )
+ urlpatterns += patterns('',
+ ...
+ )
+
+ Python lists have unlimited size, so there's no limit to how many URL
+ patterns you can construct. The only limit is that you can only create 254
+ at a time (the 255th argument is the initial prefix argument).
+
+url()
+-----
+
+.. function:: url(regex, view, kwargs=None, name=None, prefix='')
+
+You can use the ``url()`` function, instead of a tuple, as an argument to
+``patterns()``. This is convenient if you want to specify a name without the
+optional extra arguments dictionary. For example::
+
+ urlpatterns = patterns('',
+ url(r'^index/$', index_view, name="main-view"),
+ ...
+ )
+
+This function takes five arguments, most of which are optional::
+
+ url(regex, view, kwargs=None, name=None, prefix='')
+
+See :ref:`Naming URL patterns <naming-url-patterns>` for why the ``name``
+parameter is useful.
+
+The ``prefix`` parameter has the same meaning as the first argument to
+``patterns()`` and is only relevant when you're passing a string as the
+``view`` parameter.
+
+include()
+---------
+
+.. function:: include(module[, namespace=None, app_name=None])
+ include(pattern_list)
+ include((pattern_list, app_namespace, instance_namespace))
+
+ A function that takes a full Python import path to another URLconf module
+ that should be "included" in this place. Optionally, the :term:`application
+ namespace` and :term:`instance namespace` where the entries will be included
+ into can also be specified.
+
+ ``include()`` also accepts as an argument either an iterable that returns
+ URL patterns or a 3-tuple containing such iterable plus the names of the
+ application and instance namespaces.
+
+ :arg module: URLconf module (or module name)
+ :type module: Module or string
+ :arg namespace: Instance namespace for the URL entries being included
+ :type namespace: string
+ :arg app_name: Application namespace for the URL entries being included
+ :type app_name: string
+ :arg pattern_list: Iterable of URL entries as returned by :func:`patterns`
+ :arg app_namespace: Application namespace for the URL entries being included
+ :type app_namespace: string
+ :arg instance_namespace: Instance namespace for the URL entries being included
+ :type instance_namespace: string
+
+See :ref:`including-other-urlconfs` and :ref:`namespaces-and-include`.
+
+handler403
+----------
+
+.. data:: handler403
+
+A callable, or a string representing the full Python import path to the view
+that should be called if the user doesn't have the permissions required to
+access a resource.
+
+By default, this is ``'django.views.defaults.permission_denied'``. That default
+value should suffice.
+
+See the documentation about :ref:`the 403 (HTTP Forbidden) view
+<http_forbidden_view>` for more information.
+
+.. versionadded:: 1.4
+ ``handler403`` is new in Django 1.4.
+
+handler404
+----------
+
+.. data:: handler404
+
+A callable, or a string representing the full Python import path to the view
+that should be called if none of the URL patterns match.
+
+By default, this is ``'django.views.defaults.page_not_found'``. That default
+value should suffice.
+
+See the documentation about :ref:`the 404 (HTTP Not Found) view
+<http_not_found_view>` for more information.
+
+handler500
+----------
+
+.. data:: handler500
+
+A callable, or a string representing the full Python import path to the view
+that should be called in case of server errors. Server errors happen when you
+have runtime errors in view code.
+
+By default, this is ``'django.views.defaults.server_error'``. That default
+value should suffice.
+
+See the documentation about :ref:`the 500 (HTTP Internal Server Error) view
+<http_internal_server_error_view>` for more information.
+
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt
index de19578cac..bd3898172a 100644
--- a/docs/ref/utils.txt
+++ b/docs/ref/utils.txt
@@ -170,6 +170,37 @@ The functions defined in this module share the following properties:
``tzinfo`` attribute is a :class:`~django.utils.tzinfo.FixedOffset`
instance.
+``django.utils.decorators``
+===========================
+
+.. module:: django.utils.decorators
+ :synopsis: Functions that help with creating decorators for views.
+
+.. function:: method_decorator(decorator)
+
+ Converts a function decorator into a method decorator. See :ref:`decorating
+ class based views<decorating-class-based-views>` for example usage.
+
+.. function:: decorator_from_middleware(middleware_class)
+
+ Given a middleware class, returns a view decorator. This lets you use
+ middleware functionality on a per-view basis. The middleware is created
+ with no params passed.
+
+.. function:: decorator_from_middleware_with_args(middleware_class)
+
+ Like ``decorator_from_middleware``, but returns a function
+ that accepts the arguments to be passed to the middleware_class.
+ For example, the :func:`~django.views.decorators.cache.cache_page`
+ decorator is created from the
+ :class:`~django.middleware.cache.CacheMiddleware` like this::
+
+ cache_page = decorator_from_middleware_with_args(CacheMiddleware)
+
+ @cache_page(3600)
+ def my_view(request):
+ pass
+
``django.utils.encoding``
=========================