Fixed #26124 -- Added missing code formatting to docs headers.

This commit is contained in:
rowanv 2016-01-24 22:26:11 +01:00 committed by Tim Graham
parent 8bf8d0e0ec
commit a6ef025dfb
93 changed files with 1658 additions and 1625 deletions

View File

@ -1,6 +1,6 @@
====================================
Writing custom django-admin commands
====================================
========================================
Writing custom ``django-admin`` commands
========================================
.. module:: django.core.management
@ -329,8 +329,8 @@ the :meth:`~BaseCommand.handle` method must be implemented.
.. _ref-basecommand-subclasses:
BaseCommand subclasses
----------------------
``BaseCommand`` subclasses
--------------------------
.. class:: AppCommand

View File

@ -25,8 +25,8 @@ version >= 2.2 and mod_wsgi >= 2.0. For example, you could:
.. _Subversion: http://subversion.tigris.org/
.. _mod_dav: https://httpd.apache.org/docs/2.2/mod/mod_dav.html
Authentication with mod_wsgi
============================
Authentication with ``mod_wsgi``
================================
.. note::
@ -100,8 +100,8 @@ details and information about alternative methods of authentication.
.. _Defining Application Groups: https://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#Defining_Application_Groups
.. _access control mechanisms documentation: https://code.google.com/p/modwsgi/wiki/AccessControlMechanisms
Authorization with mod_wsgi and Django groups
---------------------------------------------
Authorization with ``mod_wsgi`` and Django groups
-------------------------------------------------
mod_wsgi also provides functionality to restrict a particular location to
members of a group.

View File

@ -1,6 +1,6 @@
==========================================
How to use Django with Apache and mod_wsgi
==========================================
==============================================
How to use Django with Apache and ``mod_wsgi``
==============================================
Deploying Django with Apache_ and `mod_wsgi`_ is a tried and tested way to get
Django into production.
@ -91,8 +91,8 @@ should put in this file, and what else you can add to it.
See the :ref:`unicode-files` section of the Unicode reference guide for
details.
Using a virtualenv
==================
Using a ``virtualenv``
======================
If you install your project's Python dependencies inside a `virtualenv`_,
you'll need to add the path to this virtualenv's ``site-packages`` directory to
@ -113,8 +113,8 @@ Make sure you give the correct path to your virtualenv, and replace
.. _daemon-mode:
Using mod_wsgi daemon mode
==========================
Using ``mod_wsgi`` daemon mode
==============================
"Daemon mode" is the recommended mode for running mod_wsgi (on non-Windows
platforms). To create the required daemon process group and delegate the

View File

@ -29,8 +29,8 @@ matches the version you installed by executing::
python --version
About pip
=========
About ``pip``
=============
`pip`_ is a package manage for Python. It makes installing and uninstalling
Python packages (such as Django!) very easy. For the rest of the installation,

View File

@ -321,8 +321,8 @@ with the admin site:
* **admin.E035**: The value of ``readonly_fields[n]`` is not a callable, an
attribute of ``<ModelAdmin class>``, or an attribute of ``<model>``.
ModelAdmin
~~~~~~~~~~
``ModelAdmin``
~~~~~~~~~~~~~~
The following checks are performed on any
:class:`~django.contrib.admin.ModelAdmin` that is registered
@ -377,8 +377,8 @@ with the admin site:
* **admin.E128**: The value of ``date_hierarchy`` must be a ``DateField`` or
``DateTimeField``.
InlineModelAdmin
~~~~~~~~~~~~~~~~
``InlineModelAdmin``
~~~~~~~~~~~~~~~~~~~~
The following checks are performed on any
:class:`~django.contrib.admin.InlineModelAdmin` that is registered as an
@ -394,8 +394,8 @@ inline on a :class:`~django.contrib.admin.ModelAdmin`.
* **admin.E206**: The value of ``formset`` must inherit from
``BaseModelFormSet``.
GenericInlineModelAdmin
~~~~~~~~~~~~~~~~~~~~~~~
``GenericInlineModelAdmin``
~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following checks are performed on any
:class:`~django.contrib.contenttypes.admin.GenericInlineModelAdmin` that is
@ -409,8 +409,8 @@ registered as an inline on a :class:`~django.contrib.admin.ModelAdmin`.
* **admin.E304**: ``<model>`` has no ``GenericForeignKey`` using content type
field ``<field name>`` and object ID field ``<field name>``.
AdminSite
~~~~~~~~~
``AdminSite``
~~~~~~~~~~~~~
The following checks are performed on the default
:class:`~django.contrib.admin.AdminSite`:

View File

@ -13,8 +13,8 @@ views or various mixins. Because this inheritance chain is very important, the
ancestor classes are documented under the section title of **Ancestors (MRO)**.
MRO is an acronym for Method Resolution Order.
View
====
``View``
========
.. class:: django.views.generic.base.View
@ -102,8 +102,8 @@ View
Handles responding to requests for the OPTIONS HTTP verb. Returns a
list of the allowed HTTP method names for the view.
TemplateView
============
``TemplateView``
================
.. class:: django.views.generic.base.TemplateView
@ -154,8 +154,8 @@ TemplateView
* Populated (through :class:`~django.views.generic.base.ContextMixin`) with
the keyword arguments captured from the URL pattern that served the view.
RedirectView
============
``RedirectView``
================
.. class:: django.views.generic.base.RedirectView

View File

@ -11,8 +11,9 @@ documentation organized by the class which defines the behavior, see
Simple generic views
====================
View
----
``View``
--------
.. class:: View()
**Attributes** (with optional accessor):
@ -26,8 +27,9 @@ View
* ``head()``
* :meth:`~django.views.generic.base.View.http_method_not_allowed`
TemplateView
------------
``TemplateView``
----------------
.. class:: TemplateView()
**Attributes** (with optional accessor):
@ -48,8 +50,9 @@ TemplateView
* :meth:`~django.views.generic.base.View.http_method_not_allowed`
* :meth:`~django.views.generic.base.TemplateResponseMixin.render_to_response`
RedirectView
------------
``RedirectView``
----------------
.. class:: RedirectView()
**Attributes** (with optional accessor):
@ -75,8 +78,9 @@ RedirectView
Detail Views
============
DetailView
----------
``DetailView``
--------------
.. class:: DetailView()
**Attributes** (with optional accessor):
@ -109,8 +113,9 @@ DetailView
List Views
==========
ListView
--------
``ListView``
------------
.. class:: ListView()
**Attributes** (with optional accessor):
@ -145,8 +150,9 @@ ListView
Editing views
=============
FormView
--------
``FormView``
------------
.. class:: FormView()
**Attributes** (with optional accessor):
@ -175,8 +181,9 @@ FormView
* :meth:`~django.views.generic.edit.ProcessFormView.post`
* :meth:`~django.views.generic.edit.ProcessFormView.put`
CreateView
----------
``CreateView``
--------------
.. class:: CreateView()
**Attributes** (with optional accessor):
@ -217,8 +224,9 @@ CreateView
* ``put()``
* :meth:`~django.views.generic.base.TemplateResponseMixin.render_to_response`
UpdateView
----------
``UpdateView``
--------------
.. class:: UpdateView()
**Attributes** (with optional accessor):
@ -259,8 +267,9 @@ UpdateView
* ``put()``
* :meth:`~django.views.generic.base.TemplateResponseMixin.render_to_response`
DeleteView
----------
``DeleteView``
--------------
.. class:: DeleteView()
**Attributes** (with optional accessor):
@ -296,8 +305,9 @@ DeleteView
Date-based views
================
ArchiveIndexView
----------------
``ArchiveIndexView``
--------------------
.. class:: ArchiveIndexView()
**Attributes** (with optional accessor):
@ -334,8 +344,9 @@ ArchiveIndexView
* :meth:`~django.views.generic.list.MultipleObjectMixin.paginate_queryset`
* :meth:`~django.views.generic.base.TemplateResponseMixin.render_to_response`
YearArchiveView
---------------
``YearArchiveView``
-------------------
.. class:: YearArchiveView()
**Attributes** (with optional accessor):
@ -375,8 +386,9 @@ YearArchiveView
* :meth:`~django.views.generic.list.MultipleObjectMixin.paginate_queryset`
* :meth:`~django.views.generic.base.TemplateResponseMixin.render_to_response`
MonthArchiveView
----------------
``MonthArchiveView``
--------------------
.. class:: MonthArchiveView()
**Attributes** (with optional accessor):
@ -419,8 +431,9 @@ MonthArchiveView
* :meth:`~django.views.generic.list.MultipleObjectMixin.paginate_queryset`
* :meth:`~django.views.generic.base.TemplateResponseMixin.render_to_response`
WeekArchiveView
---------------
``WeekArchiveView``
-------------------
.. class:: WeekArchiveView()
**Attributes** (with optional accessor):
@ -461,8 +474,9 @@ WeekArchiveView
* :meth:`~django.views.generic.list.MultipleObjectMixin.paginate_queryset`
* :meth:`~django.views.generic.base.TemplateResponseMixin.render_to_response`
DayArchiveView
--------------
``DayArchiveView``
------------------
.. class:: DayArchiveView()
**Attributes** (with optional accessor):
@ -509,8 +523,9 @@ DayArchiveView
* :meth:`~django.views.generic.list.MultipleObjectMixin.paginate_queryset`
* :meth:`~django.views.generic.base.TemplateResponseMixin.render_to_response`
TodayArchiveView
----------------
``TodayArchiveView``
--------------------
.. class:: TodayArchiveView()
**Attributes** (with optional accessor):
@ -557,8 +572,9 @@ TodayArchiveView
* :meth:`~django.views.generic.list.MultipleObjectMixin.paginate_queryset`
* :meth:`~django.views.generic.base.TemplateResponseMixin.render_to_response`
DateDetailView
--------------
``DateDetailView``
------------------
.. class:: DateDetailView()
**Attributes** (with optional accessor):

View File

@ -22,8 +22,8 @@ views for displaying drilldown pages for date-based data.
def get_absolute_url(self):
return reverse('article-detail', kwargs={'pk': self.pk})
ArchiveIndexView
================
``ArchiveIndexView``
====================
.. class:: ArchiveIndexView
@ -86,8 +86,8 @@ ArchiveIndexView
This will output all articles.
YearArchiveView
===============
``YearArchiveView``
===================
.. class:: YearArchiveView
@ -191,8 +191,8 @@ YearArchiveView
{% endfor %}
</div>
MonthArchiveView
================
``MonthArchiveView``
====================
.. class:: MonthArchiveView
@ -288,8 +288,8 @@ MonthArchiveView
{% endif %}
</p>
WeekArchiveView
===============
``WeekArchiveView``
===================
.. class:: WeekArchiveView
@ -391,8 +391,8 @@ WeekArchiveView
output format that supports the US based week system. The :tfilter:`date`
filter ``'%U'`` outputs the number of seconds since the Unix epoch.
DayArchiveView
==============
``DayArchiveView``
==================
.. class:: DayArchiveView
@ -493,8 +493,8 @@ DayArchiveView
{% endif %}
</p>
TodayArchiveView
================
``TodayArchiveView``
====================
.. class:: TodayArchiveView
@ -550,8 +550,8 @@ TodayArchiveView
a different template, set the ``template_name`` attribute to be the
name of the new template.
DateDetailView
==============
``DateDetailView``
==================
.. class:: DateDetailView

View File

@ -5,8 +5,8 @@ Generic display views
The two following generic class-based views are designed to display data. On
many projects they are typically the most commonly used views.
DetailView
==========
``DetailView``
==============
.. class:: django.views.generic.detail.DetailView
@ -72,8 +72,8 @@ DetailView
<p>Published: {{ object.pub_date|date }}</p>
<p>Date: {{ now|date }}</p>
ListView
========
``ListView``
============
.. class:: django.views.generic.list.ListView

View File

@ -24,8 +24,8 @@ editing content:
def get_absolute_url(self):
return reverse('author-detail', kwargs={'pk': self.pk})
FormView
========
``FormView``
============
.. class:: django.views.generic.edit.FormView
@ -80,8 +80,8 @@ FormView
</form>
CreateView
==========
``CreateView``
==============
.. class:: django.views.generic.edit.CreateView
@ -135,8 +135,8 @@ CreateView
<input type="submit" value="Create" />
</form>
UpdateView
==========
``UpdateView``
==============
.. class:: django.views.generic.edit.UpdateView
@ -192,8 +192,8 @@ UpdateView
<input type="submit" value="Update" />
</form>
DeleteView
==========
``DeleteView``
==============
.. class:: django.views.generic.edit.DeleteView

View File

@ -10,8 +10,8 @@ Date-based mixins
:func:`~time.strftime` format characters. Do not try to use the format
characters from the :ttag:`now` template tag as they are not compatible.
YearMixin
=========
``YearMixin``
=============
.. class:: YearMixin
@ -62,8 +62,8 @@ YearMixin
:attr:`~BaseDateListView.allow_empty` and
:attr:`~DateMixin.allow_future`.
MonthMixin
==========
``MonthMixin``
==============
.. class:: MonthMixin
@ -114,8 +114,8 @@ MonthMixin
:attr:`~BaseDateListView.allow_empty` and
:attr:`~DateMixin.allow_future`.
DayMixin
========
``DayMixin``
============
.. class:: DayMixin
@ -166,8 +166,8 @@ DayMixin
:attr:`~BaseDateListView.allow_empty` and
:attr:`~DateMixin.allow_future`.
WeekMixin
=========
``WeekMixin``
=============
.. class:: WeekMixin
@ -219,8 +219,8 @@ WeekMixin
:attr:`~BaseDateListView.allow_empty` and
:attr:`~DateMixin.allow_future`.
DateMixin
=========
``DateMixin``
=============
.. class:: DateMixin
@ -265,8 +265,8 @@ DateMixin
is greater than the current date/time. Returns
:attr:`~DateMixin.allow_future` by default.
BaseDateListView
================
``BaseDateListView``
====================
.. class:: BaseDateListView

View File

@ -14,8 +14,8 @@ The following mixins are used to construct Django's editing views:
Examples of how these are combined into editing views can be found at
the documentation on :doc:`/ref/class-based-views/generic-editing`.
FormMixin
=========
``FormMixin``
=============
.. class:: django.views.generic.edit.FormMixin
@ -94,8 +94,8 @@ FormMixin
Calls :meth:`get_form` and adds the result to the context data with the
name 'form'.
ModelFormMixin
==============
``ModelFormMixin``
==================
.. class:: django.views.generic.edit.ModelFormMixin
@ -180,8 +180,8 @@ ModelFormMixin
Renders a response, providing the invalid form as context.
ProcessFormView
===============
``ProcessFormView``
===================
.. class:: django.views.generic.edit.ProcessFormView
@ -220,8 +220,8 @@ ProcessFormView
through to :meth:`post`.
DeletionMixin
=============
``DeletionMixin``
=================
.. class:: django.views.generic.edit.DeletionMixin

View File

@ -2,8 +2,8 @@
Multiple object mixins
======================
MultipleObjectMixin
===================
``MultipleObjectMixin``
=======================
.. class:: django.views.generic.list.MultipleObjectMixin
@ -192,8 +192,8 @@ MultipleObjectMixin
this context variable will be ``None``.
MultipleObjectTemplateResponseMixin
===================================
``MultipleObjectTemplateResponseMixin``
=======================================
.. class:: django.views.generic.list.MultipleObjectTemplateResponseMixin

View File

@ -2,8 +2,8 @@
Simple mixins
=============
ContextMixin
============
``ContextMixin``
================
.. class:: django.views.generic.base.ContextMixin
@ -31,8 +31,8 @@ ContextMixin
the documentation on :ref:`rendering a template context
<alters-data-description>`.
TemplateResponseMixin
=====================
``TemplateResponseMixin``
=========================
.. class:: django.views.generic.base.TemplateResponseMixin

View File

@ -2,8 +2,8 @@
Single object mixins
====================
SingleObjectMixin
=================
``SingleObjectMixin``
=====================
.. class:: django.views.generic.detail.SingleObjectMixin
@ -131,8 +131,8 @@ SingleObjectMixin
default this simply returns the value of :attr:`slug_field`.
SingleObjectTemplateResponseMixin
=================================
``SingleObjectTemplateResponseMixin``
=====================================
.. class:: django.views.generic.detail.SingleObjectTemplateResponseMixin

View File

@ -51,8 +51,8 @@ decorators if it is not already present in the response.
How to use it
=============
Setting X-Frame-Options for all responses
-----------------------------------------
Setting ``X-Frame-Options`` for all responses
---------------------------------------------
To set the same ``X-Frame-Options`` value for all responses in your site, put
``'django.middleware.clickjacking.XFrameOptionsMiddleware'`` to
@ -85,8 +85,8 @@ that tells the middleware not to set the header::
return HttpResponse("This page is safe to load in a frame on any site.")
Setting X-Frame-Options per view
--------------------------------
Setting ``X-Frame-Options`` per view
------------------------------------
To set the ``X-Frame-Options`` header on a per view basis, Django provides these
decorators::
@ -113,8 +113,8 @@ The ``X-Frame-Options`` header will only protect against clickjacking in a
modern browser. Older browsers will quietly ignore the header and need `other
clickjacking prevention techniques`_.
Browsers that support X-Frame-Options
-------------------------------------
Browsers that support ``X-Frame-Options``
-----------------------------------------
* Internet Explorer 8+
* Firefox 3.6.9+

View File

@ -101,8 +101,8 @@ Other topics
admin.site.register(Author)
The register decorator
----------------------
The ``register`` decorator
--------------------------
.. function:: register(*models, site=django.admin.sites.site)

View File

@ -9,8 +9,8 @@ topic guide </topics/auth/index>`.
.. currentmodule:: django.contrib.auth
User
====
``User`` model
==============
Fields
------
@ -262,8 +262,8 @@ Manager methods
:attr:`~models.User.is_superuser` to ``True``.
Anonymous users
===============
``AnonymousUser`` object
========================
.. class:: models.AnonymousUser
@ -296,8 +296,8 @@ In practice, you probably won't need to use
:class:`~django.contrib.auth.models.AnonymousUser` objects on your own, but
they're used by Web requests, as explained in the next section.
Permission
==========
``Permission`` model
====================
.. class:: models.Permission
@ -328,8 +328,8 @@ Methods
:class:`~django.contrib.auth.models.Permission` objects have the standard
data-access methods like any other :doc:`Django model </ref/models/instances>`.
Group
=====
``Group`` model
===============
.. class:: models.Group

View File

@ -2,8 +2,8 @@
GeoDjango Management Commands
=============================
inspectdb
=========
``inspectdb``
=============
.. describe:: django-admin inspectdb
@ -12,8 +12,8 @@ When :mod:`django.contrib.gis` is in your :setting:`INSTALLED_APPS`, the
The overridden command is spatially-aware, and places geometry fields in the
auto-generated model definition, where appropriate.
ogrinspect
==========
``ogrinspect``
==============
.. django-admin:: ogrinspect data_source model_name

View File

@ -35,8 +35,8 @@ Measurement Relationships Operations Editors
:class:`Translate`
================== ======================= ====================== =================== ================== =====================
Area
====
``Area``
========
.. class:: Area(expression, **extra)
@ -47,8 +47,8 @@ field as an :class:`~django.contrib.gis.measure.Area` measure. On MySQL, a raw
float value is returned, as it's not possible to automatically determine the
unit of the field.
AsGeoJSON
=========
``AsGeoJSON``
=============
.. class:: AsGeoJSON(expression, bbox=False, crs=False, precision=8, **extra)
@ -79,8 +79,8 @@ Keyword Argument Description
representation -- the default value is 8.
===================== =====================================================
AsGML
=====
``AsGML``
=========
.. class:: AsGML(expression, version=2, precision=8, **extra)
@ -110,8 +110,8 @@ Keyword Argument Description
__ https://en.wikipedia.org/wiki/Geography_Markup_Language
AsKML
=====
``AsKML``
=========
.. class:: AsKML(expression, precision=8, **extra)
@ -137,8 +137,8 @@ Keyword Argument Description
__ https://developers.google.com/kml/documentation/
AsSVG
=====
``AsSVG``
=========
.. class:: AsSVG(expression, relative=False, precision=8, **extra)
@ -161,8 +161,8 @@ Keyword Argument Description
__ http://www.w3.org/Graphics/SVG/
BoundingCircle
==============
``BoundingCircle``
==================
.. class:: BoundingCircle(expression, num_seg=48, **extra)
@ -171,8 +171,8 @@ BoundingCircle
Accepts a single geographic field or expression and returns the smallest circle
polygon that can fully contain the geometry.
Centroid
========
``Centroid``
============
.. class:: Centroid(expression, **extra)
@ -181,8 +181,8 @@ Centroid
Accepts a single geographic field or expression and returns the ``centroid``
value of the geometry.
Difference
==========
``Difference``
==============
.. class:: Difference(expr1, expr2, **extra)
@ -196,8 +196,8 @@ geometry B.
MySQL support was added.
Distance
========
``Distance``
============
.. class:: Distance(expr1, expr2, spheroid=None, **extra)
@ -240,8 +240,8 @@ queryset is calculated::
in kilometers. See :doc:`measure` for usage details and the list of
:ref:`supported_units`.
Envelope
========
``Envelope``
============
.. class:: Envelope(expression, **extra)
@ -250,8 +250,8 @@ Envelope
Accepts a single geographic field or expression and returns the geometry
representing the bounding box of the geometry.
ForceRHR
========
``ForceRHR``
============
.. class:: ForceRHR(expression, **extra)
@ -261,8 +261,8 @@ Accepts a single geographic field or expression and returns a modified version
of the polygon/multipolygon in which all of the vertices follow the
right-hand rule.
GeoHash
=======
``GeoHash``
===========
.. class:: GeoHash(expression, **extra)
@ -277,8 +277,8 @@ representation of the geometry.
__ https://en.wikipedia.org/wiki/Geohash
Intersection
============
``Intersection``
================
.. class:: Intersection(expr1, expr2, **extra)
@ -291,8 +291,8 @@ intersection between them.
MySQL support was added.
Length
======
``Length``
==========
.. class:: Length(expression, spheroid=True, **extra)
@ -308,8 +308,8 @@ specify if the calculation should be based on a simple sphere (less
accurate, less resource-intensive) or on a spheroid (more accurate, more
resource-intensive) with the ``spheroid`` keyword argument.
MemSize
=======
``MemSize``
===========
.. class:: MemSize(expression, **extra)
@ -318,8 +318,8 @@ MemSize
Accepts a single geographic field or expression and returns the memory size
(number of bytes) that the geometry field takes.
NumGeometries
=============
``NumGeometries``
=================
.. class:: NumGeometries(expression, **extra)
@ -329,8 +329,8 @@ Accepts a single geographic field or expression and returns the number of
geometries if the geometry field is a collection (e.g., a ``GEOMETRYCOLLECTION``
or ``MULTI*`` field); otherwise returns ``None``.
NumPoints
=========
``NumPoints``
=============
.. class:: NumPoints(expression, **extra)
@ -339,8 +339,8 @@ NumPoints
Accepts a single geographic field or expression and returns the number of points
in the first linestring in the geometry field; otherwise returns ``None``.
Perimeter
=========
``Perimeter``
=============
.. class:: Perimeter(expression, **extra)
@ -351,8 +351,8 @@ geometry field as a :class:`~django.contrib.gis.measure.Distance` object. On
MySQL, a raw float value is returned, as it's not possible to automatically
determine the unit of the field.
PointOnSurface
==============
``PointOnSurface``
==================
.. class:: PointOnSurface(expression, **extra)
@ -361,8 +361,8 @@ PointOnSurface
Accepts a single geographic field or expression and returns a ``Point`` geometry
guaranteed to lie on the surface of the field; otherwise returns ``None``.
Reverse
=======
``Reverse``
===========
.. class:: Reverse(expression, **extra)
@ -371,8 +371,8 @@ Reverse
Accepts a single geographic field or expression and returns a geometry with
reversed coordinates.
Scale
=====
``Scale``
=========
.. class:: Scale(expression, x, y, z=0.0, **extra)
@ -382,8 +382,8 @@ Accepts a single geographic field or expression and returns a geometry with
scaled coordinates by multiplying them with the ``x``, ``y``, and optionally
``z`` parameters.
SnapToGrid
==========
``SnapToGrid``
==============
.. class:: SnapToGrid(expression, *args, **extra)
@ -402,8 +402,8 @@ Number of Arguments Description
4 X, Y sizes and the corresponding X, Y origins.
=================== =====================================================
SymDifference
=============
``SymDifference``
=================
.. class:: SymDifference(expr1, expr2, **extra)
@ -417,8 +417,8 @@ parameters.
MySQL support was added.
Transform
=========
``Transform``
=============
.. class:: Transform(expression, srid, **extra)
@ -434,8 +434,8 @@ the transformed geometry to the spatial reference system specified by the
the spatial database used. In other words, the SRID numbers used for Oracle
are not necessarily the same as those used by PostGIS.
Translate
=========
``Translate``
=============
.. class:: Translate(expression, x, y, z=0.0, **extra)
@ -445,8 +445,8 @@ Accepts a single geographic field or expression and returns a geometry with
its coordinates offset by the ``x``, ``y``, and optionally ``z`` numeric
parameters.
Union
=====
``Union``
=========
.. class:: Union(expr1, expr2, **extra)

View File

@ -1531,8 +1531,8 @@ Settings
.. setting:: GDAL_LIBRARY_PATH
GDAL_LIBRARY_PATH
-----------------
``GDAL_LIBRARY_PATH``
---------------------
A string specifying the location of the GDAL library. Typically,
this setting is only used if the GDAL library is in a non-standard

View File

@ -60,8 +60,8 @@ usage::
.. setting:: GEOIP_PATH
GEOIP_PATH
----------
``GEOIP_PATH``
--------------
A string specifying the directory where the GeoIP data files are
located. This setting is *required* unless manually specified
@ -69,8 +69,8 @@ with ``path`` keyword when initializing the :class:`GeoIP` object.
.. setting:: GEOIP_LIBRARY_PATH
GEOIP_LIBRARY_PATH
------------------
``GEOIP_LIBRARY_PATH``
----------------------
A string specifying the location of the GeoIP C library. Typically,
this setting is only used if the GeoIP C library is in a non-standard
@ -78,16 +78,16 @@ location (e.g., ``/home/sue/lib/libGeoIP.so``).
.. setting:: GEOIP_COUNTRY
GEOIP_COUNTRY
-------------
``GEOIP_COUNTRY``
-----------------
The basename to use for the GeoIP country data file.
Defaults to ``'GeoIP.dat'``.
.. setting:: GEOIP_CITY
GEOIP_CITY
----------
``GEOIP_CITY``
--------------
The basename to use for the GeoIP city data file.
Defaults to ``'GeoLiteCity.dat'``.

View File

@ -54,8 +54,8 @@ Here is an example of its usage::
.. setting:: GEOIP_PATH
GEOIP_PATH
----------
``GEOIP_PATH``
--------------
A string specifying the directory where the GeoIP data files are
located. This setting is *required* unless manually specified
@ -63,16 +63,16 @@ with ``path`` keyword when initializing the :class:`GeoIP2` object.
.. setting:: GEOIP_COUNTRY
GEOIP_COUNTRY
-------------
``GEOIP_COUNTRY``
-----------------
The basename to use for the GeoIP country data file. Defaults to
``'GeoLite2-Country.mmdb'``.
.. setting:: GEOIP_CITY
GEOIP_CITY
----------
``GEOIP_CITY``
--------------
The basename to use for the GeoIP city data file. Defaults to
``'GeoLite2-City.mmdb'``.

View File

@ -23,8 +23,8 @@ compatible with a particular spatial backend, refer to the
.. fieldlookup:: bbcontains
bbcontains
----------
``bbcontains``
--------------
*Availability*: PostGIS, MySQL, SpatiaLite
@ -45,8 +45,8 @@ SpatiaLite ``MbrContains(poly, geom)``
.. fieldlookup:: bboverlaps
bboverlaps
----------
``bboverlaps``
--------------
*Availability*: PostGIS, MySQL, SpatiaLite
@ -67,8 +67,8 @@ SpatiaLite ``MbrOverlaps(poly, geom)``
.. fieldlookup:: contained
contained
---------
``contained``
-------------
*Availability*: PostGIS, MySQL, SpatiaLite
@ -89,8 +89,8 @@ SpatiaLite ``MbrWithin(poly, geom)``
.. fieldlookup:: gis-contains
contains
--------
``contains``
------------
*Availability*: PostGIS, Oracle, MySQL, SpatiaLite
@ -111,8 +111,8 @@ SpatiaLite ``Contains(poly, geom)``
.. fieldlookup:: contains_properly
contains_properly
-----------------
``contains_properly``
---------------------
*Availability*: PostGIS
@ -131,8 +131,8 @@ PostGIS ``ST_ContainsProperly(poly, geom)``
.. fieldlookup:: coveredby
coveredby
---------
``coveredby``
-------------
*Availability*: PostGIS, Oracle
@ -152,8 +152,8 @@ Oracle ``SDO_COVEREDBY(poly, geom)``
.. fieldlookup:: covers
covers
------
``covers``
----------
*Availability*: PostGIS, Oracle
@ -173,8 +173,8 @@ Oracle ``SDO_COVERS(poly, geom)``
.. fieldlookup:: crosses
crosses
-------
``crosses``
-----------
*Availability*: PostGIS, SpatiaLite
@ -193,8 +193,8 @@ SpatiaLite ``Crosses(poly, geom)``
.. fieldlookup:: disjoint
disjoint
--------
``disjoint``
------------
*Availability*: PostGIS, Oracle, MySQL, SpatiaLite
@ -215,23 +215,23 @@ SpatiaLite ``Disjoint(poly, geom)``
.. fieldlookup:: equals
equals
------
``equals``
----------
*Availability*: PostGIS, Oracle, MySQL, SpatiaLite
.. fieldlookup:: exact
.. fieldlookup:: same_as
exact, same_as
--------------
``exact``, ``same_as``
----------------------
*Availability*: PostGIS, Oracle, MySQL, SpatiaLite
.. fieldlookup:: intersects
intersects
----------
``intersects``
--------------
*Availability*: PostGIS, Oracle, MySQL, SpatiaLite
@ -252,15 +252,15 @@ SpatiaLite ``Intersects(poly, geom)``
.. fieldlookup:: overlaps
overlaps
--------
``overlaps``
------------
*Availability*: PostGIS, Oracle, MySQL, SpatiaLite
.. fieldlookup:: relate
relate
------
``relate``
----------
*Availability*: PostGIS, Oracle, SpatiaLite
@ -311,8 +311,8 @@ Oracle SQL equivalent::
.. fieldlookup:: touches
touches
-------
``touches``
-----------
*Availability*: PostGIS, Oracle, MySQL, SpatiaLite
@ -333,8 +333,8 @@ SpatiaLite ``Touches(poly, geom)``
.. fieldlookup:: within
within
------
``within``
----------
*Availability*: PostGIS, Oracle, MySQL, SpatiaLite
@ -355,8 +355,8 @@ SpatiaLite ``Within(poly, geom)``
.. fieldlookup:: left
left
----
``left``
--------
*Availability*: PostGIS
@ -373,8 +373,8 @@ PostGIS equivalent::
.. fieldlookup:: right
right
-----
``right``
---------
*Availability*: PostGIS
@ -391,8 +391,8 @@ PostGIS equivalent::
.. fieldlookup:: overlaps_left
overlaps_left
-------------
``overlaps_left``
-----------------
*Availability*: PostGIS
@ -410,8 +410,8 @@ PostGIS equivalent::
.. fieldlookup:: overlaps_right
overlaps_right
--------------
``overlaps_right``
------------------
*Availability*: PostGIS
@ -428,8 +428,8 @@ PostGIS equivalent::
.. fieldlookup:: overlaps_above
overlaps_above
--------------
``overlaps_above``
------------------
*Availability*: PostGIS
@ -446,8 +446,8 @@ PostGIS equivalent::
.. fieldlookup:: overlaps_below
overlaps_below
--------------
``overlaps_below``
------------------
*Availability*: PostGIS
@ -464,8 +464,8 @@ PostGIS equivalent::
.. fieldlookup:: strictly_above
strictly_above
--------------
``strictly_above``
------------------
*Availability*: PostGIS
@ -482,8 +482,8 @@ PostGIS equivalent::
.. fieldlookup:: strictly_below
strictly_below
--------------
``strictly_below``
------------------
*Availability*: PostGIS
@ -532,8 +532,8 @@ function is used with projected coordinate systems.
.. fieldlookup:: distance_gt
distance_gt
-----------
``distance_gt``
---------------
Returns models where the distance to the geometry field from the lookup
geometry is greater than the given distance value.
@ -552,8 +552,8 @@ SpatiaLite ``Distance(poly, geom) > 5``
.. fieldlookup:: distance_gte
distance_gte
------------
``distance_gte``
----------------
Returns models where the distance to the geometry field from the lookup
geometry is greater than or equal to the given distance value.
@ -572,8 +572,8 @@ SpatiaLite ``Distance(poly, geom) >= 5``
.. fieldlookup:: distance_lt
distance_lt
-----------
``distance_lt``
---------------
Returns models where the distance to the geometry field from the lookup
geometry is less than the given distance value.
@ -592,8 +592,8 @@ SpatiaLite ``Distance(poly, geom) < 5``
.. fieldlookup:: distance_lte
distance_lte
------------
``distance_lte``
----------------
Returns models where the distance to the geometry field from the lookup
geometry is less than or equal to the given distance value.
@ -612,8 +612,8 @@ SpatiaLite ``Distance(poly, geom) <= 5``
.. fieldlookup:: dwithin
dwithin
-------
``dwithin``
-----------
Returns models where the distance to the geometry field from the lookup
geometry are within the given distance from one another. Note that you can only

View File

@ -1107,8 +1107,8 @@ Settings
.. setting:: GEOS_LIBRARY_PATH
GEOS_LIBRARY_PATH
-----------------
``GEOS_LIBRARY_PATH``
---------------------
A string specifying the location of the GEOS C library. Typically,
this setting is only used if the GEOS C library is in a non-standard

View File

@ -1,6 +1,6 @@
==================
GeoJSON Serializer
==================
======================
``GeoJSON`` Serializer
======================
.. module:: django.contrib.gis.serializers.geojson
:synopsis: Serialization of GeoDjango models in the GeoJSON format.

View File

@ -1,6 +1,6 @@
========================
django.contrib.humanize
========================
===========================
``django.contrib.humanize``
===========================
.. module:: django.contrib.humanize
:synopsis: A set of Django template filters useful for adding a "human
@ -15,8 +15,8 @@ filters.
.. templatefilter:: apnumber
apnumber
========
``apnumber``
============
For numbers 1-9, returns the number spelled out. Otherwise, returns the
number. This follows Associated Press style.
@ -31,8 +31,8 @@ You can pass in either an integer or a string representation of an integer.
.. templatefilter:: intcomma
intcomma
========
``intcomma``
============
Converts an integer to a string containing commas every three digits.
@ -53,8 +53,8 @@ You can pass in either an integer or a string representation of an integer.
.. templatefilter:: intword
intword
=======
``intword``
===========
Converts a large integer to a friendly text representation. Works best for
numbers over 1 million.
@ -78,8 +78,8 @@ You can pass in either an integer or a string representation of an integer.
.. templatefilter:: naturalday
naturalday
==========
``naturalday``
==============
For dates that are the current day or within one day, return "today",
"tomorrow" or "yesterday", as appropriate. Otherwise, format the date using
@ -97,8 +97,8 @@ Examples (when 'today' is 17 Feb 2007):
.. templatefilter:: naturaltime
naturaltime
===========
``naturaltime``
===============
For datetime values, returns a string representing how many seconds,
minutes or hours ago it was -- falling back to the :tfilter:`timesince`
@ -129,8 +129,8 @@ Examples (when 'now' is 17 Feb 2007 16:30:00):
.. templatefilter:: ordinal
ordinal
=======
``ordinal``
===========
Converts an integer to its ordinal as a string.

View File

@ -36,8 +36,8 @@ those packages have.
staticfiles
syndication
admin
=====
``admin``
=========
The automatic Django administrative interface. For more information, see
:doc:`Tutorial 2 </intro/tutorial02>` and the
@ -45,23 +45,23 @@ The automatic Django administrative interface. For more information, see
Requires the auth_ and contenttypes_ contrib packages to be installed.
auth
====
``auth``
========
Django's authentication framework.
See :doc:`/topics/auth/index`.
contenttypes
============
``contenttypes``
================
A light framework for hooking into "types" of content, where each installed
Django model is a separate content type.
See the :doc:`contenttypes documentation </ref/contrib/contenttypes>`.
flatpages
=========
``flatpages``
=============
A framework for managing simple "flat" HTML content in a database.
@ -69,52 +69,52 @@ See the :doc:`flatpages documentation </ref/contrib/flatpages>`.
Requires the sites_ contrib package to be installed as well.
gis
====
``gis``
=======
A world-class geospatial framework built on top of Django, that enables
storage, manipulation and display of spatial data.
See the :doc:`/ref/contrib/gis/index` documentation for more.
humanize
========
``humanize``
============
A set of Django template filters useful for adding a "human touch" to data.
See the :doc:`humanize documentation </ref/contrib/humanize>`.
messages
========
``messages``
============
A framework for storing and retrieving temporary cookie- or session-based
messages
See the :doc:`messages documentation </ref/contrib/messages>`.
postgres
========
``postgres``
============
A collection of PostgreSQL specific features.
See the :doc:`contrib.postgres documentation </ref/contrib/postgres/index>`.
redirects
=========
``redirects``
=============
A framework for managing redirects.
See the :doc:`redirects documentation </ref/contrib/redirects>`.
sessions
========
``sessions``
============
A framework for storing data in anonymous sessions.
See the :doc:`sessions documentation </topics/http/sessions>`.
sites
=====
``sites``
=========
A light framework that lets you operate multiple websites off of the same
database and Django installation. It gives you hooks for associating objects to
@ -122,15 +122,15 @@ one or more sites.
See the :doc:`sites documentation </ref/contrib/sites>`.
sitemaps
========
``sitemaps``
============
A framework for generating Google sitemap XML files.
See the :doc:`sitemaps documentation </ref/contrib/sitemaps>`.
syndication
===========
``syndication``
===============
A framework for generating syndication feeds, in RSS and Atom, quite easily.

View File

@ -21,47 +21,47 @@ These functions are described in more detail in the `PostgreSQL docs
General-purpose aggregation functions
=====================================
ArrayAgg
--------
``ArrayAgg``
------------
.. class:: ArrayAgg(expression, **extra)
Returns a list of values, including nulls, concatenated into an array.
BitAnd
------
``BitAnd``
----------
.. class:: BitAnd(expression, **extra)
Returns an ``int`` of the bitwise ``AND`` of all non-null input values, or
``None`` if all values are null.
BitOr
-----
``BitOr``
---------
.. class:: BitOr(expression, **extra)
Returns an ``int`` of the bitwise ``OR`` of all non-null input values, or
``None`` if all values are null.
BoolAnd
-------
``BoolAnd``
-----------
.. class:: BoolAnd(expression, **extra)
Returns ``True``, if all input values are true, ``None`` if all values are
null or if there are no values, otherwise ``False`` .
BoolOr
------
``BoolOr``
----------
.. class:: BoolOr(expression, **extra)
Returns ``True`` if at least one input value is true, ``None`` if all
values are null or if there are no values, otherwise ``False``.
StringAgg
---------
``StringAgg``
-------------
.. class:: StringAgg(expression, delimiter)
@ -81,16 +81,16 @@ Aggregate functions for statistics
The arguments ``y`` and ``x`` for all these functions can be the name of a
field or an expression returning a numeric data. Both are required.
Corr
----
``Corr``
--------
.. class:: Corr(y, x)
Returns the correlation coefficient as a ``float``, or ``None`` if there
aren't any matching rows.
CovarPop
--------
``CovarPop``
------------
.. class:: CovarPop(y, x, sample=False)
@ -105,32 +105,32 @@ CovarPop
However, if ``sample=True``, the return value will be the sample
population covariance.
RegrAvgX
--------
``RegrAvgX``
------------
.. class:: RegrAvgX(y, x)
Returns the average of the independent variable (``sum(x)/N``) as a
``float``, or ``None`` if there aren't any matching rows.
RegrAvgY
--------
``RegrAvgY``
------------
.. class:: RegrAvgY(y, x)
Returns the average of the independent variable (``sum(y)/N``) as a
``float``, or ``None`` if there aren't any matching rows.
RegrCount
---------
``RegrCount``
-------------
.. class:: RegrCount(y, x)
Returns an ``int`` of the number of input rows in which both expressions
are not null.
RegrIntercept
-------------
``RegrIntercept``
-----------------
.. class:: RegrIntercept(y, x)
@ -138,16 +138,16 @@ RegrIntercept
by the ``(x, y)`` pairs as a ``float``, or ``None`` if there aren't any
matching rows.
RegrR2
------
``RegrR2``
----------
.. class:: RegrR2(y, x)
Returns the square of the correlation coefficient as a ``float``, or
``None`` if there aren't any matching rows.
RegrSlope
---------
``RegrSlope``
-------------
.. class:: RegrSlope(y, x)
@ -155,16 +155,16 @@ RegrSlope
by the ``(x, y)`` pairs as a ``float``, or ``None`` if there aren't any
matching rows.
RegrSXX
-------
``RegrSXX``
-----------
.. class:: RegrSXX(y, x)
Returns ``sum(x^2) - sum(x)^2/N`` ("sum of squares" of the independent
variable) as a ``float``, or ``None`` if there aren't any matching rows.
RegrSXY
-------
``RegrSXY``
-----------
.. class:: RegrSXY(y, x)
@ -172,8 +172,8 @@ RegrSXY
times dependent variable) as a ``float``, or ``None`` if there aren't any
matching rows.
RegrSYY
-------
``RegrSYY``
-----------
.. class:: RegrSYY(y, x)

View File

