2015-09-20 08:34:58 +08:00
|
|
|
=============================================
|
|
|
|
Django 1.10 release notes - UNDER DEVELOPMENT
|
|
|
|
=============================================
|
|
|
|
|
|
|
|
Welcome to Django 1.10!
|
|
|
|
|
2016-06-02 23:41:49 +08:00
|
|
|
These release notes cover the :ref:`new features <whats-new-1.10>`, as well as
|
|
|
|
some :ref:`backwards incompatible changes <backwards-incompatible-1.10>` you'll
|
|
|
|
want to be aware of when upgrading from Django 1.9 or older versions. We've
|
|
|
|
:ref:`dropped some features <removed-features-1.10>` that have reached the end
|
|
|
|
of their deprecation cycle, and we've :ref:`begun the deprecation process for
|
|
|
|
some features <deprecated-features-1.10>`.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
|
|
|
Python compatibility
|
|
|
|
====================
|
|
|
|
|
|
|
|
Like Django 1.9, Django 1.10 requires Python 2.7, 3.4, or 3.5. We **highly
|
|
|
|
recommend** and only officially support the latest release of each series.
|
|
|
|
|
2016-06-02 23:41:49 +08:00
|
|
|
.. _whats-new-1.10:
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
What's new in Django 1.10
|
|
|
|
=========================
|
|
|
|
|
2015-06-01 05:45:03 +08:00
|
|
|
Full text search for PostgreSQL
|
|
|
|
-------------------------------
|
|
|
|
|
|
|
|
``django.contrib.postgres`` now includes a :doc:`collection of database
|
|
|
|
functions </ref/contrib/postgres/search>` to allow the use of the full text
|
|
|
|
search engine. You can search across multiple fields in your relational
|
|
|
|
database, combine the searches with other lookups, use different language
|
|
|
|
configurations and weightings, and rank the results by relevance.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-06-06 00:37:48 +08:00
|
|
|
It also now includes trigram support, using the :lookup:`trigram_similar`
|
|
|
|
lookup, and the :class:`~django.contrib.postgres.search.TrigramSimilarity` and
|
|
|
|
:class:`~django.contrib.postgres.search.TrigramDistance` expressions.
|
|
|
|
|
2015-11-07 23:12:37 +08:00
|
|
|
New-style middleware
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
:doc:`A new style of middleware is introduced </topics/http/middleware>` to
|
|
|
|
solve the lack of strict request/response layering of the old-style of
|
|
|
|
middleware described in `DEP 0005
|
|
|
|
<https://github.com/django/deps/blob/master/final/0005-improved-middleware.rst>`_.
|
|
|
|
You'll need to :ref:`adapt old, custom middleware <upgrading-middleware>` and
|
|
|
|
switch from the ``MIDDLEWARE_CLASSES`` setting to the new :setting:`MIDDLEWARE`
|
|
|
|
setting to take advantage of the improvements.
|
|
|
|
|
2016-04-23 01:39:13 +08:00
|
|
|
Official support for Unicode usernames
|
|
|
|
--------------------------------------
|
|
|
|
|
|
|
|
The :class:`~django.contrib.auth.models.User` model in ``django.contrib.auth``
|
|
|
|
originally only accepted ASCII letters in usernames. Although it wasn't a
|
|
|
|
deliberate choice, Unicode characters have always been accepted when using
|
|
|
|
Python 3.
|
|
|
|
|
|
|
|
The username validator now explicitly accepts Unicode letters by
|
|
|
|
default on Python 3 only. This default behavior can be overridden by changing
|
|
|
|
the :attr:`~django.contrib.auth.models.User.username_validator` attribute of
|
|
|
|
the ``User`` model, or to any proxy of that model, using either
|
|
|
|
:class:`~django.contrib.auth.validators.ASCIIUsernameValidator` or
|
|
|
|
:class:`~django.contrib.auth.validators.UnicodeUsernameValidator`. Custom user
|
|
|
|
models may also use those validators.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
Minor features
|
2016-01-03 18:56:22 +08:00
|
|
|
--------------
|
2015-09-20 08:34:58 +08:00
|
|
|
|
|
|
|
:mod:`django.contrib.admin`
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-10-13 14:52:49 +08:00
|
|
|
* For sites running on a subpath, the default :attr:`URL for the "View site"
|
|
|
|
link <django.contrib.admin.AdminSite.site_url>` at the top of each admin page
|
|
|
|
will now point to ``request.META['SCRIPT_NAME']`` if set, instead of ``/``.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-09-07 17:51:03 +08:00
|
|
|
* The success message that appears after adding or editing an object now
|
|
|
|
contains a link to the object's change form.
|
|
|
|
|
2015-11-23 18:46:19 +08:00
|
|
|
* All inline JavaScript is removed so you can enable the
|
|
|
|
``Content-Security-Policy`` HTTP header if you wish.
|
|
|
|
|
2015-11-07 23:46:50 +08:00
|
|
|
* The new :attr:`InlineModelAdmin.classes
|
|
|
|
<django.contrib.admin.InlineModelAdmin.classes>` attribute allows specifying
|
|
|
|
classes on inline fieldsets. Inlines with a ``collapse`` class will be
|
|
|
|
initially collapsed and their header will have a small "show" link.
|
|
|
|
|
2015-11-07 19:31:06 +08:00
|
|
|
* If a user doesn't have the add permission, the ``object-tools`` block on a
|
|
|
|
model's changelist will now be rendered (without the add button, of course).
|
|
|
|
This makes it easier to add custom tools in this case.
|
|
|
|
|
2015-12-27 02:51:22 +08:00
|
|
|
* The :class:`~django.contrib.admin.models.LogEntry` model now stores change
|
|
|
|
messages in a JSON structure so that the message can be dynamically translated
|
|
|
|
using the current active language. A new ``LogEntry.get_change_message()``
|
|
|
|
method is now the preferred way of retrieving the change message.
|
|
|
|
|
2016-01-28 08:43:04 +08:00
|
|
|
* Selected objects for fields in ``ModelAdmin.raw_id_fields`` now have a link
|
|
|
|
to object's change form.
|
|
|
|
|
2016-01-14 16:26:44 +08:00
|
|
|
* Added "No date" and "Has date" choices for ``DateFieldListFilter`` if the
|
|
|
|
field is nullable.
|
|
|
|
|
2016-05-17 08:42:01 +08:00
|
|
|
* The jQuery library embedded in the admin is upgraded from version 2.1.4 to
|
|
|
|
2.2.3.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
:mod:`django.contrib.auth`
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-12-26 20:14:07 +08:00
|
|
|
* Added support for the :ref:`Argon2 password hash <argon2_usage>`. It's
|
|
|
|
recommended over PBKDF2, however, it's not the default as it requires a
|
|
|
|
third-party library.
|
|
|
|
|
2015-09-20 08:42:44 +08:00
|
|
|
* The default iteration count for the PBKDF2 password hasher has been increased
|
|
|
|
by 25%. This backwards compatible change will not affect users who have
|
|
|
|
subclassed ``django.contrib.auth.hashers.PBKDF2PasswordHasher`` to change the
|
|
|
|
default value.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-10-02 03:52:18 +08:00
|
|
|
* The :func:`~django.contrib.auth.views.logout` view sends "no-cache" headers
|
|
|
|
to prevent an issue where Safari caches redirects and prevents a user from
|
|
|
|
being able to log out.
|
|
|
|
|
2015-07-06 04:54:25 +08:00
|
|
|
* Added the optional ``backend`` argument to :func:`~django.contrib.auth.login`
|
2016-01-08 00:06:19 +08:00
|
|
|
to allow using it without credentials.
|
2015-07-06 04:54:25 +08:00
|
|
|
|
2015-08-26 14:07:06 +08:00
|
|
|
* The new :setting:`LOGOUT_REDIRECT_URL` setting controls the redirect of the
|
|
|
|
:func:`~django.contrib.auth.views.logout` view, if the view doesn't get a
|
|
|
|
``next_page`` argument.
|
|
|
|
|
2015-11-12 07:48:16 +08:00
|
|
|
* The new ``redirect_authenticated_user`` parameter for the
|
|
|
|
:func:`~django.contrib.auth.views.login` view allows redirecting
|
|
|
|
authenticated users visiting the login page.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
:mod:`django.contrib.gis`
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-10-07 04:05:53 +08:00
|
|
|
* :ref:`Distance lookups <distance-lookups>` now accept expressions as the
|
|
|
|
distance value parameter.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-11-10 01:36:12 +08:00
|
|
|
* The new :attr:`GEOSGeometry.unary_union
|
|
|
|
<django.contrib.gis.geos.GEOSGeometry.unary_union>` property computes the
|
|
|
|
union of all the elements of this geometry.
|
|
|
|
|
2015-11-20 18:11:25 +08:00
|
|
|
* Added the :meth:`GEOSGeometry.covers()
|
|
|
|
<django.contrib.gis.geos.GEOSGeometry.covers>` binary predicate.
|
|
|
|
|
2015-11-24 22:48:00 +08:00
|
|
|
* Added the :meth:`GDALBand.statistics()
|
|
|
|
<django.contrib.gis.gdal.GDALBand.statistics>` method and
|
|
|
|
:attr:`~django.contrib.gis.gdal.GDALBand.mean`
|
|
|
|
and :attr:`~django.contrib.gis.gdal.GDALBand.std` attributes.
|
|
|
|
|
2015-12-01 11:08:41 +08:00
|
|
|
* Added support for the :class:`~django.contrib.gis.db.models.MakeLine`
|
2015-12-04 12:52:16 +08:00
|
|
|
aggregate and :class:`~django.contrib.gis.db.models.functions.GeoHash`
|
|
|
|
function on SpatiaLite.
|
2015-12-01 11:08:41 +08:00
|
|
|
|
2015-12-03 13:42:22 +08:00
|
|
|
* Added support for the
|
|
|
|
:class:`~django.contrib.gis.db.models.functions.Difference`,
|
|
|
|
:class:`~django.contrib.gis.db.models.functions.Intersection`, and
|
|
|
|
:class:`~django.contrib.gis.db.models.functions.SymDifference`
|
|
|
|
functions on MySQL.
|
|
|
|
|
2015-11-24 17:21:32 +08:00
|
|
|
* Added support for instantiating empty GEOS geometries.
|
|
|
|
|
2015-12-05 22:05:52 +08:00
|
|
|
* The new :attr:`~django.contrib.gis.geos.WKTWriter.trim` and
|
|
|
|
:attr:`~django.contrib.gis.geos.WKTWriter.precision` properties
|
|
|
|
of :class:`~django.contrib.gis.geos.WKTWriter` allow controlling
|
|
|
|
output of the fractional part of the coordinates in WKT.
|
|
|
|
|
2015-12-18 18:26:22 +08:00
|
|
|
* Added the :attr:`LineString.closed
|
|
|
|
<django.contrib.gis.geos.LineString.closed>` and
|
|
|
|
:attr:`MultiLineString.closed
|
|
|
|
<django.contrib.gis.geos.MultiLineString.closed>` properties.
|
|
|
|
|
2016-02-24 02:57:53 +08:00
|
|
|
* The :doc:`GeoJSON serializer </ref/contrib/gis/serializers>` now outputs the
|
|
|
|
primary key of objects in the ``properties`` dictionary if specific fields
|
|
|
|
aren't specified.
|
|
|
|
|
2016-03-29 21:42:35 +08:00
|
|
|
* The ability to replicate input data on the :meth:`GDALBand.data()
|
|
|
|
<django.contrib.gis.gdal.GDALBand.data>` method was added. Band data can
|
|
|
|
now be updated with repeated values efficiently.
|
|
|
|
|
2016-04-06 19:50:25 +08:00
|
|
|
* Added database functions
|
|
|
|
:class:`~django.contrib.gis.db.models.functions.IsValid` and
|
|
|
|
:class:`~django.contrib.gis.db.models.functions.MakeValid`, as well as the
|
|
|
|
:lookup:`isvalid` lookup, all for PostGIS. This allows filtering and
|
|
|
|
repairing invalid geometries on the database side.
|
|
|
|
|
2016-04-22 00:03:14 +08:00
|
|
|
* Added raster support for all :doc:`spatial lookups
|
|
|
|
</ref/contrib/gis/geoquerysets>`.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
:mod:`django.contrib.postgres`
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-01-25 20:30:40 +08:00
|
|
|
* For convenience, :class:`~django.contrib.postgres.fields.HStoreField` now
|
|
|
|
casts its keys and values to strings.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
|
|
|
:mod:`django.contrib.sessions`
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-03-23 19:52:17 +08:00
|
|
|
* The :djadmin:`clearsessions` management command now removes file-based
|
|
|
|
sessions.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
|
|
|
:mod:`django.contrib.sites`
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-11-07 06:55:44 +08:00
|
|
|
* The :class:`~django.contrib.sites.models.Site` model now supports
|
|
|
|
:ref:`natural keys <topics-serialization-natural-keys>`.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
|
|
|
:mod:`django.contrib.staticfiles`
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-11-07 19:24:38 +08:00
|
|
|
* The :ttag:`static` template tag now uses ``django.contrib.staticfiles``
|
|
|
|
if it's in ``INSTALLED_APPS``. This is especially useful for third-party apps
|
|
|
|
which can now always use ``{% load static %}`` (instead of
|
|
|
|
``{% load staticfiles %}`` or ``{% load static from staticfiles %}``) and
|
|
|
|
not worry about whether or not the ``staticfiles`` app is installed.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
|
|
|
Cache
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-10-08 14:05:01 +08:00
|
|
|
* The file-based cache backend now uses the highest pickling protocol.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
|
|
|
CSRF
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-11-07 21:18:06 +08:00
|
|
|
* The default :setting:`CSRF_FAILURE_VIEW`, ``views.csrf.csrf_failure()`` now
|
|
|
|
accepts an optional ``template_name`` parameter, defaulting to
|
|
|
|
``'403_csrf.html'``, to control the template used to render the page.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
Fixed #20869 -- made CSRF tokens change every request by salt-encrypting them
Note that the cookie is not changed every request, just the token retrieved
by the `get_token()` method (used also by the `{% csrf_token %}` tag).
While at it, made token validation strict: Where, before, any length was
accepted and non-ASCII chars were ignored, we now treat anything other than
`[A-Za-z0-9]{64}` as invalid (except for 32-char tokens, which, for
backwards-compatibility, are accepted and replaced by 64-char ones).
Thanks Trac user patrys for reporting, github user adambrenecki
for initial patch, Tim Graham for help, and Curtis Maloney,
Collin Anderson, Florian Apolloner, Markus Holtermann & Jon Dufresne
for reviews.
2015-11-08 00:35:45 +08:00
|
|
|
* To protect against `BREACH`_ attacks, the CSRF protection mechanism now
|
|
|
|
changes the form token value on every request (while keeping an invariant
|
|
|
|
secret which can be used to validate the different tokens).
|
|
|
|
|
|
|
|
.. _BREACH: http://breachattack.com/
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
Database backends
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-01-20 09:43:41 +08:00
|
|
|
* Temporal data subtraction was unified on all backends.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-08-21 13:38:58 +08:00
|
|
|
* If the database supports it, backends can set
|
|
|
|
``DatabaseFeatures.can_return_ids_from_bulk_insert=True`` and implement
|
|
|
|
``DatabaseOperations.fetch_returned_insert_ids()`` to set primary keys
|
|
|
|
on objects created using ``QuerySet.bulk_create()``.
|
|
|
|
|
2016-02-16 04:42:24 +08:00
|
|
|
* Added keyword arguments to the ``as_sql()`` methods of various expressions
|
|
|
|
(``Func``, ``When``, ``Case``, and ``OrderBy``) to allow database backends to
|
|
|
|
customize them without mutating ``self``, which isn't safe when using
|
|
|
|
different database backends. See the ``arg_joiner`` and ``**extra_context``
|
|
|
|
parameters of :meth:`Func.as_sql() <django.db.models.Func.as_sql>` for an
|
|
|
|
example.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
File Storage
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-02-09 23:00:14 +08:00
|
|
|
* Storage backends now present a timezone-aware API with new methods
|
|
|
|
:meth:`~django.core.files.storage.Storage.get_accessed_time`,
|
|
|
|
:meth:`~django.core.files.storage.Storage.get_created_time`, and
|
|
|
|
:meth:`~django.core.files.storage.Storage.get_modified_time`. They return a
|
|
|
|
timezone-aware ``datetime`` if :setting:`USE_TZ` is ``True`` and a naive
|
|
|
|
``datetime`` in the local timezone otherwise.
|
|
|
|
|
2016-03-21 09:51:17 +08:00
|
|
|
* The new :meth:`Storage.generate_filename()
|
|
|
|
<django.core.files.storage.Storage.generate_filename>` method makes it easier
|
|
|
|
to implement custom storages that don't use the ``os.path`` calls previously
|
|
|
|
in :class:`~django.db.models.FileField`.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
|
|
|
Forms
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-11-07 19:24:38 +08:00
|
|
|
* Form and widget ``Media`` is now served using
|
|
|
|
:mod:`django.contrib.staticfiles` if installed.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-04-19 08:57:05 +08:00
|
|
|
* The ``<input>`` tag rendered by :class:`~django.forms.CharField` now includes
|
|
|
|
a ``minlength`` attribute if the field has a ``min_length``.
|
|
|
|
|
2016-03-29 02:02:04 +08:00
|
|
|
* Required form fields now have the ``required`` HTML attribute. Set the new
|
|
|
|
:attr:`Form.use_required_attribute <django.forms.Form.use_required_attribute>`
|
|
|
|
attribute to ``False`` to disable it. The ``required`` attribute isn't
|
|
|
|
included on forms of formsets because the browser validation may not be
|
|
|
|
correct when adding and deleting formsets.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
Generic Views
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-01-09 19:40:08 +08:00
|
|
|
* The :class:`~django.views.generic.base.View` class can now be imported from
|
|
|
|
``django.views``.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
|
|
|
Internationalization
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-12-15 01:36:09 +08:00
|
|
|
* The :func:`~django.conf.urls.i18n.i18n_patterns` helper function can now be
|
|
|
|
used in a root URLConf specified using :attr:`request.urlconf
|
|
|
|
<django.http.HttpRequest.urlconf>`.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-02-29 16:24:19 +08:00
|
|
|
* By setting the new ``prefix_default_language`` parameter for
|
|
|
|
:func:`~django.conf.urls.i18n.i18n_patterns` to ``False``, you can allow
|
|
|
|
accessing the default language without a URL prefix.
|
|
|
|
|
2016-03-29 01:23:04 +08:00
|
|
|
* :func:`~django.views.i18n.set_language` now returns a 204 status code (No
|
|
|
|
Content) for AJAX requests when there is no ``next`` parameter in ``POST`` or
|
|
|
|
``GET``.
|
|
|
|
|
2016-03-08 04:52:08 +08:00
|
|
|
* The :class:`~django.views.i18n.JavaScriptCatalog` and
|
|
|
|
:class:`~django.views.i18n.JSONCatalog` class-based views supersede the
|
|
|
|
deprecated ``javascript_catalog()`` and ``json_catalog()`` function-based
|
|
|
|
views. The new views are almost equivalent to the old ones except that by
|
|
|
|
default the new views collect all JavaScript strings in the ``djangojs``
|
|
|
|
translation domain from all installed apps rather than only the JavaScript
|
|
|
|
strings from :setting:`LOCALE_PATHS`.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
Management Commands
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-02-14 01:14:36 +08:00
|
|
|
* :func:`~django.core.management.call_command` now returns the value returned
|
|
|
|
from the ``command.handle()`` method.
|
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
* The new :option:`check --fail-level` option allows specifying the message
|
|
|
|
level that will cause the command to exit with a non-zero status.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
* The new :option:`makemigrations --check` option makes the command exit
|
|
|
|
with a non-zero status when model changes without migrations are detected.
|
2015-10-21 08:39:48 +08:00
|
|
|
|
2015-11-07 21:43:06 +08:00
|
|
|
* :djadmin:`makemigrations` now displays the path to the migration files that
|
|
|
|
it generates.
|
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
* The :option:`shell --interface` option now accepts ``python`` to force use of
|
|
|
|
the "plain" Python interpreter.
|
2015-12-14 03:33:39 +08:00
|
|
|
|
2016-01-12 09:59:34 +08:00
|
|
|
* The new :option:`shell --command` option lets you run a command as Django and
|
|
|
|
exit, instead of opening the interactive shell.
|
2015-11-07 19:07:28 +08:00
|
|
|
|
2016-01-27 19:15:38 +08:00
|
|
|
* Added a warning to :djadmin:`dumpdata` if a proxy model is specified (which
|
|
|
|
results in no output) without its concrete parent.
|
|
|
|
|
2016-02-12 18:02:36 +08:00
|
|
|
* The new :attr:`BaseCommand.requires_migrations_checks
|
|
|
|
<django.core.management.BaseCommand.requires_migrations_checks>` attribute
|
|
|
|
may be set to ``True`` if you want your command to print a warning, like
|
|
|
|
:djadmin:`runserver` does, if the set of migrations on disk don't match the
|
|
|
|
migrations in the database.
|
|
|
|
|
2016-03-03 09:12:56 +08:00
|
|
|
* To assist with testing, :func:`~django.core.management.call_command` now
|
|
|
|
accepts a command object as the first argument.
|
|
|
|
|
2016-02-28 01:13:01 +08:00
|
|
|
* The :djadmin:`shell` command supports tab completion on systems using
|
|
|
|
``libedit``, e.g. Mac OSX.
|
|
|
|
|
2015-11-02 07:53:43 +08:00
|
|
|
* The :djadmin:`inspectdb` command lets you choose what tables should be
|
|
|
|
inspected by specifying their names as arguments.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
Migrations
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-11-17 05:41:46 +08:00
|
|
|
* Added support for serialization of ``enum.Enum`` objects.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-01-09 16:12:46 +08:00
|
|
|
* Added the ``elidable`` argument to the
|
|
|
|
:class:`~django.db.migrations.operations.RunSQL` and
|
|
|
|
:class:`~django.db.migrations.operations.RunPython` operations to allow them
|
|
|
|
to be removed when squashing migrations.
|
|
|
|
|
2016-01-31 04:46:28 +08:00
|
|
|
* Added support for :ref:`non-atomic migrations <non-atomic-migrations>` by
|
|
|
|
setting the ``atomic`` attribute on a ``Migration``.
|
|
|
|
|
2016-04-02 20:46:59 +08:00
|
|
|
* The ``migrate`` and ``makemigrations`` commands now check for a consistent
|
|
|
|
migration history. If they find some unapplied dependencies of an applied
|
|
|
|
migration, ``InconsistentMigrationHistory`` is raised.
|
|
|
|
|
2016-05-13 23:58:54 +08:00
|
|
|
* The :func:`~django.db.models.signals.pre_migrate` and
|
|
|
|
:func:`~django.db.models.signals.post_migrate` signals now dispatch their
|
|
|
|
migration ``plan`` and ``apps``.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
Models
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-10-02 02:57:58 +08:00
|
|
|
* Reverse foreign keys from proxy models are now propagated to their
|
|
|
|
concrete class. The reverse relation attached by a
|
|
|
|
:class:`~django.db.models.ForeignKey` pointing to a proxy model is now
|
|
|
|
accessible as a descriptor on the proxied model class and may be referenced in
|
|
|
|
queryset filtering.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-11-13 15:56:10 +08:00
|
|
|
* The new :meth:`Field.rel_db_type() <django.db.models.Field.rel_db_type>`
|
|
|
|
method returns the database column data type for fields such as ``ForeignKey``
|
|
|
|
and ``OneToOneField`` that point to another field.
|
|
|
|
|
2015-10-31 18:01:08 +08:00
|
|
|
* The :attr:`~django.db.models.Func.arity` class attribute is added to
|
|
|
|
:class:`~django.db.models.Func`. This attribute can be used to set the number
|
|
|
|
of arguments the function accepts.
|
|
|
|
|
2015-07-02 16:43:15 +08:00
|
|
|
* Added :class:`~django.db.models.BigAutoField` which acts much like an
|
|
|
|
:class:`~django.db.models.AutoField` except that it is guaranteed
|
|
|
|
to fit numbers from ``1`` to ``9223372036854775807``.
|
|
|
|
|
2015-10-30 14:24:46 +08:00
|
|
|
* :meth:`QuerySet.in_bulk() <django.db.models.query.QuerySet.in_bulk>`
|
|
|
|
may be called without any arguments to return all objects in the queryset.
|
|
|
|
|
2015-09-30 01:52:26 +08:00
|
|
|
* :attr:`~django.db.models.ForeignKey.related_query_name` now supports
|
|
|
|
app label and class interpolation using the ``'%(app_label)s'`` and
|
|
|
|
``'%(class)s'`` strings.
|
|
|
|
|
2015-08-03 20:03:41 +08:00
|
|
|
* Allowed overriding model fields inherited from abstract base classes.
|
|
|
|
|
2015-08-15 20:41:57 +08:00
|
|
|
* The :func:`~django.db.models.prefetch_related_objects` function is now a
|
|
|
|
public API.
|
|
|
|
|
2015-08-21 13:38:58 +08:00
|
|
|
* :meth:`QuerySet.bulk_create() <django.db.models.query.QuerySet.bulk_create>`
|
|
|
|
sets the primary key on objects when using PostgreSQL.
|
|
|
|
|
2015-06-05 22:20:37 +08:00
|
|
|
* Added the :class:`~django.db.models.functions.Cast` database function.
|
|
|
|
|
2016-03-28 03:20:54 +08:00
|
|
|
* A proxy model may now inherit multiple proxy models that share a common
|
|
|
|
non-abstract parent class.
|
|
|
|
|
2016-03-05 20:05:47 +08:00
|
|
|
* Added :class:`~django.db.models.functions.datetime.Extract` functions
|
|
|
|
to extract datetime components as integers, such as year and hour.
|
|
|
|
|
|
|
|
* Added :class:`~django.db.models.functions.datetime.Trunc` functions to
|
|
|
|
truncate a date or datetime to a significant component. They enable queries
|
|
|
|
like sales-per-day or sales-per-hour.
|
|
|
|
|
2016-04-20 04:34:08 +08:00
|
|
|
* ``Model.__init__()`` now sets values of virtual fields from its keyword
|
|
|
|
arguments.
|
|
|
|
|
2016-04-17 19:55:55 +08:00
|
|
|
* The new :attr:`Meta.base_manager_name
|
|
|
|
<django.db.models.Options.base_manager_name>` and
|
|
|
|
:attr:`Meta.default_manager_name
|
|
|
|
<django.db.models.Options.default_manager_name>` options allow controlling
|
|
|
|
the :attr:`~django.db.models.Model._base_manager` and
|
|
|
|
:attr:`~django.db.models.Model._default_manager`, respectively.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
Requests and Responses
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-10-02 22:44:35 +08:00
|
|
|
* Added ``request.user`` to the debug view.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-10-21 05:23:58 +08:00
|
|
|
* Added :class:`~django.http.HttpResponse` methods
|
|
|
|
:meth:`~django.http.HttpResponse.readable()` and
|
|
|
|
:meth:`~django.http.HttpResponse.seekable()` to make an instance a
|
|
|
|
stream-like object and allow wrapping it with :py:class:`io.TextIOWrapper`.
|
|
|
|
|
2015-08-07 13:51:39 +08:00
|
|
|
* Added the :attr:`HttpResponse.content_type
|
|
|
|
<django.http.HttpRequest.content_type>` and
|
|
|
|
:attr:`~django.http.HttpRequest.content_params` attributes which are
|
|
|
|
parsed from the ``CONTENT_TYPE`` header.
|
|
|
|
|
2016-03-12 10:36:08 +08:00
|
|
|
* The parser for ``request.COOKIES`` is simplified to better match the behavior
|
|
|
|
of browsers. ``request.COOKIES`` may now contain cookies that are invalid
|
|
|
|
according to :rfc:`6265` but are possible to set via ``document.cookie``.
|
|
|
|
|
2015-09-27 02:15:26 +08:00
|
|
|
Serialization
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~~~~
|
2015-09-27 02:15:26 +08:00
|
|
|
|
|
|
|
* The ``django.core.serializers.json.DjangoJSONEncoder`` now knows how to
|
|
|
|
serialize lazy strings, typically used for translatable content.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
Templates
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-11-08 17:06:07 +08:00
|
|
|
* Added the ``autoescape`` option to the
|
|
|
|
:class:`~django.template.backends.django.DjangoTemplates` backend and the
|
|
|
|
:class:`~django.template.Engine` class.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-04-09 23:25:00 +08:00
|
|
|
* Added the ``is`` and ``is not`` comparison operators to the :ttag:`if` tag.
|
2016-01-22 11:50:06 +08:00
|
|
|
|
2015-11-05 18:59:56 +08:00
|
|
|
* Allowed :tfilter:`dictsort` to order a list of lists by an element at a
|
|
|
|
specified index.
|
|
|
|
|
2016-04-09 20:09:08 +08:00
|
|
|
* The :func:`~django.template.context_processors.debug` context processor
|
|
|
|
contains queries for all database aliases instead of only the default alias.
|
|
|
|
|
2016-03-24 16:39:37 +08:00
|
|
|
* Added relative path support for string arguments of the :ttag:`extends` and
|
|
|
|
:ttag:`include` template tags.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
Tests
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-02-13 08:41:31 +08:00
|
|
|
* To better catch bugs, :class:`~django.test.TestCase` now checks deferrable
|
|
|
|
database constraints at the end of each test.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-11-07 21:57:56 +08:00
|
|
|
* Tests and test cases can be :ref:`marked with tags <topics-tagging-tests>`
|
|
|
|
and run selectively with the new :option:`test --tag` and :option:`test
|
|
|
|
--exclude-tag` options.
|
|
|
|
|
2016-03-22 20:23:22 +08:00
|
|
|
* Added the :setting:`DATABASES['TEST']['MIGRATE'] <TEST_MIGRATE>` option to
|
|
|
|
allow disabling of migrations during test database creation.
|
|
|
|
|
2016-04-02 22:11:47 +08:00
|
|
|
* You can now login and use sessions with the test client even if
|
|
|
|
:mod:`django.contrib.sessions` is not in :setting:`INSTALLED_APPS`.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
URLs
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-10-24 03:02:34 +08:00
|
|
|
* An addition in :func:`django.setup()` allows URL resolving that happens
|
|
|
|
outside of the request/response cycle (e.g. in management commands and
|
|
|
|
standalone scripts) to take :setting:`FORCE_SCRIPT_NAME` into account when it
|
|
|
|
is set.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
|
|
|
Validators
|
2016-01-03 18:56:22 +08:00
|
|
|
~~~~~~~~~~
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-11-07 18:08:16 +08:00
|
|
|
* :class:`~django.core.validators.URLValidator` now limits the length of
|
|
|
|
domain name labels to 63 characters and the total length of domain
|
|
|
|
names to 253 characters per :rfc:`1034`.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-02-16 06:10:00 +08:00
|
|
|
* :func:`~django.core.validators.int_list_validator` now accepts an optional
|
|
|
|
``allow_negative`` boolean parameter, defaulting to ``False``, to allow
|
|
|
|
negative integers.
|
|
|
|
|
2016-06-02 23:41:49 +08:00
|
|
|
.. _backwards-incompatible-1.10:
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
Backwards incompatible changes in 1.10
|
|
|
|
======================================
|
|
|
|
|
|
|
|
.. warning::
|
|
|
|
|
|
|
|
In addition to the changes outlined in this section, be sure to review the
|
|
|
|
:ref:`removed-features-1.10` for the features that have reached the end of
|
|
|
|
their deprecation cycle and therefore been removed. If you haven't updated
|
|
|
|
your code within the deprecation timeline for a given feature, its removal
|
|
|
|
may appear as a backwards incompatible change.
|
|
|
|
|
|
|
|
Database backend API
|
2016-01-03 18:56:22 +08:00
|
|
|
--------------------
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-01-26 06:50:46 +08:00
|
|
|
* GIS's ``AreaField`` uses an unspecified underlying numeric type that could in
|
|
|
|
practice be any numeric Python type. ``decimal.Decimal`` values retrieved
|
|
|
|
from the database are now converted to ``float`` to make it easier to combine
|
|
|
|
them with values used by the GIS libraries.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-01-20 09:43:41 +08:00
|
|
|
* In order to enable temporal subtraction you must set the
|
|
|
|
``supports_temporal_subtraction`` database feature flag to ``True`` and
|
|
|
|
implement the ``DatabaseOperations.subtract_temporals()`` method. This
|
|
|
|
method should return the SQL and parameters required to compute the
|
|
|
|
difference in microseconds between the ``lhs`` and ``rhs`` arguments in the
|
|
|
|
datatype used to store :class:`~django.db.models.DurationField`.
|
|
|
|
|
2015-10-10 09:03:04 +08:00
|
|
|
``select_related()`` prohibits non-relational fields for nested relations
|
2016-02-07 02:40:19 +08:00
|
|
|
-------------------------------------------------------------------------
|
2015-10-10 09:03:04 +08:00
|
|
|
|
|
|
|
Django 1.8 added validation for non-relational fields in ``select_related()``::
|
|
|
|
|
|
|
|
>>> Book.objects.select_related('title')
|
|
|
|
Traceback (most recent call last):
|
|
|
|
...
|
|
|
|
FieldError: Non-relational field given in select_related: 'title'
|
|
|
|
|
|
|
|
But it didn't prohibit nested non-relation fields as it does now::
|
|
|
|
|
|
|
|
>>> Book.objects.select_related('author__name')
|
|
|
|
Traceback (most recent call last):
|
|
|
|
...
|
|
|
|
FieldError: Non-relational field given in select_related: 'name'
|
|
|
|
|
2015-10-08 03:29:20 +08:00
|
|
|
``_meta.get_fields()`` returns consistent reverse fields for proxy models
|
2016-02-07 02:40:19 +08:00
|
|
|
-------------------------------------------------------------------------
|
2015-10-08 03:29:20 +08:00
|
|
|
|
|
|
|
Before Django 1.10, the :meth:`~django.db.models.options.Options.get_fields`
|
|
|
|
method returned different reverse fields when called on a proxy model compared
|
|
|
|
to its proxied concrete class. This inconsistency was fixed by returning the
|
|
|
|
full set of fields pointing to a concrete class or one of its proxies in both
|
|
|
|
cases.
|
|
|
|
|
2015-12-30 03:52:48 +08:00
|
|
|
:attr:`AbstractUser.username <django.contrib.auth.models.User.username>` ``max_length`` increased to 150
|
2016-02-07 02:40:19 +08:00
|
|
|
--------------------------------------------------------------------------------------------------------
|
2015-10-29 03:59:17 +08:00
|
|
|
|
|
|
|
A migration for :attr:`django.contrib.auth.models.User.username` is included.
|
|
|
|
If you have a custom user model inheriting from ``AbstractUser``, you'll need
|
|
|
|
to generate and apply a database migration for your user model.
|
|
|
|
|
2015-12-30 03:52:48 +08:00
|
|
|
We considered an increase to 254 characters to more easily allow the use of
|
|
|
|
email addresses (which are limited to 254 characters) as usernames but rejected
|
|
|
|
it due to a MySQL limitation. When using the ``utf8mb4`` encoding (recommended
|
|
|
|
for proper Unicode support), MySQL can only create unique indexes with 191
|
|
|
|
characters by default. Therefore, if you need a longer length, please use a
|
|
|
|
custom user model.
|
|
|
|
|
2015-10-29 03:59:17 +08:00
|
|
|
If you want to preserve the 30 character limit for usernames, use a custom form
|
|
|
|
when creating a user or changing usernames::
|
|
|
|
|
|
|
|
from django.contrib.auth.forms import UserCreationForm
|
|
|
|
|
|
|
|
class MyUserCreationForm(UserCreationForm):
|
|
|
|
username = forms.CharField(
|
|
|
|
max_length=30,
|
|
|
|
help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.',
|
|
|
|
)
|
|
|
|
|
|
|
|
If you wish to keep this restriction in the admin, set ``UserAdmin.add_form``
|
|
|
|
to use this form::
|
|
|
|
|
2015-12-09 03:40:55 +08:00
|
|
|
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
2015-10-29 03:59:17 +08:00
|
|
|
from django.contrib.auth.models import User
|
|
|
|
|
2015-12-09 03:40:55 +08:00
|
|
|
class UserAdmin(BaseUserAdmin):
|
2015-10-29 03:59:17 +08:00
|
|
|
add_form = MyUserCreationForm
|
|
|
|
|
|
|
|
admin.site.unregister(User)
|
2015-12-09 03:40:55 +08:00
|
|
|
admin.site.register(User, UserAdmin)
|
2015-10-29 03:59:17 +08:00
|
|
|
|
2015-12-24 00:47:40 +08:00
|
|
|
Dropped support for PostgreSQL 9.1
|
2016-02-07 02:40:19 +08:00
|
|
|
----------------------------------
|
2015-12-24 00:47:40 +08:00
|
|
|
|
|
|
|
Upstream support for PostgreSQL 9.1 ends in September 2016. As a consequence,
|
|
|
|
Django 1.10 sets PostgreSQL 9.2 as the minimum version it officially supports.
|
|
|
|
|
2015-11-07 00:19:41 +08:00
|
|
|
``runserver`` output goes through logging
|
2016-02-07 02:40:19 +08:00
|
|
|
-----------------------------------------
|
2015-11-07 00:19:41 +08:00
|
|
|
|
|
|
|
Request and response handling of the ``runserver`` command is sent to the
|
|
|
|
:ref:`django-server-logger` logger instead of to ``sys.stderr``. If you
|
|
|
|
disable Django's logging configuration or override it with your own, you'll
|
|
|
|
need to add the appropriate logging configuration if you want to see that
|
|
|
|
output::
|
|
|
|
|
|
|
|
'formatters': {
|
|
|
|
'django.server': {
|
|
|
|
'()': 'django.utils.log.ServerFormatter',
|
|
|
|
'format': '[%(server_time)s] %(message)s',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'handlers': {
|
|
|
|
'django.server': {
|
|
|
|
'level': 'INFO',
|
|
|
|
'class': 'logging.StreamHandler',
|
|
|
|
'formatter': 'django.server',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers': {
|
|
|
|
'django.server': {
|
|
|
|
'handlers': ['django.server'],
|
|
|
|
'level': 'INFO',
|
|
|
|
'propagate': False,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-07 02:40:19 +08:00
|
|
|
``auth.CustomUser`` and ``auth.ExtensionUser`` test models were removed
|
|
|
|
-----------------------------------------------------------------------
|
2016-02-05 00:47:51 +08:00
|
|
|
|
|
|
|
Since the introduction of migrations for the contrib apps in Django 1.8, the
|
|
|
|
tables of these custom user test models were not created anymore making them
|
|
|
|
unusable in a testing context.
|
|
|
|
|
2016-01-26 20:03:54 +08:00
|
|
|
Apps registry is no longer auto-populated when unpickling models outside of Django
|
|
|
|
----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
The apps registry is no longer auto-populated when unpickling models. This was
|
|
|
|
added in Django 1.7.2 as an attempt to allow unpickling models outside of
|
|
|
|
Django, such as in an RQ worker, without calling ``django.setup()``, but it
|
|
|
|
creates the possibility of a deadlock. To adapt your code in the case of RQ,
|
|
|
|
you can `provide your own worker script <http://python-rq.org/docs/workers/>`_
|
|
|
|
that calls ``django.setup()``.
|
|
|
|
|
2016-02-11 09:46:57 +08:00
|
|
|
Removed null assignment check for non-null foreign key fields
|
|
|
|
-------------------------------------------------------------
|
|
|
|
|
|
|
|
In older versions, assigning ``None`` to a non-nullable ``ForeignKey`` or
|
|
|
|
``OneToOneField`` raised ``ValueError('Cannot assign None: "model.field" does
|
|
|
|
not allow null values.')``. For consistency with other model fields which don't
|
|
|
|
have a similar check, this check is removed.
|
|
|
|
|
2016-02-09 03:22:38 +08:00
|
|
|
Removed weak password hashers from the default ``PASSWORD_HASHERS`` setting
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Django 0.90 stored passwords as unsalted MD5. Django 0.91 added support for
|
|
|
|
salted SHA1 with automatic upgrade of passwords when a user logs in. Django 1.4
|
|
|
|
added PBKDF2 as the default password hasher.
|
|
|
|
|
|
|
|
If you have an old Django project with MD5 or SHA1 (even salted) encoded
|
|
|
|
passwords, be aware that these can be cracked fairly easily with today's
|
|
|
|
hardware. To make Django users acknowledge continued use of weak hashers, the
|
|
|
|
following hashers are removed from the default :setting:`PASSWORD_HASHERS`
|
|
|
|
setting::
|
|
|
|
|
|
|
|
'django.contrib.auth.hashers.SHA1PasswordHasher'
|
|
|
|
'django.contrib.auth.hashers.MD5PasswordHasher'
|
|
|
|
'django.contrib.auth.hashers.UnsaltedSHA1PasswordHasher'
|
|
|
|
'django.contrib.auth.hashers.UnsaltedMD5PasswordHasher'
|
|
|
|
'django.contrib.auth.hashers.CryptPasswordHasher'
|
|
|
|
|
|
|
|
Consider using a :ref:`wrapped password hasher <wrapping-password-hashers>` to
|
|
|
|
strengthen the hashes in your database. If that's not feasible, add the
|
|
|
|
:setting:`PASSWORD_HASHERS` setting to your project and add back any hashers
|
|
|
|
that you need.
|
|
|
|
|
|
|
|
You can check if your database has any of the removed hashers like this::
|
|
|
|
|
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
|
|
# Unsalted MD5/SHA1:
|
|
|
|
User.objects.filter(password__startswith='md5$$')
|
|
|
|
User.objects.filter(password__startswith='sha1$$')
|
|
|
|
# Salted MD5/SHA1:
|
|
|
|
User.objects.filter(password__startswith='md5$').exclude(password__startswith='md5$$')
|
|
|
|
User.objects.filter(password__startswith='sha1$').exclude(password__startswith='sha1$$')
|
|
|
|
# Crypt hasher:
|
|
|
|
User.objects.filter(password__startswith='crypt$$')
|
|
|
|
|
|
|
|
from django.db.models import CharField
|
|
|
|
from django.db.models.functions import Length
|
|
|
|
CharField.register_lookup(Length)
|
|
|
|
# Unsalted MD5 passwords might not have an 'md5$$' prefix:
|
|
|
|
User.objects.filter(password__length=32)
|
|
|
|
|
2016-04-24 01:13:31 +08:00
|
|
|
``Field.get_prep_lookup()`` and ``Field.get_db_prep_lookup()`` methods are removed
|
|
|
|
----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
If you have a custom field that implements either of these methods, register a
|
|
|
|
custom lookup for it. For example::
|
|
|
|
|
|
|
|
from django.db.models import Field
|
|
|
|
from django.db.models.lookups import Exact
|
|
|
|
|
|
|
|
class MyField(Field):
|
|
|
|
...
|
|
|
|
|
|
|
|
class MyFieldExact(Exact):
|
|
|
|
def get_prep_lookup(self):
|
|
|
|
# do_custom_stuff_for_myfield
|
|
|
|
....
|
|
|
|
|
|
|
|
MyField.register_lookup(MyFieldExact)
|
|
|
|
|
2016-04-17 02:05:47 +08:00
|
|
|
:mod:`django.contrib.gis`
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
* Support for SpatiaLite < 3.0 and GEOS < 3.3 is dropped.
|
|
|
|
|
|
|
|
* The ``add_postgis_srs()`` backwards compatibility alias for
|
|
|
|
``django.contrib.gis.utils.add_srs_entry()`` is removed.
|
|
|
|
|
|
|
|
* On Oracle/GIS, the :class:`~django.contrib.gis.db.models.functions.Area`
|
|
|
|
aggregate function now returns a ``float`` instead of ``decimal.Decimal``.
|
|
|
|
(It's still wrapped in a measure of square meters.)
|
|
|
|
|
|
|
|
* The default :class:`~django.contrib.gis.geos.GEOSGeometry` representation (WKT
|
|
|
|
output) is trimmed by default. That is, instead of
|
|
|
|
``POINT (23.0000000000000000 5.5000000000000000)``, you'll get
|
|
|
|
``POINT (23 5.5)``.
|
|
|
|
|
2015-01-08 02:41:29 +08:00
|
|
|
Maximum size of a request body and the number of GET/POST parameters is limited
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Two new settings help mitigate denial-of-service attacks via large requests:
|
|
|
|
|
|
|
|
* :setting:`DATA_UPLOAD_MAX_MEMORY_SIZE` limits the size that a request body
|
|
|
|
may be. File uploads don't count towards this limit.
|
|
|
|
* :setting:`DATA_UPLOAD_MAX_NUMBER_FIELDS` limits the number of GET/POST
|
|
|
|
parameters that are parsed.
|
|
|
|
|
|
|
|
Applications that receive unusually large form posts may need to tune these
|
|
|
|
settings.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
Miscellaneous
|
2016-02-07 02:40:19 +08:00
|
|
|
-------------
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-10-10 09:06:00 +08:00
|
|
|
* The ``repr()`` of a ``QuerySet`` is wrapped in ``<QuerySet >`` to
|
2015-10-06 07:07:34 +08:00
|
|
|
disambiguate it from a plain list when debugging.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-11-18 00:51:26 +08:00
|
|
|
* ``utils.version.get_version()`` returns :pep:`440` compliant release
|
|
|
|
candidate versions (e.g. '1.10rc1' instead of '1.10c1').
|
|
|
|
|
Fixed #20869 -- made CSRF tokens change every request by salt-encrypting them
Note that the cookie is not changed every request, just the token retrieved
by the `get_token()` method (used also by the `{% csrf_token %}` tag).
While at it, made token validation strict: Where, before, any length was
accepted and non-ASCII chars were ignored, we now treat anything other than
`[A-Za-z0-9]{64}` as invalid (except for 32-char tokens, which, for
backwards-compatibility, are accepted and replaced by 64-char ones).
Thanks Trac user patrys for reporting, github user adambrenecki
for initial patch, Tim Graham for help, and Curtis Maloney,
Collin Anderson, Florian Apolloner, Markus Holtermann & Jon Dufresne
for reviews.
2015-11-08 00:35:45 +08:00
|
|
|
* CSRF token values are now required to be strings of 64 alphanumerics; values
|
|
|
|
of 32 alphanumerics, as set by older versions of Django by default, are
|
|
|
|
automatically replaced by strings of 64 characters. Other values are
|
|
|
|
considered invalid. This should only affect developers or users who replace
|
|
|
|
these tokens.
|
|
|
|
|
2015-12-12 01:43:02 +08:00
|
|
|
* The ``LOGOUT_URL`` setting is removed as Django hasn't made use of it
|
|
|
|
since pre-1.0. If you use it in your project, you can add it to your
|
2015-12-12 01:54:04 +08:00
|
|
|
project's settings. The default value was ``'/accounts/logout/'``.
|
2015-12-12 01:43:02 +08:00
|
|
|
|
2015-11-12 03:17:32 +08:00
|
|
|
* Objects with a ``close()`` method such as files and generators passed to
|
|
|
|
:class:`~django.http.HttpResponse` are now closed immediately instead of when
|
|
|
|
the WSGI server calls ``close()`` on the response.
|
|
|
|
|
2015-12-09 20:18:44 +08:00
|
|
|
* A redundant ``transaction.atomic()`` call in ``QuerySet.update_or_create()``
|
|
|
|
is removed. This may affect query counts tested by
|
|
|
|
``TransactionTestCase.assertNumQueries()``.
|
|
|
|
|
2015-12-22 03:26:42 +08:00
|
|
|
* Support for ``skip_validation`` in ``BaseCommand.execute(**options)`` is
|
|
|
|
removed. Use ``skip_checks`` (added in Django 1.7) instead.
|
|
|
|
|
2016-01-03 03:11:18 +08:00
|
|
|
* :djadmin:`loaddata` now raises a ``CommandError`` instead of showing a
|
|
|
|
warning when the specified fixture file is not found.
|
|
|
|
|
2015-12-27 02:51:22 +08:00
|
|
|
* Instead of directly accessing the ``LogEntry.change_message`` attribute, it's
|
|
|
|
now better to call the ``LogEntry.get_change_message()`` method which will
|
|
|
|
provide the message in the current language.
|
|
|
|
|
2015-11-08 00:24:07 +08:00
|
|
|
* The default error views now raise ``TemplateDoesNotExist`` if a nonexistent
|
|
|
|
``template_name`` is specified.
|
|
|
|
|
2016-01-25 12:15:42 +08:00
|
|
|
* The unused ``choices`` keyword argument of the ``Select`` and
|
|
|
|
``SelectMultiple`` widgets' ``render()`` method is removed. The ``choices``
|
|
|
|
argument of the ``render_options()`` method is also removed, making
|
|
|
|
``selected_choices`` the first argument.
|
|
|
|
|
2016-02-13 08:41:31 +08:00
|
|
|
* Tests that violate deferrable database constraints will now error when run on
|
|
|
|
a database that supports deferrable constraints.
|
|
|
|
|
2016-03-03 10:01:36 +08:00
|
|
|
* Built-in management commands now use indexing of keys in ``options``, e.g.
|
|
|
|
``options['verbosity']``, instead of ``options.get()`` and no longer perform
|
|
|
|
any type coercion. This could be a problem if you're calling commands using
|
|
|
|
``Command.execute()`` (which bypasses the argument parser that sets a default
|
|
|
|
value) instead of :func:`~django.core.management.call_command`. Instead of
|
|
|
|
calling ``Command.execute()``, pass the command object as the first argument
|
|
|
|
to ``call_command()``.
|
|
|
|
|
2016-02-05 22:46:19 +08:00
|
|
|
* :class:`~django.contrib.auth.backends.ModelBackend` and
|
|
|
|
:class:`~django.contrib.auth.backends.RemoteUserBackend` now reject inactive
|
|
|
|
users. This means that inactive users can't login and will be logged
|
|
|
|
out if they are switched from ``is_active=True`` to ``False``. If you need
|
|
|
|
the previous behavior, use the new
|
|
|
|
:class:`~django.contrib.auth.backends.AllowAllUsersModelBackend` or
|
|
|
|
:class:`~django.contrib.auth.backends.AllowAllUsersRemoteUserBackend`
|
|
|
|
in :setting:`AUTHENTICATION_BACKENDS` instead.
|
|
|
|
|
2016-02-06 03:03:06 +08:00
|
|
|
* In light of the previous change, the test client's
|
|
|
|
:meth:`~django.test.Client.login()` method no longer always rejects inactive
|
|
|
|
users but instead delegates this decision to the authentication backend.
|
|
|
|
|
2016-03-29 01:23:04 +08:00
|
|
|
* :func:`django.views.i18n.set_language` may now return a 204 status code for
|
|
|
|
AJAX requests.
|
|
|
|
|
2016-04-03 18:39:18 +08:00
|
|
|
* The ``base_field`` attribute of
|
|
|
|
:class:`~django.contrib.postgres.fields.RangeField` is now a type of field,
|
|
|
|
not an instance of a field. If you have created a custom subclass of
|
|
|
|
:class:`~django.contrib.postgres.fields.RangeField`, you should change the
|
|
|
|
``base_field`` attribute.
|
|
|
|
|
2016-04-03 21:43:51 +08:00
|
|
|
* Middleware classes are now initialized when the server starts rather than
|
|
|
|
during the first request.
|
|
|
|
|
2016-04-02 19:18:26 +08:00
|
|
|
* If you override ``is_authenticated()`` or ``is_anonymous()`` in a custom user
|
|
|
|
model, you must convert them to attributes or properties as described in
|
|
|
|
:ref:`the deprecation note <user-is-auth-anon-deprecation>`.
|
|
|
|
|
2016-04-03 22:50:01 +08:00
|
|
|
* When using :attr:`ModelAdmin.save_as=True
|
|
|
|
<django.contrib.admin.ModelAdmin.save_as>`, the "Save as new" button now
|
|
|
|
redirects to the change view for the new object instead of to the model's
|
|
|
|
changelist. If you need the previous behavior, set the new
|
|
|
|
:attr:`ModelAdmin.save_as_continue
|
|
|
|
<django.contrib.admin.ModelAdmin.save_as_continue>` attribute to ``False``.
|
|
|
|
|
2016-03-29 02:02:04 +08:00
|
|
|
* Required form fields now have the ``required`` HTML attribute. Set the
|
|
|
|
:attr:`Form.use_required_attribute <django.forms.Form.use_required_attribute>`
|
|
|
|
attribute to ``False`` to disable it. You could also add the ``novalidate``
|
|
|
|
attribute to ``<form>`` if you don't want browser validation.
|
|
|
|
|
2016-04-25 19:56:07 +08:00
|
|
|
* The WSGI handler no longer removes content of responses from ``HEAD``
|
|
|
|
requests or responses with a ``status_code`` of 100-199, 204, or 304. Most
|
|
|
|
Web servers already implement this behavior. Responses retrieved using the
|
|
|
|
Django test client continue to have these "response fixes" applied.
|
|
|
|
|
2016-02-02 17:33:09 +08:00
|
|
|
* ``Model.__init__()`` now receives ``django.db.models.DEFERRED`` as the value
|
|
|
|
of deferred fields.
|
|
|
|
|
|
|
|
* The ``Model._deferred`` attribute is removed as dynamic model classes when
|
|
|
|
using ``QuerySet.defer()`` and ``only()`` is removed.
|
|
|
|
|
2016-03-21 09:51:17 +08:00
|
|
|
* :meth:`Storage.save() <django.core.files.storage.Storage.save>` no longer
|
|
|
|
replaces ``'\'`` with ``'/'``. This behavior is moved to
|
|
|
|
:class:`~django.core.files.storage.FileSystemStorage` since this is a storage
|
|
|
|
specific implementation detail. Any Windows user with a custom storage
|
|
|
|
implementation that relies on this behavior will need to implement it in the
|
|
|
|
custom storage's ``save()`` method.
|
|
|
|
|
|
|
|
* Private :class:`~django.db.models.FileField` methods ``get_directory_name()``
|
|
|
|
and ``get_filename()`` are no longer called (and are now deprecated) which is
|
|
|
|
a backwards incompatible change for users overriding those methods on custom
|
|
|
|
fields. To adapt such code, override ``FileField.generate_filename()`` or
|
|
|
|
:meth:`Storage.generate_filename()
|
|
|
|
<django.core.files.storage.Storage.generate_filename>` instead. It
|
|
|
|
might be possible to use :attr:`~django.db.models.FileField.upload_to` also.
|
|
|
|
|
2016-05-04 00:22:46 +08:00
|
|
|
* The subject of mail sent by ``AdminEmailHandler`` is no longer truncated at
|
|
|
|
989 characters. If you were counting on a limited length, truncate the subject
|
|
|
|
yourself.
|
|
|
|
|
2016-03-05 20:05:47 +08:00
|
|
|
* Private expressions ``django.db.models.expressions.Date`` and ``DateTime``
|
|
|
|
are removed. The new :class:`~django.db.models.functions.datetime.Trunc`
|
|
|
|
expressions provide the same functionality.
|
|
|
|
|
2016-05-27 22:36:16 +08:00
|
|
|
* The ``_base_manager`` and ``_default_manager`` attributes are removed from
|
|
|
|
model instances. They remain accessible on the model class.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
.. _deprecated-features-1.10:
|
|
|
|
|
|
|
|
Features deprecated in 1.10
|
|
|
|
===========================
|
|
|
|
|
2015-10-09 05:17:10 +08:00
|
|
|
Direct assignment to a reverse foreign key or many-to-many relation
|
2016-01-03 18:56:22 +08:00
|
|
|
-------------------------------------------------------------------
|
2015-10-09 05:17:10 +08:00
|
|
|
|
|
|
|
Instead of assigning related objects using direct assignment::
|
|
|
|
|
|
|
|
>>> new_list = [obj1, obj2, obj3]
|
|
|
|
>>> e.related_set = new_list
|
|
|
|
|
|
|
|
Use the :meth:`~django.db.models.fields.related.RelatedManager.set` method
|
|
|
|
added in Django 1.9::
|
|
|
|
|
|
|
|
>>> e.related_set.set([obj1, obj2, obj3])
|
|
|
|
|
|
|
|
This prevents confusion about an assignment resulting in an implicit save.
|
|
|
|
|
2016-02-09 23:00:14 +08:00
|
|
|
Non-timezone-aware :class:`~django.core.files.storage.Storage` API
|
|
|
|
------------------------------------------------------------------
|
|
|
|
|
|
|
|
The old, non-timezone-aware methods ``accessed_time()``, ``created_time()``,
|
|
|
|
and ``modified_time()`` are deprecated in favor of the new ``get_*_time()``
|
|
|
|
methods.
|
|
|
|
|
|
|
|
Third-party storage backends should implement the new methods and mark the old
|
|
|
|
ones as deprecated. Until then, the new ``get_*_time()`` methods on the base
|
|
|
|
:class:`~django.core.files.storage.Storage` class convert ``datetime``\s from
|
|
|
|
the old methods as required and emit a deprecation warning as they do so.
|
|
|
|
|
|
|
|
Third-party storage backends may retain the old methods as long as they
|
|
|
|
wish to support earlier versions of Django.
|
|
|
|
|
2015-11-05 02:56:14 +08:00
|
|
|
:mod:`django.contrib.gis`
|
2016-01-03 18:56:22 +08:00
|
|
|
-------------------------
|
2015-11-05 02:56:14 +08:00
|
|
|
|
|
|
|
* The ``get_srid()`` and ``set_srid()`` methods of
|
|
|
|
:class:`~django.contrib.gis.geos.GEOSGeometry` are deprecated in favor
|
|
|
|
of the :attr:`~django.contrib.gis.geos.GEOSGeometry.srid` property.
|
|
|
|
|
2015-11-05 11:45:42 +08:00
|
|
|
* The ``get_x()``, ``set_x()``, ``get_y()``, ``set_y()``, ``get_z()``, and
|
|
|
|
``set_z()`` methods of :class:`~django.contrib.gis.geos.Point` are deprecated
|
|
|
|
in favor of the ``x``, ``y``, and ``z`` properties.
|
|
|
|
|
2015-11-05 13:37:51 +08:00
|
|
|
* The ``get_coords()`` and ``set_coords()`` methods of
|
|
|
|
:class:`~django.contrib.gis.geos.Point` are deprecated in favor of the
|
|
|
|
``tuple`` property.
|
|
|
|
|
2015-11-26 02:59:57 +08:00
|
|
|
* The ``cascaded_union`` property of
|
|
|
|
:class:`~django.contrib.gis.geos.MultiPolygon` is deprecated in favor of the
|
|
|
|
:attr:`~django.contrib.gis.geos.GEOSGeometry.unary_union` property.
|
|
|
|
|
2016-04-17 02:40:05 +08:00
|
|
|
* The ``django.contrib.gis.utils.precision_wkt()`` function is deprecated in
|
|
|
|
favor of :class:`~django.contrib.gis.geos.WKTWriter`.
|
|
|
|
|
2016-02-08 07:22:48 +08:00
|
|
|
``CommaSeparatedIntegerField`` model field
|
|
|
|
------------------------------------------
|
|
|
|
|
|
|
|
``CommaSeparatedIntegerField`` is deprecated in favor of
|
|
|
|
:class:`~django.db.models.CharField` with the
|
|
|
|
:func:`~django.core.validators.validate_comma_separated_integer_list`
|
|
|
|
validator::
|
|
|
|
|
|
|
|
from django.core.validators import validate_comma_separated_integer_list
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
class MyModel(models.Model):
|
|
|
|
numbers = models.CharField(..., validators=[validate_comma_separated_integer_list])
|
|
|
|
|
|
|
|
If you're using Oracle, ``CharField`` uses a different database field type
|
|
|
|
(``NVARCHAR2``) than ``CommaSeparatedIntegerField`` (``VARCHAR2``). Depending
|
|
|
|
on your database settings, this might imply a different encoding, and thus a
|
|
|
|
different length (in bytes) for the same contents. If your stored values are
|
|
|
|
longer than the 4000 byte limit of ``NVARCHAR2``, you should use ``TextField``
|
|
|
|
(``NCLOB``) instead. In this case, if you have any queries that group by the
|
|
|
|
field (e.g. annotating the model with an aggregation or using ``distinct()``)
|
|
|
|
you'll need to change them (to defer the field).
|
|
|
|
|
2016-02-24 15:10:09 +08:00
|
|
|
Using a model name as a query lookup when ``default_related_name`` is set
|
|
|
|
-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Assume the following models::
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
class Foo(models.Model):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Bar(models.Model):
|
|
|
|
foo = models.ForeignKey(Foo)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
default_related_name = 'bars'
|
|
|
|
|
|
|
|
In older versions, :attr:`~django.db.models.Options.default_related_name`
|
|
|
|
couldn't be used as a query lookup. This is fixed and support for the old
|
|
|
|
lookup name is deprecated. For example, since ``default_related_name`` is set
|
|
|
|
in model ``Bar``, instead of using the model name ``bar`` as the lookup::
|
|
|
|
|
|
|
|
>>> bar = Bar.objects.get(pk=1)
|
2016-04-01 06:27:21 +08:00
|
|
|
>>> Foo.objects.get(bar=bar)
|
2016-02-24 15:10:09 +08:00
|
|
|
|
|
|
|
use the default_related_name ``bars``::
|
|
|
|
|
2016-04-01 06:27:21 +08:00
|
|
|
>>> Foo.objects.get(bars=bar)
|
2016-02-24 15:10:09 +08:00
|
|
|
|
2015-06-05 19:31:44 +08:00
|
|
|
.. _search-lookup-replacement:
|
|
|
|
|
|
|
|
``__search`` query lookup
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
The ``search`` lookup, which supports MySQL only and is extremely limited in
|
|
|
|
features, is deprecated. Replace it with a custom lookup::
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
class Search(models.Lookup):
|
|
|
|
lookup_name = 'search'
|
|
|
|
|
|
|
|
def as_mysql(self, compiler, connection):
|
|
|
|
lhs, lhs_params = self.process_lhs(compiler, connection)
|
|
|
|
rhs, rhs_params = self.process_rhs(compiler, connection)
|
|
|
|
params = lhs_params + rhs_params
|
|
|
|
return 'MATCH (%s) AGAINST (%s IN BOOLEAN MODE)' % (lhs, rhs), params
|
|
|
|
|
|
|
|
models.CharField.register_lookup(Search)
|
|
|
|
models.TextField.register_lookup(Search)
|
|
|
|
|
2016-04-02 19:18:26 +08:00
|
|
|
.. _user-is-auth-anon-deprecation:
|
|
|
|
|
|
|
|
Using ``User.is_authenticated()`` and ``User.is_anonymous()`` as methods
|
|
|
|
------------------------------------------------------------------------
|
|
|
|
|
|
|
|
The ``is_authenticated()`` and ``is_anonymous()`` methods of
|
|
|
|
:class:`~django.contrib.auth.models.AbstractBaseUser` and
|
|
|
|
:class:`~django.contrib.auth.models.AnonymousUser` classes are now
|
|
|
|
properties. They will still work as methods until Django 2.0, but all usage
|
|
|
|
in Django now uses attribute access.
|
|
|
|
|
|
|
|
For example, if you use
|
|
|
|
:class:`~django.contrib.auth.middleware.AuthenticationMiddleware` and want
|
|
|
|
to know whether the user is currently logged-in you would use::
|
|
|
|
|
|
|
|
if request.user.is_authenticated:
|
|
|
|
... # Do something for logged-in users.
|
|
|
|
else:
|
|
|
|
... # Do something for anonymous users.
|
|
|
|
|
|
|
|
instead of ``request.user.is_authenticated()``.
|
|
|
|
|
|
|
|
This change avoids accidental information leakage if you forget to call the
|
|
|
|
method, e.g.::
|
|
|
|
|
|
|
|
if request.user.is_authenticated:
|
|
|
|
return sensitive_information
|
|
|
|
|
|
|
|
If you override these methods in a custom user model, you must change them to
|
|
|
|
properties or attributes.
|
|
|
|
|
2016-02-19 11:37:11 +08:00
|
|
|
Custom manager classes available through ``prefetch_related`` must define a ``_apply_rel_filters()`` method
|
|
|
|
-----------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
If you defined a custom manager class available through
|
|
|
|
:meth:`~django.db.models.query.QuerySet.prefetch_related` you must make sure
|
|
|
|
it defines a ``_apply_rel_filters()`` method.
|
|
|
|
|
|
|
|
This method must accept a :class:`~django.db.models.query.QuerySet` instance
|
|
|
|
as its single argument and return a filtered version of the queryset for the
|
|
|
|
model instance the manager is bound to.
|
|
|
|
|
2016-05-11 00:46:47 +08:00
|
|
|
The "escape" half of ``django.utils.safestring``
|
|
|
|
------------------------------------------------
|
|
|
|
|
|
|
|
The ``mark_for_escaping()`` function and the classes it uses: ``EscapeData``,
|
|
|
|
``EscapeBytes``, ``EscapeText``, ``EscapeString``, and ``EscapeUnicode`` are
|
|
|
|
deprecated.
|
|
|
|
|
|
|
|
As a result, the "lazy" behavior of the ``escape`` filter (where it would
|
|
|
|
always be applied as the last filter no matter where in the filter chain it
|
|
|
|
appeared) is deprecated. The filter will change to immediately apply
|
|
|
|
:func:`~django.utils.html.conditional_escape` in Django 2.0.
|
|
|
|
|
2016-04-17 19:55:55 +08:00
|
|
|
``Manager.use_for_related_fields`` and inheritance changes
|
|
|
|
----------------------------------------------------------
|
|
|
|
|
|
|
|
``Manager.use_for_related_fields`` is deprecated in favor of setting
|
|
|
|
:attr:`Meta.base_manager_name <django.db.models.Options.base_manager_name>` on
|
|
|
|
the model.
|
|
|
|
|
|
|
|
Model ``Manager`` inheritance will follow MRO inheritance rules in Django 2.0,
|
|
|
|
changing the current behavior where managers defined on non-abstract base
|
|
|
|
classes aren't inherited by child classes. A deprecating warning with
|
|
|
|
instructions on how to adapt your code is raised if you have any affected
|
|
|
|
managers. You'll either redeclare a manager from an abstract model on the child
|
|
|
|
class to override the manager from the concrete model, or you'll set the
|
|
|
|
model's ``Meta.manager_inheritance_from_future=True`` option to opt-in to the
|
|
|
|
new inheritance behavior.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
Miscellaneous
|
2016-01-03 18:56:22 +08:00
|
|
|
-------------
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-10-21 08:39:48 +08:00
|
|
|
* The ``makemigrations --exit`` option is deprecated in favor of the
|
2016-01-12 09:59:34 +08:00
|
|
|
:option:`makemigrations --check` option.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2015-11-07 21:30:20 +08:00
|
|
|
* ``django.utils.functional.allow_lazy()`` is deprecated in favor of the new
|
|
|
|
:func:`~django.utils.functional.keep_lazy` function which can be used with a
|
|
|
|
more natural decorator syntax.
|
|
|
|
|
2015-12-14 03:33:39 +08:00
|
|
|
* The ``shell --plain`` option is deprecated in favor of ``-i python`` or
|
|
|
|
``--interface python``.
|
|
|
|
|
2015-12-30 23:51:16 +08:00
|
|
|
* Importing from the ``django.core.urlresolvers`` module is deprecated in
|
|
|
|
favor of its new location, :mod:`django.urls`.
|
|
|
|
|
2016-02-23 02:25:01 +08:00
|
|
|
* The template ``Context.has_key()`` method is deprecated in favor of ``in``.
|
|
|
|
|
2016-03-21 01:10:55 +08:00
|
|
|
* The private attribute ``virtual_fields`` of ``Model._meta`` is
|
|
|
|
deprecated in favor of ``private_fields``.
|
|
|
|
|
|
|
|
* The private keyword arguments ``virtual_only`` in
|
|
|
|
``Field.contribute_to_class()`` and ``virtual`` in
|
|
|
|
``Model._meta.add_field()`` are deprecated in favor of ``private_only``
|
|
|
|
and ``private``, respectively.
|
|
|
|
|
2016-03-08 04:52:08 +08:00
|
|
|
* The ``javascript_catalog()`` and ``json_catalog()`` views are deprecated in
|
|
|
|
favor of class-based views :class:`~django.views.i18n.JavaScriptCatalog`
|
|
|
|
and :class:`~django.views.i18n.JSONCatalog`.
|
|
|
|
|
2016-04-23 00:59:41 +08:00
|
|
|
* In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a
|
|
|
|
``parent_link`` is deprecated. Add ``parent_link=True`` to such fields.
|
|
|
|
|
2016-04-24 01:15:45 +08:00
|
|
|
* The private API ``Widget._format_value()`` is made public and renamed to
|
|
|
|
:meth:`~django.forms.Widget.format_value`. The old name will work
|
|
|
|
through a deprecation period.
|
|
|
|
|
2016-03-21 09:51:17 +08:00
|
|
|
* Private ``FileField`` methods ``get_directory_name()`` and ``get_filename()``
|
|
|
|
are deprecated in favor of performing this work in
|
|
|
|
:meth:`Storage.generate_filename()
|
|
|
|
<django.core.files.storage.Storage.generate_filename>`).
|
|
|
|
|
2016-05-10 01:13:55 +08:00
|
|
|
* Old-style middleware that uses ``settings.MIDDLEWARE_CLASSES`` are
|
|
|
|
deprecated. :ref:`Adapt old, custom middleware <upgrading-middleware>` and
|
|
|
|
use the new :setting:`MIDDLEWARE` setting.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
.. _removed-features-1.10:
|
|
|
|
|
|
|
|
Features removed in 1.10
|
|
|
|
========================
|
|
|
|
|
|
|
|
These features have reached the end of their deprecation cycle and so have been
|
|
|
|
removed in Django 1.10 (please see the :ref:`deprecation timeline
|
|
|
|
<deprecation-removed-in-1.10>` for more details):
|
|
|
|
|
|
|
|
* Support for calling a ``SQLCompiler`` directly as an alias for calling its
|
|
|
|
``quote_name_unless_alias`` method is removed.
|
|
|
|
|
|
|
|
* The ``cycle`` and ``firstof`` template tags are removed from the ``future``
|
|
|
|
template tag library.
|
|
|
|
|
|
|
|
* ``django.conf.urls.patterns()`` is removed.
|
|
|
|
|
|
|
|
* Support for the ``prefix`` argument to
|
|
|
|
``django.conf.urls.i18n.i18n_patterns()`` is removed.
|
|
|
|
|
|
|
|
* ``SimpleTestCase.urls`` is removed.
|
|
|
|
|
|
|
|
* Using an incorrect count of unpacked values in the ``for`` template tag
|
|
|
|
raises an exception rather than failing silently.
|
|
|
|
|
2015-12-30 23:51:16 +08:00
|
|
|
* The ability to :func:`~django.urls.reverse` URLs using a dotted Python path
|
|
|
|
is removed.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
2016-03-02 23:48:13 +08:00
|
|
|
* The ability to use a dotted Python path for the ``LOGIN_URL`` and
|
|
|
|
``LOGIN_REDIRECT_URL`` settings is removed.
|
|
|
|
|
2015-09-20 08:34:58 +08:00
|
|
|
* Support for ``optparse`` is dropped for custom management commands.
|
|
|
|
|
|
|
|
* The class ``django.core.management.NoArgsCommand`` is removed.
|
|
|
|
|
|
|
|
* ``django.core.context_processors`` module is removed.
|
|
|
|
|
|
|
|
* ``django.db.models.sql.aggregates`` module is removed.
|
|
|
|
|
|
|
|
* ``django.contrib.gis.db.models.sql.aggregates`` module is removed.
|
|
|
|
|
|
|
|
* The following methods and properties of ``django.db.sql.query.Query`` are
|
|
|
|
removed:
|
|
|
|
|
|
|
|
* Properties: ``aggregates`` and ``aggregate_select``
|
|
|
|
* Methods: ``add_aggregate``, ``set_aggregate_mask``, and
|
|
|
|
``append_aggregate_mask``.
|
|
|
|
|
|
|
|
* ``django.template.resolve_variable`` is removed.
|
|
|
|
|
|
|
|
* The following private APIs are removed from
|
|
|
|
:class:`django.db.models.options.Options` (``Model._meta``):
|
|
|
|
|
|
|
|
* ``get_field_by_name()``
|
|
|
|
* ``get_all_field_names()``
|
|
|
|
* ``get_fields_with_model()``
|
|
|
|
* ``get_concrete_fields_with_model()``
|
|
|
|
* ``get_m2m_with_model()``
|
|
|
|
* ``get_all_related_objects()``
|
|
|
|
* ``get_all_related_objects_with_model()``
|
|
|
|
* ``get_all_related_many_to_many_objects()``
|
|
|
|
* ``get_all_related_m2m_objects_with_model()``
|
|
|
|
|
|
|
|
* The ``error_message`` argument of ``django.forms.RegexField`` is removed.
|
|
|
|
|
|
|
|
* The ``unordered_list`` filter no longer supports old style lists.
|
|
|
|
|
|
|
|
* Support for string ``view`` arguments to ``url()`` is removed.
|
|
|
|
|
|
|
|
* The backward compatible shim to rename ``django.forms.Form._has_changed()``
|
|
|
|
to ``has_changed()`` is removed.
|
|
|
|
|
|
|
|
* The ``removetags`` template filter is removed.
|
|
|
|
|
|
|
|
* The ``remove_tags()`` and ``strip_entities()`` functions in
|
|
|
|
``django.utils.html`` is removed.
|
|
|
|
|
|
|
|
* The ``is_admin_site`` argument to
|
|
|
|
``django.contrib.auth.views.password_reset()`` is removed.
|
|
|
|
|
|
|
|
* ``django.db.models.field.subclassing.SubfieldBase`` is removed.
|
|
|
|
|
|
|
|
* ``django.utils.checksums`` is removed.
|
|
|
|
|
|
|
|
* The ``original_content_type_id`` attribute on
|
|
|
|
``django.contrib.admin.helpers.InlineAdminForm`` is removed.
|
|
|
|
|
|
|
|
* The backwards compatibility shim to allow ``FormMixin.get_form()`` to be
|
|
|
|
defined with no default value for its ``form_class`` argument is removed.
|
|
|
|
|
|
|
|
* The following settings are removed:
|
|
|
|
|
|
|
|
* ``ALLOWED_INCLUDE_ROOTS``
|
|
|
|
* ``TEMPLATE_CONTEXT_PROCESSORS``
|
|
|
|
* ``TEMPLATE_DEBUG``
|
|
|
|
* ``TEMPLATE_DIRS``
|
|
|
|
* ``TEMPLATE_LOADERS``
|
|
|
|
* ``TEMPLATE_STRING_IF_INVALID``
|
|
|
|
|
|
|
|
* The backwards compatibility alias ``django.template.loader.BaseLoader`` is
|
|
|
|
removed.
|
|
|
|
|
|
|
|
* Django template objects returned by
|
|
|
|
:func:`~django.template.loader.get_template` and
|
|
|
|
:func:`~django.template.loader.select_template` no longer accept a
|
|
|
|
:class:`~django.template.Context` in their
|
|
|
|
:meth:`~django.template.backends.base.Template.render()` method.
|
|
|
|
|
|
|
|
* :doc:`Template response APIs </ref/template-response>` enforce the use of
|
|
|
|
:class:`dict` and backend-dependent template objects instead of
|
|
|
|
:class:`~django.template.Context` and :class:`~django.template.Template`
|
|
|
|
respectively.
|
|
|
|
|
|
|
|
* The ``current_app`` parameter for the following function and classes is
|
|
|
|
removed:
|
|
|
|
|
|
|
|
* ``django.shortcuts.render()``
|
|
|
|
* ``django.template.Context()``
|
|
|
|
* ``django.template.RequestContext()``
|
|
|
|
* ``django.template.response.TemplateResponse()``
|
|
|
|
|
|
|
|
* The ``dictionary`` and ``context_instance`` parameters for the following
|
|
|
|
functions are removed:
|
|
|
|
|
|
|
|
* ``django.shortcuts.render()``
|
|
|
|
* ``django.shortcuts.render_to_response()``
|
|
|
|
* ``django.template.loader.render_to_string()``
|
|
|
|
|
|
|
|
* The ``dirs`` parameter for the following functions is removed:
|
|
|
|
|
|
|
|
* ``django.template.loader.get_template()``
|
|
|
|
* ``django.template.loader.select_template()``
|
|
|
|
* ``django.shortcuts.render()``
|
|
|
|
* ``django.shortcuts.render_to_response()``
|
|
|
|
|
|
|
|
* Session verification is enabled regardless of whether or not
|
|
|
|
``'django.contrib.auth.middleware.SessionAuthenticationMiddleware'`` is in
|
2015-09-03 08:50:34 +08:00
|
|
|
``MIDDLEWARE_CLASSES``. ``SessionAuthenticationMiddleware`` no longer has
|
|
|
|
any purpose and can be removed from ``MIDDLEWARE_CLASSES``. It's kept as
|
|
|
|
a stub until Django 2.0 as a courtesy for users who don't read this note.
|
2015-09-20 08:34:58 +08:00
|
|
|
|
|
|
|
* Private attribute ``django.db.models.Field.related`` is removed.
|
|
|
|
|
|
|
|
* The ``--list`` option of the ``migrate`` management command is removed.
|
|
|
|
|
|
|
|
* The ``ssi`` template tag is removed.
|
|
|
|
|
|
|
|
* Support for the ``=`` comparison operator in the ``if`` template tag is
|
|
|
|
removed.
|
|
|
|
|
|
|
|
* The backwards compatibility shims to allow ``Storage.get_available_name()``
|
|
|
|
and ``Storage.save()`` to be defined without a ``max_length`` argument are
|
|
|
|
removed.
|
|
|
|
|
|
|
|
* Support for the legacy ``%(<foo>)s`` syntax in ``ModelFormMixin.success_url``
|
|
|
|
is removed.
|
|
|
|
|
|
|
|
* ``GeoQuerySet`` aggregate methods ``collect()``, ``extent()``, ``extent3d()``,
|
|
|
|
``make_line()``, and ``unionagg()`` are removed.
|
|
|
|
|
|
|
|
* The ability to specify ``ContentType.name`` when creating a content type
|
|
|
|
instance is removed.
|
|
|
|
|
|
|
|
* Support for the old signature of ``allow_migrate`` is removed.
|
|
|
|
|
|
|
|
* Support for the syntax of ``{% cycle %}`` that uses comma-separated arguments
|
|
|
|
is removed.
|
|
|
|
|
|
|
|
* The warning that :class:`~django.core.signing.Signer` issued when given an
|
|
|
|
invalid separator is now a ``ValueError``.
|