2017-03-22 23:47:45 +08:00
|
|
|
|
=========================
|
|
|
|
|
Django 1.11 release notes
|
|
|
|
|
=========================
|
|
|
|
|
|
2017-04-05 17:16:19 +08:00
|
|
|
|
*April 4, 2017*
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
|
|
|
|
Welcome to Django 1.11!
|
|
|
|
|
|
2016-06-02 23:41:49 +08:00
|
|
|
|
These release notes cover the :ref:`new features <whats-new-1.11>`, as well as
|
|
|
|
|
some :ref:`backwards incompatible changes <backwards-incompatible-1.11>` you'll
|
|
|
|
|
want to be aware of when upgrading from Django 1.10 or older versions. We've
|
|
|
|
|
:ref:`begun the deprecation process for some features
|
|
|
|
|
<deprecated-features-1.11>`.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-06-06 18:46:20 +08:00
|
|
|
|
See the :doc:`/howto/upgrade-version` guide if you're updating an existing
|
|
|
|
|
project.
|
|
|
|
|
|
2020-04-14 15:32:09 +08:00
|
|
|
|
Django 1.11 is designated as a :term:`long-term support release
|
|
|
|
|
<Long-term support release>`. It will receive security updates for at least
|
|
|
|
|
three years after its release. Support for the previous LTS, Django 1.8, will
|
|
|
|
|
end in April 2018.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
|
|
|
|
Python compatibility
|
|
|
|
|
====================
|
|
|
|
|
|
2018-11-18 04:39:57 +08:00
|
|
|
|
Django 1.11 requires Python 2.7, 3.4, 3.5, 3.6, or 3.7 (as of 1.11.17). We
|
|
|
|
|
**highly recommend** and only officially support the latest release of each
|
|
|
|
|
series.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
|
|
|
|
The Django 1.11.x series is the last to support Python 2. The next major
|
2017-08-11 23:17:08 +08:00
|
|
|
|
release, Django 2.0, will only support Python 3.4+.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-06-02 03:17:25 +08:00
|
|
|
|
Deprecating warnings are no longer loud by default
|
|
|
|
|
==================================================
|
|
|
|
|
|
|
|
|
|
Unlike older versions of Django, Django's own deprecation warnings are no
|
|
|
|
|
longer displayed by default. This is consistent with Python's default behavior.
|
|
|
|
|
|
|
|
|
|
This change allows third-party apps to support both Django 1.11 LTS and Django
|
|
|
|
|
1.8 LTS without having to add code to avoid deprecation warnings.
|
|
|
|
|
|
|
|
|
|
Following the release of Django 2.0, we suggest that third-party app authors
|
|
|
|
|
drop support for all versions of Django prior to 1.11. At that time, you should
|
|
|
|
|
be able run your package's tests using ``python -Wd`` so that deprecation
|
|
|
|
|
warnings do appear. After making the deprecation warning fixes, your app should
|
|
|
|
|
be compatible with Django 2.0.
|
|
|
|
|
|
2016-06-02 23:41:49 +08:00
|
|
|
|
.. _whats-new-1.11:
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
What's new in Django 1.11
|
|
|
|
|
=========================
|
|
|
|
|
|
2016-08-24 09:52:25 +08:00
|
|
|
|
Class-based model indexes
|
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
|
|
The new :mod:`django.db.models.indexes` module contains classes which ease
|
|
|
|
|
creating database indexes. Indexes are added to models using the
|
|
|
|
|
:attr:`Meta.indexes <django.db.models.Options.indexes>` option.
|
|
|
|
|
|
|
|
|
|
The :class:`~django.db.models.Index` class creates a b-tree index, as if you
|
|
|
|
|
used :attr:`~django.db.models.Field.db_index` on the model field or
|
2023-09-12 11:56:16 +08:00
|
|
|
|
``index_together`` on the model ``Meta`` class. It can be subclassed to support
|
|
|
|
|
different index types, such as
|
2016-08-24 09:52:25 +08:00
|
|
|
|
:class:`~django.contrib.postgres.indexes.GinIndex`. It also allows defining the
|
|
|
|
|
order (ASC/DESC) for the columns of the index.
|
|
|
|
|
|
2016-12-28 06:00:56 +08:00
|
|
|
|
Template-based widget rendering
|
|
|
|
|
-------------------------------
|
|
|
|
|
|
|
|
|
|
To ease customizing widgets, form widget rendering is now done using the
|
|
|
|
|
template system rather than in Python. See :doc:`/ref/forms/renderers`.
|
|
|
|
|
|
|
|
|
|
You may need to adjust any custom widgets that you've written for a few
|
|
|
|
|
:ref:`backwards incompatible changes <template-widget-incompatibilities-1-11>`.
|
|
|
|
|
|
2016-04-20 14:56:51 +08:00
|
|
|
|
``Subquery`` expressions
|
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
|
|
The new :class:`~django.db.models.Subquery` and
|
|
|
|
|
:class:`~django.db.models.Exists` database expressions allow creating
|
|
|
|
|
explicit subqueries. Subqueries may refer to fields from the outer queryset
|
|
|
|
|
using the :class:`~django.db.models.OuterRef` class.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Minor features
|
|
|
|
|
--------------
|
|
|
|
|
|
|
|
|
|
:mod:`django.contrib.admin`
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2016-05-06 01:52:54 +08:00
|
|
|
|
* :attr:`.ModelAdmin.date_hierarchy` can now reference fields across relations.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-09-29 17:55:10 +08:00
|
|
|
|
* The new :meth:`ModelAdmin.get_exclude()
|
|
|
|
|
<django.contrib.admin.ModelAdmin.get_exclude>` hook allows specifying the
|
|
|
|
|
exclude fields based on the request or model instance.
|
|
|
|
|
|
2016-11-13 03:09:15 +08:00
|
|
|
|
* The ``popup_response.html`` template can now be overridden per app, per
|
|
|
|
|
model, or by setting the :attr:`.ModelAdmin.popup_response_template`
|
|
|
|
|
attribute.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
:mod:`django.contrib.auth`
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2016-05-20 21:18:55 +08:00
|
|
|
|
* The default iteration count for the PBKDF2 password hasher is increased by
|
|
|
|
|
20%.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-05-15 23:28:00 +08:00
|
|
|
|
* The :class:`~django.contrib.auth.views.LoginView` and
|
|
|
|
|
:class:`~django.contrib.auth.views.LogoutView` class-based views supersede the
|
|
|
|
|
deprecated ``login()`` and ``logout()`` function-based views.
|
|
|
|
|
|
2013-04-10 05:31:58 +08:00
|
|
|
|
* The :class:`~django.contrib.auth.views.PasswordChangeView`,
|
|
|
|
|
:class:`~django.contrib.auth.views.PasswordChangeDoneView`,
|
|
|
|
|
:class:`~django.contrib.auth.views.PasswordResetView`,
|
|
|
|
|
:class:`~django.contrib.auth.views.PasswordResetDoneView`,
|
|
|
|
|
:class:`~django.contrib.auth.views.PasswordResetConfirmView`, and
|
|
|
|
|
:class:`~django.contrib.auth.views.PasswordResetCompleteView` class-based
|
|
|
|
|
views supersede the deprecated ``password_change()``,
|
|
|
|
|
``password_change_done()``, ``password_reset()``, ``password_reset_done()``,
|
|
|
|
|
``password_reset_confirm()``, and ``password_reset_complete()`` function-based
|
|
|
|
|
views.
|
|
|
|
|
|
2016-07-28 06:33:07 +08:00
|
|
|
|
* The new ``post_reset_login`` attribute for
|
|
|
|
|
:class:`~django.contrib.auth.views.PasswordResetConfirmView` allows
|
|
|
|
|
automatically logging in a user after a successful password reset.
|
2017-03-08 08:52:26 +08:00
|
|
|
|
If you have multiple ``AUTHENTICATION_BACKENDS`` configured, use the
|
|
|
|
|
``post_reset_login_backend`` attribute to choose which one to use.
|
2016-07-28 06:33:07 +08:00
|
|
|
|
|
2017-01-13 22:17:54 +08:00
|
|
|
|
* To avoid the possibility of leaking a password reset token via the HTTP
|
|
|
|
|
Referer header (for example, if the reset page includes a reference to CSS or
|
|
|
|
|
JavaScript hosted on another domain), the
|
|
|
|
|
:class:`~django.contrib.auth.views.PasswordResetConfirmView` (but not the
|
|
|
|
|
deprecated ``password_reset_confirm()`` function-based view) stores the token
|
|
|
|
|
in a session and redirects to itself to present the password change form to
|
|
|
|
|
the user without the token in the URL.
|
|
|
|
|
|
2016-08-16 07:29:12 +08:00
|
|
|
|
* :func:`~django.contrib.auth.update_session_auth_hash` now rotates the session
|
|
|
|
|
key to allow a password change to invalidate stolen session cookies.
|
|
|
|
|
|
2016-07-27 07:10:08 +08:00
|
|
|
|
* The new ``success_url_allowed_hosts`` attribute for
|
|
|
|
|
:class:`~django.contrib.auth.views.LoginView` and
|
|
|
|
|
:class:`~django.contrib.auth.views.LogoutView` allows specifying a set of
|
|
|
|
|
hosts that are safe for redirecting after login and logout.
|
|
|
|
|
|
2016-04-15 01:12:30 +08:00
|
|
|
|
* Added password validators ``help_text`` to
|
|
|
|
|
:class:`~django.contrib.auth.forms.UserCreationForm`.
|
|
|
|
|
|
2016-07-11 22:40:39 +08:00
|
|
|
|
* The ``HttpRequest`` is now passed to :func:`~django.contrib.auth.authenticate`
|
|
|
|
|
which in turn passes it to the authentication backend if it accepts a
|
|
|
|
|
``request`` argument.
|
|
|
|
|
|
2016-02-19 08:58:30 +08:00
|
|
|
|
* The :func:`~django.contrib.auth.signals.user_login_failed` signal now
|
|
|
|
|
receives a ``request`` argument.
|
|
|
|
|
|
2016-09-19 20:55:18 +08:00
|
|
|
|
* :class:`~django.contrib.auth.forms.PasswordResetForm` supports custom user
|
|
|
|
|
models that use an email field named something other than ``'email'``.
|
|
|
|
|
Set :attr:`CustomUser.EMAIL_FIELD
|
|
|
|
|
<django.contrib.auth.models.CustomUser.EMAIL_FIELD>` to the name of the field.
|
|
|
|
|
|
2016-10-01 04:06:02 +08:00
|
|
|
|
* :func:`~django.contrib.auth.get_user_model` can now be called at import time,
|
|
|
|
|
even in modules that define models.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
:mod:`django.contrib.contenttypes`
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2015-10-02 22:46:29 +08:00
|
|
|
|
* When stale content types are detected in the
|
|
|
|
|
:djadmin:`remove_stale_contenttypes` command, there's now a list of related
|
|
|
|
|
objects such as ``auth.Permission``\s that will also be deleted. Previously,
|
|
|
|
|
only the content types were listed (and this prompt was after ``migrate``
|
|
|
|
|
rather than in a separate command).
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
|
|
|
|
:mod:`django.contrib.gis`
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2016-06-10 14:50:07 +08:00
|
|
|
|
* The new :meth:`.GEOSGeometry.from_gml` and :meth:`.OGRGeometry.from_gml`
|
|
|
|
|
methods allow creating geometries from GML.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-07-22 04:54:07 +08:00
|
|
|
|
* Added support for the :lookup:`dwithin` lookup on SpatiaLite.
|
|
|
|
|
|
2016-11-16 20:07:36 +08:00
|
|
|
|
* The :class:`~django.contrib.gis.db.models.functions.Area` function,
|
|
|
|
|
:class:`~django.contrib.gis.db.models.functions.Distance` function, and
|
|
|
|
|
distance lookups now work with geodetic coordinates on SpatiaLite.
|
|
|
|
|
|
2016-08-10 23:13:08 +08:00
|
|
|
|
* The OpenLayers-based form widgets now use ``OpenLayers.js`` from
|
|
|
|
|
``https://cdnjs.cloudflare.com`` which is more suitable for production use
|
2018-09-26 14:48:47 +08:00
|
|
|
|
than the old ``https://openlayers.org/`` source. They are also updated to use
|
2018-07-18 23:24:07 +08:00
|
|
|
|
OpenLayers 3.
|
2016-08-10 23:13:08 +08:00
|
|
|
|
|
2016-09-19 15:58:58 +08:00
|
|
|
|
* PostGIS migrations can now change field dimensions.
|
|
|
|
|
|
2020-03-31 16:37:38 +08:00
|
|
|
|
* Added the ability to pass the ``size``, ``shape``, and ``offset`` parameters
|
|
|
|
|
when creating :class:`~django.contrib.gis.gdal.GDALRaster` objects.
|
2016-11-11 20:09:38 +08:00
|
|
|
|
|
2016-11-13 21:13:34 +08:00
|
|
|
|
* Added SpatiaLite support for the
|
|
|
|
|
:class:`~django.contrib.gis.db.models.functions.IsValid` function,
|
|
|
|
|
:class:`~django.contrib.gis.db.models.functions.MakeValid` function, and
|
|
|
|
|
:lookup:`isvalid` lookup.
|
|
|
|
|
|
2016-12-01 00:22:56 +08:00
|
|
|
|
* Added Oracle support for the
|
2016-12-16 03:00:08 +08:00
|
|
|
|
:class:`~django.contrib.gis.db.models.functions.AsGML` function,
|
2016-12-14 18:44:23 +08:00
|
|
|
|
:class:`~django.contrib.gis.db.models.functions.BoundingCircle` function,
|
2016-12-16 03:00:08 +08:00
|
|
|
|
:class:`~django.contrib.gis.db.models.functions.IsValid` function, and
|
2016-12-01 00:22:56 +08:00
|
|
|
|
:lookup:`isvalid` lookup.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
:mod:`django.contrib.postgres`
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2016-05-15 17:53:16 +08:00
|
|
|
|
* The new ``distinct`` argument for
|
|
|
|
|
:class:`~django.contrib.postgres.aggregates.StringAgg` determines if
|
|
|
|
|
concatenated values will be distinct.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-10-13 20:39:44 +08:00
|
|
|
|
* The new :class:`~django.contrib.postgres.indexes.GinIndex` and
|
|
|
|
|
:class:`~django.contrib.postgres.indexes.BrinIndex` classes allow
|
|
|
|
|
creating ``GIN`` and ``BRIN`` indexes in the database.
|
2016-08-24 09:52:25 +08:00
|
|
|
|
|
2021-01-14 16:33:12 +08:00
|
|
|
|
* ``django.contrib.postgres.fields.JSONField`` accepts a new ``encoder``
|
2016-08-12 03:05:52 +08:00
|
|
|
|
parameter to specify a custom class to encode data types not supported by the
|
|
|
|
|
standard encoder.
|
|
|
|
|
|
2022-08-03 17:42:51 +08:00
|
|
|
|
* The new ``CIText`` mixin and
|
2016-06-02 05:43:59 +08:00
|
|
|
|
:class:`~django.contrib.postgres.operations.CITextExtension` migration
|
|
|
|
|
operation allow using PostgreSQL's ``citext`` extension for case-insensitive
|
2022-08-03 17:42:51 +08:00
|
|
|
|
lookups. Three fields are provided: ``CICharField``, ``CIEmailField``, and
|
|
|
|
|
``CITextField``.
|
2016-06-02 05:43:59 +08:00
|
|
|
|
|
2016-11-13 04:42:20 +08:00
|
|
|
|
* The new :class:`~django.contrib.postgres.aggregates.JSONBAgg` allows
|
2016-09-26 19:16:03 +08:00
|
|
|
|
aggregating values as a JSON array.
|
|
|
|
|
|
2017-04-11 00:31:36 +08:00
|
|
|
|
* The :class:`~django.contrib.postgres.fields.HStoreField` (model field) and
|
|
|
|
|
:class:`~django.contrib.postgres.forms.HStoreField` (form field) allow
|
|
|
|
|
storing null values.
|
2016-12-09 08:17:02 +08:00
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Cache
|
|
|
|
|
~~~~~
|
|
|
|
|
|
2016-08-31 20:12:40 +08:00
|
|
|
|
* Memcached backends now pass the contents of :setting:`OPTIONS <CACHES-OPTIONS>`
|
|
|
|
|
as keyword arguments to the client constructors, allowing for more advanced
|
|
|
|
|
control of client behavior. See the :ref:`cache arguments <cache_arguments>`
|
|
|
|
|
documentation for examples.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-09-01 01:15:22 +08:00
|
|
|
|
* Memcached backends now allow defining multiple servers as a comma-delimited
|
|
|
|
|
string in :setting:`LOCATION <CACHES-LOCATION>`, for convenience with
|
|
|
|
|
third-party services that use such strings in environment variables.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
CSRF
|
|
|
|
|
~~~~
|
|
|
|
|
|
2016-07-01 00:42:11 +08:00
|
|
|
|
* Added the :setting:`CSRF_USE_SESSIONS` setting to allow storing the CSRF
|
|
|
|
|
token in the user's session rather than in a cookie.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
|
|
|
|
Database backends
|
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2016-06-23 23:52:14 +08:00
|
|
|
|
* Added the ``skip_locked`` argument to :meth:`.QuerySet.select_for_update()`
|
|
|
|
|
on PostgreSQL 9.5+ and Oracle to execute queries with
|
|
|
|
|
``FOR UPDATE SKIP LOCKED``.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-08-15 22:10:40 +08:00
|
|
|
|
* Added the :setting:`TEST['TEMPLATE'] <TEST_TEMPLATE>` setting to let
|
|
|
|
|
PostgreSQL users specify a template for creating the test database.
|
|
|
|
|
|
2022-12-02 03:23:43 +08:00
|
|
|
|
* :meth:`.QuerySet.iterator()` now uses `server-side cursors`_ on PostgreSQL.
|
|
|
|
|
This feature transfers some of the worker memory load (used to hold query
|
|
|
|
|
results) to the database and might increase database memory usage.
|
|
|
|
|
|
|
|
|
|
.. _server-side cursors: https://www.psycopg.org/docs/usage.html#server-side-cursors
|
2016-06-04 06:31:21 +08:00
|
|
|
|
|
2017-01-18 00:16:15 +08:00
|
|
|
|
* Added MySQL support for the ``'isolation_level'`` option in
|
|
|
|
|
:setting:`OPTIONS` to allow specifying the :ref:`transaction isolation level
|
|
|
|
|
<mysql-isolation-level>`. To avoid possible data loss, it's recommended to
|
|
|
|
|
switch from MySQL's default level, repeatable read, to read committed.
|
|
|
|
|
|
2017-03-11 06:02:44 +08:00
|
|
|
|
* Added support for ``cx_Oracle`` 5.3.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Email
|
|
|
|
|
~~~~~
|
|
|
|
|
|
2016-06-03 07:41:13 +08:00
|
|
|
|
* Added the :setting:`EMAIL_USE_LOCALTIME` setting to allow sending SMTP date
|
|
|
|
|
headers in the local time zone rather than in UTC.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-08-03 21:53:06 +08:00
|
|
|
|
* ``EmailMessage.attach()`` and ``attach_file()`` now fall back to MIME type
|
2020-04-30 17:33:04 +08:00
|
|
|
|
:mimetype:`application/octet-stream` when binary content that can't be
|
|
|
|
|
decoded as UTF-8 is specified for a :mimetype:`text/*` attachment.
|
2016-08-03 21:53:06 +08:00
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
File Storage
|
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
2016-05-23 00:43:56 +08:00
|
|
|
|
* To make it wrappable by :class:`io.TextIOWrapper`,
|
|
|
|
|
:class:`~django.core.files.File` now has the ``readable()``, ``writable()``,
|
|
|
|
|
and ``seekable()`` methods.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
|
|
|
|
Forms
|
|
|
|
|
~~~~~
|
|
|
|
|
|
2020-07-04 14:58:11 +08:00
|
|
|
|
* The new ``empty_value`` attribute on :class:`~django.forms.CharField`,
|
|
|
|
|
:class:`~django.forms.EmailField`, :class:`~django.forms.RegexField`,
|
|
|
|
|
:class:`~django.forms.SlugField`, and :class:`~django.forms.URLField` allows
|
|
|
|
|
specifying the Python value to use to represent "empty".
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-08-19 08:55:47 +08:00
|
|
|
|
* The new :meth:`Form.get_initial_for_field()
|
|
|
|
|
<django.forms.Form.get_initial_for_field>` method returns initial data for a
|
|
|
|
|
form field.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Internationalization
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2016-06-03 03:13:47 +08:00
|
|
|
|
* Number formatting and the :setting:`NUMBER_GROUPING` setting support
|
|
|
|
|
non-uniform digit grouping.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
|
|
|
|
Management Commands
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2016-05-17 14:52:01 +08:00
|
|
|
|
* The new :option:`loaddata --exclude` option allows excluding models and apps
|
|
|
|
|
while loading data from fixtures.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-11-05 19:31:37 +08:00
|
|
|
|
* The new :option:`diffsettings --default` option allows specifying a settings
|
|
|
|
|
module other than Django's default settings to compare against.
|
|
|
|
|
|
2016-11-06 20:52:06 +08:00
|
|
|
|
* ``app_label``\s arguments now limit the :option:`showmigrations --plan`
|
|
|
|
|
output.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Migrations
|
|
|
|
|
~~~~~~~~~~
|
|
|
|
|
|
2016-11-06 20:53:00 +08:00
|
|
|
|
* Added support for serialization of ``uuid.UUID`` objects.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
|
|
|
|
Models
|
|
|
|
|
~~~~~~
|
|
|
|
|
|
2016-05-26 04:33:35 +08:00
|
|
|
|
* Added support for callable values in the ``defaults`` argument of
|
|
|
|
|
:meth:`QuerySet.update_or_create()
|
|
|
|
|
<django.db.models.query.QuerySet.update_or_create>` and
|
|
|
|
|
:meth:`~django.db.models.query.QuerySet.get_or_create`.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-03-27 04:09:08 +08:00
|
|
|
|
* :class:`~django.db.models.ImageField` now has a default
|
|
|
|
|
:data:`~django.core.validators.validate_image_file_extension` validator.
|
2017-05-28 15:05:21 +08:00
|
|
|
|
(This validator moved to the form field in :doc:`Django 1.11.2 <1.11.2>`.)
|
2016-03-27 04:09:08 +08:00
|
|
|
|
|
2016-06-19 11:38:24 +08:00
|
|
|
|
* Added support for time truncation to
|
2017-10-14 00:20:11 +08:00
|
|
|
|
:class:`~django.db.models.functions.Trunc` functions.
|
2016-06-19 11:38:24 +08:00
|
|
|
|
|
2017-10-14 00:20:11 +08:00
|
|
|
|
* Added the :class:`~django.db.models.functions.ExtractWeek` function to
|
|
|
|
|
extract the week from :class:`~django.db.models.DateField` and
|
2016-11-11 21:01:40 +08:00
|
|
|
|
:class:`~django.db.models.DateTimeField` and exposed it through the
|
|
|
|
|
:lookup:`week` lookup.
|
|
|
|
|
|
2017-10-14 00:20:11 +08:00
|
|
|
|
* Added the :class:`~django.db.models.functions.TruncTime` function to truncate
|
|
|
|
|
:class:`~django.db.models.DateTimeField` to its time component and exposed it
|
|
|
|
|
through the :lookup:`time` lookup.
|
2016-06-19 11:39:26 +08:00
|
|
|
|
|
2016-08-15 09:35:12 +08:00
|
|
|
|
* Added support for expressions in :meth:`.QuerySet.values` and
|
|
|
|
|
:meth:`~.QuerySet.values_list`.
|
|
|
|
|
|
2016-06-03 02:05:25 +08:00
|
|
|
|
* Added support for query expressions on lookups that take multiple arguments,
|
|
|
|
|
such as ``range``.
|
|
|
|
|
|
2016-09-21 05:31:23 +08:00
|
|
|
|
* You can now use the ``unique=True`` option with
|
|
|
|
|
:class:`~django.db.models.FileField`.
|
|
|
|
|
|
2016-07-27 21:17:05 +08:00
|
|
|
|
* Added the ``nulls_first`` and ``nulls_last`` parameters to
|
|
|
|
|
:class:`Expression.asc() <django.db.models.Expression.asc>` and
|
|
|
|
|
:meth:`~django.db.models.Expression.desc` to control
|
|
|
|
|
the ordering of null values.
|
|
|
|
|
|
2015-12-15 03:13:21 +08:00
|
|
|
|
* The new ``F`` expression ``bitleftshift()`` and ``bitrightshift()`` methods
|
|
|
|
|
allow :ref:`bitwise shift operations <using-f-expressions-in-filters>`.
|
|
|
|
|
|
2017-01-14 21:32:07 +08:00
|
|
|
|
* Added :meth:`.QuerySet.union`, :meth:`~.QuerySet.intersection`, and
|
|
|
|
|
:meth:`~.QuerySet.difference`.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Requests and Responses
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2016-06-04 06:50:38 +08:00
|
|
|
|
* Added :meth:`QueryDict.fromkeys() <django.http.QueryDict.fromkeys>`.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-06-18 16:51:38 +08:00
|
|
|
|
* :class:`~django.middleware.common.CommonMiddleware` now sets the
|
|
|
|
|
``Content-Length`` response header for non-streaming responses.
|
|
|
|
|
|
2016-07-29 00:48:07 +08:00
|
|
|
|
* Added the :setting:`SECURE_HSTS_PRELOAD` setting to allow appending the
|
|
|
|
|
``preload`` directive to the ``Strict-Transport-Security`` header.
|
|
|
|
|
|
2016-04-03 18:15:10 +08:00
|
|
|
|
* :class:`~django.middleware.http.ConditionalGetMiddleware` now adds the
|
|
|
|
|
``ETag`` header to responses.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Serialization
|
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
2016-06-08 09:22:30 +08:00
|
|
|
|
* The new ``django.core.serializers.base.Serializer.stream_class`` attribute
|
|
|
|
|
allows subclasses to customize the default stream.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-06-28 19:48:19 +08:00
|
|
|
|
* The encoder used by the :ref:`JSON serializer <serialization-formats-json>`
|
|
|
|
|
can now be customized by passing a ``cls`` keyword argument to the
|
|
|
|
|
``serializers.serialize()`` function.
|
|
|
|
|
|
2016-05-26 20:48:36 +08:00
|
|
|
|
* :class:`~django.core.serializers.json.DjangoJSONEncoder` now serializes
|
|
|
|
|
:class:`~datetime.timedelta` objects (used by
|
|
|
|
|
:class:`~django.db.models.DurationField`).
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Templates
|
|
|
|
|
~~~~~~~~~
|
|
|
|
|
|
2016-06-03 05:11:43 +08:00
|
|
|
|
* :meth:`~django.utils.safestring.mark_safe` can now be used as a decorator.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-06-27 21:56:21 +08:00
|
|
|
|
* The :class:`~django.template.backends.jinja2.Jinja2` template backend now
|
|
|
|
|
supports context processors by setting the ``'context_processors'`` option in
|
|
|
|
|
:setting:`OPTIONS <TEMPLATES-OPTIONS>`.
|
|
|
|
|
|
2016-08-26 17:39:06 +08:00
|
|
|
|
* The :ttag:`regroup` tag now returns ``namedtuple``\s instead of dictionaries
|
|
|
|
|
so you can unpack the group object directly in a loop, e.g.
|
|
|
|
|
``{% for grouper, list in regrouped %}``.
|
|
|
|
|
|
2016-07-03 22:19:06 +08:00
|
|
|
|
* Added a :ttag:`resetcycle` template tag to allow resetting the sequence of
|
|
|
|
|
the :ttag:`cycle` template tag.
|
|
|
|
|
|
2016-12-14 05:50:00 +08:00
|
|
|
|
* You can now specify specific directories for a particular
|
|
|
|
|
:class:`filesystem.Loader <django.template.loaders.filesystem.Loader>`.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Tests
|
|
|
|
|
~~~~~
|
|
|
|
|
|
2016-08-05 01:26:21 +08:00
|
|
|
|
* Added :meth:`.DiscoverRunner.get_test_runner_kwargs` to allow customizing the
|
|
|
|
|
keyword arguments passed to the test runner.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-08-11 01:46:54 +08:00
|
|
|
|
* Added the :option:`test --debug-mode` option to help troubleshoot test
|
2016-08-13 20:33:58 +08:00
|
|
|
|
failures by setting the :setting:`DEBUG` setting to ``True``.
|
2016-08-09 16:40:40 +08:00
|
|
|
|
|
2016-07-03 06:20:14 +08:00
|
|
|
|
* The new :func:`django.test.utils.setup_databases` (moved from
|
|
|
|
|
``django.test.runner``) and :func:`~django.test.utils.teardown_databases`
|
|
|
|
|
functions make it easier to build custom test runners.
|
|
|
|
|
|
2016-08-11 18:47:12 +08:00
|
|
|
|
* Added support for :meth:`python:unittest.TestCase.subTest`’s when using the
|
|
|
|
|
:option:`test --parallel` option.
|
|
|
|
|
|
2016-03-18 22:24:13 +08:00
|
|
|
|
* ``DiscoverRunner`` now runs the system checks at the start of a test run.
|
|
|
|
|
Override the :meth:`.DiscoverRunner.run_checks` method if you want to disable
|
|
|
|
|
that.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Validators
|
|
|
|
|
~~~~~~~~~~
|
|
|
|
|
|
2016-03-27 04:09:08 +08:00
|
|
|
|
* Added :class:`~django.core.validators.FileExtensionValidator` to validate
|
|
|
|
|
file extensions and
|
|
|
|
|
:data:`~django.core.validators.validate_image_file_extension` to validate
|
|
|
|
|
image files.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-06-02 23:41:49 +08:00
|
|
|
|
.. _backwards-incompatible-1.11:
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Backwards incompatible changes in 1.11
|
|
|
|
|
======================================
|
|
|
|
|
|
2016-06-14 22:18:33 +08:00
|
|
|
|
:mod:`django.contrib.gis`
|
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
|
|
* To simplify the codebase and because it's easier to install than when
|
|
|
|
|
``contrib.gis`` was first released, :ref:`gdalbuild` is now a required
|
|
|
|
|
dependency for GeoDjango. In older versions, it's only required for SQLite.
|
|
|
|
|
|
2016-09-16 04:15:02 +08:00
|
|
|
|
* ``contrib.gis.maps`` is removed as it interfaces with a retired version of
|
2019-11-25 23:28:47 +08:00
|
|
|
|
the Google Maps API and seems to be unmaintained. If you're using it,
|
|
|
|
|
:ticket:`let us know <14284>`.
|
2016-09-16 04:15:02 +08:00
|
|
|
|
|
2016-11-23 16:23:06 +08:00
|
|
|
|
* The ``GEOSGeometry`` equality operator now also compares SRID.
|
|
|
|
|
|
2015-05-25 23:31:26 +08:00
|
|
|
|
* The OpenLayers-based form widgets now use OpenLayers 3, and the
|
|
|
|
|
``gis/openlayers.html`` and ``gis/openlayers-osm.html`` templates have been
|
|
|
|
|
updated. Check your project if you subclass these widgets or extend the
|
2017-03-21 22:50:48 +08:00
|
|
|
|
templates. Also, the new widgets work a bit differently than the old ones.
|
|
|
|
|
Instead of using a toolbar in the widget, you click to draw, click and drag
|
|
|
|
|
to move the map, and click and drag a point/vertex/corner to move it.
|
2015-05-25 23:31:26 +08:00
|
|
|
|
|
2017-01-16 22:58:26 +08:00
|
|
|
|
* Support for SpatiaLite < 4.0 is dropped.
|
|
|
|
|
|
|
|
|
|
* Support for GDAL 1.7 and 1.8 is dropped.
|
|
|
|
|
|
2017-04-26 21:45:33 +08:00
|
|
|
|
* The widgets in ``contrib.gis.forms.widgets`` and the admin's
|
|
|
|
|
``OpenLayersWidget`` use the :doc:`form rendering API </ref/forms/renderers>`
|
|
|
|
|
rather than ``loader.render_to_string()``. If you're using a custom widget
|
|
|
|
|
template, you'll need to be sure your form renderer can locate it. For
|
|
|
|
|
example, you could use the :class:`~django.forms.renderers.TemplatesSetting`
|
|
|
|
|
renderer.
|
|
|
|
|
|
2017-01-11 22:21:29 +08:00
|
|
|
|
:mod:`django.contrib.staticfiles`
|
|
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
|
|
* ``collectstatic`` may now fail during post-processing when using a hashed
|
|
|
|
|
static files storage if a reference loop exists (e.g. ``'foo.css'``
|
|
|
|
|
references ``'bar.css'`` which itself references ``'foo.css'``) or if the
|
|
|
|
|
chain of files referencing other files is too deep to resolve in several
|
|
|
|
|
passes. In the latter case, increase the number of passes using
|
|
|
|
|
:attr:`.ManifestStaticFilesStorage.max_post_process_passes`.
|
|
|
|
|
|
|
|
|
|
* When using ``ManifestStaticFilesStorage``, static files not found in the
|
|
|
|
|
manifest at runtime now raise a ``ValueError`` instead of returning an
|
|
|
|
|
unchanged path. You can revert to the old behavior by setting
|
|
|
|
|
:attr:`.ManifestStaticFilesStorage.manifest_strict` to ``False``.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Database backend API
|
|
|
|
|
--------------------
|
|
|
|
|
|
2017-06-06 23:33:09 +08:00
|
|
|
|
This section describes changes that may be needed in third-party database
|
|
|
|
|
backends.
|
|
|
|
|
|
2016-06-19 11:38:24 +08:00
|
|
|
|
* The ``DatabaseOperations.time_trunc_sql()`` method is added to support
|
|
|
|
|
``TimeField`` truncation. It accepts a ``lookup_type`` and ``field_name``
|
|
|
|
|
arguments and returns the appropriate SQL to truncate the given time field
|
|
|
|
|
``field_name`` to a time object with only the given specificity. The
|
|
|
|
|
``lookup_type`` argument can be either ``'hour'``, ``'minute'``, or
|
|
|
|
|
``'second'``.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-06-19 11:39:26 +08:00
|
|
|
|
* The ``DatabaseOperations.datetime_cast_time_sql()`` method is added to
|
|
|
|
|
support the :lookup:`time` lookup. It accepts a ``field_name`` and ``tzname``
|
|
|
|
|
arguments and returns the SQL necessary to cast a datetime value to time value.
|
|
|
|
|
|
2016-06-23 23:52:14 +08:00
|
|
|
|
* To enable ``FOR UPDATE SKIP LOCKED`` support, set
|
|
|
|
|
``DatabaseFeatures.has_select_for_update_skip_locked = True``.
|
|
|
|
|
|
2016-07-26 09:04:28 +08:00
|
|
|
|
* The new ``DatabaseFeatures.supports_index_column_ordering`` attribute
|
|
|
|
|
specifies if a database allows defining ordering for columns in indexes. The
|
|
|
|
|
default value is ``True`` and the ``DatabaseIntrospection.get_constraints()``
|
|
|
|
|
method should include an ``'orders'`` key in each of the returned
|
|
|
|
|
dictionaries with a list of ``'ASC'`` and/or ``'DESC'`` values corresponding
|
2018-07-18 23:24:07 +08:00
|
|
|
|
to the ordering of each column in the index.
|
2016-07-26 09:04:28 +08:00
|
|
|
|
|
2016-08-20 18:14:02 +08:00
|
|
|
|
* :djadmin:`inspectdb` no longer calls ``DatabaseIntrospection.get_indexes()``
|
|
|
|
|
which is deprecated. Custom database backends should ensure all types of
|
|
|
|
|
indexes are returned by ``DatabaseIntrospection.get_constraints()``.
|
|
|
|
|
|
2016-11-29 02:29:21 +08:00
|
|
|
|
* Renamed the ``ignores_quoted_identifier_case`` feature to
|
|
|
|
|
``ignores_table_name_case`` to more accurately reflect how it is used.
|
|
|
|
|
|
2016-06-04 06:31:21 +08:00
|
|
|
|
* The ``name`` keyword argument is added to the
|
|
|
|
|
``DatabaseWrapper.create_cursor(self, name=None)`` method to allow usage of
|
|
|
|
|
server-side cursors on backends that support it.
|
|
|
|
|
|
2016-05-29 08:11:42 +08:00
|
|
|
|
Dropped support for PostgreSQL 9.2 and PostGIS 2.0
|
2016-06-22 23:16:18 +08:00
|
|
|
|
--------------------------------------------------
|
2016-05-29 08:11:42 +08:00
|
|
|
|
|
|
|
|
|
Upstream support for PostgreSQL 9.2 ends in September 2017. As a consequence,
|
|
|
|
|
Django 1.11 sets PostgreSQL 9.3 as the minimum version it officially supports.
|
|
|
|
|
|
|
|
|
|
Support for PostGIS 2.0 is also removed as PostgreSQL 9.2 is the last version
|
|
|
|
|
to support it.
|
|
|
|
|
|
2017-03-22 00:23:17 +08:00
|
|
|
|
Also, the minimum supported version of psycopg2 is increased from 2.4.5 to
|
|
|
|
|
2.5.4.
|
|
|
|
|
|
2017-05-23 01:16:56 +08:00
|
|
|
|
.. _liveservertestcase-port-zero-change:
|
|
|
|
|
|
2016-06-24 00:04:05 +08:00
|
|
|
|
``LiveServerTestCase`` binds to port zero
|
|
|
|
|
-----------------------------------------
|
|
|
|
|
|
|
|
|
|
Rather than taking a port range and iterating to find a free port,
|
|
|
|
|
``LiveServerTestCase`` binds to port zero and relies on the operating system
|
|
|
|
|
to assign a free port. The ``DJANGO_LIVE_TEST_SERVER_ADDRESS`` environment
|
|
|
|
|
variable is no longer used, and as it's also no longer used, the
|
|
|
|
|
``manage.py test --liveserver`` option is removed.
|
|
|
|
|
|
2017-05-23 01:16:56 +08:00
|
|
|
|
If you need to bind ``LiveServerTestCase`` to a specific port, use the ``port``
|
|
|
|
|
attribute added in Django 1.11.2.
|
|
|
|
|
|
2016-08-19 20:32:21 +08:00
|
|
|
|
Protection against insecure redirects in :mod:`django.contrib.auth` and ``i18n`` views
|
|
|
|
|
--------------------------------------------------------------------------------------
|
2016-08-19 19:40:21 +08:00
|
|
|
|
|
2016-08-19 20:32:21 +08:00
|
|
|
|
``LoginView``, ``LogoutView`` (and the deprecated function-based equivalents),
|
|
|
|
|
and :func:`~django.views.i18n.set_language` protect users from being redirected
|
|
|
|
|
to non-HTTPS ``next`` URLs when the app is running over HTTPS.
|
2016-08-19 19:40:21 +08:00
|
|
|
|
|
2016-09-16 11:42:31 +08:00
|
|
|
|
``QuerySet.get_or_create()`` and ``update_or_create()`` validate arguments
|
|
|
|
|
--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
To prevent typos from passing silently,
|
|
|
|
|
:meth:`~django.db.models.query.QuerySet.get_or_create` and
|
|
|
|
|
:meth:`~django.db.models.query.QuerySet.update_or_create` check that their
|
|
|
|
|
arguments are model fields. This should be backwards-incompatible only in the
|
|
|
|
|
fact that it might expose a bug in your project.
|
|
|
|
|
|
2016-10-08 09:06:49 +08:00
|
|
|
|
``pytz`` is a required dependency and support for ``settings.TIME_ZONE = None`` is removed
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
To simplify Django's timezone handling, ``pytz`` is now a required dependency.
|
|
|
|
|
It's automatically installed along with Django.
|
|
|
|
|
|
|
|
|
|
Support for ``settings.TIME_ZONE = None`` is removed as the behavior isn't
|
|
|
|
|
commonly used and is questionably useful. If you want to automatically detect
|
2023-04-17 07:14:09 +08:00
|
|
|
|
the timezone based on the system timezone, you can use :pypi:`tzlocal`::
|
2016-10-08 09:06:49 +08:00
|
|
|
|
|
|
|
|
|
from tzlocal import get_localzone
|
|
|
|
|
|
|
|
|
|
TIME_ZONE = get_localzone().zone
|
|
|
|
|
|
|
|
|
|
This works similar to ``settings.TIME_ZONE = None`` except that it also sets
|
|
|
|
|
``os.environ['TZ']``. `Let us know
|
2021-04-27 19:09:00 +08:00
|
|
|
|
<https://groups.google.com/g/django-developers/c/OAV3FChfuPM/discussion>`__
|
2016-10-08 09:06:49 +08:00
|
|
|
|
if there's a use case where you find you can't adapt your code to set a
|
|
|
|
|
``TIME_ZONE``.
|
|
|
|
|
|
2016-11-05 19:47:12 +08:00
|
|
|
|
HTML changes in admin templates
|
|
|
|
|
-------------------------------
|
|
|
|
|
|
|
|
|
|
``<p class="help">`` is replaced with a ``<div>`` tag to allow including lists
|
|
|
|
|
inside help text.
|
|
|
|
|
|
|
|
|
|
Read-only fields are wrapped in ``<div class="readonly">...</div>`` instead of
|
|
|
|
|
``<p>...</p>`` to allow any kind of HTML as the field's content.
|
|
|
|
|
|
2016-12-28 06:00:56 +08:00
|
|
|
|
.. _template-widget-incompatibilities-1-11:
|
|
|
|
|
|
|
|
|
|
Changes due to the introduction of template-based widget rendering
|
|
|
|
|
------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
Some undocumented classes in ``django.forms.widgets`` are removed:
|
|
|
|
|
|
|
|
|
|
* ``SubWidget``
|
|
|
|
|
* ``RendererMixin``, ``ChoiceFieldRenderer``, ``RadioFieldRenderer``,
|
|
|
|
|
``CheckboxFieldRenderer``
|
|
|
|
|
* ``ChoiceInput``, ``RadioChoiceInput``, ``CheckboxChoiceInput``
|
|
|
|
|
|
2017-06-14 18:11:17 +08:00
|
|
|
|
The undocumented ``Select.render_option()`` method is removed.
|
|
|
|
|
|
2016-12-28 06:00:56 +08:00
|
|
|
|
The ``Widget.format_output()`` method is removed. Use a custom widget template
|
|
|
|
|
instead.
|
|
|
|
|
|
2017-01-17 01:58:21 +08:00
|
|
|
|
Some widget values, such as ``<select>`` options, are now localized if
|
|
|
|
|
``settings.USE_L10N=True``. You could revert to the old behavior with custom
|
|
|
|
|
widget templates that uses the :ttag:`localize` template tag to turn off
|
|
|
|
|
localization.
|
|
|
|
|
|
2017-04-26 21:40:48 +08:00
|
|
|
|
``django.template.backends.django.Template.render()`` prohibits non-dict context
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
For compatibility with multiple template engines,
|
|
|
|
|
``django.template.backends.django.Template.render()`` (returned from high-level
|
|
|
|
|
template loader APIs such as ``loader.get_template()``) must receive a
|
|
|
|
|
dictionary of context rather than ``Context`` or ``RequestContext``. If you
|
|
|
|
|
were passing either of the two classes, pass a dictionary instead -- doing so
|
|
|
|
|
is backwards-compatible with older versions of Django.
|
2016-12-29 05:03:20 +08:00
|
|
|
|
|
2016-11-06 19:03:05 +08:00
|
|
|
|
Model state changes in migration operations
|
|
|
|
|
-------------------------------------------
|
|
|
|
|
|
|
|
|
|
To improve the speed of applying migrations, rendering of related models is
|
|
|
|
|
delayed until an operation that needs them (e.g. ``RunPython``). If you have a
|
|
|
|
|
custom operation that works with model classes or model instances from the
|
|
|
|
|
``from_state`` argument in ``database_forwards()`` or ``database_backwards()``,
|
|
|
|
|
you must render model states using the ``clear_delayed_apps_cache()`` method as
|
|
|
|
|
described in :ref:`writing your own migration operation
|
|
|
|
|
<writing-your-own-migration-operation>`.
|
|
|
|
|
|
2018-04-11 01:26:50 +08:00
|
|
|
|
Server-side cursors on PostgreSQL
|
|
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
|
|
The change to make :meth:`.QuerySet.iterator()` use server-side cursors on
|
2020-04-01 20:48:52 +08:00
|
|
|
|
PostgreSQL prevents running Django with PgBouncer in transaction pooling mode.
|
2020-03-31 16:37:38 +08:00
|
|
|
|
To reallow that, use the :setting:`DISABLE_SERVER_SIDE_CURSORS
|
2018-04-11 01:26:50 +08:00
|
|
|
|
<DATABASE-DISABLE_SERVER_SIDE_CURSORS>` setting (added in Django 1.11.1) in
|
|
|
|
|
:setting:`DATABASES`.
|
|
|
|
|
|
|
|
|
|
See :ref:`transaction-pooling-server-side-cursors` for more discussion.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Miscellaneous
|
|
|
|
|
-------------
|
|
|
|
|
|
2016-05-25 00:50:20 +08:00
|
|
|
|
* If no items in the feed have a ``pubdate`` or ``updateddate`` attribute,
|
|
|
|
|
:meth:`SyndicationFeed.latest_post_date()
|
|
|
|
|
<django.utils.feedgenerator.SyndicationFeed.latest_post_date>` now returns
|
|
|
|
|
the current UTC date/time, instead of a datetime without any timezone
|
|
|
|
|
information.
|
2016-05-20 10:28:24 +08:00
|
|
|
|
|
2016-06-23 00:10:42 +08:00
|
|
|
|
* CSRF failures are logged to the ``django.security.csrf`` logger instead of
|
2016-06-03 08:24:48 +08:00
|
|
|
|
``django.request``.
|
|
|
|
|
|
2016-06-04 06:02:38 +08:00
|
|
|
|
* :setting:`ALLOWED_HOSTS` validation is no longer disabled when running tests.
|
|
|
|
|
If your application includes tests with custom host names, you must include
|
|
|
|
|
those host names in :setting:`ALLOWED_HOSTS`. See
|
|
|
|
|
:ref:`topics-testing-advanced-multiple-hosts`.
|
|
|
|
|
|
2016-04-24 01:35:18 +08:00
|
|
|
|
* Using a foreign key's id (e.g. ``'field_id'``) in ``ModelAdmin.list_display``
|
2016-06-10 03:05:59 +08:00
|
|
|
|
displays the related object's ID. Remove the ``_id`` suffix if you want the
|
|
|
|
|
old behavior of the string representation of the object.
|
2016-04-24 01:35:18 +08:00
|
|
|
|
|
2016-05-18 22:30:42 +08:00
|
|
|
|
* In model forms, :class:`~django.db.models.CharField` with ``null=True`` now
|
|
|
|
|
saves ``NULL`` for blank values instead of empty strings.
|
|
|
|
|
|
|
|
|
|
* On Oracle, :meth:`Model.validate_unique()
|
|
|
|
|
<django.db.models.Model.validate_unique>` no longer checks empty strings for
|
|
|
|
|
uniqueness as the database interprets the value as ``NULL``.
|
|
|
|
|
|
2016-06-16 18:06:59 +08:00
|
|
|
|
* If you subclass :class:`.AbstractUser` and override ``clean()``, be sure it
|
|
|
|
|
calls ``super()``. :meth:`.BaseUserManager.normalize_email` is called in a
|
|
|
|
|
new :meth:`.AbstractUser.clean` method so that normalization is applied in
|
|
|
|
|
cases like model form validation.
|
|
|
|
|
|
2016-07-03 22:41:59 +08:00
|
|
|
|
* ``EmailField`` and ``URLField`` no longer accept the ``strip`` keyword
|
|
|
|
|
argument. Remove it because it doesn't have an effect in older versions of
|
2017-02-07 20:49:46 +08:00
|
|
|
|
Django as these fields always strip whitespace.
|
2016-07-03 22:41:59 +08:00
|
|
|
|
|
2016-09-22 06:12:13 +08:00
|
|
|
|
* The ``checked`` and ``selected`` attribute rendered by form widgets now uses
|
|
|
|
|
HTML5 boolean syntax rather than XHTML's ``checked='checked'`` and
|
|
|
|
|
``selected='selected'``.
|
2016-07-22 13:05:17 +08:00
|
|
|
|
|
2016-06-05 20:15:00 +08:00
|
|
|
|
* :meth:`RelatedManager.add()
|
|
|
|
|
<django.db.models.fields.related.RelatedManager.add>`,
|
|
|
|
|
:meth:`~django.db.models.fields.related.RelatedManager.remove`,
|
|
|
|
|
:meth:`~django.db.models.fields.related.RelatedManager.clear`, and
|
|
|
|
|
:meth:`~django.db.models.fields.related.RelatedManager.set` now
|
|
|
|
|
clear the ``prefetch_related()`` cache.
|
|
|
|
|
|
2016-08-08 17:38:10 +08:00
|
|
|
|
* To prevent possible loss of saved settings,
|
|
|
|
|
:func:`~django.test.utils.setup_test_environment` now raises an exception if
|
|
|
|
|
called a second time before calling
|
|
|
|
|
:func:`~django.test.utils.teardown_test_environment`.
|
|
|
|
|
|
2016-08-19 21:37:37 +08:00
|
|
|
|
* The undocumented ``DateTimeAwareJSONEncoder`` alias for
|
|
|
|
|
:class:`~django.core.serializers.json.DjangoJSONEncoder` (renamed in Django
|
|
|
|
|
1.0) is removed.
|
|
|
|
|
|
2016-09-03 21:06:33 +08:00
|
|
|
|
* The :class:`cached template loader <django.template.loaders.cached.Loader>`
|
2018-01-11 19:48:29 +08:00
|
|
|
|
is now enabled if :setting:`OPTIONS['loaders'] <TEMPLATES-OPTIONS>` isn't
|
|
|
|
|
specified and :setting:`OPTIONS['debug'] <TEMPLATES-OPTIONS>` is ``False``
|
|
|
|
|
(the latter option defaults to the value of :setting:`DEBUG`). This could
|
2016-09-03 21:06:33 +08:00
|
|
|
|
be backwards-incompatible if you have some :ref:`template tags that aren't
|
|
|
|
|
thread safe <template_tag_thread_safety>`.
|
|
|
|
|
|
2015-10-02 22:46:29 +08:00
|
|
|
|
* The prompt for stale content type deletion no longer occurs after running the
|
|
|
|
|
``migrate`` command. Use the new :djadmin:`remove_stale_contenttypes` command
|
|
|
|
|
instead.
|
|
|
|
|
|
2016-09-08 23:58:42 +08:00
|
|
|
|
* The admin's widget for ``IntegerField`` uses ``type="number"`` rather than
|
|
|
|
|
``type="text"``.
|
|
|
|
|
|
2016-09-13 11:26:24 +08:00
|
|
|
|
* Conditional HTTP headers are now parsed and compared according to the
|
|
|
|
|
:rfc:`7232` Conditional Requests specification rather than the older
|
|
|
|
|
:rfc:`2616`.
|
2016-09-01 21:32:20 +08:00
|
|
|
|
|
2016-09-15 16:10:21 +08:00
|
|
|
|
* :func:`~django.utils.cache.patch_response_headers` no longer adds a
|
|
|
|
|
``Last-Modified`` header. According to the :rfc:`7234#section-4.2.2`, this
|
|
|
|
|
header is useless alongside other caching headers that provide an explicit
|
|
|
|
|
expiration time, e.g. ``Expires`` or ``Cache-Control``.
|
|
|
|
|
:class:`~django.middleware.cache.UpdateCacheMiddleware` and
|
|
|
|
|
:func:`~django.utils.cache.add_never_cache_headers` call
|
|
|
|
|
``patch_response_headers()`` and therefore are also affected by this change.
|
|
|
|
|
|
2016-04-15 01:10:55 +08:00
|
|
|
|
* In the admin templates, ``<p class="help">`` is replaced with a ``<div>`` tag
|
|
|
|
|
to allow including lists inside help text.
|
|
|
|
|
|
2016-11-05 19:39:46 +08:00
|
|
|
|
* :class:`~django.middleware.http.ConditionalGetMiddleware` no longer sets the
|
2021-07-23 14:48:16 +08:00
|
|
|
|
``Date`` header as web servers set that header. It also no longer sets the
|
2016-11-05 19:39:46 +08:00
|
|
|
|
``Content-Length`` header as this is now done by
|
|
|
|
|
:class:`~django.middleware.common.CommonMiddleware`.
|
2016-10-14 20:02:19 +08:00
|
|
|
|
|
2017-11-08 23:02:30 +08:00
|
|
|
|
If you have a middleware that modifies a response's content and appears
|
|
|
|
|
before ``CommonMiddleware`` in the ``MIDDLEWARE`` or ``MIDDLEWARE_CLASSES``
|
|
|
|
|
settings, you must reorder your middleware so that responses aren't modified
|
|
|
|
|
after ``Content-Length`` is set, or have the response modifying middleware
|
|
|
|
|
reset the ``Content-Length`` header.
|
|
|
|
|
|
2016-10-01 03:08:35 +08:00
|
|
|
|
* :meth:`~django.apps.AppConfig.get_model` and
|
|
|
|
|
:meth:`~django.apps.AppConfig.get_models` now raise
|
|
|
|
|
:exc:`~django.core.exceptions.AppRegistryNotReady` if they're called before
|
|
|
|
|
models of all applications have been loaded. Previously they only required
|
|
|
|
|
the target application's models to be loaded and thus could return models
|
2016-05-03 18:21:54 +08:00
|
|
|
|
without all their relations set up. If you need the old behavior of
|
|
|
|
|
``get_model()``, set the ``require_ready`` argument to ``False``.
|
2016-10-01 03:08:35 +08:00
|
|
|
|
|
2016-11-08 03:54:21 +08:00
|
|
|
|
* The unused ``BaseCommand.can_import_settings`` attribute is removed.
|
|
|
|
|
|
2016-11-30 08:01:12 +08:00
|
|
|
|
* The undocumented ``django.utils.functional.lazy_property`` is removed.
|
|
|
|
|
|
2016-11-16 21:22:38 +08:00
|
|
|
|
* For consistency with non-multipart requests, ``MultiPartParser.parse()`` now
|
|
|
|
|
leaves ``request.POST`` immutable. If you're modifying that ``QueryDict``,
|
|
|
|
|
you must now first copy it, e.g. ``request.POST.copy()``.
|
|
|
|
|
|
2016-12-30 01:45:25 +08:00
|
|
|
|
* Support for ``cx_Oracle`` < 5.2 is removed.
|
|
|
|
|
|
2017-01-10 01:02:43 +08:00
|
|
|
|
* Support for IPython < 1.0 is removed from the ``shell`` command.
|
|
|
|
|
|
2017-05-07 02:45:10 +08:00
|
|
|
|
* The signature of private API ``Widget.build_attrs()`` changed from
|
|
|
|
|
``extra_attrs=None, **kwargs`` to ``base_attrs, extra_attrs=None``.
|
|
|
|
|
|
2017-05-07 01:14:15 +08:00
|
|
|
|
* File-like objects (e.g., :class:`~io.StringIO` and :class:`~io.BytesIO`)
|
|
|
|
|
uploaded to an :class:`~django.db.models.ImageField` using the test client
|
|
|
|
|
now require a ``name`` attribute with a value that passes the
|
|
|
|
|
:data:`~django.core.validators.validate_image_file_extension` validator.
|
|
|
|
|
See the note in :meth:`.Client.post`.
|
|
|
|
|
|
2018-08-04 22:24:22 +08:00
|
|
|
|
* :class:`~django.db.models.FileField` now moves rather than copies the file
|
|
|
|
|
it receives. With the default file upload settings, files larger than
|
|
|
|
|
:setting:`FILE_UPLOAD_MAX_MEMORY_SIZE` now have the same permissions as
|
|
|
|
|
temporary files (often ``0o600``) rather than the system's standard umask
|
|
|
|
|
(often ``0o6644``). Set the :setting:`FILE_UPLOAD_PERMISSIONS` if you need
|
|
|
|
|
the same permission regardless of file size.
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
.. _deprecated-features-1.11:
|
|
|
|
|
|
|
|
|
|
Features deprecated in 1.11
|
|
|
|
|
===========================
|
|
|
|
|
|
2016-10-05 02:39:49 +08:00
|
|
|
|
``models.permalink()`` decorator
|
|
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
|
|
Use :func:`django.urls.reverse` instead. For example::
|
|
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
|
|
2023-03-01 03:53:28 +08:00
|
|
|
|
|
2016-10-05 02:39:49 +08:00
|
|
|
|
class MyModel(models.Model):
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
@models.permalink
|
|
|
|
|
def url(self):
|
|
|
|
|
return ("guitarist_detail", [self.slug])
|
|
|
|
|
|
|
|
|
|
becomes::
|
|
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
|
from django.urls import reverse
|
|
|
|
|
|
2023-03-01 03:53:28 +08:00
|
|
|
|
|
2016-10-05 02:39:49 +08:00
|
|
|
|
class MyModel(models.Model):
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
def url(self):
|
|
|
|
|
return reverse("guitarist_detail", args=[self.slug])
|
|
|
|
|
|
2016-05-20 10:28:24 +08:00
|
|
|
|
Miscellaneous
|
|
|
|
|
-------------
|
|
|
|
|
|
2016-05-15 23:28:00 +08:00
|
|
|
|
* ``contrib.auth``’s ``login()`` and ``logout()`` function-based views are
|
|
|
|
|
deprecated in favor of new class-based views
|
|
|
|
|
:class:`~django.contrib.auth.views.LoginView` and
|
|
|
|
|
:class:`~django.contrib.auth.views.LogoutView`.
|
2013-04-10 05:31:58 +08:00
|
|
|
|
|
2016-07-22 22:43:54 +08:00
|
|
|
|
* The unused ``extra_context`` parameter of
|
|
|
|
|
``contrib.auth.views.logout_then_login()`` is deprecated.
|
|
|
|
|
|
2013-04-10 05:31:58 +08:00
|
|
|
|
* ``contrib.auth``’s ``password_change()``, ``password_change_done()``,
|
|
|
|
|
``password_reset()``, ``password_reset_done()``, ``password_reset_confirm()``,
|
|
|
|
|
and ``password_reset_complete()`` function-based views are deprecated in favor
|
|
|
|
|
of new class-based views
|
|
|
|
|
:class:`~django.contrib.auth.views.PasswordChangeView`,
|
|
|
|
|
:class:`~django.contrib.auth.views.PasswordChangeDoneView`,
|
|
|
|
|
:class:`~django.contrib.auth.views.PasswordResetView`,
|
|
|
|
|
:class:`~django.contrib.auth.views.PasswordResetDoneView`,
|
|
|
|
|
:class:`~django.contrib.auth.views.PasswordResetConfirmView`, and
|
|
|
|
|
:class:`~django.contrib.auth.views.PasswordResetCompleteView`.
|
2016-07-03 06:20:14 +08:00
|
|
|
|
|
|
|
|
|
* ``django.test.runner.setup_databases()`` is moved to
|
|
|
|
|
:func:`django.test.utils.setup_databases`. The old location is deprecated.
|
2016-08-16 18:07:03 +08:00
|
|
|
|
|
|
|
|
|
* ``django.utils.translation.string_concat()`` is deprecated in
|
|
|
|
|
favor of :func:`django.utils.text.format_lazy`. ``string_concat(*strings)``
|
|
|
|
|
can be replaced by ``format_lazy('{}' * len(strings), *strings)``.
|
2016-08-31 20:12:40 +08:00
|
|
|
|
|
|
|
|
|
* For the ``PyLibMCCache`` cache backend, passing ``pylibmc`` behavior settings
|
|
|
|
|
as top-level attributes of ``OPTIONS`` is deprecated. Set them under a
|
|
|
|
|
``behaviors`` key within ``OPTIONS`` instead.
|
2016-07-27 11:45:07 +08:00
|
|
|
|
|
|
|
|
|
* The ``host`` parameter of ``django.utils.http.is_safe_url()`` is deprecated
|
|
|
|
|
in favor of the new ``allowed_hosts`` parameter.
|
2016-09-09 09:24:22 +08:00
|
|
|
|
|
|
|
|
|
* Silencing exceptions raised while rendering the
|
|
|
|
|
:ttag:`{% include %} <include>` template tag is deprecated as the behavior is
|
|
|
|
|
often more confusing than helpful. In Django 2.1, the exception will be
|
|
|
|
|
raised.
|
2016-08-20 18:14:02 +08:00
|
|
|
|
|
|
|
|
|
* ``DatabaseIntrospection.get_indexes()`` is deprecated in favor of
|
|
|
|
|
``DatabaseIntrospection.get_constraints()``.
|
2016-07-11 22:40:39 +08:00
|
|
|
|
|
|
|
|
|
* :func:`~django.contrib.auth.authenticate` now passes a ``request`` argument
|
|
|
|
|
to the ``authenticate()`` method of authentication backends. Support for
|
2017-02-24 23:15:41 +08:00
|
|
|
|
methods that don't accept ``request`` as the first positional argument will
|
|
|
|
|
be removed in Django 2.1.
|
2016-04-03 18:15:10 +08:00
|
|
|
|
|
|
|
|
|
* The ``USE_ETAGS`` setting is deprecated in favor of
|
|
|
|
|
:class:`~django.middleware.http.ConditionalGetMiddleware` which now adds the
|
|
|
|
|
``ETag`` header to responses regardless of the setting. ``CommonMiddleware``
|
|
|
|
|
and ``django.utils.cache.patch_response_headers()`` will no longer set ETags
|
|
|
|
|
when the deprecation ends.
|
2016-11-24 06:04:10 +08:00
|
|
|
|
|
|
|
|
|
* ``Model._meta.has_auto_field`` is deprecated in favor of checking if
|
|
|
|
|
``Model._meta.auto_field is not None``.
|
2016-12-28 04:59:13 +08:00
|
|
|
|
|
|
|
|
|
* Using regular expression groups with ``iLmsu#`` in ``url()`` is deprecated.
|
|
|
|
|
The only group that's useful is ``(?i)`` for case-insensitive URLs, however,
|
|
|
|
|
case-insensitive URLs aren't a good practice because they create multiple
|
|
|
|
|
entries for search engines, for example. An alternative solution could be to
|
|
|
|
|
create a :data:`~django.conf.urls.handler404` that looks for uppercase
|
|
|
|
|
characters in the URL and redirects to a lowercase equivalent.
|
2016-12-28 06:00:56 +08:00
|
|
|
|
|
|
|
|
|
* The ``renderer`` argument is added to the :meth:`Widget.render()
|
|
|
|
|
<django.forms.Widget.render>` method. Methods that don't accept that argument
|
|
|
|
|
will work through a deprecation period.
|