@ -7,8 +7,8 @@ module.
.. currentmodule:: django.contrib.postgres.fields
ArrayField
==========
``ArrayField``
==============
.. class:: ArrayField(base_field, size=None, **options)
@ -91,8 +91,8 @@ ArrayField
If irregular shapes are required, then the underlying field should be made
nullable and the values padded with ``None``.
Querying ArrayField
-------------------
Querying ``ArrayField``
-----------------------
There are a number of custom lookups and transforms for :class:`ArrayField`.
We will use the following example model::
@ -109,8 +109,8 @@ We will use the following example model::
.. fieldlookup:: arrayfield.contains
contains
~~~~~~~~
``contains``
~~~~~~~~~~~~
The :lookup:`contains` lookup is overridden on :class:`ArrayField`. The
returned objects will be those where the values passed are a subset of the
@ -131,8 +131,8 @@ data. It uses the SQL operator ``@>``. For example::
.. fieldlookup:: arrayfield.contained_by
contained_by
~~~~~~~~~~~~
``contained_by``
~~~~~~~~~~~~~~~~
This is the inverse of the :lookup:`contains <arrayfield.contains>` lookup -
the objects returned will be those where the data is a subset of the values
@ -150,8 +150,8 @@ passed. It uses the SQL operator ``<@``. For example::
.. fieldlookup:: arrayfield.overlap
overlap
~~~~~~~
``overlap``
~~~~~~~~~~~
Returns objects where the data shares any results with the values passed. Uses
the SQL operator ``&&``. For example::
@ -168,8 +168,8 @@ the SQL operator ``&&``. For example::
.. fieldlookup:: arrayfield.len
len
~~~
``len``
~~~~~~~
Returns the length of the array. The lookups available afterwards are those
available for :class:`~django.db.models.IntegerField`. For example::
@ -242,16 +242,16 @@ lookups available after the transform do not change. For example::
at the database level and cannot be supported in a logical, consistent
fashion by Django.
Indexing ArrayField
-------------------
Indexing ``ArrayField``
-----------------------
At present using :attr:`~django.db.models.Field.db_index` will create a
``btree`` index. This does not offer particularly significant help to querying.
A more useful index is a ``GIN`` index, which you should create using a
:class:`~django.db.migrations.operations.RunSQL` operation.
HStoreField
===========
``HStoreField``
===============
.. class:: HStoreField(**options)
@ -292,8 +292,8 @@ HStoreField
valid for a given field. This can be done using the
:class:`~django.contrib.postgres.validators.KeysValidator`.
Querying HStoreField
--------------------
Querying ``HStoreField``
------------------------
In addition to the ability to query by key, there are a number of custom
lookups available for ``HStoreField``.
@ -340,8 +340,8 @@ need to use the :lookup:`hstorefield.contains` lookup instead.
.. fieldlookup:: hstorefield.contains
contains
~~~~~~~~
``contains``
~~~~~~~~~~~~
The :lookup:`contains` lookup is overridden on
:class:`~django.contrib.postgres.fields.HStoreField`. The returned objects are
@ -360,8 +360,8 @@ field. It uses the SQL operator ``@>``. For example::
.. fieldlookup:: hstorefield.contained_by
contained_by
~~~~~~~~~~~~
``contained_by``
~~~~~~~~~~~~~~~~
This is the inverse of the :lookup:`contains <hstorefield.contains>` lookup -
the objects returned will be those where the key-value pairs on the object are
@ -380,8 +380,8 @@ example::
.. fieldlookup:: hstorefield.has_key
has_key
~~~~~~~
``has_key``
~~~~~~~~~~~
Returns objects where the given key is in the data. Uses the SQL operator
``?``. For example::
@ -394,8 +394,8 @@ Returns objects where the given key is in the data. Uses the SQL operator
.. fieldlookup:: hstorefield.has_any_keys
has_any_keys
~~~~~~~~~~~~
``has_any_keys``
~~~~~~~~~~~~~~~~
.. versionadded:: 1.9
@ -411,8 +411,8 @@ operator ``?|``. For example::
.. fieldlookup:: hstorefield.has_keys
has_keys
~~~~~~~~
``has_keys``
~~~~~~~~~~~~
Returns objects where all of the given keys are in the data. Uses the SQL operator
``?&``. For example::
@ -425,8 +425,8 @@ Returns objects where all of the given keys are in the data. Uses the SQL operat
.. fieldlookup:: hstorefield.keys
keys
~~~~
``keys``
~~~~~~~~
Returns objects where the array of keys is the given value. Note that the order
is not guaranteed to be reliable, so this transform is mainly useful for using
@ -442,8 +442,8 @@ in conjunction with lookups on
.. fieldlookup:: hstorefield.values
values
~~~~~~
``values``
~~~~~~~~~~
Returns objects where the array of values is the given value. Note that the
order is not guaranteed to be reliable, so this transform is mainly useful for
@ -457,8 +457,8 @@ using in conjunction with lookups on
>>> Dog.objects.filter(data__values__contains=['collie'])
<QuerySet [<Dog: Meg>]>
JSONField
=========
``JSONField``
=============
.. versionadded:: 1.9
@ -492,8 +492,8 @@ JSONField
**As a result, this field requires PostgreSQL ≥ 9.4 and Psycopg2 ≥ 2.5.4**.
Querying JSONField
------------------
Querying ``JSONField``
----------------------
We will use the following example model::
@ -588,8 +588,8 @@ All of the range fields translate to :ref:`psycopg2 Range objects
information is necessary. The default is lower bound included, upper bound
excluded.
IntegerRangeField
-----------------
``IntegerRangeField``
---------------------
.. class:: IntegerRangeField(**options)
@ -598,8 +598,8 @@ IntegerRangeField
the database and a :class:`~psycopg2:psycopg2.extras.NumericRange` in
Python.
BigIntegerRangeField
--------------------
``BigIntegerRangeField``
------------------------
.. class:: BigIntegerRangeField(**options)
@ -608,8 +608,8 @@ BigIntegerRangeField
in the database and a :class:`~psycopg2:psycopg2.extras.NumericRange` in
Python.
FloatRangeField
---------------
``FloatRangeField``
-------------------
.. class:: FloatRangeField(**options)
@ -617,8 +617,8 @@ FloatRangeField
:class:`~django.db.models.FloatField`. Represented by a ``numrange`` in the
database and a :class:`~psycopg2:psycopg2.extras.NumericRange` in Python.
DateTimeRangeField
------------------
``DateTimeRangeField``
----------------------
.. class:: DateTimeRangeField(**options)
@ -627,8 +627,8 @@ DateTimeRangeField
the database and a :class:`~psycopg2:psycopg2.extras.DateTimeTZRange` in
Python.
DateRangeField
--------------
``DateRangeField``
------------------
.. class:: DateRangeField(**options)
@ -675,16 +675,16 @@ operators ``@>``, ``<@``, and ``&&`` respectively.
.. fieldlookup:: rangefield.contains
contains
^^^^^^^^
``contains``
^^^^^^^^^^^^
>>> Event.objects.filter(ages__contains=NumericRange(4, 5))
<QuerySet [<Event: Soft play>]>
.. fieldlookup:: rangefield.contained_by
contained_by
^^^^^^^^^^^^
``contained_by``
^^^^^^^^^^^^^^^^
>>> Event.objects.filter(ages__contained_by=NumericRange(0, 15))
<QuerySet [<Event: Soft play>]>
@ -707,8 +707,8 @@ contained_by
.. fieldlookup:: rangefield.overlap
overlap
^^^^^^^
``overlap``
^^^^^^^^^^^
>>> Event.objects.filter(ages__overlap=NumericRange(8, 12))
<QuerySet [<Event: Soft play>]>
@ -724,8 +724,8 @@ the specific range comparison operators.
.. fieldlookup:: rangefield.fully_lt
fully_lt
^^^^^^^^
``fully_lt``
^^^^^^^^^^^^
The returned ranges are strictly less than the passed range. In other words,
all the points in the returned range are less than all those in the passed
@ -736,8 +736,8 @@ range.
.. fieldlookup:: rangefield.fully_gt
fully_gt
^^^^^^^^
``fully_gt``
^^^^^^^^^^^^
The returned ranges are strictly greater than the passed range. In other words,
the all the points in the returned range are greater than all those in the
@ -748,8 +748,8 @@ passed range.
.. fieldlookup:: rangefield.not_lt
not_lt
^^^^^^
``not_lt``
^^^^^^^^^^
The returned ranges do not contain any points less than the passed range, that
is the lower bound of the returned range is at least the lower bound of the
@ -760,8 +760,8 @@ passed range.
.. fieldlookup:: rangefield.not_gt
not_gt
^^^^^^
``not_gt``
^^^^^^^^^^
The returned ranges do not contain any points greater than the passed range, that
is the upper bound of the returned range is at most the upper bound of the
@ -772,8 +772,8 @@ passed range.
.. fieldlookup:: rangefield.adjacent_to
adjacent_to
^^^^^^^^^^^
``adjacent_to``
^^^^^^^^^^^^^^^
The returned ranges share a bound with the passed range.
@ -788,8 +788,8 @@ lower or upper bound, or query based on emptiness.
.. fieldlookup:: rangefield.startswith
startswith
^^^^^^^^^^
``startswith``
^^^^^^^^^^^^^^
Returned objects have the given lower bound. Can be chained to valid lookups
for the base field.
@ -799,8 +799,8 @@ for the base field.
.. fieldlookup:: rangefield.endswith
endswith
^^^^^^^^
``endswith``
^^^^^^^^^^^^
Returned objects have the given upper bound. Can be chained to valid lookups
for the base field.
@ -810,8 +810,8 @@ for the base field.
.. fieldlookup:: rangefield.isempty
isempty
^^^^^^^
``isempty``
^^^^^^^^^^^
Returned objects are empty ranges. Can be chained to valid lookups for a
:class:`~django.db.models.BooleanField`.

View File

@ -10,8 +10,8 @@ All of these fields and widgets are available from the
Fields
======
SimpleArrayField
----------------
``SimpleArrayField``
--------------------
.. class:: SimpleArrayField(base_field, delimiter=',', max_length=None, min_length=None)
@ -82,8 +82,8 @@ SimpleArrayField
however it is a useful way to format data from a client-side widget for
submission to the server.
SplitArrayField
---------------
``SplitArrayField``
-------------------
.. class:: SplitArrayField(base_field, size, remove_trailing_nulls=False)
@ -138,8 +138,8 @@ SplitArrayField
['1', '', '3'] # -> [1, None, 3]
['', '2', ''] # -> [None, 2]
HStoreField
-----------
``HStoreField``
---------------
.. class:: HStoreField
@ -159,8 +159,8 @@ HStoreField
valid for a given field. This can be done using the
:class:`~django.contrib.postgres.validators.KeysValidator`.
JSONField
---------
``JSONField``
-------------
.. class:: JSONField
@ -183,8 +183,8 @@ omitted value as an unbounded range. They also validate that the lower bound is
not greater than the upper bound. All of these fields use
:class:`~django.contrib.postgres.forms.RangeWidget`.
IntegerRangeField
~~~~~~~~~~~~~~~~~
``IntegerRangeField``
~~~~~~~~~~~~~~~~~~~~~
.. class:: IntegerRangeField
@ -193,8 +193,8 @@ IntegerRangeField
:class:`~django.contrib.postgres.fields.IntegerRangeField` and
:class:`~django.contrib.postgres.fields.BigIntegerRangeField`.
FloatRangeField
~~~~~~~~~~~~~~~
``FloatRangeField``
~~~~~~~~~~~~~~~~~~~
.. class:: FloatRangeField
@ -202,8 +202,8 @@ FloatRangeField
:class:`~psycopg2:psycopg2.extras.NumericRange`. Default for
:class:`~django.contrib.postgres.fields.FloatRangeField`.
DateTimeRangeField
~~~~~~~~~~~~~~~~~~
``DateTimeRangeField``
~~~~~~~~~~~~~~~~~~~~~~
.. class:: DateTimeRangeField
@ -211,8 +211,8 @@ DateTimeRangeField
:class:`~psycopg2:psycopg2.extras.DateTimeTZRange`. Default for
:class:`~django.contrib.postgres.fields.DateTimeRangeField`.
DateRangeField
~~~~~~~~~~~~~~
``DateRangeField``
~~~~~~~~~~~~~~~~~~
.. class:: DateRangeField
@ -223,8 +223,8 @@ DateRangeField
Widgets
=======
RangeWidget
-----------
``RangeWidget``
---------------
.. class:: RangeWidget(base_widget, attrs=None)

View File

@ -7,8 +7,8 @@ All of these functions are available from the
.. currentmodule:: django.contrib.postgres.functions
TransactionNow
==============
``TransactionNow``
==================
.. class:: TransactionNow()

View File

@ -2,8 +2,8 @@
PostgreSQL specific lookups
===========================
Unaccent
========
``Unaccent``
============
.. fieldlookup:: unaccent

View File

@ -7,8 +7,8 @@ the ``django.contrib.postgres.operations`` module.
.. currentmodule:: django.contrib.postgres.operations
CreateExtension
===============
``CreateExtension``
===================
.. class:: CreateExtension(name)
@ -18,8 +18,8 @@ CreateExtension
This is a required argument. The name of the extension to be installed.
HStoreExtension
===============
``HStoreExtension``
===================
.. class:: HStoreExtension()
@ -27,8 +27,8 @@ HStoreExtension
which will install the ``hstore`` extension and also immediately set up the
connection to interpret hstore data.
UnaccentExtension
=================
``UnaccentExtension``
=====================
.. class:: UnaccentExtension()

View File

@ -22,11 +22,17 @@ Validators
Range validators
================
``RangeMaxValueValidator``
--------------------------
.. class:: RangeMaxValueValidator(limit_value, message=None)
Validates that the upper bound of the range is not greater than
``limit_value``.
``RangeMinValueValidator``
--------------------------
.. class:: RangeMinValueValidator(limit_value, message=None)
Validates that the lower bound of the range is not less than the

View File

@ -75,8 +75,8 @@ The sitemap view takes an extra, required argument: ``{'sitemaps': sitemaps}``.
a :class:`~django.contrib.sitemaps.Sitemap` class (e.g.,
``BlogSitemap(some_var)``).
Sitemap classes
===============
``Sitemap`` classes
===================
A :class:`~django.contrib.sitemaps.Sitemap` class is a simple Python
class that represents a "section" of entries in your sitemap. For example,
@ -129,8 +129,8 @@ Note:
:attr:`~Sitemap.location()` calls ``get_absolute_url()`` on each object
and returns the result.
Sitemap class reference
=======================
``Sitemap`` class reference
===========================
.. class:: Sitemap

View File

@ -1,6 +1,6 @@
===================
The staticfiles app
===================
=======================
The ``staticfiles`` app
=======================
.. module:: django.contrib.staticfiles
:synopsis: An app for handling static files.
@ -34,8 +34,8 @@ Management Commands
``django.contrib.staticfiles`` exposes three management commands.
collectstatic
-------------
``collectstatic``
-----------------
.. django-admin:: collectstatic
@ -128,8 +128,8 @@ For a full list of options, refer to the commands own help by running::
$ python manage.py collectstatic --help
findstatic
----------
``findstatic``
--------------
.. django-admin:: findstatic static file [static file ...]
@ -177,8 +177,8 @@ the directories which were searched::
.. _staticfiles-runserver:
runserver
---------
``runserver``
-------------
.. django-admin:: runserver [addrport]
@ -218,8 +218,8 @@ Example usage::
Storages
========
StaticFilesStorage
------------------
``StaticFilesStorage``
----------------------
.. class:: storage.StaticFilesStorage
@ -238,8 +238,8 @@ The :class:`~django.contrib.staticfiles.storage.CachedStaticFilesStorage`
uses this behind the scenes to replace the paths with their hashed
counterparts and update the cache appropriately.
ManifestStaticFilesStorage
--------------------------
``ManifestStaticFilesStorage``
------------------------------
.. class:: storage.ManifestStaticFilesStorage
@ -317,8 +317,8 @@ hashing algorithm.
.. _`url()`: http://www.w3.org/TR/CSS2/syndata.html#uri
.. _`Cascading Style Sheets`: http://www.w3.org/Style/CSS/
CachedStaticFilesStorage
------------------------
``CachedStaticFilesStorage``
----------------------------
.. class:: storage.CachedStaticFilesStorage

View File

@ -31,8 +31,8 @@ feed, write a :class:`~django.contrib.syndication.views.Feed` class
and point to an instance of it in your :doc:`URLconf
</topics/http/urls>`.
Feed classes
------------
``Feed`` classes
----------------
A :class:`~django.contrib.syndication.views.Feed` class is a Python
class that represents a syndication feed. A feed can be simple (e.g.,
@ -381,8 +381,8 @@ And the accompanying URLconf::
# ...
]
Feed class reference
--------------------
``Feed`` class reference
------------------------
.. class:: views.Feed

View File

@ -1,6 +1,6 @@
==========================
django-admin and manage.py
==========================
==================================
``django-admin`` and ``manage.py``
==================================
``django-admin`` is Django's command-line utility for administrative tasks.
This document outlines all it can do.
@ -96,8 +96,8 @@ information that ``django-admin`` prints to the console.
Available commands
==================
check
-----
``check``
---------
.. django-admin:: check [app_label [app_label ...]]
@ -147,8 +147,8 @@ make it part of your integration test suite.
Specifies the message level that will cause the command to exit with a non-zero
status. Default is ``ERROR``.
compilemessages
---------------
``compilemessages``
-------------------
.. django-admin:: compilemessages
@ -184,8 +184,8 @@ Example usage::
django-admin compilemessages -x pt_BR
django-admin compilemessages -x pt_BR -x fr
createcachetable
----------------
``createcachetable``
--------------------
.. django-admin:: createcachetable
@ -207,8 +207,8 @@ customize it or use the migrations framework.
The ``--dry-run`` option was added.
dbshell
-------
``dbshell``
-----------
.. django-admin:: dbshell
@ -230,8 +230,8 @@ program manually.
Specifies the database onto which to open a shell. Defaults to ``default``.
diffsettings
------------
``diffsettings``
----------------
.. django-admin:: diffsettings
@ -248,8 +248,8 @@ example, the default settings don't define :setting:`ROOT_URLCONF`, so
Displays all settings, even if they have Django's default value. Such settings
are prefixed by ``"###"``.
dumpdata
--------
``dumpdata``
------------
.. django-admin:: dumpdata [app_label[.ModelName] [app_label[.ModelName] ...]]
@ -328,8 +328,8 @@ progress bar is shown in the terminal.
The progress bar in the terminal was added.
flush
-----
``flush``
---------
.. django-admin:: flush
@ -351,8 +351,8 @@ Suppresses all user prompts.
Specifies the database to flush. Defaults to ``default``.
inspectdb
---------
``inspectdb``
-------------
.. django-admin:: inspectdb
@ -410,8 +410,8 @@ it because ``True`` is its default value).
Specifies the database to introspect. Defaults to ``default``.
loaddata
--------
``loaddata``
------------
.. django-admin:: loaddata fixture [fixture ...]
@ -559,8 +559,8 @@ defined, name the fixture ``mydata.master.json`` or
``mydata.master.json.gz`` and the fixture will only be loaded when you
specify you want to load data into the ``master`` database.
makemessages
------------
``makemessages``
----------------
.. django-admin:: makemessages
@ -660,8 +660,8 @@ language files from being created.
See :ref:`customizing-makemessages` for instructions on how to customize
the keywords that :djadmin:`makemessages` passes to ``xgettext``.
makemigrations
--------------
``makemigrations``
------------------
.. django-admin:: makemigrations [app_label [app_label ...]]
@ -719,8 +719,8 @@ Makes ``makemigrations`` exit with error code 1 when no migrations are created
Makes ``makemigrations`` exit with a non-zero status when model changes without
migrations are detected.
migrate
-------
``migrate``
-----------
.. django-admin:: migrate [app_label] [migration_name]
@ -774,8 +774,8 @@ Allows creating tables for apps without migrations. While this isn't
recommended, the migrations framework is sometimes too slow on large projects
with hundreds of models.
runserver
---------
``runserver``
-------------
.. django-admin:: runserver [addrport]
@ -905,8 +905,8 @@ By default, the development server doesn't serve any static files for your site
you want to configure Django to serve static media, read
:doc:`/howto/static-files/index`.
sendtestemail
-------------
``sendtestemail``
-----------------
.. django-admin:: sendtestemail [email [email ...]]
@ -930,8 +930,8 @@ Mails the email addresses specified in :setting:`MANAGERS` using
Mails the email addresses specified in :setting:`ADMINS` using
:meth:`~django.core.mail.mail_admins()`.
shell
-----
``shell``
---------
.. django-admin:: shell
@ -977,8 +977,8 @@ Lets you pass a command as a string to execute it as Django, like so::
django-admin shell --command="import django; print(django.__version__)"
showmigrations
--------------
``showmigrations``
------------------
.. django-admin:: showmigrations [app_label [app_label ...]]
@ -1006,8 +1006,8 @@ of 2 and above, all dependencies of a migration will also be shown.
Specifies the database to examine. Defaults to ``default``.
sqlflush
--------
``sqlflush``
------------
.. django-admin:: sqlflush
@ -1018,8 +1018,8 @@ command.
Specifies the database for which to print the SQL. Defaults to ``default``.
sqlmigrate
----------
``sqlmigrate``
--------------
.. django-admin:: sqlmigrate app_label migration_name
@ -1044,8 +1044,8 @@ Specifies the database for which to generate the SQL. Defaults to ``default``.
generated for each migration operation is preceded by the operation's
description.
sqlsequencereset
----------------
``sqlsequencereset``
--------------------
.. django-admin:: sqlsequencereset app_label [app_label ...]
@ -1061,8 +1061,8 @@ of sync with its automatically incremented field data.
Specifies the database for which to print the SQL. Defaults to ``default``.
squashmigrations
----------------
``squashmigrations``
--------------------
.. django-admin:: squashmigrations app_label [start_migration_name] migration_name
@ -1094,8 +1094,8 @@ Suppresses all user prompts.
The ``--no-input`` alias was added.
startapp
--------
``startapp``
------------
.. django-admin:: startapp name [directory]
@ -1186,8 +1186,8 @@ files is:
.. _source: https://github.com/django/django/tree/master/django/conf/app_template/
startproject
------------
``startproject``
----------------
.. django-admin:: startproject name [directory]
@ -1240,8 +1240,8 @@ for :djadmin:`startapp`.
.. _`template source`: https://github.com/django/django/tree/master/django/conf/project_template/
test
----
``test``
--------
.. django-admin:: test [test_label [test_label ...]]
@ -1348,8 +1348,8 @@ don't.
in order to exchange them between processes. See
:ref:`python:pickle-picklable` for details.
testserver
----------
``testserver``
--------------
.. django-admin:: testserver [fixture [fixture ...]]
@ -1427,8 +1427,8 @@ their application.
``django.contrib.auth``
-----------------------
changepassword
~~~~~~~~~~~~~~
``changepassword``
~~~~~~~~~~~~~~~~~~
.. django-admin:: changepassword [<username>]
@ -1448,8 +1448,8 @@ Example usage::
django-admin changepassword ringo
createsuperuser
~~~~~~~~~~~~~~~
``createsuperuser``
~~~~~~~~~~~~~~~~~~~
.. django-admin:: createsuperuser
@ -1488,8 +1488,8 @@ instance.
``django.contrib.gis``
----------------------
ogrinspect
~~~~~~~~~~
``ogrinspect``
~~~~~~~~~~~~~~
This command is only available if :doc:`GeoDjango </ref/contrib/gis/index>`
(``django.contrib.gis``) is installed.
@ -1500,8 +1500,8 @@ documentation.
``django.contrib.sessions``
---------------------------
clearsessions
~~~~~~~~~~~~~~~
``clearsessions``
~~~~~~~~~~~~~~~~~
.. django-admin:: clearsessions
@ -1510,8 +1510,8 @@ Can be run as a cron job or directly to clean out expired sessions.
``django.contrib.sitemaps``
---------------------------
ping_google
~~~~~~~~~~~
``ping_google``
~~~~~~~~~~~~~~~
This command is only available if the :doc:`Sitemaps framework
</ref/contrib/sitemaps>` (``django.contrib.sitemaps``) is installed.
@ -1522,8 +1522,8 @@ documentation.
``django.contrib.staticfiles``
------------------------------
collectstatic
~~~~~~~~~~~~~
``collectstatic``
~~~~~~~~~~~~~~~~~
This command is only available if the :doc:`static files application
</howto/static-files/index>` (``django.contrib.staticfiles``) is installed.
@ -1531,8 +1531,8 @@ This command is only available if the :doc:`static files application
Please refer to its :djadmin:`description <collectstatic>` in the
:doc:`staticfiles </ref/contrib/staticfiles>` documentation.
findstatic
~~~~~~~~~~
``findstatic``
~~~~~~~~~~~~~~
This command is only available if the :doc:`static files application
</howto/static-files/index>` (``django.contrib.staticfiles``) is installed.

