mirror of
https://github.com/django/django.git
synced 2025-09-16 15:35:17 +00:00
Fixed #26483 -- Updated docs.python.org links to use Intersphinx.
This commit is contained in:
parent
413f3bb5c8
commit
f5ff5010cd
20 changed files with 75 additions and 108 deletions
|
@ -2,9 +2,9 @@
|
|||
``contrib`` packages
|
||||
====================
|
||||
|
||||
Django aims to follow Python's `"batteries included" philosophy`_. It ships
|
||||
with a variety of extra, optional tools that solve common Web-development
|
||||
problems.
|
||||
Django aims to follow Python's :ref:`"batteries included" philosophy
|
||||
<tut-batteries-included>`. It ships with a variety of extra, optional tools
|
||||
that solve common Web-development problems.
|
||||
|
||||
This code lives in ``django/contrib`` in the Django distribution. This document
|
||||
gives a rundown of the packages in ``contrib``, along with any dependencies
|
||||
|
@ -17,8 +17,6 @@ those packages have.
|
|||
``'django.contrib.redirects'``) to your :setting:`INSTALLED_APPS` setting
|
||||
and re-run ``manage.py migrate``.
|
||||
|
||||
.. _"batteries included" philosophy: https://docs.python.org/tutorial/stdlib.html#batteries-included
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
|
|
|
@ -599,8 +599,8 @@ Other model instance methods
|
|||
|
||||
A few object methods have special purposes.
|
||||
|
||||
``__str__``
|
||||
-----------
|
||||
``__str__()``
|
||||
-------------
|
||||
|
||||
.. method:: Model.__str__()
|
||||
|
||||
|
@ -626,8 +626,8 @@ For example::
|
|||
If you'd like compatibility with Python 2, you can decorate your model class
|
||||
with :func:`~django.utils.encoding.python_2_unicode_compatible` as shown above.
|
||||
|
||||
``__eq__``
|
||||
----------
|
||||
``__eq__()``
|
||||
------------
|
||||
|
||||
.. method:: Model.__eq__()
|
||||
|
||||
|
@ -655,22 +655,20 @@ For example::
|
|||
MyModel(id=1) != MultitableInherited(id=1)
|
||||
MyModel(id=1) != MyModel(id=2)
|
||||
|
||||
``__hash__``
|
||||
------------
|
||||
``__hash__()``
|
||||
--------------
|
||||
|
||||
.. method:: Model.__hash__()
|
||||
|
||||
The ``__hash__`` method is based on the instance's primary key value. It
|
||||
is effectively hash(obj.pk). If the instance doesn't have a primary key
|
||||
value then a ``TypeError`` will be raised (otherwise the ``__hash__``
|
||||
The ``__hash__()`` method is based on the instance's primary key value. It
|
||||
is effectively ``hash(obj.pk)``. If the instance doesn't have a primary key
|
||||
value then a ``TypeError`` will be raised (otherwise the ``__hash__()``
|
||||
method would return different values before and after the instance is
|
||||
saved, but changing the ``__hash__`` value of an instance `is forbidden
|
||||
in Python`_).
|
||||
saved, but changing the :meth:`~object.__hash__` value of an instance is
|
||||
forbidden in Python.
|
||||
|
||||
.. _is forbidden in Python: https://docs.python.org/reference/datamodel.html#object.__hash__
|
||||
|
||||
``get_absolute_url``
|
||||
--------------------
|
||||
``get_absolute_url()``
|
||||
----------------------
|
||||
|
||||
.. method:: Model.get_absolute_url()
|
||||
|
||||
|
|
|
@ -924,16 +924,15 @@ Default::
|
|||
|
||||
A list of formats that will be accepted when inputting data on a date field.
|
||||
Formats will be tried in order, using the first valid one. Note that these
|
||||
format strings use Python's datetime_ module syntax, not the format strings
|
||||
from the ``date`` Django template tag.
|
||||
format strings use Python's :ref:`datetime module syntax
|
||||
<strftime-strptime-behavior>`, not the format strings from the :tfilter:`date`
|
||||
template filter.
|
||||
|
||||
When :setting:`USE_L10N` is ``True``, the locale-dictated format has higher
|
||||
precedence and will be applied instead.
|
||||
|
||||
See also :setting:`DATETIME_INPUT_FORMATS` and :setting:`TIME_INPUT_FORMATS`.
|
||||
|
||||
.. _datetime: https://docs.python.org/library/datetime.html#strftime-strptime-behavior
|
||||
|
||||
.. setting:: DATETIME_FORMAT
|
||||
|
||||
``DATETIME_FORMAT``
|
||||
|
@ -972,16 +971,15 @@ Default::
|
|||
|
||||
A list of formats that will be accepted when inputting data on a datetime
|
||||
field. Formats will be tried in order, using the first valid one. Note that
|
||||
these format strings use Python's datetime_ module syntax, not the format
|
||||
strings from the ``date`` Django template tag.
|
||||
these format strings use Python's :ref:`datetime module syntax
|
||||
<strftime-strptime-behavior>`, not the format strings from the :tfilter:`date`
|
||||
template filter.
|
||||
|
||||
When :setting:`USE_L10N` is ``True``, the locale-dictated format has higher
|
||||
precedence and will be applied instead.
|
||||
|
||||
See also :setting:`DATE_INPUT_FORMATS` and :setting:`TIME_INPUT_FORMATS`.
|
||||
|
||||
.. _datetime: https://docs.python.org/library/datetime.html#strftime-strptime-behavior
|
||||
|
||||
.. setting:: DEBUG
|
||||
|
||||
``DEBUG``
|
||||
|
@ -1730,14 +1728,12 @@ __ https://github.com/django/django/blob/master/django/utils/log.py
|
|||
Default: ``'logging.config.dictConfig'``
|
||||
|
||||
A path to a callable that will be used to configure logging in the
|
||||
Django project. Points at a instance of Python's `dictConfig`_
|
||||
configuration method by default.
|
||||
Django project. Points at a instance of Python's :ref:`dictConfig
|
||||
<logging-config-dictschema>` configuration method by default.
|
||||
|
||||
If you set :setting:`LOGGING_CONFIG` to ``None``, the logging
|
||||
configuration process will be skipped.
|
||||
|
||||
.. _dictConfig: https://docs.python.org/library/logging.config.html#configuration-dictionary-schema
|
||||
|
||||
.. setting:: MANAGERS
|
||||
|
||||
``MANAGERS``
|
||||
|
@ -2368,16 +2364,15 @@ Default::
|
|||
|
||||
A list of formats that will be accepted when inputting data on a time field.
|
||||
Formats will be tried in order, using the first valid one. Note that these
|
||||
format strings use Python's datetime_ module syntax, not the format strings
|
||||
from the ``date`` Django template tag.
|
||||
format strings use Python's :ref:`datetime module syntax
|
||||
<strftime-strptime-behavior>`, not the format strings from the :tfilter:`date`
|
||||
template filter.
|
||||
|
||||
When :setting:`USE_L10N` is ``True``, the locale-dictated format has higher
|
||||
precedence and will be applied instead.
|
||||
|
||||
See also :setting:`DATE_INPUT_FORMATS` and :setting:`DATETIME_INPUT_FORMATS`.
|
||||
|
||||
.. _datetime: https://docs.python.org/library/datetime.html#strftime-strptime-behavior
|
||||
|
||||
.. setting:: TIME_ZONE
|
||||
|
||||
``TIME_ZONE``
|
||||
|
|
|
@ -2044,11 +2044,8 @@ If ``value`` is ``"Joel is a slug"``, the output will be ``"joel-is-a-slug"``.
|
|||
----------------
|
||||
|
||||
Formats the variable according to the argument, a string formatting specifier.
|
||||
This specifier uses Python string formatting syntax, with the exception that
|
||||
the leading "%" is dropped.
|
||||
|
||||
See https://docs.python.org/library/stdtypes.html#string-formatting-operations
|
||||
for documentation of Python string formatting
|
||||
This specifier uses the :ref:`old-string-formatting` syntax, with the exception
|
||||
that the leading "%" is dropped.
|
||||
|
||||
For example::
|
||||
|
||||
|
|
|
@ -618,14 +618,14 @@ escaping HTML.
|
|||
|
||||
.. function:: format_html(format_string, *args, **kwargs)
|
||||
|
||||
This is similar to `str.format`_, except that it is appropriate for
|
||||
This is similar to :meth:`str.format`, except that it is appropriate for
|
||||
building up HTML fragments. All args and kwargs are passed through
|
||||
:func:`conditional_escape` before being passed to ``str.format``.
|
||||
:func:`conditional_escape` before being passed to ``str.format()``.
|
||||
|
||||
For the case of building up small HTML fragments, this function is to be
|
||||
preferred over string interpolation using ``%`` or ``str.format`` directly,
|
||||
because it applies escaping to all arguments - just like the Template system
|
||||
applies escaping by default.
|
||||
preferred over string interpolation using ``%`` or ``str.format()``
|
||||
directly, because it applies escaping to all arguments - just like the
|
||||
template system applies escaping by default.
|
||||
|
||||
So, instead of writing::
|
||||
|
||||
|
@ -642,14 +642,12 @@ escaping HTML.
|
|||
This has the advantage that you don't need to apply :func:`escape` to each
|
||||
argument and risk a bug and an XSS vulnerability if you forget one.
|
||||
|
||||
Note that although this function uses ``str.format`` to do the
|
||||
interpolation, some of the formatting options provided by `str.format`_
|
||||
Note that although this function uses ``str.format()`` to do the
|
||||
interpolation, some of the formatting options provided by ``str.format()``
|
||||
(e.g. number formatting) will not work, since all arguments are passed
|
||||
through :func:`conditional_escape` which (ultimately) calls
|
||||
:func:`~django.utils.encoding.force_text` on the values.
|
||||
|
||||
.. _str.format: https://docs.python.org/library/stdtypes.html#str.format
|
||||
|
||||
.. function:: format_html_join(sep, format_string, args_generator)
|
||||
|
||||
A wrapper of :func:`format_html`, for the common case of a group of
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue