mirror of https://github.com/django/django.git
Fixed #25159 -- Removed brackets from class/function/method signatures in docs.
Thanks hellbeast for the initial patch.
This commit is contained in:
parent
29465d438e
commit
87d55081ea
|
@ -257,7 +257,7 @@ Writing this view is left as an exercise to the reader.
|
||||||
Making actions available site-wide
|
Making actions available site-wide
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
.. method:: AdminSite.add_action(action[, name])
|
.. method:: AdminSite.add_action(action, name=None)
|
||||||
|
|
||||||
Some actions are best if they're made available to *any* object in the admin
|
Some actions are best if they're made available to *any* object in the admin
|
||||||
site -- the export action defined above would be a good candidate. You can
|
site -- the export action defined above would be a good candidate. You can
|
||||||
|
|
|
@ -101,7 +101,7 @@ Other topics
|
||||||
The register decorator
|
The register decorator
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
.. function:: register(*models, [site=django.admin.sites.site])
|
.. function:: register(*models, site=django.admin.sites.site)
|
||||||
|
|
||||||
There is also a decorator for registering your ``ModelAdmin`` classes::
|
There is also a decorator for registering your ``ModelAdmin`` classes::
|
||||||
|
|
||||||
|
@ -2830,7 +2830,7 @@ supplied by the admin views for the current model.
|
||||||
The ``staff_member_required`` decorator
|
The ``staff_member_required`` decorator
|
||||||
=======================================
|
=======================================
|
||||||
|
|
||||||
.. function:: staff_member_required([redirect_field_name=REDIRECT_FIELD_NAME, login_url='admin:login'])
|
.. function:: staff_member_required(redirect_field_name='next', login_url='admin:login')
|
||||||
|
|
||||||
This decorator is used on the admin views that require authorization. A
|
This decorator is used on the admin views that require authorization. A
|
||||||
view decorated with this function will having the following behavior:
|
view decorated with this function will having the following behavior:
|
||||||
|
|
|
@ -196,7 +196,7 @@ The ``ContentTypeManager``
|
||||||
it's preferred to use this method over the usual
|
it's preferred to use this method over the usual
|
||||||
``ContentType.objects.get(pk=id)``
|
``ContentType.objects.get(pk=id)``
|
||||||
|
|
||||||
.. method:: get_for_model(model[, for_concrete_model=True])
|
.. method:: get_for_model(model, for_concrete_model=True)
|
||||||
|
|
||||||
Takes either a model class or an instance of a model, and returns the
|
Takes either a model class or an instance of a model, and returns the
|
||||||
:class:`~django.contrib.contenttypes.models.ContentType` instance
|
:class:`~django.contrib.contenttypes.models.ContentType` instance
|
||||||
|
@ -204,7 +204,7 @@ The ``ContentTypeManager``
|
||||||
the :class:`~django.contrib.contenttypes.models.ContentType` of a proxy
|
the :class:`~django.contrib.contenttypes.models.ContentType` of a proxy
|
||||||
model.
|
model.
|
||||||
|
|
||||||
.. method:: get_for_models(*models[, for_concrete_models=True])
|
.. method:: get_for_models(*models, for_concrete_models=True)
|
||||||
|
|
||||||
Takes a variadic number of model classes, and returns a dictionary
|
Takes a variadic number of model classes, and returns a dictionary
|
||||||
mapping the model classes to the
|
mapping the model classes to the
|
||||||
|
|
|
@ -58,7 +58,7 @@ points, polygons, etc.), as well as the names and types of any
|
||||||
additional fields (:class:`Field`) of data that may be associated with
|
additional fields (:class:`Field`) of data that may be associated with
|
||||||
each feature in that layer.
|
each feature in that layer.
|
||||||
|
|
||||||
.. class:: DataSource(ds_input, [encoding='utf-8'])
|
.. class:: DataSource(ds_input, encoding='utf-8')
|
||||||
|
|
||||||
The constructor for ``DataSource`` only requires one parameter: the path of
|
The constructor for ``DataSource`` only requires one parameter: the path of
|
||||||
the file you want to read. However, OGR
|
the file you want to read. However, OGR
|
||||||
|
@ -244,7 +244,7 @@ __ http://www.gdal.org/ogr/ogr_formats.html
|
||||||
>>> layer.get_fields('Name')
|
>>> layer.get_fields('Name')
|
||||||
['Pueblo', 'Lawrence', 'Houston']
|
['Pueblo', 'Lawrence', 'Houston']
|
||||||
|
|
||||||
.. method:: get_geoms([geos=False])
|
.. method:: get_geoms(geos=False)
|
||||||
|
|
||||||
A method that returns a list containing the geometry of each feature
|
A method that returns a list containing the geometry of each feature
|
||||||
in the layer. If the optional argument ``geos`` is set to ``True``
|
in the layer. If the optional argument ``geos`` is set to ``True``
|
||||||
|
@ -445,7 +445,7 @@ systems and coordinate transformation::
|
||||||
>>> from django.contrib.gis.gdal import OGRGeometry
|
>>> from django.contrib.gis.gdal import OGRGeometry
|
||||||
>>> polygon = OGRGeometry('POLYGON((0 0, 5 0, 5 5, 0 5))')
|
>>> polygon = OGRGeometry('POLYGON((0 0, 5 0, 5 5, 0 5))')
|
||||||
|
|
||||||
.. class:: OGRGeometry(geom_input[, srs=None])
|
.. class:: OGRGeometry(geom_input, srs=None)
|
||||||
|
|
||||||
This object is a wrapper for the `OGR Geometry`__ class.
|
This object is a wrapper for the `OGR Geometry`__ class.
|
||||||
These objects are instantiated directly from the given ``geom_input``
|
These objects are instantiated directly from the given ``geom_input``
|
||||||
|
@ -1416,7 +1416,7 @@ blue.
|
||||||
|
|
||||||
This property can now be set as well.
|
This property can now be set as well.
|
||||||
|
|
||||||
.. method:: datatype([as_string=False])
|
.. method:: datatype(as_string=False)
|
||||||
|
|
||||||
The data type contained in the band, as an integer constant between 0
|
The data type contained in the band, as an integer constant between 0
|
||||||
(Unknown) and 11. If ``as_string`` is ``True``, the data type is
|
(Unknown) and 11. If ``as_string`` is ``True``, the data type is
|
||||||
|
|
|
@ -89,7 +89,7 @@ Defaults to ``'GeoLiteCity.dat'``.
|
||||||
``GeoIP`` API
|
``GeoIP`` API
|
||||||
=============
|
=============
|
||||||
|
|
||||||
.. class:: GeoIP([path=None, cache=0, country=None, city=None])
|
.. class:: GeoIP(path=None, cache=0, country=None, city=None)
|
||||||
|
|
||||||
The ``GeoIP`` object does not require any parameters to use the default
|
The ``GeoIP`` object does not require any parameters to use the default
|
||||||
settings. However, at the very least the :setting:`GEOIP_PATH` setting
|
settings. However, at the very least the :setting:`GEOIP_PATH` setting
|
||||||
|
|
|
@ -4,7 +4,7 @@ GeoQuerySet API Reference
|
||||||
|
|
||||||
.. currentmodule:: django.contrib.gis.db.models
|
.. currentmodule:: django.contrib.gis.db.models
|
||||||
|
|
||||||
.. class:: GeoQuerySet([model=None])
|
.. class:: GeoQuerySet(model=None)
|
||||||
|
|
||||||
.. _spatial-lookups:
|
.. _spatial-lookups:
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ Geometry Objects
|
||||||
``GEOSGeometry``
|
``GEOSGeometry``
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
.. class:: GEOSGeometry(geo_input[, srid=None])
|
.. class:: GEOSGeometry(geo_input, srid=None)
|
||||||
|
|
||||||
:param geo_input: Geometry input value (string or buffer)
|
:param geo_input: Geometry input value (string or buffer)
|
||||||
:param srid: spatial reference identifier
|
:param srid: spatial reference identifier
|
||||||
|
@ -782,7 +782,7 @@ Example::
|
||||||
>>> from django.contrib.gis.geos import fromfile
|
>>> from django.contrib.gis.geos import fromfile
|
||||||
>>> g = fromfile('/home/bob/geom.wkt')
|
>>> g = fromfile('/home/bob/geom.wkt')
|
||||||
|
|
||||||
.. function:: fromstr(string, [,srid=None])
|
.. function:: fromstr(string, srid=None)
|
||||||
|
|
||||||
:param string: string that contains spatial data
|
:param string: string that contains spatial data
|
||||||
:type string: string
|
:type string: string
|
||||||
|
|
|
@ -85,7 +85,7 @@ system is defined for the layer, use the ``source_srs`` keyword with a
|
||||||
``LayerMapping`` API
|
``LayerMapping`` API
|
||||||
====================
|
====================
|
||||||
|
|
||||||
.. class:: LayerMapping(model, data_source, mapping[, layer=0, source_srs=None, encoding=None, transaction_mode='commit_on_success', transform=True, unique=True, using='default'])
|
.. class:: LayerMapping(model, data_source, mapping, layer=0, source_srs=None, encoding=None, transaction_mode='commit_on_success', transform=True, unique=True, using='default')
|
||||||
|
|
||||||
The following are the arguments and keywords that may be used during
|
The following are the arguments and keywords that may be used during
|
||||||
instantiation of ``LayerMapping`` objects.
|
instantiation of ``LayerMapping`` objects.
|
||||||
|
@ -146,7 +146,7 @@ Keyword Arguments
|
||||||
``save()`` Keyword Arguments
|
``save()`` Keyword Arguments
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
.. method:: LayerMapping.save([verbose=False, fid_range=False, step=False, progress=False, silent=False, stream=sys.stdout, strict=False])
|
.. method:: LayerMapping.save(verbose=False, fid_range=False, step=False, progress=False, silent=False, stream=sys.stdout, strict=False)
|
||||||
|
|
||||||
The ``save()`` method also accepts keywords. These keywords are
|
The ``save()`` method also accepts keywords. These keywords are
|
||||||
used for controlling output logging, error handling, and for importing
|
used for controlling output logging, error handling, and for importing
|
||||||
|
|
|
@ -10,10 +10,10 @@ OGR Inspection
|
||||||
``ogrinspect``
|
``ogrinspect``
|
||||||
==============
|
==============
|
||||||
|
|
||||||
.. function:: ogrinspect(data_source, model_name[, **kwargs])
|
.. function:: ogrinspect(data_source, model_name, **kwargs)
|
||||||
:noindex:
|
:noindex:
|
||||||
|
|
||||||
``mapping``
|
``mapping``
|
||||||
===========
|
===========
|
||||||
|
|
||||||
.. function:: mapping(data_source, [geom_name='geom', layer_key=0, multi_geom=False])
|
.. function:: mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False)
|
||||||
|
|
|
@ -34,7 +34,7 @@ The ``File`` Class
|
||||||
|
|
||||||
The read/write mode for the file.
|
The read/write mode for the file.
|
||||||
|
|
||||||
.. method:: open([mode=None])
|
.. method:: open(mode=None)
|
||||||
|
|
||||||
Open or reopen the file (which also does ``File.seek(0)``).
|
Open or reopen the file (which also does ``File.seek(0)``).
|
||||||
The ``mode`` argument allows the same values
|
The ``mode`` argument allows the same values
|
||||||
|
@ -44,7 +44,7 @@ The ``File`` Class
|
||||||
was originally opened with; ``None`` means to reopen with the original
|
was originally opened with; ``None`` means to reopen with the original
|
||||||
mode.
|
mode.
|
||||||
|
|
||||||
.. method:: read([num_bytes=None])
|
.. method:: read(num_bytes=None)
|
||||||
|
|
||||||
Read content from the file. The optional ``size`` is the number of
|
Read content from the file. The optional ``size`` is the number of
|
||||||
bytes to read; if not specified, the file will be read to the end.
|
bytes to read; if not specified, the file will be read to the end.
|
||||||
|
@ -62,7 +62,7 @@ The ``File`` Class
|
||||||
|
|
||||||
.. _universal newlines: https://www.python.org/dev/peps/pep-0278
|
.. _universal newlines: https://www.python.org/dev/peps/pep-0278
|
||||||
|
|
||||||
.. method:: chunks([chunk_size=None])
|
.. method:: chunks(chunk_size=None)
|
||||||
|
|
||||||
Iterate over the file yielding "chunks" of a given size. ``chunk_size``
|
Iterate over the file yielding "chunks" of a given size. ``chunk_size``
|
||||||
defaults to 64 KB.
|
defaults to 64 KB.
|
||||||
|
@ -70,12 +70,12 @@ The ``File`` Class
|
||||||
This is especially useful with very large files since it allows them to
|
This is especially useful with very large files since it allows them to
|
||||||
be streamed off disk and avoids storing the whole file in memory.
|
be streamed off disk and avoids storing the whole file in memory.
|
||||||
|
|
||||||
.. method:: multiple_chunks([chunk_size=None])
|
.. method:: multiple_chunks(chunk_size=None)
|
||||||
|
|
||||||
Returns ``True`` if the file is large enough to require multiple chunks
|
Returns ``True`` if the file is large enough to require multiple chunks
|
||||||
to access all of its content give some ``chunk_size``.
|
to access all of its content give some ``chunk_size``.
|
||||||
|
|
||||||
.. method:: write([content])
|
.. method:: write(content)
|
||||||
|
|
||||||
Writes the specified content string to the file. Depending on the
|
Writes the specified content string to the file. Depending on the
|
||||||
storage system behind the scenes, this content might not be fully
|
storage system behind the scenes, this content might not be fully
|
||||||
|
@ -141,7 +141,7 @@ Additional methods on files attached to objects
|
||||||
Any :class:`File` that is associated with an object (as with ``Car.photo``,
|
Any :class:`File` that is associated with an object (as with ``Car.photo``,
|
||||||
below) will also have a couple of extra methods:
|
below) will also have a couple of extra methods:
|
||||||
|
|
||||||
.. method:: File.save(name, content, [save=True])
|
.. method:: File.save(name, content, save=True)
|
||||||
|
|
||||||
Saves a new file with the file name and contents provided. This will not
|
Saves a new file with the file name and contents provided. This will not
|
||||||
replace the existing file, but will create a new file and update the object
|
replace the existing file, but will create a new file and update the object
|
||||||
|
@ -159,7 +159,7 @@ below) will also have a couple of extra methods:
|
||||||
:class:`File` or of a subclass of :class:`File`, such as
|
:class:`File` or of a subclass of :class:`File`, such as
|
||||||
:class:`~django.core.files.base.ContentFile`.
|
:class:`~django.core.files.base.ContentFile`.
|
||||||
|
|
||||||
.. method:: File.delete([save=True])
|
.. method:: File.delete(save=True)
|
||||||
|
|
||||||
Removes the file from the model instance and deletes the underlying file.
|
Removes the file from the model instance and deletes the underlying file.
|
||||||
If ``save`` is ``True``, the model's ``save()`` method will be called once
|
If ``save`` is ``True``, the model's ``save()`` method will be called once
|
||||||
|
|
|
@ -15,7 +15,7 @@ Django provides two convenient ways to access the current storage class:
|
||||||
:setting:`DEFAULT_FILE_STORAGE`. :class:`DefaultStorage` uses
|
:setting:`DEFAULT_FILE_STORAGE`. :class:`DefaultStorage` uses
|
||||||
:func:`~django.core.files.storage.get_storage_class` internally.
|
:func:`~django.core.files.storage.get_storage_class` internally.
|
||||||
|
|
||||||
.. function:: get_storage_class([import_path=None])
|
.. function:: get_storage_class(import_path=None)
|
||||||
|
|
||||||
Returns a class or module which implements the storage API.
|
Returns a class or module which implements the storage API.
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ Django provides two convenient ways to access the current storage class:
|
||||||
The FileSystemStorage Class
|
The FileSystemStorage Class
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
.. class:: FileSystemStorage([location=None, base_url=None, file_permissions_mode=None, directory_permissions_mode=None])
|
.. class:: FileSystemStorage(location=None, base_url=None, file_permissions_mode=None, directory_permissions_mode=None)
|
||||||
|
|
||||||
The :class:`~django.core.files.storage.FileSystemStorage` class implements
|
The :class:`~django.core.files.storage.FileSystemStorage` class implements
|
||||||
basic file storage on a local filesystem. It inherits from
|
basic file storage on a local filesystem. It inherits from
|
||||||
|
|
|
@ -396,7 +396,7 @@ otherwise. See :ref:`automatic-primary-key-fields`.
|
||||||
``BigIntegerField``
|
``BigIntegerField``
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
.. class:: BigIntegerField([**options])
|
.. class:: BigIntegerField(**options)
|
||||||
|
|
||||||
A 64 bit integer, much like an :class:`IntegerField` except that it is
|
A 64 bit integer, much like an :class:`IntegerField` except that it is
|
||||||
guaranteed to fit numbers from ``-9223372036854775808`` to
|
guaranteed to fit numbers from ``-9223372036854775808`` to
|
||||||
|
@ -406,7 +406,7 @@ guaranteed to fit numbers from ``-9223372036854775808`` to
|
||||||
``BinaryField``
|
``BinaryField``
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
.. class:: BinaryField([**options])
|
.. class:: BinaryField(**options)
|
||||||
|
|
||||||
A field to store raw binary data. It only supports ``bytes`` assignment. Be
|
A field to store raw binary data. It only supports ``bytes`` assignment. Be
|
||||||
aware that this field has limited functionality. For example, it is not possible
|
aware that this field has limited functionality. For example, it is not possible
|
||||||
|
@ -437,7 +437,7 @@ isn't defined.
|
||||||
``CharField``
|
``CharField``
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
.. class:: CharField(max_length=None, [**options])
|
.. class:: CharField(max_length=None, **options)
|
||||||
|
|
||||||
A string field, for small- to large-sized strings.
|
A string field, for small- to large-sized strings.
|
||||||
|
|
||||||
|
@ -470,7 +470,7 @@ The default form widget for this field is a :class:`~django.forms.TextInput`.
|
||||||
``CommaSeparatedIntegerField``
|
``CommaSeparatedIntegerField``
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
.. class:: CommaSeparatedIntegerField(max_length=None, [**options])
|
.. class:: CommaSeparatedIntegerField(max_length=None, **options)
|
||||||
|
|
||||||
A field of integers separated by commas. As in :class:`CharField`, the
|
A field of integers separated by commas. As in :class:`CharField`, the
|
||||||
:attr:`~CharField.max_length` argument is required and the note about database
|
:attr:`~CharField.max_length` argument is required and the note about database
|
||||||
|
@ -479,7 +479,7 @@ portability mentioned there should be heeded.
|
||||||
``DateField``
|
``DateField``
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
.. class:: DateField([auto_now=False, auto_now_add=False, **options])
|
.. class:: DateField(auto_now=False, auto_now_add=False, **options)
|
||||||
|
|
||||||
A date, represented in Python by a ``datetime.date`` instance. Has a few extra,
|
A date, represented in Python by a ``datetime.date`` instance. Has a few extra,
|
||||||
optional arguments:
|
optional arguments:
|
||||||
|
@ -525,7 +525,7 @@ Any combination of these options will result in an error.
|
||||||
``DateTimeField``
|
``DateTimeField``
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
.. class:: DateTimeField([auto_now=False, auto_now_add=False, **options])
|
.. class:: DateTimeField(auto_now=False, auto_now_add=False, **options)
|
||||||
|
|
||||||
A date and time, represented in Python by a ``datetime.datetime`` instance.
|
A date and time, represented in Python by a ``datetime.datetime`` instance.
|
||||||
Takes the same extra arguments as :class:`DateField`.
|
Takes the same extra arguments as :class:`DateField`.
|
||||||
|
@ -537,7 +537,7 @@ The default form widget for this field is a single
|
||||||
``DecimalField``
|
``DecimalField``
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
.. class:: DecimalField(max_digits=None, decimal_places=None, [**options])
|
.. class:: DecimalField(max_digits=None, decimal_places=None, **options)
|
||||||
|
|
||||||
A fixed-precision decimal number, represented in Python by a
|
A fixed-precision decimal number, represented in Python by a
|
||||||
:class:`~decimal.Decimal` instance. Has two **required** arguments:
|
:class:`~decimal.Decimal` instance. Has two **required** arguments:
|
||||||
|
@ -576,7 +576,7 @@ when :attr:`~django.forms.Field.localize` is ``False`` or
|
||||||
|
|
||||||
.. versionadded:: 1.8
|
.. versionadded:: 1.8
|
||||||
|
|
||||||
.. class:: DurationField([**options])
|
.. class:: DurationField(**options)
|
||||||
|
|
||||||
A field for storing periods of time - modeled in Python by
|
A field for storing periods of time - modeled in Python by
|
||||||
:class:`~python:datetime.timedelta`. When used on PostgreSQL, the data type
|
:class:`~python:datetime.timedelta`. When used on PostgreSQL, the data type
|
||||||
|
@ -592,7 +592,7 @@ SECOND(6)``. Otherwise a ``bigint`` of microseconds is used.
|
||||||
``EmailField``
|
``EmailField``
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
.. class:: EmailField([max_length=254, **options])
|
.. class:: EmailField(max_length=254, **options)
|
||||||
|
|
||||||
A :class:`CharField` that checks that the value is a valid email address. It
|
A :class:`CharField` that checks that the value is a valid email address. It
|
||||||
uses :class:`~django.core.validators.EmailValidator` to validate the input.
|
uses :class:`~django.core.validators.EmailValidator` to validate the input.
|
||||||
|
@ -605,7 +605,7 @@ uses :class:`~django.core.validators.EmailValidator` to validate the input.
|
||||||
``FileField``
|
``FileField``
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
.. class:: FileField([upload_to=None, max_length=100, **options])
|
.. class:: FileField(upload_to=None, max_length=100, **options)
|
||||||
|
|
||||||
A file-upload field.
|
A file-upload field.
|
||||||
|
|
||||||
|
@ -821,7 +821,7 @@ periodically via e.g. cron).
|
||||||
``FilePathField``
|
``FilePathField``
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
.. class:: FilePathField(path=None, [match=None, recursive=False, max_length=100, **options])
|
.. class:: FilePathField(path=None, match=None, recursive=False, max_length=100, **options)
|
||||||
|
|
||||||
A :class:`CharField` whose choices are limited to the filenames in a certain
|
A :class:`CharField` whose choices are limited to the filenames in a certain
|
||||||
directory on the filesystem. Has three special arguments, of which the first is
|
directory on the filesystem. Has three special arguments, of which the first is
|
||||||
|
@ -874,7 +874,7 @@ can change the maximum length using the :attr:`~CharField.max_length` argument.
|
||||||
``FloatField``
|
``FloatField``
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
.. class:: FloatField([**options])
|
.. class:: FloatField(**options)
|
||||||
|
|
||||||
A floating-point number represented in Python by a ``float`` instance.
|
A floating-point number represented in Python by a ``float`` instance.
|
||||||
|
|
||||||
|
@ -896,7 +896,7 @@ when :attr:`~django.forms.Field.localize` is ``False`` or
|
||||||
``ImageField``
|
``ImageField``
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
.. class:: ImageField([upload_to=None, height_field=None, width_field=None, max_length=100, **options])
|
.. class:: ImageField(upload_to=None, height_field=None, width_field=None, max_length=100, **options)
|
||||||
|
|
||||||
Inherits all attributes and methods from :class:`FileField`, but also
|
Inherits all attributes and methods from :class:`FileField`, but also
|
||||||
validates that the uploaded object is a valid image.
|
validates that the uploaded object is a valid image.
|
||||||
|
@ -931,7 +931,7 @@ The default form widget for this field is a
|
||||||
``IntegerField``
|
``IntegerField``
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
.. class:: IntegerField([**options])
|
.. class:: IntegerField(**options)
|
||||||
|
|
||||||
An integer. Values from ``-2147483648`` to ``2147483647`` are safe in all
|
An integer. Values from ``-2147483648`` to ``2147483647`` are safe in all
|
||||||
databases supported by Django. The default form widget for this field is a
|
databases supported by Django. The default form widget for this field is a
|
||||||
|
@ -941,7 +941,7 @@ is ``False`` or :class:`~django.forms.TextInput` otherwise.
|
||||||
``GenericIPAddressField``
|
``GenericIPAddressField``
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
.. class:: GenericIPAddressField([protocol=both, unpack_ipv4=False, **options])
|
.. class:: GenericIPAddressField(protocol=both, unpack_ipv4=False, **options)
|
||||||
|
|
||||||
An IPv4 or IPv6 address, in string format (e.g. ``192.0.2.30`` or
|
An IPv4 or IPv6 address, in string format (e.g. ``192.0.2.30`` or
|
||||||
``2a02:42fe::4``). The default form widget for this field is a
|
``2a02:42fe::4``). The default form widget for this field is a
|
||||||
|
@ -972,7 +972,7 @@ values are stored as null.
|
||||||
``NullBooleanField``
|
``NullBooleanField``
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
.. class:: NullBooleanField([**options])
|
.. class:: NullBooleanField(**options)
|
||||||
|
|
||||||
Like a :class:`BooleanField`, but allows ``NULL`` as one of the options. Use
|
Like a :class:`BooleanField`, but allows ``NULL`` as one of the options. Use
|
||||||
this instead of a :class:`BooleanField` with ``null=True``. The default form
|
this instead of a :class:`BooleanField` with ``null=True``. The default form
|
||||||
|
@ -981,7 +981,7 @@ widget for this field is a :class:`~django.forms.NullBooleanSelect`.
|
||||||
``PositiveIntegerField``
|
``PositiveIntegerField``
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
.. class:: PositiveIntegerField([**options])
|
.. class:: PositiveIntegerField(**options)
|
||||||
|
|
||||||
Like an :class:`IntegerField`, but must be either positive or zero (``0``).
|
Like an :class:`IntegerField`, but must be either positive or zero (``0``).
|
||||||
Values from ``0`` to ``2147483647`` are safe in all databases supported by
|
Values from ``0`` to ``2147483647`` are safe in all databases supported by
|
||||||
|
@ -990,7 +990,7 @@ Django. The value ``0`` is accepted for backward compatibility reasons.
|
||||||
``PositiveSmallIntegerField``
|
``PositiveSmallIntegerField``
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
.. class:: PositiveSmallIntegerField([**options])
|
.. class:: PositiveSmallIntegerField(**options)
|
||||||
|
|
||||||
Like a :class:`PositiveIntegerField`, but only allows values under a certain
|
Like a :class:`PositiveIntegerField`, but only allows values under a certain
|
||||||
(database-dependent) point. Values from ``0`` to ``32767`` are safe in all
|
(database-dependent) point. Values from ``0`` to ``32767`` are safe in all
|
||||||
|
@ -999,7 +999,7 @@ databases supported by Django.
|
||||||
``SlugField``
|
``SlugField``
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
.. class:: SlugField([max_length=50, **options])
|
.. class:: SlugField(max_length=50, **options)
|
||||||
|
|
||||||
:term:`Slug` is a newspaper term. A slug is a short label for something,
|
:term:`Slug` is a newspaper term. A slug is a short label for something,
|
||||||
containing only letters, numbers, underscores or hyphens. They're generally used
|
containing only letters, numbers, underscores or hyphens. They're generally used
|
||||||
|
@ -1026,7 +1026,7 @@ of some other value. You can do this automatically in the admin using
|
||||||
``SmallIntegerField``
|
``SmallIntegerField``
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
.. class:: SmallIntegerField([**options])
|
.. class:: SmallIntegerField(**options)
|
||||||
|
|
||||||
Like an :class:`IntegerField`, but only allows values under a certain
|
Like an :class:`IntegerField`, but only allows values under a certain
|
||||||
(database-dependent) point. Values from ``-32768`` to ``32767`` are safe in all
|
(database-dependent) point. Values from ``-32768`` to ``32767`` are safe in all
|
||||||
|
@ -1035,7 +1035,7 @@ databases supported by Django.
|
||||||
``TextField``
|
``TextField``
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
.. class:: TextField([**options])
|
.. class:: TextField(**options)
|
||||||
|
|
||||||
A large text field. The default form widget for this field is a
|
A large text field. The default form widget for this field is a
|
||||||
:class:`~django.forms.Textarea`.
|
:class:`~django.forms.Textarea`.
|
||||||
|
@ -1055,7 +1055,7 @@ However it is not enforced at the model or database level. Use a
|
||||||
``TimeField``
|
``TimeField``
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
.. class:: TimeField([auto_now=False, auto_now_add=False, **options])
|
.. class:: TimeField(auto_now=False, auto_now_add=False, **options)
|
||||||
|
|
||||||
A time, represented in Python by a ``datetime.time`` instance. Accepts the same
|
A time, represented in Python by a ``datetime.time`` instance. Accepts the same
|
||||||
auto-population options as :class:`DateField`.
|
auto-population options as :class:`DateField`.
|
||||||
|
@ -1066,7 +1066,7 @@ The admin adds some JavaScript shortcuts.
|
||||||
``URLField``
|
``URLField``
|
||||||
------------
|
------------
|
||||||
|
|
||||||
.. class:: URLField([max_length=200, **options])
|
.. class:: URLField(max_length=200, **options)
|
||||||
|
|
||||||
A :class:`CharField` for a URL.
|
A :class:`CharField` for a URL.
|
||||||
|
|
||||||
|
@ -1081,7 +1081,7 @@ Like all :class:`CharField` subclasses, :class:`URLField` takes the optional
|
||||||
|
|
||||||
.. versionadded:: 1.8
|
.. versionadded:: 1.8
|
||||||
|
|
||||||
.. class:: UUIDField([**options])
|
.. class:: UUIDField(**options)
|
||||||
|
|
||||||
A field for storing universally unique identifiers. Uses Python's
|
A field for storing universally unique identifiers. Uses Python's
|
||||||
:class:`~python:uuid.UUID` class. When used on PostgreSQL, this stores in a
|
:class:`~python:uuid.UUID` class. When used on PostgreSQL, this stores in a
|
||||||
|
@ -1116,7 +1116,7 @@ Django also defines a set of fields that represent relations.
|
||||||
``ForeignKey``
|
``ForeignKey``
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
.. class:: ForeignKey(othermodel, [**options])
|
.. class:: ForeignKey(othermodel, **options)
|
||||||
|
|
||||||
A many-to-one relationship. Requires a positional argument: the class to which
|
A many-to-one relationship. Requires a positional argument: the class to which
|
||||||
the model is related.
|
the model is related.
|
||||||
|
@ -1374,7 +1374,7 @@ The possible values for :attr:`~ForeignKey.on_delete` are found in
|
||||||
``ManyToManyField``
|
``ManyToManyField``
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
.. class:: ManyToManyField(othermodel, [**options])
|
.. class:: ManyToManyField(othermodel, **options)
|
||||||
|
|
||||||
A many-to-many relationship. Requires a positional argument: the class to
|
A many-to-many relationship. Requires a positional argument: the class to
|
||||||
which the model is related, which works exactly the same as it does for
|
which the model is related, which works exactly the same as it does for
|
||||||
|
@ -1577,7 +1577,7 @@ relationship at the database level.
|
||||||
``OneToOneField``
|
``OneToOneField``
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
.. class:: OneToOneField(othermodel, [parent_link=False, **options])
|
.. class:: OneToOneField(othermodel, parent_link=False, **options)
|
||||||
|
|
||||||
A one-to-one relationship. Conceptually, this is similar to a
|
A one-to-one relationship. Conceptually, this is similar to a
|
||||||
:class:`ForeignKey` with :attr:`unique=True <Field.unique>`, but the
|
:class:`ForeignKey` with :attr:`unique=True <Field.unique>`, but the
|
||||||
|
|
|
@ -312,7 +312,7 @@ Saving objects
|
||||||
|
|
||||||
To save an object back to the database, call ``save()``:
|
To save an object back to the database, call ``save()``:
|
||||||
|
|
||||||
.. method:: Model.save([force_insert=False, force_update=False, using=DEFAULT_DB_ALIAS, update_fields=None])
|
.. method:: Model.save(force_insert=False, force_update=False, using=DEFAULT_DB_ALIAS, update_fields=None)
|
||||||
|
|
||||||
If you want customized saving behavior, you can override this ``save()``
|
If you want customized saving behavior, you can override this ``save()``
|
||||||
method. See :ref:`overriding-model-methods` for more details.
|
method. See :ref:`overriding-model-methods` for more details.
|
||||||
|
@ -533,7 +533,7 @@ value, the field will be added to the updated fields.
|
||||||
Deleting objects
|
Deleting objects
|
||||||
================
|
================
|
||||||
|
|
||||||
.. method:: Model.delete([using=DEFAULT_DB_ALIAS, keep_parents=False])
|
.. method:: Model.delete(using=DEFAULT_DB_ALIAS, keep_parents=False)
|
||||||
|
|
||||||
Issues an SQL ``DELETE`` for the object. This only deletes the object in the
|
Issues an SQL ``DELETE`` for the object. This only deletes the object in the
|
||||||
database; the Python instance will still exist and will still have data in
|
database; the Python instance will still exist and will still have data in
|
||||||
|
|
|
@ -198,7 +198,7 @@ Lookup reference
|
||||||
The name of this lookup, used to identify it on parsing query
|
The name of this lookup, used to identify it on parsing query
|
||||||
expressions. It cannot contain the string ``"__"``.
|
expressions. It cannot contain the string ``"__"``.
|
||||||
|
|
||||||
.. method:: process_lhs(compiler, connection[, lhs=None])
|
.. method:: process_lhs(compiler, connection, lhs=None)
|
||||||
|
|
||||||
Returns a tuple ``(lhs_string, lhs_params)``, as returned by
|
Returns a tuple ``(lhs_string, lhs_params)``, as returned by
|
||||||
``compiler.compile(lhs)``. This method can be overridden to tune how
|
``compiler.compile(lhs)``. This method can be overridden to tune how
|
||||||
|
|
|
@ -128,7 +128,7 @@ QuerySet API
|
||||||
|
|
||||||
Here's the formal declaration of a ``QuerySet``:
|
Here's the formal declaration of a ``QuerySet``:
|
||||||
|
|
||||||
.. class:: QuerySet([model=None, query=None, using=None])
|
.. class:: QuerySet(model=None, query=None, using=None)
|
||||||
|
|
||||||
Usually when you'll interact with a ``QuerySet`` you'll use it by
|
Usually when you'll interact with a ``QuerySet`` you'll use it by
|
||||||
:ref:`chaining filters <chaining-filters>`. To make this work, most
|
:ref:`chaining filters <chaining-filters>`. To make this work, most
|
||||||
|
@ -429,7 +429,7 @@ remain undefined afterward).
|
||||||
distinct
|
distinct
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
|
||||||
.. method:: distinct([*fields])
|
.. method:: distinct(*fields)
|
||||||
|
|
||||||
Returns a new ``QuerySet`` that uses ``SELECT DISTINCT`` in its SQL query. This
|
Returns a new ``QuerySet`` that uses ``SELECT DISTINCT`` in its SQL query. This
|
||||||
eliminates duplicate rows from the query results.
|
eliminates duplicate rows from the query results.
|
||||||
|
|
|
@ -36,7 +36,7 @@ Related objects reference
|
||||||
In this example, the methods below will be available both on
|
In this example, the methods below will be available both on
|
||||||
``topping.pizza_set`` and on ``pizza.toppings``.
|
``topping.pizza_set`` and on ``pizza.toppings``.
|
||||||
|
|
||||||
.. method:: add(obj1, [obj2, ...])
|
.. method:: add(*objs)
|
||||||
|
|
||||||
Adds the specified model objects to the related object set.
|
Adds the specified model objects to the related object set.
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ Related objects reference
|
||||||
parameter ``blog`` to ``create()``. Django figures out that the new
|
parameter ``blog`` to ``create()``. Django figures out that the new
|
||||||
``Entry`` object's ``blog`` field should be set to ``b``.
|
``Entry`` object's ``blog`` field should be set to ``b``.
|
||||||
|
|
||||||
.. method:: remove(obj1, [obj2, ...])
|
.. method:: remove(*objs)
|
||||||
|
|
||||||
Removes the specified model objects from the related object set::
|
Removes the specified model objects from the related object set::
|
||||||
|
|
||||||
|
|
|
@ -539,7 +539,7 @@ In addition, ``QueryDict`` has the following methods:
|
||||||
>>> q.dict()
|
>>> q.dict()
|
||||||
{'a': '5'}
|
{'a': '5'}
|
||||||
|
|
||||||
.. method:: QueryDict.urlencode([safe])
|
.. method:: QueryDict.urlencode(safe=None)
|
||||||
|
|
||||||
Returns a string of the data in query-string format. Example::
|
Returns a string of the data in query-string format. Example::
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ lower level APIs:
|
||||||
Configuring an engine
|
Configuring an engine
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
.. class:: Engine([dirs][, app_dirs][, allowed_include_roots][, context_processors][, debug][, loaders][, string_if_invalid][, file_charset][, libraries][, builtins])
|
.. class:: Engine(dirs=None, app_dirs=False, allowed_include_roots=None, context_processors=None, debug=False, loaders=None, string_if_invalid='', file_charset='utf-8', libraries=None, builtins=None)
|
||||||
|
|
||||||
.. versionadded:: 1.8
|
.. versionadded:: 1.8
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ Once you have a compiled :class:`Template` object, you can render a context
|
||||||
with it. You can reuse the same template to render it several times with
|
with it. You can reuse the same template to render it several times with
|
||||||
different contexts.
|
different contexts.
|
||||||
|
|
||||||
.. class:: Context([dict_][, current_app])
|
.. class:: Context(dict_=None, current_app=_current_app_undefined)
|
||||||
|
|
||||||
This class lives at ``django.template.Context``. The constructor takes
|
This class lives at ``django.template.Context``. The constructor takes
|
||||||
two optional arguments:
|
two optional arguments:
|
||||||
|
@ -585,7 +585,7 @@ against ``dict``::
|
||||||
Subclassing Context: RequestContext
|
Subclassing Context: RequestContext
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
.. class:: RequestContext(request[, dict_][, processors])
|
.. class:: RequestContext(request, dict_=None, processors=None)
|
||||||
|
|
||||||
Django comes with a special ``Context`` class,
|
Django comes with a special ``Context`` class,
|
||||||
``django.template.RequestContext``, that acts slightly differently from the
|
``django.template.RequestContext``, that acts slightly differently from the
|
||||||
|
|
|
@ -10,7 +10,7 @@ reverse()
|
||||||
If you need to use something similar to the :ttag:`url` template tag in
|
If you need to use something similar to the :ttag:`url` template tag in
|
||||||
your code, Django provides the following function:
|
your code, Django provides the following function:
|
||||||
|
|
||||||
.. function:: reverse(viewname, [urlconf=None, args=None, kwargs=None, current_app=None])
|
.. function:: reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None)
|
||||||
|
|
||||||
``viewname`` can be a string containing the Python path to the view object, a
|
``viewname`` can be a string containing the Python path to the view object, a
|
||||||
:ref:`URL pattern name <naming-url-patterns>`, or the callable view object.
|
:ref:`URL pattern name <naming-url-patterns>`, or the callable view object.
|
||||||
|
@ -97,7 +97,7 @@ reverse_lazy()
|
||||||
|
|
||||||
A lazily evaluated version of `reverse()`_.
|
A lazily evaluated version of `reverse()`_.
|
||||||
|
|
||||||
.. function:: reverse_lazy(viewname, [urlconf=None, args=None, kwargs=None, current_app=None])
|
.. function:: reverse_lazy(viewname, urlconf=None, args=None, kwargs=None, current_app=None)
|
||||||
|
|
||||||
It is useful for when you need to use a URL reversal before your project's
|
It is useful for when you need to use a URL reversal before your project's
|
||||||
URLConf is loaded. Some common cases where this function is necessary are:
|
URLConf is loaded. Some common cases where this function is necessary are:
|
||||||
|
|
|
@ -128,9 +128,9 @@ parameter is useful.
|
||||||
include()
|
include()
|
||||||
---------
|
---------
|
||||||
|
|
||||||
.. function:: include(module[, namespace=None, app_name=None])
|
.. function:: include(module, namespace=None, app_name=None)
|
||||||
include(pattern_list)
|
include(pattern_list)
|
||||||
include((pattern_list, app_namespace)[, namespace=None])
|
include((pattern_list, app_namespace), namespace=None)
|
||||||
include((pattern_list, app_namespace, instance_namespace))
|
include((pattern_list, app_namespace, instance_namespace))
|
||||||
|
|
||||||
A function that takes a full Python import path to another URLconf module
|
A function that takes a full Python import path to another URLconf module
|
||||||
|
|
|
@ -334,7 +334,7 @@ SyndicationFeed
|
||||||
|
|
||||||
Base class for all syndication feeds. Subclasses should provide write().
|
Base class for all syndication feeds. Subclasses should provide write().
|
||||||
|
|
||||||
.. method:: __init__(title, link, description, [language=None, author_email=None, author_name=None, author_link=None, subtitle=None, categories=None, feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, **kwargs])
|
.. method:: __init__(title, link, description, language=None, author_email=None, author_name=None, author_link=None, subtitle=None, categories=None, feed_url=None, feed_copyright=None, feed_guid=None, ttl=None, **kwargs)
|
||||||
|
|
||||||
Initialize the feed with the given dictionary of metadata, which applies
|
Initialize the feed with the given dictionary of metadata, which applies
|
||||||
to the entire feed.
|
to the entire feed.
|
||||||
|
@ -345,7 +345,7 @@ SyndicationFeed
|
||||||
All parameters should be Unicode objects, except ``categories``, which
|
All parameters should be Unicode objects, except ``categories``, which
|
||||||
should be a sequence of Unicode objects.
|
should be a sequence of Unicode objects.
|
||||||
|
|
||||||
.. method:: add_item(title, link, description, [author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, unique_id=None, enclosure=None, categories=(), item_copyright=None, ttl=None, updateddate=None, **kwargs])
|
.. method:: add_item(title, link, description, author_email=None, author_name=None, author_link=None, pubdate=None, comments=None, unique_id=None, enclosure=None, categories=(), item_copyright=None, ttl=None, updateddate=None, **kwargs)
|
||||||
|
|
||||||
Adds an item to the feed. All args are expected to be Python ``unicode``
|
Adds an item to the feed. All args are expected to be Python ``unicode``
|
||||||
objects except ``pubdate`` and ``updateddate``, which are ``datetime.datetime``
|
objects except ``pubdate`` and ``updateddate``, which are ``datetime.datetime``
|
||||||
|
|
|
@ -68,7 +68,7 @@ to, or in lieu of custom ``field.clean()`` methods.
|
||||||
``RegexValidator``
|
``RegexValidator``
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
.. class:: RegexValidator([regex=None, message=None, code=None, inverse_match=None, flags=0])
|
.. class:: RegexValidator(regex=None, message=None, code=None, inverse_match=None, flags=0)
|
||||||
|
|
||||||
:param regex: If not ``None``, overrides :attr:`regex`. Can be a regular
|
:param regex: If not ``None``, overrides :attr:`regex`. Can be a regular
|
||||||
expression string or a pre-compiled regular expression.
|
expression string or a pre-compiled regular expression.
|
||||||
|
@ -115,7 +115,7 @@ to, or in lieu of custom ``field.clean()`` methods.
|
||||||
``EmailValidator``
|
``EmailValidator``
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
.. class:: EmailValidator([message=None, code=None, whitelist=None])
|
.. class:: EmailValidator(message=None, code=None, whitelist=None)
|
||||||
|
|
||||||
:param message: If not ``None``, overrides :attr:`.message`.
|
:param message: If not ``None``, overrides :attr:`.message`.
|
||||||
:param code: If not ``None``, overrides :attr:`code`.
|
:param code: If not ``None``, overrides :attr:`code`.
|
||||||
|
@ -144,7 +144,7 @@ to, or in lieu of custom ``field.clean()`` methods.
|
||||||
``URLValidator``
|
``URLValidator``
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
.. class:: URLValidator([schemes=None, regex=None, message=None, code=None])
|
.. class:: URLValidator(schemes=None, regex=None, message=None, code=None)
|
||||||
|
|
||||||
A :class:`RegexValidator` that ensures a value looks like a URL, and raises
|
A :class:`RegexValidator` that ensures a value looks like a URL, and raises
|
||||||
an error code of ``'invalid'`` if it doesn't.
|
an error code of ``'invalid'`` if it doesn't.
|
||||||
|
|
|
@ -429,7 +429,7 @@ login page::
|
||||||
The ``login_required`` decorator
|
The ``login_required`` decorator
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. function:: login_required([redirect_field_name=REDIRECT_FIELD_NAME, login_url=None])
|
.. function:: login_required(redirect_field_name='next', login_url=None)
|
||||||
|
|
||||||
As a shortcut, you can use the convenient
|
As a shortcut, you can use the convenient
|
||||||
:func:`~django.contrib.auth.decorators.login_required` decorator::
|
:func:`~django.contrib.auth.decorators.login_required` decorator::
|
||||||
|
@ -556,7 +556,7 @@ redirects to the login page::
|
||||||
return redirect('/login/?next=%s' % request.path)
|
return redirect('/login/?next=%s' % request.path)
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
.. function:: user_passes_test(func, [login_url=None, redirect_field_name=REDIRECT_FIELD_NAME])
|
.. function:: user_passes_test(func, login_url=None, redirect_field_name='next')
|
||||||
|
|
||||||
As a shortcut, you can use the convenient ``user_passes_test`` decorator
|
As a shortcut, you can use the convenient ``user_passes_test`` decorator
|
||||||
which performs a redirect when the callable returns ``False``::
|
which performs a redirect when the callable returns ``False``::
|
||||||
|
@ -643,7 +643,7 @@ redirects to the login page::
|
||||||
The ``permission_required`` decorator
|
The ``permission_required`` decorator
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
.. function:: permission_required(perm, [login_url=None, raise_exception=False])
|
.. function:: permission_required(perm, login_url=None, raise_exception=False)
|
||||||
|
|
||||||
It's a relatively common task to check whether a user has a particular
|
It's a relatively common task to check whether a user has a particular
|
||||||
permission. For that reason, Django provides a shortcut for that case: the
|
permission. For that reason, Django provides a shortcut for that case: the
|
||||||
|
@ -923,7 +923,7 @@ All authentication views
|
||||||
This is a list with all the views ``django.contrib.auth`` provides. For
|
This is a list with all the views ``django.contrib.auth`` provides. For
|
||||||
implementation details see :ref:`using-the-views`.
|
implementation details see :ref:`using-the-views`.
|
||||||
|
|
||||||
.. function:: login(request, [template_name, redirect_field_name, authentication_form, current_app, extra_context])
|
.. function:: login(request, template_name=`registration/login.html`, redirect_field_name=, authentication_form, current_app, extra_context])
|
||||||
|
|
||||||
**URL name:** ``login``
|
**URL name:** ``login``
|
||||||
|
|
||||||
|
@ -1055,7 +1055,7 @@ implementation details see :ref:`using-the-views`.
|
||||||
.. _forms documentation: ../forms/
|
.. _forms documentation: ../forms/
|
||||||
.. _site framework docs: ../sites/
|
.. _site framework docs: ../sites/
|
||||||
|
|
||||||
.. function:: logout(request, [next_page, template_name, redirect_field_name, current_app, extra_context])
|
.. function:: logout(request, next_page=None, template_name='registration/logged_out.html', redirect_field_name='next', current_app=None, extra_context=None)
|
||||||
|
|
||||||
Logs a user out.
|
Logs a user out.
|
||||||
|
|
||||||
|
@ -1108,7 +1108,7 @@ implementation details see :ref:`using-the-views`.
|
||||||
* ``extra_context``: A dictionary of context data that will be added to the
|
* ``extra_context``: A dictionary of context data that will be added to the
|
||||||
default context data passed to the template.
|
default context data passed to the template.
|
||||||
|
|
||||||
.. function:: logout_then_login(request[, login_url, current_app, extra_context])
|
.. function:: logout_then_login(request, login_url=None, current_app=None, extra_context=None)
|
||||||
|
|
||||||
Logs a user out, then redirects to the login page.
|
Logs a user out, then redirects to the login page.
|
||||||
|
|
||||||
|
@ -1131,7 +1131,7 @@ implementation details see :ref:`using-the-views`.
|
||||||
The ``current_app`` parameter is deprecated and will be removed in
|
The ``current_app`` parameter is deprecated and will be removed in
|
||||||
Django 2.0. Callers should set ``request.current_app`` instead.
|
Django 2.0. Callers should set ``request.current_app`` instead.
|
||||||
|
|
||||||
.. function:: password_change(request[, template_name, post_change_redirect, password_change_form, current_app, extra_context])
|
.. function:: password_change(request, template_name='registration/password_change_form.html', post_change_redirect=None, password_change_form=PasswordChangeForm, current_app=None, extra_context=None)
|
||||||
|
|
||||||
Allows a user to change their password.
|
Allows a user to change their password.
|
||||||
|
|
||||||
|
@ -1167,7 +1167,7 @@ implementation details see :ref:`using-the-views`.
|
||||||
|
|
||||||
* ``form``: The password change form (see ``password_change_form`` above).
|
* ``form``: The password change form (see ``password_change_form`` above).
|
||||||
|
|
||||||
.. function:: password_change_done(request[, template_name, current_app, extra_context])
|
.. function:: password_change_done(request, template_name='registration/password_change_done.html', current_app=None, extra_context=None)
|
||||||
|
|
||||||
The page shown after a user has changed their password.
|
The page shown after a user has changed their password.
|
||||||
|
|
||||||
|
@ -1191,7 +1191,7 @@ implementation details see :ref:`using-the-views`.
|
||||||
The ``current_app`` parameter is deprecated and will be removed in
|
The ``current_app`` parameter is deprecated and will be removed in
|
||||||
Django 2.0. Callers should set ``request.current_app`` instead.
|
Django 2.0. Callers should set ``request.current_app`` instead.
|
||||||
|
|
||||||
.. function:: password_reset(request[, is_admin_site, template_name, email_template_name, password_reset_form, token_generator, post_reset_redirect, from_email, current_app, extra_context, html_email_template_name])
|
.. function:: password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html', email_template_name='registration/password_reset_email.html', password_reset_form='registration/password_reset_subject.txt', token_generator=default_token_generator, post_reset_redirect=None, from_email=None, current_app=None, extra_context=None, html_email_template_name=None)
|
||||||
|
|
||||||
Allows a user to reset their password by generating a one-time use link
|
Allows a user to reset their password by generating a one-time use link
|
||||||
that can be used to reset the password, and sending that link to the
|
that can be used to reset the password, and sending that link to the
|
||||||
|
@ -1300,7 +1300,7 @@ implementation details see :ref:`using-the-views`.
|
||||||
The same template context is used for subject template. Subject must be
|
The same template context is used for subject template. Subject must be
|
||||||
single line plain text string.
|
single line plain text string.
|
||||||
|
|
||||||
.. function:: password_reset_done(request[, template_name, current_app, extra_context])
|
.. function:: password_reset_done(request, template_name='registration/password_reset_done.html', current_app=None, extra_context=None)
|
||||||
|
|
||||||
The page shown after a user has been emailed a link to reset their
|
The page shown after a user has been emailed a link to reset their
|
||||||
password. This view is called by default if the :func:`password_reset` view
|
password. This view is called by default if the :func:`password_reset` view
|
||||||
|
@ -1332,7 +1332,7 @@ implementation details see :ref:`using-the-views`.
|
||||||
The ``current_app`` parameter is deprecated and will be removed in
|
The ``current_app`` parameter is deprecated and will be removed in
|
||||||
Django 2.0. Callers should set ``request.current_app`` instead.
|
Django 2.0. Callers should set ``request.current_app`` instead.
|
||||||
|
|
||||||
.. function:: password_reset_confirm(request[, uidb64, token, template_name, token_generator, set_password_form, post_reset_redirect, current_app, extra_context])
|
.. function:: password_reset_confirm(request, uidb64=None, token=None, template_name='registration/password_reset_confirm.html', token_generator=default_token_generator, set_password_form=SetPasswordForm, post_reset_redirect=None, current_app=None, extra_context=None)
|
||||||
|
|
||||||
Presents a form for entering a new password.
|
Presents a form for entering a new password.
|
||||||
|
|
||||||
|
@ -1378,7 +1378,7 @@ implementation details see :ref:`using-the-views`.
|
||||||
The ``current_app`` parameter is deprecated and will be removed in
|
The ``current_app`` parameter is deprecated and will be removed in
|
||||||
Django 2.0. Callers should set ``request.current_app`` instead.
|
Django 2.0. Callers should set ``request.current_app`` instead.
|
||||||
|
|
||||||
.. function:: password_reset_complete(request[,template_name, current_app, extra_context])
|
.. function:: password_reset_complete(request, template_name='registration/password_reset_complete.html', current_app=None, extra_context=None)
|
||||||
|
|
||||||
Presents a view which informs the user that the password has been
|
Presents a view which informs the user that the password has been
|
||||||
successfully changed.
|
successfully changed.
|
||||||
|
@ -1407,7 +1407,7 @@ Helper functions
|
||||||
|
|
||||||
.. currentmodule:: django.contrib.auth.views
|
.. currentmodule:: django.contrib.auth.views
|
||||||
|
|
||||||
.. function:: redirect_to_login(next[, login_url, redirect_field_name])
|
.. function:: redirect_to_login(next, login_url=None, redirect_field_name='next')
|
||||||
|
|
||||||
Redirects to the login page, and then back to another URL after a
|
Redirects to the login page, and then back to another URL after a
|
||||||
successful login.
|
successful login.
|
||||||
|
@ -1500,7 +1500,7 @@ provides several built-in forms located in :mod:`django.contrib.auth.forms`:
|
||||||
A form for generating and emailing a one-time use link to reset a
|
A form for generating and emailing a one-time use link to reset a
|
||||||
user's password.
|
user's password.
|
||||||
|
|
||||||
.. method:: send_email(subject_template_name, email_template_name, context, from_email, to_email, [html_email_template_name=None])
|
.. method:: send_email(subject_template_name, email_template_name, context, from_email, to_email, html_email_template_name=None)
|
||||||
|
|
||||||
.. versionadded:: 1.8
|
.. versionadded:: 1.8
|
||||||
|
|
||||||
|
|
|
@ -447,7 +447,7 @@ can :ref:`write your own email backend <topic-custom-email-backend>`.
|
||||||
SMTP backend
|
SMTP backend
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
.. class:: backends.smtp.EmailBackend([host=None, port=None, username=None, password=None, use_tls=None, fail_silently=False, use_ssl=None, timeout=None, ssl_keyfile=None, ssl_certfile=None, **kwargs])
|
.. class:: backends.smtp.EmailBackend(host=None, port=None, username=None, password=None, use_tls=None, fail_silently=False, use_ssl=None, timeout=None, ssl_keyfile=None, ssl_certfile=None, **kwargs)
|
||||||
|
|
||||||
This is the default backend. Email will be sent through a SMTP server.
|
This is the default backend. Email will be sent through a SMTP server.
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ introduce controlled coupling for convenience's sake.
|
||||||
``render``
|
``render``
|
||||||
==========
|
==========
|
||||||
|
|
||||||
.. function:: render(request, template_name[, context][, context_instance][, content_type][, status][, current_app][, dirs][, using])
|
.. function:: render(request, template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, current_app=_current_app_undefined, dirs=_dirs_undefined, using=None)
|
||||||
|
|
||||||
Combines a given template with a given context dictionary and returns an
|
Combines a given template with a given context dictionary and returns an
|
||||||
:class:`~django.http.HttpResponse` object with that rendered text.
|
:class:`~django.http.HttpResponse` object with that rendered text.
|
||||||
|
@ -117,7 +117,7 @@ This example is equivalent to::
|
||||||
``render_to_response``
|
``render_to_response``
|
||||||
======================
|
======================
|
||||||
|
|
||||||
.. function:: render_to_response(template_name[, context][, context_instance][, content_type][, status][, dirs][, using])
|
.. function:: render_to_response(template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, dirs=_dirs_undefined, using=None)
|
||||||
|
|
||||||
Renders a given template with a given context dictionary and returns an
|
Renders a given template with a given context dictionary and returns an
|
||||||
:class:`~django.http.HttpResponse` object with that rendered text.
|
:class:`~django.http.HttpResponse` object with that rendered text.
|
||||||
|
@ -207,7 +207,7 @@ This example is equivalent to::
|
||||||
``redirect``
|
``redirect``
|
||||||
============
|
============
|
||||||
|
|
||||||
.. function:: redirect(to[, permanent=False], *args, **kwargs)
|
.. function:: redirect(to, permanent=False, *args, **kwargs)
|
||||||
|
|
||||||
Returns an :class:`~django.http.HttpResponseRedirect` to the appropriate URL
|
Returns an :class:`~django.http.HttpResponseRedirect` to the appropriate URL
|
||||||
for the arguments passed.
|
for the arguments passed.
|
||||||
|
|
|
@ -50,7 +50,7 @@ Listening to signals
|
||||||
To receive a signal, you need to register a *receiver* function that gets
|
To receive a signal, you need to register a *receiver* function that gets
|
||||||
called when the signal is sent by using the :meth:`Signal.connect` method:
|
called when the signal is sent by using the :meth:`Signal.connect` method:
|
||||||
|
|
||||||
.. method:: Signal.connect(receiver, [sender=None, weak=True, dispatch_uid=None])
|
.. method:: Signal.connect(receiver, sender=None, weak=True, dispatch_uid=None)
|
||||||
|
|
||||||
:param receiver: The callback function which will be connected to this
|
:param receiver: The callback function which will be connected to this
|
||||||
signal. See :ref:`receiver-functions` for more information.
|
signal. See :ref:`receiver-functions` for more information.
|
||||||
|
@ -208,7 +208,7 @@ its own signals.
|
||||||
Defining signals
|
Defining signals
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
.. class:: Signal([providing_args=list])
|
.. class:: Signal(providing_args=list)
|
||||||
|
|
||||||
All signals are :class:`django.dispatch.Signal` instances. The
|
All signals are :class:`django.dispatch.Signal` instances. The
|
||||||
``providing_args`` is a list of the names of arguments the signal will provide
|
``providing_args`` is a list of the names of arguments the signal will provide
|
||||||
|
@ -269,7 +269,7 @@ error instance is returned in the tuple pair for the receiver that raised the er
|
||||||
Disconnecting signals
|
Disconnecting signals
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
.. method:: Signal.disconnect([receiver=None, sender=None, dispatch_uid=None])
|
.. method:: Signal.disconnect(receiver=None, sender=None, dispatch_uid=None)
|
||||||
|
|
||||||
To disconnect a receiver from a signal, call :meth:`Signal.disconnect`. The
|
To disconnect a receiver from a signal, call :meth:`Signal.disconnect`. The
|
||||||
arguments are as described in :meth:`.Signal.connect`. The method returns
|
arguments are as described in :meth:`.Signal.connect`. The method returns
|
||||||
|
|
|
@ -95,7 +95,7 @@ Usage
|
||||||
|
|
||||||
The ``django.template.loader`` module defines two functions to load templates.
|
The ``django.template.loader`` module defines two functions to load templates.
|
||||||
|
|
||||||
.. function:: get_template(template_name[, dirs][, using])
|
.. function:: get_template(template_name, dirs=_dirs_undefined, using=None)
|
||||||
|
|
||||||
This function loads the template with the given name and returns a
|
This function loads the template with the given name and returns a
|
||||||
``Template`` object.
|
``Template`` object.
|
||||||
|
@ -128,7 +128,7 @@ The ``django.template.loader`` module defines two functions to load templates.
|
||||||
``get_template()`` returns a backend-dependent ``Template`` instead
|
``get_template()`` returns a backend-dependent ``Template`` instead
|
||||||
of a :class:`django.template.Template`.
|
of a :class:`django.template.Template`.
|
||||||
|
|
||||||
.. function:: select_template(template_name_list[, dirs][, using])
|
.. function:: select_template(template_name_list, dirs=_dirs_undefined, using=None)
|
||||||
|
|
||||||
``select_template()`` is just like ``get_template()``, except it takes a
|
``select_template()`` is just like ``get_template()``, except it takes a
|
||||||
list of template names. It tries each name in order and returns the first
|
list of template names. It tries each name in order and returns the first
|
||||||
|
@ -269,7 +269,7 @@ the following templates:
|
||||||
In addition, to cut down on the repetitive nature of loading and rendering
|
In addition, to cut down on the repetitive nature of loading and rendering
|
||||||
templates, Django provides a shortcut function which automates the process.
|
templates, Django provides a shortcut function which automates the process.
|
||||||
|
|
||||||
.. function:: render_to_string(template_name[, context][, context_instance][, request][, using])
|
.. function:: render_to_string(template_name, context=None, context_instance=_context_instance_undefined, request=None, using=None)
|
||||||
|
|
||||||
``render_to_string()`` loads a template like :func:`get_template` and
|
``render_to_string()`` loads a template like :func:`get_template` and
|
||||||
calls its ``render()`` method immediately. It takes the following
|
calls its ``render()`` method immediately. It takes the following
|
||||||
|
|
|
@ -570,7 +570,7 @@ django.db.connection.creation
|
||||||
The creation module of the database backend also provides some utilities that
|
The creation module of the database backend also provides some utilities that
|
||||||
can be useful during testing.
|
can be useful during testing.
|
||||||
|
|
||||||
.. function:: create_test_db([verbosity=1, autoclobber=False, serialize=True, keepdb=False])
|
.. function:: create_test_db(verbosity=1, autoclobber=False, serialize=True, keepdb=False)
|
||||||
|
|
||||||
Creates a new test database and runs ``migrate`` against it.
|
Creates a new test database and runs ``migrate`` against it.
|
||||||
|
|
||||||
|
@ -612,7 +612,7 @@ can be useful during testing.
|
||||||
|
|
||||||
The ``keepdb`` argument was added.
|
The ``keepdb`` argument was added.
|
||||||
|
|
||||||
.. function:: destroy_test_db(old_database_name, [verbosity=1, keepdb=False])
|
.. function:: destroy_test_db(old_database_name, verbosity=1, keepdb=False)
|
||||||
|
|
||||||
Destroys the database whose name is the value of :setting:`NAME` in
|
Destroys the database whose name is the value of :setting:`NAME` in
|
||||||
:setting:`DATABASES`, and sets :setting:`NAME` to the value of
|
:setting:`DATABASES`, and sets :setting:`NAME` to the value of
|
||||||
|
|
Loading…
Reference in New Issue