View File

@ -7,7 +7,7 @@ for basic file handling in Django.
.. currentmodule:: django.core.files
The ``File`` Class
The ``File`` class
==================
.. class:: File(file_object)
@ -90,7 +90,7 @@ The ``File`` Class
.. currentmodule:: django.core.files.base
The ``ContentFile`` Class
The ``ContentFile`` class
=========================
.. class:: ContentFile(File)
@ -107,7 +107,7 @@ The ``ContentFile`` Class
.. currentmodule:: django.core.files.images
The ``ImageFile`` Class
The ``ImageFile`` class
=======================
.. class:: ImageFile(file_object)

View File

@ -27,8 +27,8 @@ Django provides two convenient ways to access the current storage class:
given path and will return it if successful. An exception will be
raised if the import is unsuccessful.
The FileSystemStorage Class
===========================
The ``FileSystemStorage`` class
===============================
.. class:: FileSystemStorage(location=None, base_url=None, file_permissions_mode=None, directory_permissions_mode=None)
@ -62,8 +62,8 @@ The FileSystemStorage Class
The ``FileSystemStorage.delete()`` method will not raise
an exception if the given file name does not exist.
The Storage Class
=================
The ``Storage`` class
=====================
.. class:: Storage

View File

@ -8,6 +8,9 @@ Formset API reference. For introductory material about formsets, see the
.. module:: django.forms.formsets
:synopsis: Django's functions for building formsets.
``formset_factory``
===================
.. function:: formset_factory(form, formset=BaseFormSet, extra=1, can_order=False, can_delete=False, max_num=None, validate_max=False, min_num=None, validate_min=False)
Returns a ``FormSet`` class for the given ``form`` class.

View File

@ -8,6 +8,9 @@ Model Form API reference. For introductory material about model forms, see the
.. module:: django.forms.models
:synopsis: Django's functions for building model forms and formsets.
``modelform_factory``
=====================
.. function:: modelform_factory(model, form=ModelForm, fields=None, exclude=None, formfield_callback=None, widgets=None, localized_fields=None, labels=None, help_texts=None, error_messages=None, field_classes=None)
Returns a :class:`~django.forms.ModelForm` class for the given ``model``.
@ -50,6 +53,9 @@ Model Form API reference. For introductory material about model forms, see the
The ``field_classes`` keyword argument was added.
``modelformset_factory``
========================
.. function:: modelformset_factory(model, form=ModelForm, formfield_callback=None, formset=BaseModelFormSet, extra=1, can_delete=False, can_order=False, max_num=None, fields=None, exclude=None, widgets=None, validate_max=False, localized_fields=None, labels=None, help_texts=None, error_messages=None, min_num=None, validate_min=False, field_classes=None)
Returns a ``FormSet`` class for the given ``model`` class.
@ -70,6 +76,9 @@ Model Form API reference. For introductory material about model forms, see the
The ``field_classes`` keyword argument was added.
``inlineformset_factory``
=========================
.. function:: inlineformset_factory(parent_model, model, form=ModelForm, formset=BaseInlineFormSet, fk_name=None, fields=None, exclude=None, extra=3, can_order=False, can_delete=True, max_num=None, formfield_callback=None, widgets=None, validate_max=False, localized_fields=None, labels=None, help_texts=None, error_messages=None, min_num=None, validate_min=False, field_classes=None)
Returns an ``InlineFormSet`` using :func:`modelformset_factory` with

View File

@ -68,8 +68,8 @@ widget on the field. In the following example, the
See the :ref:`built-in widgets` for more information about which widgets
are available and which arguments they accept.
Widgets inheriting from the Select widget
=========================================
Widgets inheriting from the ``Select`` widget
=============================================
Widgets inheriting from the :class:`Select` widget deal with choices. They
present the user with a list of options to choose from. The different widgets

View File

@ -391,8 +391,8 @@ Adds protection against Cross Site Request Forgeries by adding hidden form
fields to POST forms and checking requests for the correct value. See the
:doc:`Cross Site Request Forgery protection documentation </ref/csrf>`.
X-Frame-Options middleware
--------------------------
``X-Frame-Options`` middleware
------------------------------
.. module:: django.middleware.clickjacking
:synopsis: Clickjacking protection

View File

@ -34,8 +34,8 @@ For introductory material, see the :doc:`migrations topic guide
Schema Operations
=================
CreateModel
-----------
``CreateModel``
---------------
.. class:: CreateModel(name, fields, options=None, bases=None, managers=None)
@ -60,15 +60,15 @@ inheriting from the standard ``models.Model``.
The first manager in the list will be the default manager for this model during
migrations.
DeleteModel
-----------
``DeleteModel``
---------------
.. class:: DeleteModel(name)
Deletes the model from the project history and its table from the database.
RenameModel
-----------
``RenameModel``
---------------
.. class:: RenameModel(old_name, new_name)
@ -80,16 +80,16 @@ the autodetector, this will look like you deleted a model with the old name
and added a new one with a different name, and the migration it creates will
lose any data in the old table.
AlterModelTable
---------------
``AlterModelTable``
-------------------
.. class:: AlterModelTable(name, table)
Changes the model's table name (the :attr:`~django.db.models.Options.db_table`
option on the ``Meta`` subclass).
AlterUniqueTogether
-------------------
``AlterUniqueTogether``
-----------------------
.. class:: AlterUniqueTogether(name, unique_together)
@ -97,8 +97,8 @@ Changes the model's set of unique constraints (the
:attr:`~django.db.models.Options.unique_together` option on the ``Meta``
subclass).
AlterIndexTogether
------------------
``AlterIndexTogether``
----------------------
.. class:: AlterIndexTogether(name, index_together)
@ -106,8 +106,8 @@ Changes the model's set of custom indexes (the
:attr:`~django.db.models.Options.index_together` option on the ``Meta``
subclass).
AlterOrderWithRespectTo
-----------------------
``AlterOrderWithRespectTo``
---------------------------
.. class:: AlterOrderWithRespectTo(name, order_with_respect_to)
@ -115,8 +115,8 @@ Makes or deletes the ``_order`` column needed for the
:attr:`~django.db.models.Options.order_with_respect_to` option on the ``Meta``
subclass.
AlterModelOptions
-----------------
``AlterModelOptions``
---------------------
.. class:: AlterModelOptions(name, options)
@ -125,15 +125,15 @@ like ``permissions`` and ``verbose_name``. Does not affect the database, but
persists these changes for :class:`RunPython` instances to use. ``options``
should be a dictionary mapping option names to values.
AlterModelManagers
------------------
``AlterModelManagers``
----------------------
.. class:: AlterModelManagers(name, managers)
Alters the managers that are available during migrations.
AddField
--------
``AddField``
------------
.. class:: AddField(model_name, name, field, preserve_default=True)
@ -150,8 +150,8 @@ a default value to put into existing rows. It does not affect the behavior
of setting defaults in the database directly - Django never sets database
defaults and always applies them in the Django ORM code.
RemoveField
-----------
``RemoveField``
---------------
.. class:: RemoveField(model_name, name)
@ -163,8 +163,8 @@ irreversible) if the field is nullable or if it has a default value that can be
used to populate the recreated column. If the field is not nullable and does
not have a default value, the operation is irreversible.
AlterField
----------
``AlterField``
--------------
.. class:: AlterField(model_name, name, field, preserve_default=True)
@ -184,8 +184,8 @@ Note that not all changes are possible on all databases - for example, you
cannot change a text-type field like ``models.TextField()`` into a number-type
field like ``models.IntegerField()`` on most databases.
RenameField
-----------
``RenameField``
---------------
.. class:: RenameField(model_name, old_name, new_name)
@ -195,8 +195,8 @@ is set, its column name).
Special Operations
==================
RunSQL
------
``RunSQL``
----------
.. class:: RunSQL(sql, reverse_sql=None, state_operations=None, hints=None, elidable=False)
@ -266,8 +266,8 @@ be removed (elided) when :ref:`squashing migrations <migration-squashing>`.
The ``elidable`` argument was added.
RunPython
---------
``RunPython``
-------------
.. class:: RunPython(code, reverse_code=None, atomic=True, hints=None, elidable=False)
@ -382,8 +382,8 @@ attribute.
The ``elidable`` argument was added.
SeparateDatabaseAndState
------------------------
``SeparateDatabaseAndState``
----------------------------
.. class:: SeparateDatabaseAndState(database_operations=None, state_operations=None)

View File

@ -34,8 +34,8 @@ We'll be using the following model in the subsequent examples::
default=REGULAR,
)
When
----
``When``
--------
.. class:: When(condition=None, then=None, **lookups)
@ -74,8 +74,8 @@ Keep in mind that each of these values can be an expression.
>>> When(then__exact=0, then=1)
>>> When(Q(then=0), then=1)
Case
----
``Case``
--------
.. class:: Case(*cases, **extra)

View File

@ -23,8 +23,8 @@ We don't usually recommend allowing ``null=True`` for ``CharField`` since this
allows the field to have two "empty values", but it's important for the
``Coalesce`` example below.
Coalesce
========
``Coalesce``
============
.. class:: Coalesce(*expressions, **extra)
@ -64,8 +64,8 @@ Usage examples::
>>> now_sql = RawSQL("cast(%s as datetime)", (now,))
>>> Coalesce('updated', now_sql)
Concat
======
``Concat``
==========
.. class:: Concat(*expressions, **extra)
@ -91,8 +91,8 @@ Usage example::
>>> print(author.screen_name)
Margaret Smith (Maggie)
Greatest
========
``Greatest``
============
.. class:: Greatest(*expressions, **extra)
@ -135,8 +135,8 @@ and ``comment.modified``.
The PostgreSQL behavior can be emulated using ``Coalesce`` if you know
a sensible minimum value to provide as a default.
Least
=====
``Least``
=========
.. class:: Least(*expressions, **extra)
@ -159,8 +159,8 @@ will result in a database error.
The PostgreSQL behavior can be emulated using ``Coalesce`` if you know
a sensible maximum value to provide as a default.
Length
======
``Length``
==========
.. class:: Length(expression, **extra)
@ -190,8 +190,8 @@ It can also be registered as a transform. For example::
The ability to register the function as a transform was added.
Lower
=====
``Lower``
=========
.. class:: Lower(expression, **extra)
@ -212,8 +212,8 @@ Usage example::
The ability to register the function as a transform was added.
Now
===
``Now``
=======
.. class:: Now()
@ -235,8 +235,8 @@ Usage example::
``Now()`` uses ``STATEMENT_TIMESTAMP`` instead. If you need the transaction
timestamp, use :class:`django.contrib.postgres.functions.TransactionNow`.
Substr
======
``Substr``
==========
.. class:: Substr(expression, pos, length=None, **extra)
@ -254,8 +254,8 @@ Usage example::
>>> print(Author.objects.get(name='Margaret Smith').alias)
marga
Upper
=====
``Upper``
=========
.. class:: Upper(expression, **extra)

View File

@ -743,8 +743,8 @@ equivalent to XSS or CSRF attacks.
columns with a default max length of 100 characters. As with other fields, you
can change the maximum length using the :attr:`~CharField.max_length` argument.
FileField and FieldFile
~~~~~~~~~~~~~~~~~~~~~~~
``FileField`` and ``FieldFile``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. currentmodule:: django.db.models.fields.files

View File

@ -117,8 +117,8 @@ following methods:
Defines the type of class returned by the ``get_lookup()`` method. It must
be a :class:`~django.db.models.Field` instance.
Transform reference
===================
``Transform`` reference
=======================
.. class:: Transform
@ -162,8 +162,8 @@ Transform reference
:class:`~django.db.models.Field` instance. By default is the same as
its ``lhs.output_field``.
Lookup reference
================
``Lookup`` reference
====================
.. class:: Lookup

View File

@ -1,6 +1,6 @@
======================
QuerySet API reference
======================
==========================
``QuerySet`` API reference
==========================
.. currentmodule:: django.db.models.query
@ -15,8 +15,8 @@ Throughout this reference we'll use the :ref:`example Weblog models
.. _when-querysets-are-evaluated:
When QuerySets are evaluated
============================
When ``QuerySet``\s are evaluated
=================================
Internally, a ``QuerySet`` can be constructed, filtered, sliced, and generally
passed around without actually hitting the database. No database activity
@ -80,8 +80,8 @@ You can evaluate a ``QuerySet`` in the following ways:
.. _pickling QuerySets:
Pickling QuerySets
------------------
Pickling ``QuerySet``\s
-----------------------
If you :mod:`pickle` a ``QuerySet``, this will force all the results to be loaded
into memory prior to pickling. Pickling is usually used as a precursor to
@ -121,8 +121,8 @@ described here.
.. _queryset-api:
QuerySet API
============
``QuerySet`` API
================
Here's the formal declaration of a ``QuerySet``:
@ -157,15 +157,15 @@ Here's the formal declaration of a ``QuerySet``:
.. currentmodule:: django.db.models.query.QuerySet
Methods that return new QuerySets
---------------------------------
Methods that return new ``QuerySet``\s
--------------------------------------
Django provides a range of ``QuerySet`` refinement methods that modify either
the types of results returned by the ``QuerySet`` or the way its SQL query is
executed.
filter
~~~~~~
``filter()``
~~~~~~~~~~~~
.. method:: filter(**kwargs)
@ -179,8 +179,8 @@ underlying SQL statement.
If you need to execute more complex queries (for example, queries with ``OR`` statements),
you can use :class:`Q objects <django.db.models.Q>`.
exclude
~~~~~~~
``exclude()``
~~~~~~~~~~~~~
.. method:: exclude(**kwargs)
@ -217,8 +217,8 @@ Note the second example is more restrictive.
If you need to execute more complex queries (for example, queries with ``OR`` statements),
you can use :class:`Q objects <django.db.models.Q>`.
annotate
~~~~~~~~
``annotate()``
~~~~~~~~~~~~~~
.. method:: annotate(*args, **kwargs)
@ -265,8 +265,8 @@ control the name of the annotation::
For an in-depth discussion of aggregation, see :doc:`the topic guide on
Aggregation </topics/db/aggregation>`.
order_by
~~~~~~~~
``order_by()``
~~~~~~~~~~~~~~
.. method:: order_by(*fields)
@ -387,8 +387,8 @@ query will be ordered by ``pub_date`` and not ``headline``::
incurs a cost to your database. Each foreign key you add will
implicitly include all of its default orderings as well.
reverse
~~~~~~~
``reverse()``
~~~~~~~~~~~~~
.. method:: reverse()
@ -414,8 +414,8 @@ defined for a given ``QuerySet``, calling ``reverse()`` on it has no real
effect (the ordering was undefined prior to calling ``reverse()``, and will
remain undefined afterward).
distinct
~~~~~~~~
``distinct()``
~~~~~~~~~~~~~~
.. method:: distinct(*fields)
@ -497,8 +497,8 @@ Examples (those after the first will only work on PostgreSQL)::
by the relation `_id` field (``blog_id`` in this case) or the referenced
one (``blog__pk``) to make sure both expressions match.
values
~~~~~~
``values()``
~~~~~~~~~~~~
.. method:: values(*fields)
@ -597,8 +597,8 @@ You can also refer to fields on related models with reverse relations through
pronounced if you include multiple such fields in your ``values()`` query,
in which case all possible combinations will be returned.
values_list
~~~~~~~~~~~
``values_list()``
~~~~~~~~~~~~~~~~~
.. method:: values_list(*fields, flat=False)
@ -631,8 +631,8 @@ achieve that, use ``values_list()`` followed by a ``get()`` call::
>>> Entry.objects.values_list('headline', flat=True).get(pk=1)
'First entry'
dates
~~~~~
``dates()``
~~~~~~~~~~~
.. method:: dates(field, kind, order='ASC')
@ -667,8 +667,8 @@ Examples::
>>> Entry.objects.filter(headline__contains='Lennon').dates('pub_date', 'day')
[datetime.date(2005, 3, 20)]
datetimes
~~~~~~~~~
``datetimes()``
~~~~~~~~~~~~~~~
.. method:: datetimes(field_name, kind, order='ASC', tzinfo=None)
@ -711,8 +711,8 @@ object. If it's ``None``, Django uses the :ref:`current time zone
.. _Choosing a Time Zone File: https://docs.oracle.com/cd/E11882_01/server.112/e10729/ch4datetime.htm#NLSPG258
.. _mysql_tzinfo_to_sql: https://dev.mysql.com/doc/refman/5.6/en/mysql-tzinfo-to-sql.html
none
~~~~
``none()``
~~~~~~~~~~
.. method:: none()
@ -728,8 +728,8 @@ Examples::
>>> isinstance(Entry.objects.none(), EmptyQuerySet)
True
all
~~~
``all()``
~~~~~~~~~
.. method:: all()
@ -743,8 +743,8 @@ typically caches its results. If the data in the database might have changed
since a ``QuerySet`` was evaluated, you can get updated results for the same
query by calling ``all()`` on a previously evaluated ``QuerySet``.
select_related
~~~~~~~~~~~~~~
``select_related()``
~~~~~~~~~~~~~~~~~~~~
.. method:: select_related(*fields)
@ -849,8 +849,8 @@ Chaining ``select_related`` calls works in a similar way to other methods -
that is that ``select_related('foo', 'bar')`` is equivalent to
``select_related('foo').select_related('bar')``.
prefetch_related
~~~~~~~~~~~~~~~~
``prefetch_related()``
~~~~~~~~~~~~~~~~~~~~~~
.. method:: prefetch_related(*lookups)
@ -1103,8 +1103,8 @@ where prefetching with a custom ``QuerySet`` is useful:
specific order to avoid creating extra queries; therefore it's recommended
to always carefully order ``prefetch_related`` arguments.
extra
~~~~~
``extra()``
~~~~~~~~~~~
.. method:: extra(select=None, where=None, params=None, tables=None, order_by=None, select_params=None)
@ -1311,8 +1311,8 @@ of the arguments is required, but you should use at least one of them.
both rows will match. To prevent this, perform the correct typecasting
before using the value in a query.
defer
~~~~~
``defer()``
~~~~~~~~~~~
.. method:: defer(*fields)
@ -1410,9 +1410,8 @@ one, doing so will result in an error.
deferred fields, only the loaded fields will be saved. See
:meth:`~django.db.models.Model.save()` for more details.
only
~~~~
``only()``
~~~~~~~~~~
.. method:: only(*fields)
@ -1460,8 +1459,8 @@ is an error as well.
deferred fields, only the loaded fields will be saved. See
:meth:`~django.db.models.Model.save()` for more details.
using
~~~~~
``using()``
~~~~~~~~~~~
.. method:: using(alias)
@ -1478,8 +1477,8 @@ For example::
# queries the database with the 'backup' alias
>>> Entry.objects.using('backup')
select_for_update
~~~~~~~~~~~~~~~~~
``select_for_update()``
~~~~~~~~~~~~~~~~~~~~~~~
.. method:: select_for_update(nowait=False)
@ -1533,8 +1532,8 @@ raised if ``select_for_update()`` is used in autocommit mode.
``select_for_update()`` you should use
:class:`~django.test.TransactionTestCase`.
raw
~~~
``raw()``
~~~~~~~~~
.. method:: raw(raw_query, params=None, translations=None)
@ -1550,8 +1549,8 @@ See the :doc:`/topics/db/sql` for more information.
filtering. As such, it should generally be called from the ``Manager`` or
from a fresh ``QuerySet`` instance.
Methods that do not return QuerySets
------------------------------------
Methods that do not return ``QuerySet``\s
-----------------------------------------
The following ``QuerySet`` methods evaluate the ``QuerySet`` and return
something *other than* a ``QuerySet``.
@ -1559,8 +1558,8 @@ something *other than* a ``QuerySet``.
These methods do not use a cache (see :ref:`caching-and-querysets`). Rather,
they query the database each time they're called.
get
~~~
``get()``
~~~~~~~~~
.. method:: get(**kwargs)
@ -1589,8 +1588,8 @@ The :exc:`~django.db.models.Model.DoesNotExist` exception inherits from
except ObjectDoesNotExist:
print("Either the entry or blog doesn't exist.")
create
~~~~~~
``create()``
~~~~~~~~~~~~
.. method:: create(**kwargs)
@ -1613,8 +1612,8 @@ database, a call to ``create()`` will fail with an
:exc:`~django.db.IntegrityError` since primary keys must be unique. Be
prepared to handle the exception if you are using manual primary keys.
get_or_create
~~~~~~~~~~~~~
``get_or_create()``
~~~~~~~~~~~~~~~~~~~
.. method:: get_or_create(defaults=None, **kwargs)
@ -1728,8 +1727,8 @@ whenever a request to a page has a side effect on your data. For more, see
chapter because it isn't related to that book, but it can't create it either
because ``title`` field should be unique.
update_or_create
~~~~~~~~~~~~~~~~
``update_or_create()``
~~~~~~~~~~~~~~~~~~~~~~
.. method:: update_or_create(defaults=None, **kwargs)
@ -1770,8 +1769,8 @@ As described above in :meth:`get_or_create`, this method is prone to a
race-condition which can result in multiple rows being inserted simultaneously
if uniqueness is not enforced at the database level.
bulk_create
~~~~~~~~~~~
``bulk_create()``
~~~~~~~~~~~~~~~~~
.. method:: bulk_create(objs, batch_size=None)
@ -1802,8 +1801,8 @@ The ``batch_size`` parameter controls how many objects are created in single
query. The default is to create all objects in one batch, except for SQLite
where the default is such that at most 999 variables per query are used.
count
~~~~~
``count()``
~~~~~~~~~~~
.. method:: count()
@ -1833,8 +1832,8 @@ retrieving model instances from it (for example, by iterating over it), it's
probably more efficient to use ``len(queryset)`` which won't cause an extra
database query like ``count()`` would.
in_bulk
~~~~~~~
``in_bulk()``
~~~~~~~~~~~~~
.. method:: in_bulk(id_list=None)
@ -1859,8 +1858,8 @@ If you pass ``in_bulk()`` an empty list, you'll get an empty dictionary.
In older versions, ``id_list`` was a required argument.
iterator
~~~~~~~~
``iterator()``
~~~~~~~~~~~~~~
.. method:: iterator()
@ -1889,8 +1888,8 @@ ignored since these two optimizations do not make sense together.
.. _server side cursors: http://initd.org/psycopg/docs/usage.html#server-side-cursors
latest
~~~~~~
``latest()``
~~~~~~~~~~~~
.. method:: latest(field_name=None)
@ -1914,16 +1913,16 @@ given parameters.
Note that ``earliest()`` and ``latest()`` exist purely for convenience and
readability.
earliest
~~~~~~~~
``earliest()``
~~~~~~~~~~~~~~
.. method:: earliest(field_name=None)
Works otherwise like :meth:`~django.db.models.query.QuerySet.latest` except
the direction is changed.
first
~~~~~
``first()``
~~~~~~~~~~~
.. method:: first()
@ -1943,14 +1942,15 @@ equivalent to the above example::
except IndexError:
p = None
last
~~~~
``last()``
~~~~~~~~~~
.. method:: last()
Works like :meth:`first()`, but returns the last object in the queryset.
aggregate
~~~~~~~~~
``aggregate()``
~~~~~~~~~~~~~~~
.. method:: aggregate(*args, **kwargs)
@ -1985,8 +1985,8 @@ control the name of the aggregation value that is returned::
For an in-depth discussion of aggregation, see :doc:`the topic guide on
Aggregation </topics/db/aggregation>`.
exists
~~~~~~
``exists()``
~~~~~~~~~~~~
.. method:: exists()
@ -2031,8 +2031,8 @@ more overall work (one query for the existence check plus an extra one to later
retrieve the results) than simply using ``bool(some_queryset)``, which
retrieves the results and then checks if any were returned.
update
~~~~~~
``update()``
~~~~~~~~~~~~
.. method:: update(**kwargs)
@ -2105,8 +2105,8 @@ update a bunch of records for a model that has a custom
e.comments_on = False
e.save()
delete
~~~~~~
``delete()``
~~~~~~~~~~~~
.. method:: delete()
@ -2163,8 +2163,8 @@ ForeignKeys which are set to :attr:`~django.db.models.ForeignKey.on_delete`
Note that the queries generated in object deletion is an implementation
detail subject to change.
as_manager
~~~~~~~~~~
``as_manager()``
~~~~~~~~~~~~~~~~
.. classmethod:: as_manager()
@ -2174,8 +2174,8 @@ with a copy of the ``QuerySet``s methods. See
.. _field-lookups:
Field lookups
-------------
``Field`` lookups
-----------------
Field lookups are how you specify the meat of an SQL ``WHERE`` clause. They're
specified as keyword arguments to the ``QuerySet`` methods :meth:`filter()`,
@ -2192,8 +2192,8 @@ As a convenience when no lookup type is provided (like in
.. fieldlookup:: exact
exact
~~~~~
``exact``
~~~~~~~~~
Exact match. If the value provided for comparison is ``None``, it will be
interpreted as an SQL ``NULL`` (see :lookup:`isnull` for more details).
@ -2219,8 +2219,8 @@ SQL equivalents::
.. fieldlookup:: iexact
iexact
~~~~~~
``iexact``
~~~~~~~~~~
Case-insensitive exact match. If the value provided for comparison is ``None``,
it will be interpreted as an SQL ``NULL`` (see :lookup:`isnull` for more
@ -2248,8 +2248,8 @@ Note the first query will match ``'Beatles Blog'``, ``'beatles blog'``,
.. fieldlookup:: contains
contains
~~~~~~~~
``contains``
~~~~~~~~~~~~
Case-sensitive containment test.
@ -2273,8 +2273,8 @@ honored today'``.
.. fieldlookup:: icontains
icontains
~~~~~~~~~
``icontains``
~~~~~~~~~~~~~
Case-insensitive containment test.
@ -2294,8 +2294,8 @@ SQL equivalent::
.. fieldlookup:: in
in
~~
``in``
~~~~~~
In a given list.
@ -2353,8 +2353,8 @@ extract two field values, where only one is expected::
.. fieldlookup:: gt
gt
~~
``gt``
~~~~~~
Greater than.
@ -2368,29 +2368,29 @@ SQL equivalent::
.. fieldlookup:: gte
gte
~~~
``gte``
~~~~~~~
Greater than or equal to.
.. fieldlookup:: lt
lt
~~
``lt``
~~~~~~
Less than.
.. fieldlookup:: lte
lte
~~~
``lte``
~~~~~~~
Less than or equal to.
.. fieldlookup:: startswith
startswith
~~~~~~~~~~
``startswith``
~~~~~~~~~~~~~~
Case-sensitive starts-with.
@ -2407,8 +2407,8 @@ like ``istartswith`` for SQLite.
.. fieldlookup:: istartswith
istartswith
~~~~~~~~~~~
``istartswith``
~~~~~~~~~~~~~~~
Case-insensitive starts-with.
@ -2428,8 +2428,8 @@ SQL equivalent::
.. fieldlookup:: endswith
endswith
~~~~~~~~
``endswith``
~~~~~~~~~~~~
Case-sensitive ends-with.
@ -2449,8 +2449,8 @@ SQL equivalent::
.. fieldlookup:: iendswith
iendswith
~~~~~~~~~
``iendswith``
~~~~~~~~~~~~~
Case-insensitive ends-with.
@ -2470,8 +2470,8 @@ SQL equivalent::
.. fieldlookup:: range
range
~~~~~
``range``
~~~~~~~~~
Range test (inclusive).
@ -2502,8 +2502,8 @@ numbers and even characters.
.. fieldlookup:: date
date
~~~~
``date``
~~~~~~~~
.. versionadded:: 1.9
@ -2523,8 +2523,8 @@ zone before filtering.
.. fieldlookup:: year
year
~~~~
``year``
~~~~~~~~
For date and datetime fields, an exact year match. Allows chaining additional
field lookups. Takes an integer year.
@ -2550,8 +2550,8 @@ current time zone before filtering.
.. fieldlookup:: month
month
~~~~~
``month``
~~~~~~~~~
For date and datetime fields, an exact month match. Allows chaining additional
field lookups. Takes an integer 1 (January) through 12 (December).
@ -2578,8 +2578,8 @@ in the database <database-time-zone-definitions>`.
.. fieldlookup:: day
day
~~~
``day``
~~~~~~~
For date and datetime fields, an exact day match. Allows chaining additional
field lookups. Takes an integer day.
@ -2609,8 +2609,8 @@ in the database <database-time-zone-definitions>`.
.. fieldlookup:: week_day
week_day
~~~~~~~~
``week_day``
~~~~~~~~~~~~
For date and datetime fields, a 'day of the week' match. Allows chaining
additional field lookups.
@ -2640,8 +2640,8 @@ in the database <database-time-zone-definitions>`.
.. fieldlookup:: hour
hour
~~~~
``hour``
~~~~~~~~
For datetime and time fields, an exact hour match. Allows chaining additional
field lookups. Takes an integer between 0 and 23.
@ -2674,8 +2674,8 @@ to the current time zone before filtering.
.. fieldlookup:: minute
minute
~~~~~~
``minute``
~~~~~~~~~~
For datetime and time fields, an exact minute match. Allows chaining additional
field lookups. Takes an integer between 0 and 59.
@ -2708,8 +2708,8 @@ to the current time zone before filtering.
.. fieldlookup:: second
second
~~~~~~
``second``
~~~~~~~~~~
For datetime and time fields, an exact second match. Allows chaining additional
field lookups. Takes an integer between 0 and 59.
@ -2742,8 +2742,8 @@ to the current time zone before filtering.
.. fieldlookup:: isnull
isnull
~~~~~~
``isnull``
~~~~~~~~~~
Takes either ``True`` or ``False``, which correspond to SQL queries of
``IS NULL`` and ``IS NOT NULL``, respectively.
@ -2758,8 +2758,8 @@ SQL equivalent::
.. fieldlookup:: search
search
~~~~~~
``search``
~~~~~~~~~~
A boolean full-text search, taking advantage of full-text indexing. This is
like :lookup:`contains` but is significantly faster due to full-text indexing.
@ -2780,8 +2780,8 @@ full text searches. See the `MySQL documentation`_ for additional details.
.. fieldlookup:: regex
regex
~~~~~
``regex``
~~~~~~~~~
Case-sensitive regular expression match.
@ -2809,8 +2809,8 @@ regular expression syntax is recommended.
.. fieldlookup:: iregex
iregex
~~~~~~
``iregex``
~~~~~~~~~~
Case-insensitive regular expression match.
@ -2882,8 +2882,8 @@ of the return value
Keyword arguments that can provide extra context for the SQL generated
by the aggregate.
Avg
~~~
``Avg``
~~~~~~~
.. class:: Avg(expression, output_field=FloatField(), **extra)
@ -2899,8 +2899,8 @@ Avg
The ``output_field`` parameter was added to allow aggregating over
non-numeric columns, such as ``DurationField``.
Count
~~~~~
``Count``
~~~~~~~~~
.. class:: Count(expression, distinct=False, **extra)
@ -2918,8 +2918,8 @@ Count
This is the SQL equivalent of ``COUNT(DISTINCT <field>)``. The default
value is ``False``.
Max
~~~
``Max``
~~~~~~~
.. class:: Max(expression, output_field=None, **extra)
@ -2928,8 +2928,8 @@ Max
* Default alias: ``<field>__max``
* Return type: same as input field, or ``output_field`` if supplied
Min
~~~
``Min``
~~~~~~~
.. class:: Min(expression, output_field=None, **extra)
@ -2938,8 +2938,8 @@ Min
* Default alias: ``<field>__min``
* Return type: same as input field, or ``output_field`` if supplied
StdDev
~~~~~~
``StdDev``
~~~~~~~~~~
.. class:: StdDev(expression, sample=False, **extra)
@ -2962,8 +2962,8 @@ StdDev
documentation`_ for instructions on obtaining and installing this
extension.
Sum
~~~
``Sum``
~~~~~~~
.. class:: Sum(expression, output_field=None, **extra)
@ -2972,8 +2972,8 @@ Sum
* Default alias: ``<field>__sum``
* Return type: same as input field, or ``output_field`` if supplied
Variance
~~~~~~~~
``Variance``
~~~~~~~~~~~~
.. class:: Variance(expression, sample=False, **extra)

View File

@ -19,8 +19,8 @@ This document explains the APIs for :class:`HttpRequest` and
:class:`HttpResponse` objects, which are defined in the :mod:`django.http`
module.
HttpRequest objects
===================
``HttpRequest`` objects
=======================
.. class:: HttpRequest
@ -374,8 +374,8 @@ Methods
process(element)
QueryDict objects
=================
``QueryDict`` objects
=====================
.. class:: QueryDict
@ -571,8 +571,8 @@ In addition, ``QueryDict`` has the following methods:
>>> q.urlencode(safe='/')
'next=/a%26b/'
HttpResponse objects
====================
``HttpResponse`` objects
========================
.. class:: HttpResponse
@ -855,8 +855,8 @@ Methods
.. _ref-httpresponse-subclasses:
HttpResponse subclasses
-----------------------
``HttpResponse`` subclasses
---------------------------
Django includes a number of ``HttpResponse`` subclasses that handle different
types of HTTP responses. Like ``HttpResponse``, these subclasses live in
@ -921,8 +921,8 @@ types of HTTP responses. Like ``HttpResponse``, these subclasses live in
:class:`~django.template.response.SimpleTemplateResponse`, and the
``render`` method must itself return a valid response object.
JsonResponse objects
====================
``JsonResponse`` objects
========================
.. class:: JsonResponse(data, encoder=DjangoJSONEncoder, safe=True, json_dumps_params=None, **kwargs)
@ -994,8 +994,8 @@ parameter to the constructor method::
.. _httpresponse-streaming:
StreamingHttpResponse objects
=============================
``StreamingHttpResponse`` objects
=================================
.. class:: StreamingHttpResponse
@ -1069,8 +1069,8 @@ Attributes
This is always ``True``.
FileResponse objects
====================
``FileResponse`` objects
========================
.. class:: FileResponse

View File

@ -42,8 +42,8 @@ migrations will look for: ``can_rollback_ddl`` and
Methods
=======
execute
-------
``execute()``
-------------
.. method:: BaseDatabaseSchemaEditor.execute(sql, params=[])
@ -51,24 +51,24 @@ Executes the SQL statement passed in, with parameters if supplied. This
is a simple wrapper around the normal database cursors that allows
capture of the SQL to a ``.sql`` file if the user wishes.
create_model
------------
``create_model()``
------------------
.. method:: BaseDatabaseSchemaEditor.create_model(model)
Creates a new table in the database for the provided model, along with any
unique constraints or indexes it requires.
delete_model
------------
``delete_model()``
------------------
.. method:: BaseDatabaseSchemaEditor.delete_model(model)
Drops the model's table in the database along with any unique constraints
or indexes it has.
alter_unique_together
---------------------
``alter_unique_together()``
---------------------------
.. method:: BaseDatabaseSchemaEditor.alter_unique_together(model, old_unique_together, new_unique_together)
@ -76,8 +76,8 @@ Changes a model's :attr:`~django.db.models.Options.unique_together` value; this
will add or remove unique constraints from the model's table until they match
the new value.
alter_index_together
--------------------
``alter_index_together()``
--------------------------
.. method:: BaseDatabaseSchemaEditor.alter_index_together(model, old_index_together, new_index_together)
@ -85,22 +85,22 @@ Changes a model's :attr:`~django.db.models.Options.index_together` value; this
will add or remove indexes from the model's table until they match the new
value.
alter_db_table
--------------
``alter_db_table()``
--------------------
.. method:: BaseDatabaseSchemaEditor.alter_db_table(model, old_db_table, new_db_table)
Renames the model's table from ``old_db_table`` to ``new_db_table``.
alter_db_tablespace
-------------------
``alter_db_tablespace()``
-------------------------
.. method:: BaseDatabaseSchemaEditor.alter_db_tablespace(model, old_db_tablespace, new_db_tablespace)
Moves the model's table from one tablespace to another.
add_field
---------
``add_field()``
---------------
.. method:: BaseDatabaseSchemaEditor.add_field(model, field)
@ -115,8 +115,8 @@ of creating a column, it will make a table to represent the relationship. If
If the field is a ``ForeignKey``, this will also add the foreign key
constraint to the column.
remove_field
------------
``remove_field()``
------------------
.. method:: BaseDatabaseSchemaEditor.remove_field(model, field)
@ -128,8 +128,8 @@ If the field is a ManyToManyField without a value for ``through``, it will
remove the table created to track the relationship. If
``through`` is provided, it is a no-op.
alter_field
------------
``alter_field()``
-----------------
.. method:: BaseDatabaseSchemaEditor.alter_field(model, old_field, new_field, strict=False)
@ -155,8 +155,8 @@ Attributes
All attributes should be considered read-only unless stated otherwise.
connection
----------
``connection``
--------------
.. attribute:: SchemaEditor.connection

File diff suppressed because it is too large Load Diff

View File

@ -42,8 +42,8 @@ model system.
as ``'polls.Answer'``. This sort of reference can be quite handy when
dealing with circular import dependencies and swappable models.
pre_init
--------
``pre_init``
------------
.. attribute:: django.db.models.signals.pre_init
:module:
@ -81,8 +81,8 @@ Argument Value
``kwargs`` ``{'question': "What's up?", 'pub_date': datetime.now()}``
========== ===============================================================
post_init
---------
``post_init``
-------------
.. data:: django.db.models.signals.post_init
:module:
@ -97,8 +97,8 @@ Arguments sent with this signal:
``instance``
The actual instance of the model that's just been created.
pre_save
--------
``pre_save``
------------
.. data:: django.db.models.signals.pre_save
:module:
@ -127,8 +127,8 @@ Arguments sent with this signal:
The set of fields to update explicitly specified in the ``save()`` method.
``None`` if this argument was not used in the ``save()`` call.
post_save
---------
``post_save``
-------------
.. data:: django.db.models.signals.post_save
:module:
@ -160,8 +160,8 @@ Arguments sent with this signal:
The set of fields to update explicitly specified in the ``save()`` method.
``None`` if this argument was not used in the ``save()`` call.
pre_delete
----------
``pre_delete``
--------------
.. data:: django.db.models.signals.pre_delete
:module:
@ -180,8 +180,8 @@ Arguments sent with this signal:
``using``
The database alias being used.
post_delete
-----------
``post_delete``
---------------
.. data:: django.db.models.signals.post_delete
:module:
@ -204,8 +204,8 @@ Arguments sent with this signal:
``using``
The database alias being used.
m2m_changed
-----------
``m2m_changed``
---------------
.. data:: django.db.models.signals.m2m_changed
:module:
@ -343,8 +343,8 @@ Argument Value
``using`` ``"default"`` (since the default router sends writes here)
============== ============================================================
class_prepared
--------------
``class_prepared``
------------------
.. data:: django.db.models.signals.class_prepared
:module:
@ -369,8 +369,8 @@ Management signals
Signals sent by :doc:`django-admin </ref/django-admin>`.
pre_migrate
-----------
``pre_migrate``
---------------
.. data:: django.db.models.signals.pre_migrate
:module:
@ -405,8 +405,8 @@ Arguments sent with this signal:
``using``
The alias of database on which a command will operate.
post_migrate
------------
``post_migrate``
----------------
.. data:: django.db.models.signals.post_migrate
:module:
@ -480,8 +480,8 @@ Request/response signals
Signals sent by the core framework when processing a request.
request_started
---------------
``request_started``
-------------------
.. data:: django.core.signals.request_started
:module:
@ -496,8 +496,8 @@ Arguments sent with this signal:
``environ``
The ``environ`` dictionary provided to the request.
request_finished
----------------
``request_finished``
--------------------
.. data:: django.core.signals.request_finished
:module:
@ -517,8 +517,8 @@ Arguments sent with this signal:
``sender``
The handler class, as above.
got_request_exception
---------------------
``got_request_exception``
-------------------------
.. data:: django.core.signals.got_request_exception
:module:
@ -541,8 +541,8 @@ Test signals
Signals only sent when :ref:`running tests <running-tests>`.
setting_changed
---------------
``setting_changed``
-------------------
.. data:: django.test.signals.setting_changed
:module:
@ -573,8 +573,8 @@ Arguments sent with this signal:
``enter``
A boolean; ``True`` if the setting is applied, ``False`` if restored.
template_rendered
-----------------
``template_rendered``
---------------------
.. data:: django.test.signals.template_rendered
:module:
@ -603,8 +603,8 @@ Database Wrappers
Signals sent by the database wrapper when a database connection is
initiated.
connection_created
------------------
``connection_created``
----------------------
.. data:: django.db.backends.signals.connection_created
:module:

View File

@ -1,6 +1,6 @@
===========================================
TemplateResponse and SimpleTemplateResponse
===========================================
===================================================
``TemplateResponse`` and ``SimpleTemplateResponse``
===================================================
.. module:: django.template.response
:synopsis: Classes dealing with lazy-rendered HTTP responses.
@ -21,8 +21,8 @@ the details of the template and context that was provided by the view to
compute the response. The final output of the response is not computed until
it is needed, later in the response process.
SimpleTemplateResponse objects
==============================
``SimpleTemplateResponse`` objects
==================================
.. class:: SimpleTemplateResponse()
@ -137,8 +137,8 @@ Methods
subsequent calls, it will return the result obtained from the first call.
TemplateResponse objects
========================
``TemplateResponse`` objects
============================
.. class:: TemplateResponse()
@ -278,8 +278,8 @@ has been rendered, and will be provided the fully rendered
If the template has already been rendered, the callback will be
invoked immediately.
Using TemplateResponse and SimpleTemplateResponse
=================================================
Using ``TemplateResponse`` and ``SimpleTemplateResponse``
=========================================================
A :class:`TemplateResponse` object can be used anywhere that a normal
:class:`django.http.HttpResponse` can be used. It can also be used as an

View File

@ -421,8 +421,8 @@ variables or use a custom template tag or filter to workaround the limitation.
.. _playing-with-context:
Playing with Context objects
============================
Playing with ``Context`` objects
================================
Most of the time, you'll instantiate :class:`Context` objects by passing in a
fully-populated dictionary to ``Context()``. But you can add and delete items
@ -579,8 +579,8 @@ against ``dict``::
.. _subclassing-context-requestcontext:
Subclassing Context: RequestContext
-----------------------------------
Subclassing ``Context``: ``RequestContext``
-------------------------------------------
.. class:: RequestContext(request, dict_=None, processors=None)
@ -667,8 +667,8 @@ Here's what each of the built-in processors does:
.. currentmodule:: django.contrib.auth.context_processors
django.contrib.auth.context_processors.auth
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``django.contrib.auth.context_processors.auth``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. function:: auth
@ -685,8 +685,8 @@ variables:
.. currentmodule:: django.template.context_processors
django.template.context_processors.debug
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``django.template.context_processors.debug``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. function:: debug
@ -702,8 +702,8 @@ the request's IP address (``request.META['REMOTE_ADDR']``) is in the
and how long it took. The list is in order by query and lazily generated
on access.
django.template.context_processors.i18n
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``django.template.context_processors.i18n``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If this processor is enabled, every ``RequestContext`` will contain these two
variables:
@ -714,35 +714,35 @@ variables:
See :doc:`/topics/i18n/index` for more.
django.template.context_processors.media
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``django.template.context_processors.media``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If this processor is enabled, every ``RequestContext`` will contain a variable
``MEDIA_URL``, providing the value of the :setting:`MEDIA_URL` setting.
django.template.context_processors.static
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``django.template.context_processors.static``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. function:: static
If this processor is enabled, every ``RequestContext`` will contain a variable
``STATIC_URL``, providing the value of the :setting:`STATIC_URL` setting.
django.template.context_processors.csrf
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``django.template.context_processors.csrf``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This processor adds a token that is needed by the :ttag:`csrf_token` template
tag for protection against :doc:`Cross Site Request Forgeries
</ref/csrf>`.
django.template.context_processors.request
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``django.template.context_processors.request``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If this processor is enabled, every ``RequestContext`` will contain a variable
``request``, which is the current :class:`~django.http.HttpRequest`.
django.contrib.messages.context_processors.messages
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``django.contrib.messages.context_processors.messages``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If this processor is enabled, every ``RequestContext`` will contain these two
variables:

View File

@ -16,8 +16,8 @@ Built-in tag reference
.. templatetag:: autoescape
autoescape
----------
``autoescape``
--------------
Controls the current auto-escaping behavior. This tag takes either ``on`` or
``off`` as an argument and that determines whether auto-escaping is in effect
@ -40,16 +40,16 @@ Sample usage::
.. templatetag:: block
block
-----
``block``
---------
Defines a block that can be overridden by child templates. See
:ref:`Template inheritance <template-inheritance>` for more information.
.. templatetag:: comment
comment
-------
``comment``
-----------
Ignores everything between ``{% comment %}`` and ``{% endcomment %}``.
An optional note may be inserted in the first tag. For example, this is
@ -66,16 +66,16 @@ Sample usage::
.. templatetag:: csrf_token
csrf_token
----------
``csrf_token``
--------------
This tag is used for CSRF protection, as described in the documentation for
:doc:`Cross Site Request Forgeries </ref/csrf>`.
.. templatetag:: cycle
cycle
-----
``cycle``
---------
Produces one of its arguments each time this tag is encountered. The first
argument is produced on the first encounter, the second argument on the second
@ -187,16 +187,16 @@ call to ``{% cycle %}`` doesn't specify ``silent``::
.. templatetag:: debug
debug
-----
``debug``
---------
Outputs a whole load of debugging information, including the current context
and imported modules.
.. templatetag:: extends
extends
-------
``extends``
-----------
Signals that this template extends a parent template.
@ -214,8 +214,8 @@ See :ref:`template-inheritance` for more information.
.. templatetag:: filter
filter
------
``filter``
----------
Filters the contents of the block through one or more filters. Multiple
filters can be specified with pipes and filters can have arguments, just as
@ -238,8 +238,8 @@ Sample usage::
.. templatetag:: firstof
firstof
-------
``firstof``
-----------
Outputs the first argument variable that is not ``False``. Outputs nothing if
all the passed variables are ``False``.
@ -282,8 +282,8 @@ output inside a variable.
.. templatetag:: for
for
---
``for``
-------
Loops over each item in an array, making the item available in a context
variable. For example, to display a list of athletes provided in
@ -340,8 +340,8 @@ Variable Description
the current one
========================== ===============================================
for ... empty
-------------
``for`` ... ``empty``
---------------------
The ``for`` tag can take an optional ``{% empty %}`` clause whose text is
displayed if the given array is empty or could not be found::
@ -369,8 +369,8 @@ than -- the following::
.. templatetag:: if
if
--
``if``
------
The ``{% if %}`` tag evaluates a variable, and if that variable is "true" (i.e.
exists, is not empty, and is not a false boolean value) the contents of the
@ -583,8 +583,8 @@ The ``ifequal`` and ``ifnotequal`` tags will be deprecated in a future release.
.. templatetag:: ifchanged
ifchanged
---------
``ifchanged``
-------------
Check if a value has changed from the last iteration of a loop.
@ -628,8 +628,8 @@ will be displayed if the value has not changed::
.. templatetag:: include
include
-------
``include``
-----------
Loads a template and renders it with the current context. This is a way of
"including" other templates within a template.
@ -701,8 +701,8 @@ and returns an empty string.
.. templatetag:: load
load
----
``load``
--------
Loads a custom template tag set.
@ -723,8 +723,8 @@ more information.
.. templatetag:: lorem
lorem
-----
``lorem``
---------
Displays random "lorem ipsum" Latin text. This is useful for providing sample
data in templates.
@ -757,8 +757,8 @@ Examples:
.. templatetag:: now
now
---
``now``
-------
Displays the current date and/or time, using a format according to the given
string. Such string can contain format specifiers characters as described
@ -796,8 +796,8 @@ output (as a string) inside a variable. This is useful if you want to use
.. templatetag:: regroup
regroup
-------
``regroup``
-----------
Regroups a list of alike objects by a common attribute.
@ -932,8 +932,8 @@ attribute, allowing you to group on the display string rather than the
.. templatetag:: spaceless
spaceless
---------
``spaceless``
-------------
Removes whitespace between HTML tags. This includes tab
characters and newlines.
@ -961,8 +961,8 @@ this example, the space around ``Hello`` won't be stripped::
.. templatetag:: templatetag
templatetag
-----------
``templatetag``
---------------
Outputs one of the syntax characters used to compose template tags.
@ -990,8 +990,8 @@ Sample usage::
.. templatetag:: url
url
---
``url``
-------
Returns an absolute path reference (a URL without the domain name) matching a
given view and optional parameters. Any special characters in the resulting
@ -1071,8 +1071,8 @@ by the context as to the current application.
.. templatetag:: verbatim
verbatim
--------
``verbatim``
------------
Stops the template engine from rendering the contents of this block tag.
@ -1092,8 +1092,8 @@ You can also designate a specific closing tag, allowing the use of
.. templatetag:: widthratio
widthratio
----------
``widthratio``
--------------
For creating bar charts and such, this tag calculates the ratio of a given
value to a maximum value, and then applies that ratio to a constant.
@ -1115,8 +1115,8 @@ variable. It can be useful, for instance, in a :ttag:`blocktrans` like this::
.. templatetag:: with
with
----
``with``
--------
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.
@ -1146,8 +1146,8 @@ Built-in filter reference
.. templatefilter:: add
add
---
``add``
-------
Adds the argument to the value.
@ -1176,8 +1176,8 @@ output will be ``[1, 2, 3, 4, 5, 6]``.
.. templatefilter:: addslashes
addslashes
----------
``addslashes``
--------------
Adds slashes before quotes. Useful for escaping strings in CSV, for example.
@ -1190,8 +1190,8 @@ If ``value`` is ``"I'm using Django"``, the output will be
.. templatefilter:: capfirst
capfirst
--------
``capfirst``
------------
Capitalizes the first character of the value. If the first character is not
a letter, this filter has no effect.
@ -1204,8 +1204,8 @@ If ``value`` is ``"django"``, the output will be ``"Django"``.
.. templatefilter:: center
center
------
``center``
----------
Centers the value in a field of a given width.
@ -1217,8 +1217,8 @@ If ``value`` is ``"Django"``, the output will be ``" Django "``.
.. templatefilter:: cut
cut
---
``cut``
-------
Removes all values of arg from the given string.
@ -1231,8 +1231,8 @@ If ``value`` is ``"String with spaces"``, the output will be
.. templatefilter:: date
date
----
``date``
--------
Formats a date according to the given format.
@ -1360,8 +1360,8 @@ representation of a ``datetime`` value. E.g.::
.. templatefilter:: default
default
-------
``default``
-----------
If value evaluates to ``False``, uses the given default. Otherwise, uses the
value.
@ -1374,8 +1374,8 @@ If ``value`` is ``""`` (the empty string), the output will be ``nothing``.
.. templatefilter:: default_if_none
default_if_none
---------------
``default_if_none``
-------------------
If (and only if) value is ``None``, uses the given default. Otherwise, uses the
value.
@ -1391,8 +1391,8 @@ If ``value`` is ``None``, the output will be the string ``"nothing"``.
.. templatefilter:: dictsort
dictsort
--------
``dictsort``
------------
Takes a list of dictionaries and returns that list sorted by the key given in
the argument.
@ -1445,8 +1445,8 @@ then the output would be::
.. templatefilter:: dictsortreversed
dictsortreversed
----------------
``dictsortreversed``
--------------------
Takes a list of dictionaries and returns that list sorted in reverse order by
the key given in the argument. This works exactly the same as the above filter,
@ -1454,8 +1454,8 @@ but the returned value will be in reverse order.
.. templatefilter:: divisibleby
divisibleby
-----------
``divisibleby``
---------------
Returns ``True`` if the value is divisible by the argument.
@ -1467,8 +1467,8 @@ If ``value`` is ``21``, the output would be ``True``.
.. templatefilter:: escape
escape
------
``escape``
----------
Escapes a string's HTML. Specifically, it makes these replacements:
@ -1496,8 +1496,8 @@ For example, you can apply ``escape`` to fields when :ttag:`autoescape` is off::
.. templatefilter:: escapejs
escapejs
--------
``escapejs``
------------
Escapes characters for use in JavaScript strings. This does *not* make the
string safe for use in HTML, but does protect you from syntax errors when using
@ -1512,8 +1512,8 @@ the output will be ``"testing\\u000D\\u000Ajavascript \\u0027string\\u0022 \\u00
.. templatefilter:: filesizeformat
filesizeformat
--------------
``filesizeformat``
------------------
Formats the value like a 'human-readable' file size (i.e. ``'13 KB'``,
``'4.1 MB'``, ``'102 bytes'``, etc.).
@ -1534,8 +1534,8 @@ If ``value`` is 123456789, the output would be ``117.7 MB``.
.. templatefilter:: first
first
-----
``first``
---------
Returns the first item in a list.
@ -1547,8 +1547,8 @@ If ``value`` is the list ``['a', 'b', 'c']``, the output will be ``'a'``.
.. templatefilter:: floatformat
floatformat
-----------
``floatformat``
---------------
When used without an argument, rounds a floating-point number to one decimal
place -- but only if there's a decimal part to be displayed. For example:
@ -1600,8 +1600,8 @@ with an argument of ``-1``.
.. templatefilter:: force_escape
force_escape
------------
``force_escape``
----------------
Applies HTML escaping to a string (see the :tfilter:`escape` filter for
details). This filter is applied *immediately* and returns a new, escaped
@ -1618,8 +1618,8 @@ the :tfilter:`linebreaks` filter::
.. templatefilter:: get_digit
get_digit
---------
``get_digit``
-------------
Given a whole number, returns the requested digit, where 1 is the right-most
digit, 2 is the second-right-most digit, etc. Returns the original value for
@ -1634,8 +1634,8 @@ If ``value`` is ``123456789``, the output will be ``8``.
.. templatefilter:: iriencode
iriencode
---------
``iriencode``
-------------
Converts an IRI (Internationalized Resource Identifier) to a string that is
suitable for including in a URL. This is necessary if you're trying to use
@ -1652,8 +1652,8 @@ If ``value`` is ``"?test=1&me=2"``, the output will be ``"?test=1&amp;me=2"``.
.. templatefilter:: join
join
----
``join``
--------
Joins a list with a string, like Python's ``str.join(list)``
@ -1666,8 +1666,8 @@ If ``value`` is the list ``['a', 'b', 'c']``, the output will be the string
.. templatefilter:: last
last
----
``last``
--------
Returns the last item in a list.
@ -1680,8 +1680,8 @@ string ``"d"``.
.. templatefilter:: length
length
------
``length``
----------
Returns the length of the value. This works for both strings and lists.
@ -1696,8 +1696,8 @@ The filter returns ``0`` for an undefined variable.
.. templatefilter:: length_is
length_is
---------
``length_is``
-------------
Returns ``True`` if the value's length is the argument, or ``False`` otherwise.
@ -1710,8 +1710,8 @@ If ``value`` is ``['a', 'b', 'c', 'd']`` or ``"abcd"``, the output will be
.. templatefilter:: linebreaks
linebreaks
----------
``linebreaks``
--------------
Replaces line breaks in plain text with appropriate HTML; a single
newline becomes an HTML line break (``<br />``) and a new line
@ -1726,8 +1726,8 @@ slug</p>``.
.. templatefilter:: linebreaksbr
linebreaksbr
------------
``linebreaksbr``
----------------
Converts all newlines in a piece of plain text to HTML line breaks
(``<br />``).
@ -1741,8 +1741,8 @@ slug``.
.. templatefilter:: linenumbers
linenumbers
-----------
``linenumbers``
---------------
Displays text with line numbers.
@ -1764,8 +1764,8 @@ the output will be::
.. templatefilter:: ljust
ljust
-----
``ljust``
---------
Left-aligns the value in a field of a given width.
@ -1779,8 +1779,8 @@ If ``value`` is ``Django``, the output will be ``"Django "``.
.. templatefilter:: lower
lower
-----
``lower``
---------
Converts a string into all lowercase.
@ -1793,8 +1793,8 @@ If ``value`` is ``Totally LOVING this Album!``, the output will be
.. templatefilter:: make_list
make_list
---------
``make_list``
-------------
Returns the value turned into a list. For a string, it's a list of characters.
For an integer, the argument is cast into an unicode string before creating a
@ -1810,8 +1810,8 @@ list ``['1', '2', '3']``.
.. templatefilter:: phone2numeric
phone2numeric
-------------
``phone2numeric``
-----------------
Converts a phone number (possibly containing letters) to its numerical
equivalent.
@ -1827,8 +1827,8 @@ If ``value`` is ``800-COLLECT``, the output will be ``800-2655328``.
.. templatefilter:: pluralize
pluralize
---------
``pluralize``
-------------
Returns a plural suffix if the value is not 1. By default, this suffix is
``'s'``.
@ -1858,15 +1858,15 @@ Example::
.. templatefilter:: pprint
pprint
------
``pprint``
----------
A wrapper around :func:`pprint.pprint` -- for debugging, really.
.. templatefilter:: random
random
------
``random``
----------
Returns a random item from the given list.
@ -1878,8 +1878,8 @@ If ``value`` is the list ``['a', 'b', 'c', 'd']``, the output could be ``"b"``.
.. templatefilter:: rjust
rjust
-----
``rjust``
---------
Right-aligns the value in a field of a given width.
@ -1893,8 +1893,8 @@ If ``value`` is ``Django``, the output will be ``" Django"``.
.. templatefilter:: safe
safe
----
``safe``
--------
Marks a string as not requiring further HTML escaping prior to output. When
autoescaping is off, this filter has no effect.
@ -1909,8 +1909,8 @@ autoescaping is off, this filter has no effect.
.. templatefilter:: safeseq
safeseq
-------
``safeseq``
-----------
Applies the :tfilter:`safe` filter to each element of a sequence. Useful in
conjunction with other filters that operate on sequences, such as
@ -1924,8 +1924,8 @@ individual elements of the sequence.
.. templatefilter:: slice
slice
-----
``slice``
---------
Returns a slice of the list.
@ -1941,8 +1941,8 @@ If ``some_list`` is ``['a', 'b', 'c']``, the output will be ``['a', 'b']``.
.. templatefilter:: slugify
slugify
-------
``slugify``
-----------
Converts to ASCII. Converts spaces to hyphens. Removes characters that aren't
alphanumerics, underscores, or hyphens. Converts to lowercase. Also strips
@ -1956,8 +1956,8 @@ If ``value`` is ``"Joel is a slug"``, the output will be ``"joel-is-a-slug"``.
.. templatefilter:: stringformat
stringformat
------------
``stringformat``
----------------
Formats the variable according to the argument, a string formatting specifier.
This specifier uses Python string formatting syntax, with the exception that
@ -1974,8 +1974,8 @@ If ``value`` is ``10``, the output will be ``1.000000E+01``.
.. templatefilter:: striptags
striptags
---------
``striptags``
-------------
Makes all possible efforts to strip all [X]HTML tags.
@ -1998,8 +1998,8 @@ output will be ``"Joel is a slug"``.
.. templatefilter:: time
time
----
``time``
--------
Formats a time according to the given format.
@ -2044,8 +2044,8 @@ used, without applying any localization.
.. templatefilter:: timesince
timesince
---------
``timesince``
-------------
Formats a date as the time since that date (e.g., "4 days, 6 hours").
@ -2064,8 +2064,8 @@ date that is in the future relative to the comparison point.
.. templatefilter:: timeuntil
timeuntil
---------
``timeuntil``
-------------
Similar to ``timesince``, except that it measures the time from now until the
given date or datetime. For example, if today is 1 June 2006 and
@ -2085,8 +2085,8 @@ date that is in the past relative to the comparison point.
.. templatefilter:: title
title
-----
``title``
---------
Converts a string into titlecase by making words start with an uppercase
character and the remaining characters lowercase. This tag makes no effort to
@ -2100,8 +2100,8 @@ If ``value`` is ``"my FIRST post"``, the output will be ``"My First Post"``.
.. templatefilter:: truncatechars
truncatechars
-------------
``truncatechars``
-----------------
Truncates a string if it is longer than the specified number of characters.
Truncated strings will end with a translatable ellipsis sequence ("...").
@ -2116,8 +2116,8 @@ If ``value`` is ``"Joel is a slug"``, the output will be ``"Joel i..."``.
.. templatefilter:: truncatechars_html
truncatechars_html
------------------
``truncatechars_html``
----------------------
Similar to :tfilter:`truncatechars`, except that it is aware of HTML tags. Any
tags that are opened in the string and not closed before the truncation point
@ -2134,8 +2134,8 @@ Newlines in the HTML content will be preserved.
.. templatefilter:: truncatewords
truncatewords
-------------
``truncatewords``
-----------------
Truncates a string after a certain number of words.
@ -2151,8 +2151,8 @@ Newlines within the string will be removed.
.. templatefilter:: truncatewords_html
truncatewords_html
------------------
``truncatewords_html``
----------------------
Similar to :tfilter:`truncatewords`, except that it is aware of HTML tags. Any
tags that are opened in the string and not closed before the truncation point,
@ -2172,8 +2172,8 @@ Newlines in the HTML content will be preserved.
.. templatefilter:: unordered_list
unordered_list
--------------
``unordered_list``
------------------
Recursively takes a self-nested list and returns an HTML unordered list --
WITHOUT opening and closing <ul> tags.
@ -2196,8 +2196,8 @@ contains ``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``, then
.. templatefilter:: upper
upper
-----
``upper``
---------
Converts a string into all uppercase.
@ -2209,8 +2209,8 @@ If ``value`` is ``"Joel is a slug"``, the output will be ``"JOEL IS A SLUG"``.
.. templatefilter:: urlencode
urlencode
---------
``urlencode``
-------------
Escapes a value for use in a URL.
@ -2234,8 +2234,8 @@ If ``value`` is ``"https://www.example.org/"``, the output will be
.. templatefilter:: urlize
urlize
------
``urlize``
----------
Converts URLs and email addresses in text into clickable links.
@ -2278,8 +2278,8 @@ Django's built-in :tfilter:`escape` filter. The default value for
.. templatefilter:: urlizetrunc
urlizetrunc
-----------
``urlizetrunc``
---------------
Converts URLs and email addresses into clickable links just like urlize_, but
truncates URLs longer than the given character limit.
@ -2299,8 +2299,8 @@ As with urlize_, this filter should only be applied to plain text.
.. templatefilter:: wordcount
wordcount
---------
``wordcount``
-------------
Returns the number of words.
@ -2312,8 +2312,8 @@ If ``value`` is ``"Joel is a slug"``, the output will be ``4``.
.. templatefilter:: wordwrap
wordwrap
--------
``wordwrap``
------------
Wraps words at specified line length.
@ -2331,8 +2331,8 @@ If ``value`` is ``Joel is a slug``, the output would be::
.. templatefilter:: yesno
yesno
-----
``yesno``
---------
Maps values for ``True``, ``False``, and (optionally) ``None``, to the strings
"yes", "no", "maybe", or a custom mapping passed as a comma-separated list, and
@ -2360,8 +2360,8 @@ Django provides template tags and filters to control each aspect of
:doc:`internationalization </topics/i18n/index>` in templates. They allow for
granular control of translations, formatting, and time zone conversions.
i18n
----
``i18n``
--------
This library allows specifying translatable text in templates.
To enable it, set :setting:`USE_I18N` to ``True``, then load it with
@ -2369,8 +2369,8 @@ To enable it, set :setting:`USE_I18N` to ``True``, then load it with
See :ref:`specifying-translation-strings-in-template-code`.
l10n
----
``l10n``
--------
This library provides control over the localization of values in templates.
You only need to load the library using ``{% load l10n %}``, but you'll often
@ -2378,8 +2378,8 @@ set :setting:`USE_L10N` to ``True`` so that localization is active by default.
See :ref:`topic-l10n-templates`.
tz
--
``tz``
------
This library provides control over time zone conversions in templates.
Like ``l10n``, you only need to load the library using ``{% load tz %}``,
@ -2395,19 +2395,19 @@ Django comes with a couple of other template-tag libraries that you have to
enable explicitly in your :setting:`INSTALLED_APPS` setting and enable in your
template with the :ttag:`{% load %}<load>` tag.
django.contrib.humanize
-----------------------
``django.contrib.humanize``
---------------------------
A set of Django template filters useful for adding a "human touch" to data. See
:doc:`/ref/contrib/humanize`.
static
------
``static``
----------
.. templatetag:: static
static
~~~~~~
``static``
~~~~~~~~~~
To link to static files that are saved in :setting:`STATIC_ROOT` Django ships
with a :ttag:`static` template tag. If the :mod:`django.contrib.staticfiles`
@ -2443,8 +2443,8 @@ slightly different call::
.. templatetag:: get_static_prefix
get_static_prefix
~~~~~~~~~~~~~~~~~
``get_static_prefix``
~~~~~~~~~~~~~~~~~~~~~
You should prefer the :ttag:`static` template tag, but if you need more control
over exactly where and how :setting:`STATIC_URL` is injected into the template,
@ -2464,8 +2464,8 @@ the value multiple times::
.. templatetag:: get_media_prefix
get_media_prefix
~~~~~~~~~~~~~~~~
``get_media_prefix``
~~~~~~~~~~~~~~~~~~~~
Similar to the :ttag:`get_static_prefix`, ``get_media_prefix`` populates a
template variable with the media prefix :setting:`MEDIA_URL`, e.g.::

View File

@ -10,8 +10,8 @@
``django.core.urlresolvers``. Importing from the old location will continue
to work until Django 2.0.
reverse()
=========
``reverse()``
=============
If you need to use something similar to the :ttag:`url` template tag in
your code, Django provides the following function:
@ -80,8 +80,8 @@ use for reversing. By default, the root URLconf for the current thread is used.
``urllib.quote``) to the output of ``reverse()`` may produce undesirable
results.
reverse_lazy()
==============
``reverse_lazy()``
==================
A lazily evaluated version of `reverse()`_.
@ -100,8 +100,8 @@ URLConf is loaded. Some common cases where this function is necessary are:
* providing a reversed URL as a default value for a parameter in a function's
signature.
resolve()
=========
``resolve()``
=============
The ``resolve()`` function can be used for resolving URL paths to the
corresponding view functions. It has the following signature:
@ -202,8 +202,8 @@ view would raise a ``Http404`` error before redirecting to it::
return HttpResponseRedirect('/')
return response
get_script_prefix()
===================
``get_script_prefix()``
=======================
.. function:: get_script_prefix()

View File

@ -4,8 +4,8 @@
.. module:: django.conf.urls
static()
========
``static()``
============
.. function:: static.static(prefix, view=django.views.static.serve, **kwargs)
@ -18,8 +18,8 @@ Helper function to return a URL pattern for serving files in debug mode::
# ... the rest of your URLconf goes here ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
url()
=====
``url()``
=========
.. function:: url(regex, view, kwargs=None, name=None)
@ -36,8 +36,8 @@ function or method. See :ref:`views-extra-options` for an example.
See :ref:`Naming URL patterns <naming-url-patterns>` for why the ``name``
parameter is useful.
include()
=========
``include()``
=============
.. function:: include(module, namespace=None, app_name=None)
include(pattern_list)
@ -85,8 +85,8 @@ See :ref:`including-other-urlconfs` and :ref:`namespaces-and-include`.
has been deprecated and will be removed in Django 2.0. Specify the
application namespace or remove the instance namespace.
handler400
==========
``handler400``
==============
.. data:: handler400
@ -101,8 +101,8 @@ implement a custom view, be sure it returns an
See the documentation about :ref:`the 400 (bad request) view
<http_bad_request_view>` for more information.
handler403
==========
``handler403``
==============
.. data:: handler403
@ -117,8 +117,8 @@ implement a custom view, be sure it returns an
See the documentation about :ref:`the 403 (HTTP Forbidden) view
<http_forbidden_view>` for more information.
handler404
==========
``handler404``
==============
.. data:: handler404
@ -132,8 +132,8 @@ implement a custom view, be sure it returns an
See the documentation about :ref:`the 404 (HTTP Not Found) view
<http_not_found_view>` for more information.
handler500
==========
``handler500``
==============
.. data:: handler500

View File

@ -335,8 +335,8 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
See https://web.archive.org/web/20110514113830/http://diveintomark.org/archives/2004/05/28/howto-atom-id
SyndicationFeed
---------------
``SyndicationFeed``
-------------------
.. class:: SyndicationFeed
@ -402,34 +402,34 @@ SyndicationFeed
feed. If no items have either of these attributes this returns the
current date/time.
Enclosure
---------
``Enclosure``
-------------
.. class:: Enclosure
Represents an RSS enclosure
RssFeed
-------
``RssFeed``
-----------
.. class:: RssFeed(SyndicationFeed)
Rss201rev2Feed
--------------
``Rss201rev2Feed``
------------------
.. class:: Rss201rev2Feed(RssFeed)
Spec: https://cyber.law.harvard.edu/rss/rss.html
RssUserland091Feed
------------------
``RssUserland091Feed``
----------------------
.. class:: RssUserland091Feed(RssFeed)
Spec: http://backend.userland.com/rss091
Atom1Feed
---------
``Atom1Feed``
-------------
.. class:: Atom1Feed(SyndicationFeed)

View File

@ -289,8 +289,8 @@ example, the following checks if a user may view tasks::
.. _extending-user:
Extending the existing User model
=================================
Extending the existing ``User`` model
=====================================
There are two ways to extend the default
:class:`~django.contrib.auth.models.User` model without substituting your own
@ -360,8 +360,8 @@ the extra database load.
.. _auth-custom-user:
Substituting a custom User model
================================
Substituting a custom ``User`` model
====================================
Some kinds of projects may have authentication requirements for which Django's
built-in :class:`~django.contrib.auth.models.User` model is not always
@ -414,8 +414,8 @@ use as your User model.
:class:`~django.db.models.OneToOneField` to ``settings.AUTH_USER_MODEL``
as described below.
Referencing the User model
--------------------------
Referencing the ``User`` model
------------------------------
.. currentmodule:: django.contrib.auth
@ -462,8 +462,8 @@ different User model.
.. _specifying-custom-user-model:
Specifying a custom User model
------------------------------
Specifying a custom ``User`` model
----------------------------------
.. admonition:: Model design considerations
@ -716,8 +716,8 @@ utility methods:
* ``o``, ``O``, and ``0`` (lowercase letter o, uppercase letter o,
and zero)
Extending Django's default User
-------------------------------
Extending Django's default ``User``
-----------------------------------
If you're entirely happy with Django's :class:`~django.contrib.auth.models.User`
model and you just want to add some additional profile information, you could
@ -875,16 +875,16 @@ methods and attributes:
(the Django app label). If the user is inactive, this method will
always return ``False``.
.. admonition:: ModelBackend
.. admonition:: ``PermissionsMixin`` and ``ModelBackend``
If you don't include the
:class:`~django.contrib.auth.models.PermissionsMixin`, you must ensure you
don't invoke the permissions methods on ``ModelBackend``. ``ModelBackend``
assumes that certain fields are available on your user model. If your User
model doesn't provide those fields, you will receive database errors when
you check permissions.
assumes that certain fields are available on your user model. If your
``User`` model doesn't provide those fields, you will receive database
errors when you check permissions.
Custom users and Proxy models
Custom users and proxy models
-----------------------------
One limitation of custom User models is that installing a custom User model

View File

@ -17,8 +17,8 @@ are somewhat coupled.
.. _user-objects:
User objects
============
``User`` objects
================
:class:`~django.contrib.auth.models.User` objects are the core of the
authentication system. They typically represent the people interacting with
@ -112,7 +112,7 @@ passwords.
Changing a user's password will log out all their sessions. See
:ref:`session-invalidation-on-password-change` for details.
Authenticating Users
Authenticating users
--------------------
.. function:: authenticate(\**credentials)
@ -363,13 +363,14 @@ If you have an authenticated user you want to attach to the current session
:func:`~django.contrib.auth.login()`. Now you can set the backend using
the new ``backend`` argument.
Selecting the :ref:`authentication backend <authentication-backends>`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Selecting the authentication backend
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When a user logs in, the user's ID and the backend that was used for
authentication are saved in the user's session. This allows the same
authentication backend to fetch the user's details on a future request. The
authentication backend to save in the session is selected as follows:
:ref:`authentication backend <authentication-backends>` to fetch the user's
details on a future request. The authentication backend to save in the session
is selected as follows:
#. Use the value of the optional ``backend`` argument, if provided.
#. Use the value of the ``user.backend`` attribute, if present. This allows
@ -1673,7 +1674,7 @@ model. Groups can be created, and permissions can be assigned to users or
groups. A log of user edits to models made within the admin is also stored and
displayed.
Creating Users
Creating users
--------------
You should see a link to "Users" in the "Auth"
@ -1695,7 +1696,7 @@ non-superuser the ability to edit users, this is ultimately the same as giving
them superuser status because they will be able to elevate permissions of
users including themselves!
Changing Passwords
Changing passwords
------------------
User passwords are not displayed in the admin (nor stored in the database), but

View File

@ -74,8 +74,8 @@ setting.
.. _bcrypt_usage:
Using bcrypt with Django
------------------------
Using ``bcrypt`` with Django
----------------------------
Bcrypt_ is a popular password storage algorithm that's specifically designed
for long-term password storage. It's not the default used by Django since it

View File

@ -1049,8 +1049,8 @@ pages. We'll look at some of these headers in the sections that follow.
.. _using-vary-headers:
Using Vary headers
==================
Using ``Vary`` headers
======================
The ``Vary`` header defines which request headers a cache
mechanism should take into account when building its cache key. For example, if
@ -1231,8 +1231,8 @@ Example::
.. _`Cache-Control spec`: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
Order of MIDDLEWARE_CLASSES
===========================
Order of ``MIDDLEWARE_CLASSES``
===============================
If you use caching middleware, it's important to put each half in the right
place within the :setting:`MIDDLEWARE_CLASSES` setting. That's because the cache

View File

@ -120,7 +120,7 @@ The code below is equivalent to the code above::
.. _field-checking:
Field, Model, and Manager checks
Field, model, and manager checks
--------------------------------
In some cases, you won't need to register your check function -- you can
@ -185,7 +185,7 @@ the only difference is that the check is a classmethod, not an instance method::
# ... your own checks ...
return errors
Writing Tests
Writing tests
-------------
Messages are comparable. That allows you to easily write tests::

View File

@ -13,7 +13,7 @@ Implementing this yourself often results in a lot of repeated boilerplate code
this, Django provides a collection of generic class-based views for form
processing.
Basic Forms
Basic forms
===========
Given a simple contact form:
@ -60,7 +60,7 @@ Notes:
:meth:`~django.views.generic.edit.FormMixin.form_valid` simply
redirects to the :attr:`~django.views.generic.edit.FormMixin.success_url`.
Model Forms
Model forms
===========
Generic views really shine when working with models. These generic
@ -180,8 +180,8 @@ Finally, we hook these new views into the URLconf:
:attr:`~django.views.generic.detail.SingleObjectTemplateResponseMixin.template_name_suffix`
on your view class.
Models and request.user
=======================
Models and ``request.user``
===========================
To track the user that created an object using a :class:`CreateView`,
you can use a custom :class:`~django.forms.ModelForm` to do this. First, add

View File

@ -86,8 +86,8 @@ date-based generic views. These are
covered in the :doc:`mixin reference
documentation</ref/class-based-views/mixins>`.
DetailView: working with a single Django object
-----------------------------------------------
``DetailView``: working with a single Django object
---------------------------------------------------
To show the detail of an object, we basically need to do two things:
we need to look up the object and then we need to make a
@ -124,8 +124,8 @@ on a subclass to something else. (For instance, the :doc:`generic edit
views<generic-editing>` use ``_form`` for create and update views, and
``_confirm_delete`` for delete views.)
ListView: working with many Django objects
------------------------------------------
``ListView``: working with many Django objects
----------------------------------------------
Lists of objects follow roughly the same pattern: we need a (possibly
paginated) list of objects, typically a
@ -208,8 +208,8 @@ the box.
.. _method resolution order: https://www.python.org/download/releases/2.3/mro/
Using SingleObjectMixin with View
---------------------------------
Using ``SingleObjectMixin`` with View
-------------------------------------
If we want to write a simple class-based view that responds only to
``POST``, we'll subclass :class:`~django.views.generic.base.View` and
@ -271,8 +271,8 @@ to look up the ``Author`` instance. You could also use a slug, or
any of the other features of
:class:`~django.views.generic.detail.SingleObjectMixin`.
Using SingleObjectMixin with ListView
-------------------------------------
Using ``SingleObjectMixin`` with ``ListView``
---------------------------------------------
:class:`~django.views.generic.list.ListView` provides built-in
pagination, but you might want to paginate a list of objects that are
@ -404,8 +404,8 @@ is a simpler solution. First, let's look at a naive attempt to combine
``POST`` a Django :class:`~django.forms.Form` to the same URL as we're
displaying an object using :class:`DetailView`.
Using FormMixin with DetailView
-------------------------------
Using ``FormMixin`` with ``DetailView``
---------------------------------------
Think back to our earlier example of using :class:`View` and
:class:`~django.views.generic.detail.SingleObjectMixin` together. We were

View File

@ -88,8 +88,8 @@ In a hurry? Here's how to do common aggregate queries, assuming the models above
>>> pubs[0].num_books
1323
Generating aggregates over a QuerySet
=====================================
Generating aggregates over a ``QuerySet``
=========================================
Django provides two ways to generate aggregates. The first way is to generate
summary values over an entire ``QuerySet``. For example, say you wanted to
@ -134,8 +134,8 @@ the maximum and minimum price of all books, we would issue the query::
>>> Book.objects.aggregate(Avg('price'), Max('price'), Min('price'))
{'price__avg': 34.35, 'price__max': Decimal('81.20'), 'price__min': Decimal('12.99')}
Generating aggregates for each item in a QuerySet
=================================================
Generating aggregates for each item in a ``QuerySet``
=====================================================
The second way to generate summary values is to generate an independent
summary for each object in a ``QuerySet``. For example, if you are retrieving
@ -297,8 +297,8 @@ file::
(The resulting dictionary will have a key called ``'average__rating'``. If no
such alias were specified, it would be the rather long ``'book__rating__avg'``.)
Aggregations and other QuerySet clauses
=======================================
Aggregations and other ``QuerySet`` clauses
===========================================
``filter()`` and ``exclude()``
------------------------------

View File

@ -37,7 +37,7 @@ of all ``Person`` objects.
.. _custom-managers:
Custom Managers
Custom managers
===============
You can use a custom ``Manager`` in a particular model by extending the base
@ -47,7 +47,7 @@ There are two reasons you might want to customize a ``Manager``: to add extra
``Manager`` methods, and/or to modify the initial ``QuerySet`` the ``Manager``
returns.
Adding extra Manager methods
Adding extra manager methods
----------------------------
Adding extra ``Manager`` methods is the preferred way to add "table-level"
@ -97,8 +97,8 @@ that list of ``OpinionPoll`` objects with ``num_responses`` attributes.
Another thing to note about this example is that ``Manager`` methods can
access ``self.model`` to get the model class to which they're attached.
Modifying initial Manager QuerySets
-----------------------------------
Modifying a manager's initial ``QuerySet``
------------------------------------------
A ``Manager``s base ``QuerySet`` returns all objects in the system. For
example, using this model::
@ -204,8 +204,8 @@ attribute on the manager class. This is documented fully below_.
.. _calling-custom-queryset-methods-from-manager:
Calling custom ``QuerySet`` methods from the ``Manager``
--------------------------------------------------------
Calling custom ``QuerySet`` methods from the manager
----------------------------------------------------
While most methods from the standard ``QuerySet`` are accessible directly from
the ``Manager``, this is only the case for the extra methods defined on a
@ -239,8 +239,8 @@ the manager ``Person.people``.
.. _create-manager-with-queryset-methods:
Creating ``Manager`` with ``QuerySet`` methods
----------------------------------------------
Creating a manager with ``QuerySet`` methods
--------------------------------------------
In lieu of the above approach which requires duplicating methods on both the
``QuerySet`` and the ``Manager``, :meth:`QuerySet.as_manager()
@ -288,8 +288,8 @@ For example::
return
_opted_in_private_method.queryset_only = False
from_queryset
~~~~~~~~~~~~~
``from_queryset()``
~~~~~~~~~~~~~~~~~~~
.. classmethod:: from_queryset(queryset_class)
@ -438,7 +438,7 @@ be copied.
.. _manager-types:
Controlling automatic Manager types
Controlling automatic manager types
===================================
This document has already mentioned a couple of places where Django creates a
@ -484,7 +484,7 @@ it will use :class:`django.db.models.Manager`.
so that existing code will :doc:`continue to work </misc/api-stability>` in
future Django versions.
Writing correct Managers for use in automatic Manager instances
Writing correct managers for use in automatic manager instances
---------------------------------------------------------------
The ``use_for_related_fields`` feature is primarily for managers that need to

View File

@ -686,8 +686,8 @@ provided in :doc:`/howto/custom-model-fields`.
.. _meta-options:
Meta options
============
``Meta`` options
================
Give your model metadata by using an inner ``class Meta``, like so::
@ -1215,8 +1215,8 @@ order by the ``last_name`` attribute when you use the proxy. This is easy::
Now normal ``Person`` queries will be unordered
and ``OrderedPerson`` queries will be ordered by ``last_name``.
QuerySets still return the model that was requested
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``QuerySet``\s still return the model that was requested
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is no way to have Django return, say, a ``MyPerson`` object whenever you
query for ``Person`` objects. A queryset for ``Person`` objects will return

View File

@ -58,14 +58,14 @@ work. This document also does not address other optimization techniques that
apply to all expensive operations, such as :doc:`general purpose caching
</topics/cache>`.
Understand QuerySets
====================
Understand ``QuerySet``\s
=========================
Understanding :doc:`QuerySets </ref/models/querysets>` is vital to getting good
performance with simple code. In particular:
Understand QuerySet evaluation
------------------------------
Understand ``QuerySet`` evaluation
----------------------------------
To avoid performance problems, it is important to understand:
@ -232,13 +232,13 @@ are most useful when you can avoid loading a lot of text data or for fields
that might take a lot of processing to convert back to Python. As always,
profile first, then optimize.
Use QuerySet.count()
--------------------
Use ``QuerySet.count()``
------------------------
...if you only want the count, rather than doing ``len(queryset)``.
Use QuerySet.exists()
---------------------
Use ``QuerySet.exists()``
-------------------------
...if you only want to find out if at least one result exists, rather than ``if
queryset``.

View File

@ -239,8 +239,8 @@ January 30, 2005, and the current day.
.. _filtered-querysets-are-unique:
Filtered QuerySets are unique
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Filtered ``QuerySet``\s are unique
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Each time you refine a :class:`~django.db.models.query.QuerySet`, you get a
brand-new :class:`~django.db.models.query.QuerySet` that is in no way bound to
@ -265,8 +265,8 @@ refinement process.
.. _querysets-are-lazy:
QuerySets are lazy
~~~~~~~~~~~~~~~~~~
``QuerySet``\s are lazy
~~~~~~~~~~~~~~~~~~~~~~~
``QuerySets`` are lazy -- the act of creating a
:class:`~django.db.models.query.QuerySet` doesn't involve any database
@ -287,11 +287,10 @@ until you "ask" for them. When you do, the
database. For more details on exactly when evaluation takes place, see
:ref:`when-querysets-are-evaluated`.
.. _retrieving-single-object-with-get:
Retrieving a single object with get
-----------------------------------
Retrieving a single object with ``get()``
-----------------------------------------
:meth:`~django.db.models.query.QuerySet.filter` will always give you a
:class:`~django.db.models.query.QuerySet`, even if only a single object matches
@ -324,8 +323,8 @@ Similarly, Django will complain if more than one item matches the
attribute of the model class itself.
Other QuerySet methods
----------------------
Other ``QuerySet`` methods
--------------------------
Most of the time you'll use :meth:`~django.db.models.query.QuerySet.all`,
:meth:`~django.db.models.query.QuerySet.get`,
@ -337,8 +336,8 @@ various :class:`~django.db.models.query.QuerySet` methods.
.. _limiting-querysets:
Limiting QuerySets
------------------
Limiting ``QuerySet``\s
-----------------------
Use a subset of Python's array-slicing syntax to limit your
:class:`~django.db.models.query.QuerySet` to a certain number of results. This
@ -663,8 +662,8 @@ The ``F()`` objects support bitwise operations by ``.bitand()`` and
>>> F('somefield').bitand(16)
The pk lookup shortcut
----------------------
The ``pk`` lookup shortcut
--------------------------
For convenience, Django provides a ``pk`` lookup shortcut, which stands for
"primary key".
@ -692,8 +691,8 @@ equivalent::
>>> Entry.objects.filter(blog__id=3) # __exact is implied
>>> Entry.objects.filter(blog__pk=3) # __pk implies __id__exact
Escaping percent signs and underscores in LIKE statements
---------------------------------------------------------
Escaping percent signs and underscores in ``LIKE`` statements
-------------------------------------------------------------
The field lookups that equate to ``LIKE`` SQL statements (``iexact``,
``contains``, ``icontains``, ``startswith``, ``istartswith``, ``endswith``
@ -720,8 +719,8 @@ for you transparently.
.. _caching-and-querysets:
Caching and QuerySets
---------------------
Caching and ``QuerySet``\s
--------------------------
Each :class:`~django.db.models.query.QuerySet` contains a cache to minimize
database access. Understanding how it works will allow you to write the most
@ -756,8 +755,8 @@ To avoid this problem, simply save the
>>> print([p.headline for p in queryset]) # Evaluate the query set.
>>> print([p.pub_date for p in queryset]) # Re-use the cache from the evaluation.
When querysets are not cached
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When ``QuerySet``\s are not cached
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Querysets do not always cache their results. When evaluating only *part* of
the queryset, the cache is checked, but if it is not populated then the items
@ -795,8 +794,8 @@ being evaluated and therefore populate the cache::
.. _complex-lookups-with-q:
Complex lookups with Q objects
==============================
Complex lookups with ``Q`` objects
==================================
Keyword argument queries -- in :meth:`~django.db.models.query.QuerySet.filter`,
etc. -- are "AND"ed together. If you need to execute more complex queries (for

View File

@ -35,8 +35,8 @@ a secure connection is used.
The character set of email sent with ``django.core.mail`` will be set to
the value of your :setting:`DEFAULT_CHARSET` setting.
send_mail()
===========
``send_mail()``
===============
.. function:: send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None, connection=None, html_message=None)
@ -74,8 +74,8 @@ are required.
The return value will be the number of successfully delivered messages (which
can be ``0`` or ``1`` since it can only send one message).
send_mass_mail()
================
``send_mass_mail()``
====================
.. function:: send_mass_mail(datatuple, fail_silently=False, auth_user=None, auth_password=None, connection=None)
@ -103,8 +103,8 @@ mail server would be opened::
The return value will be the number of successfully delivered messages.
send_mass_mail() vs. send_mail()
--------------------------------
``send_mass_mail()`` vs. ``send_mail()``
----------------------------------------
The main difference between :meth:`~django.core.mail.send_mass_mail()` and
:meth:`~django.core.mail.send_mail()` is that
@ -113,8 +113,8 @@ each time it's executed, while :meth:`~django.core.mail.send_mass_mail()` uses
a single connection for all of its messages. This makes
:meth:`~django.core.mail.send_mass_mail()` slightly more efficient.
mail_admins()
=============
``mail_admins()``
=================
.. function:: mail_admins(subject, message, fail_silently=False, connection=None, html_message=None)
@ -134,8 +134,8 @@ If ``html_message`` is provided, the resulting email will be a
:mimetype:`text/plain` content type and ``html_message`` as the
:mimetype:`text/html` content type.
mail_managers()
===============
``mail_managers()``
===================
.. function:: mail_managers(subject, message, fail_silently=False, connection=None, html_message=None)
@ -205,8 +205,8 @@ from the request's POST data, sends that to admin@example.com and redirects to
.. _emailmessage-and-smtpconnection:
The EmailMessage class
======================
The ``EmailMessage`` class
==========================
Django's :meth:`~django.core.mail.send_mail()` and
:meth:`~django.core.mail.send_mass_mail()` functions are actually thin
@ -235,8 +235,8 @@ For convenience, :class:`~django.core.mail.EmailMessage` provides a simple
messages, the email backend API :ref:`provides an alternative
<topics-sending-multiple-emails>`.
EmailMessage Objects
--------------------
``EmailMessage`` Objects
------------------------
.. class:: EmailMessage

View File

@ -193,8 +193,8 @@ sent without any data)::
.. _understanding-the-managementform:
Understanding the ManagementForm
--------------------------------
Understanding the ``ManagementForm``
------------------------------------
You may have noticed the additional data (``form-TOTAL_FORMS``,
``form-INITIAL_FORMS`` and ``form-MAX_NUM_FORMS``) that was required

View File

@ -793,8 +793,8 @@ instances of the model, you can specify an empty QuerySet::
>>> AuthorFormSet(queryset=Author.objects.none())
Changing the ``form``
---------------------
Changing the form
-----------------
By default, when you use ``modelformset_factory``, a model form will
be created using :func:`~django.forms.models.modelform_factory`.

View File

@ -85,8 +85,8 @@ Python class that defines one or more of the following methods:
.. _request-middleware:
``process_request``
-------------------
``process_request()``
---------------------
.. method:: process_request(request)
@ -106,8 +106,8 @@ return the result.
.. _view-middleware:
``process_view``
----------------
``process_view()``
------------------
.. method:: process_view(request, view_func, view_args, view_kwargs)
@ -145,8 +145,8 @@ view; it'll apply response middleware to that
.. _template-response-middleware:
``process_template_response``
-----------------------------
``process_template_response()``
-------------------------------
.. method:: process_template_response(request, response)
@ -172,8 +172,8 @@ includes ``process_template_response()``.
.. _response-middleware:
``process_response``
--------------------
``process_response()``
----------------------
.. method:: process_response(request, response)
@ -229,8 +229,8 @@ must test for streaming responses and adjust their behavior accordingly::
.. _exception-middleware:
``process_exception``
---------------------
``process_exception()``
-----------------------
.. method:: process_exception(request, exception)
@ -248,8 +248,8 @@ Again, middleware are run in reverse order during the response phase, which
includes ``process_exception``. If an exception middleware returns a response,
the middleware classes above that middleware will not be called at all.
``__init__``
------------
``__init__()``
--------------
Most middleware classes won't need an initializer since middleware classes are
essentially placeholders for the ``process_*`` methods. If you do need some

View File

@ -329,7 +329,7 @@ easily available on the internet. Although the cookie session storage signs the
cookie-stored data to prevent tampering, a :setting:`SECRET_KEY` leak
immediately escalates to a remote code execution vulnerability.
Bundled Serializers
Bundled serializers
~~~~~~~~~~~~~~~~~~~
.. class:: serializers.JSONSerializer
@ -359,7 +359,7 @@ Bundled Serializers
.. _custom-serializers:
Write Your Own Serializer
Write your own serializer
~~~~~~~~~~~~~~~~~~~~~~~~~
Note that unlike :class:`~django.contrib.sessions.serializers.PickleSerializer`,

View File

@ -12,8 +12,8 @@ The package ``django.shortcuts`` collects helper functions and classes that
"span" multiple levels of MVC. In other words, these functions/classes
introduce controlled coupling for convenience's sake.
``render``
==========
``render()``
============
.. function:: render(request, template_name, context=None, content_type=None, status=None, using=None)
@ -81,8 +81,8 @@ This example is equivalent to::
return HttpResponse(t.render(c, request),
content_type="application/xhtml+xml")
``render_to_response``
======================
``render_to_response()``
========================
.. function:: render_to_response(template_name, context=None, content_type=None, status=None, using=None)
@ -90,8 +90,8 @@ This example is equivalent to::
similarly except that it doesn't make the ``request`` available in the
response. It's not recommended and is likely to be deprecated in the future.
``redirect``
============
``redirect()``
==============
.. function:: redirect(to, permanent=False, *args, **kwargs)
@ -157,8 +157,8 @@ will be returned::
object = MyModel.objects.get(...)
return redirect(object, permanent=True)
``get_object_or_404``
=====================
``get_object_or_404()``
=======================
.. function:: get_object_or_404(klass, *args, **kwargs)
@ -230,8 +230,8 @@ Note: As with ``get()``, a
:class:`~django.core.exceptions.MultipleObjectsReturned` exception
will be raised if more than one object is found.
``get_list_or_404``
===================
``get_list_or_404()``
=====================
.. function:: get_list_or_404(klass, *args, **kwargs)

View File

@ -234,8 +234,8 @@ Performance
Each regular expression in a ``urlpatterns`` is compiled the first time it's
accessed. This makes the system blazingly fast.
Syntax of the urlpatterns variable
==================================
Syntax of the ``urlpatterns`` variable
======================================
``urlpatterns`` should be a Python list of :func:`~django.conf.urls.url`
instances.

View File

@ -94,8 +94,8 @@ to create a return class for any status code you like. For example::
Because 404 errors are by far the most common HTTP error, there's an easier way
to handle those errors.
The Http404 exception
---------------------
The ``Http404`` exception
-------------------------
.. class:: django.http.Http404()

View File

@ -76,8 +76,8 @@ Template tags
.. templatetag:: localize
localize
~~~~~~~~
``localize``
~~~~~~~~~~~~
Enables or disables localization of template variables in the
contained block.
@ -110,8 +110,8 @@ Template filters
.. templatefilter:: localize
localize
~~~~~~~~
``localize``
~~~~~~~~~~~~
Forces localization of a single value.
@ -125,11 +125,10 @@ To disable localization on a single value, use :tfilter:`unlocalize`. To control
localization over a large section of a template, use the :ttag:`localize` template
tag.
.. templatefilter:: unlocalize
unlocalize
~~~~~~~~~~
``unlocalize``
~~~~~~~~~~~~~~
Forces a single value to be printed without localization.

View File

@ -257,8 +257,8 @@ Template tags
.. templatetag:: localtime
localtime
~~~~~~~~~
``localtime``
~~~~~~~~~~~~~
Enables or disables conversion of aware datetime objects to the current time
zone in the contained block.
@ -286,8 +286,8 @@ To activate or deactivate conversion for a template block, use::
.. templatetag:: timezone
timezone
~~~~~~~~
``timezone``
~~~~~~~~~~~~
Sets or unsets the current time zone in the contained block. When the current
time zone is unset, the default time zone applies.
@ -306,8 +306,8 @@ time zone is unset, the default time zone applies.
.. templatetag:: get_current_timezone
get_current_timezone
~~~~~~~~~~~~~~~~~~~~
``get_current_timezone``
~~~~~~~~~~~~~~~~~~~~~~~~
You can get the name of the current time zone using the
``get_current_timezone`` tag::
@ -327,8 +327,8 @@ return aware datetimes.
.. templatefilter:: localtime
localtime
~~~~~~~~~
``localtime``
~~~~~~~~~~~~~
Forces conversion of a single value to the current time zone.
@ -340,8 +340,8 @@ For example::
.. templatefilter:: utc
utc
~~~
``utc``
~~~~~~~
Forces conversion of a single value to UTC.
@ -353,8 +353,8 @@ For example::
.. templatefilter:: timezone
timezone
~~~~~~~~
``timezone``
~~~~~~~~~~~~
Forces conversion of a single value to an arbitrary timezone.

View File

@ -477,8 +477,8 @@ directly with the ``number`` argument::
raise forms.ValidationError(self.error_message % number)
Joining strings: string_concat()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Joining strings: ``string_concat()``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Standard Python string joins (``''.join([...])``) will not work on lists
containing lazy translation objects. Instead, you can use

View File

@ -25,8 +25,8 @@ your operating system's package manager.
If you are just starting with Django and using Windows, you may find
:doc:`/howto/windows` useful.
Install Apache and mod_wsgi
=============================
Install Apache and ``mod_wsgi``
===============================
If you just want to experiment with Django, skip ahead to the next
section; Django includes a lightweight web server you can use for

View File

@ -692,8 +692,8 @@ the main module body, rather than the class body.
.. _custom-deconstruct-method:
Adding a deconstruct() method
-----------------------------
Adding a ``deconstruct()`` method
---------------------------------
You can let Django serialize your own custom class instances by giving the class
a ``deconstruct()`` method. It takes no arguments, and should return a tuple

View File

@ -232,8 +232,8 @@ until it's strictly required.
Databases
=========
:doc:`Database optimization </topics/db/optimization>`
------------------------------------------------------
Database optimization
---------------------
Djangos database layer provides various ways to help developers get the best
performance from their databases. The :doc:`database optimization documentation

View File

@ -131,8 +131,8 @@ and ``SafeText`` respectively.
For forwards compatibility, the new names work as of Django 1.4.2.
:meth:`~object.__str__` and ` __unicode__()`_ methods
-----------------------------------------------------
``__str__()`` and ``__unicode__()`` methods
-------------------------------------------
In Python 2, the object model specifies :meth:`~object.__str__` and
` __unicode__()`_ methods. If these methods exist, they must return
@ -370,8 +370,8 @@ Some modules were renamed in Python 3. The ``django.utils.six.moves``
module (based on the :mod:`six.moves module <six.moves>`) provides a
compatible location to import them.
PY2
~~~
``PY2``
~~~~~~~
If you need different code in Python 2 and Python 3, check :data:`six.PY2`::
@ -383,8 +383,8 @@ function.
.. module:: django.utils.six
Django customized version of six
--------------------------------
Django customized version of ``six``
------------------------------------
The version of six bundled with Django (``django.utils.six``) includes a few
customizations for internal use only.

View File

@ -68,7 +68,7 @@ be serialized.
serialized object doesn't specify all the fields that are required by a
model, the deserializer will not be able to save deserialized instances.
Inherited Models
Inherited models
----------------
If you have a model that is defined using an :ref:`abstract base class

View File

@ -48,8 +48,8 @@ Python `import search path`_.
.. _import search path: http://www.diveintopython.net/getting_to_know_python/everything_is_an_object.html
The django-admin utility
---------------------------
The ``django-admin`` utility
----------------------------
When using :doc:`django-admin </ref/django-admin>`, you can either set the
environment variable once, or explicitly pass in the settings module each time
@ -71,8 +71,8 @@ Use the ``--settings`` command-line argument to specify the settings manually::
.. _django-admin: ../django-admin/
On the server (mod_wsgi)
--------------------------
On the server (``mod_wsgi``)
----------------------------
In your live server environment, you'll need to tell your WSGI
application what settings file to use. Do that with ``os.environ``::
@ -171,8 +171,8 @@ a convention.
.. _settings-without-django-settings-module:
Using settings without setting DJANGO_SETTINGS_MODULE
=====================================================
Using settings without setting ``DJANGO_SETTINGS_MODULE``
=========================================================
In some cases, you might want to bypass the ``DJANGO_SETTINGS_MODULE``
environment variable. For example, if you're using the template system by
@ -235,8 +235,8 @@ defaults, so you must specify a value for every possible setting that might be
used in that code you are importing. Check in
``django.conf.settings.global_settings`` for the full list.
Either configure() or DJANGO_SETTINGS_MODULE is required
--------------------------------------------------------
Either ``configure()`` or ``DJANGO_SETTINGS_MODULE`` is required
----------------------------------------------------------------
If you're not setting the ``DJANGO_SETTINGS_MODULE`` environment variable, you
*must* call ``configure()`` at some point before using any code that reads

View File

@ -25,8 +25,8 @@ You may also find signing useful for the following:
protected resource, for example a downloadable file that a user has
paid for.
Protecting the SECRET_KEY
=========================
Protecting the ``SECRET_KEY``
=============================
When you create a new Django project using :djadmin:`startproject`, the
``settings.py`` file is generated automatically and gets a random
@ -79,8 +79,8 @@ generate signatures. You can use a different secret by passing it to the
<https://tools.ietf.org/html/rfc4648#section-5>`_. This alphabet contains
alphanumeric characters, hyphens, and underscores.
Using the salt argument
-----------------------
Using the ``salt`` argument
---------------------------
If you do not wish for every occurrence of a particular string to have the same
signature hash, you can use the optional ``salt`` argument to the ``Signer``

View File

@ -534,8 +534,8 @@ Methods
Testing utilities
-----------------
django.test.utils
~~~~~~~~~~~~~~~~~
``django.test.utils``
~~~~~~~~~~~~~~~~~~~~~
.. module:: django.test.utils
:synopsis: Helpers to write custom test runners.
@ -555,8 +555,8 @@ utility methods in the ``django.test.utils`` module.
magic hooks into the template system and restoring normal email
services.
django.db.connection.creation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``django.db.connection.creation``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. currentmodule:: django.db.connection.creation
@ -615,8 +615,8 @@ can be useful during testing.
.. _topics-testing-code-coverage:
Integration with coverage.py
============================
Integration with ``coverage.py``
================================
Code coverage describes how much source code has been tested. It shows which
parts of your code are being exercised by tests and which are not. It's an

View File

@ -617,8 +617,8 @@ Normal Python unit test classes extend a base class of
Hierarchy of Django unit testing classes
SimpleTestCase
--------------
``SimpleTestCase``
------------------
.. class:: SimpleTestCase()
@ -701,8 +701,8 @@ then you should use :class:`~django.test.TransactionTestCase` or
:exc:`unittest.SkipTest` in ``setUpClass()``, be sure to do it before
calling ``super()`` to avoid this.
TransactionTestCase
-------------------
``TransactionTestCase``
-----------------------
.. class:: TransactionTestCase()
@ -742,8 +742,8 @@ to test the effects of commit and rollback:
``TransactionTestCase`` inherits from :class:`~django.test.SimpleTestCase`.
TestCase
--------
``TestCase``
------------
.. class:: TestCase()
@ -811,8 +811,8 @@ additions, including:
.. _live-test-server:
LiveServerTestCase
------------------
``LiveServerTestCase``
----------------------
.. class:: LiveServerTestCase()