3.1.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. ============================================
  2. Django 3.1 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. *Expected August 2020*
  5. Welcome to Django 3.1!
  6. These release notes cover the :ref:`new features <whats-new-3.1>`, as well as
  7. some :ref:`backwards incompatible changes <backwards-incompatible-3.1>` you'll
  8. want to be aware of when upgrading from Django 3.0 or earlier. We've
  9. :ref:`dropped some features<removed-features-3.1>` that have reached the end of
  10. their deprecation cycle, and we've :ref:`begun the deprecation process for
  11. some features <deprecated-features-3.1>`.
  12. See the :doc:`/howto/upgrade-version` guide if you're updating an existing
  13. project.
  14. Python compatibility
  15. ====================
  16. Django 3.1 supports Python 3.6, 3.7, and 3.8. We **highly recommend** and only
  17. officially support the latest release of each series.
  18. .. _whats-new-3.1:
  19. What's new in Django 3.1
  20. ========================
  21. Minor features
  22. --------------
  23. :mod:`django.contrib.admin`
  24. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  25. * ...
  26. :mod:`django.contrib.admindocs`
  27. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. * ...
  29. :mod:`django.contrib.auth`
  30. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  31. * The default iteration count for the PBKDF2 password hasher is increased from
  32. 180,000 to 216,000.
  33. * Added the :setting:`PASSWORD_RESET_TIMEOUT` setting to define the minimum
  34. number of seconds a password reset link is valid for. This is encouraged
  35. instead of deprecated ``PASSWORD_RESET_TIMEOUT_DAYS``, which will be removed
  36. in Django 4.0.
  37. :mod:`django.contrib.contenttypes`
  38. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  39. * ...
  40. :mod:`django.contrib.gis`
  41. ~~~~~~~~~~~~~~~~~~~~~~~~~
  42. * :lookup:`relate` lookup is now supported on MariaDB.
  43. * Added the :attr:`.LinearRing.is_counterclockwise` property.
  44. * :class:`~django.contrib.gis.db.models.functions.AsGeoJSON` is now supported
  45. on Oracle.
  46. * Added the :class:`~django.contrib.gis.db.models.functions.AsWKB` and
  47. :class:`~django.contrib.gis.db.models.functions.AsWKT` functions.
  48. :mod:`django.contrib.messages`
  49. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  50. * ...
  51. :mod:`django.contrib.postgres`
  52. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  53. * The new :class:`~django.contrib.postgres.indexes.BloomIndex` class allows
  54. creating ``bloom`` indexes in the database. The new
  55. :class:`~django.contrib.postgres.operations.BloomExtension` migration
  56. operation installs the ``bloom`` extension to add support for this index.
  57. * :meth:`~django.db.models.Model.get_FOO_display` now supports
  58. :class:`~django.contrib.postgres.fields.ArrayField` and
  59. :class:`~django.contrib.postgres.fields.RangeField`.
  60. * The new :lookup:`rangefield.lower_inc`, :lookup:`rangefield.lower_inf`,
  61. :lookup:`rangefield.upper_inc`, and :lookup:`rangefield.upper_inf` allows
  62. querying :class:`~django.contrib.postgres.fields.RangeField` by a bound type.
  63. * :lookup:`rangefield.contained_by` now supports
  64. :class:`~django.db.models.SmallAutoField`,
  65. :class:`~django.db.models.AutoField`,
  66. :class:`~django.db.models.BigAutoField`,
  67. :class:`~django.db.models.SmallIntegerField`, and
  68. :class:`~django.db.models.DecimalField`.
  69. :mod:`django.contrib.redirects`
  70. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  71. * ...
  72. :mod:`django.contrib.sessions`
  73. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74. * ...
  75. :mod:`django.contrib.sitemaps`
  76. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77. * ...
  78. :mod:`django.contrib.sites`
  79. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80. * ...
  81. :mod:`django.contrib.staticfiles`
  82. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  83. * The :setting:`STATICFILES_DIRS` setting now supports :class:`pathlib.Path`.
  84. :mod:`django.contrib.syndication`
  85. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  86. * ...
  87. Cache
  88. ~~~~~
  89. * The :func:`~django.views.decorators.cache.cache_control` decorator and
  90. :func:`~django.utils.cache.patch_cache_control` method now support multiple
  91. field names in the ``no-cache`` directive for the ``Cache-Control`` header,
  92. according to :rfc:`7234#section-5.2.2.2`.
  93. * :meth:`~django.core.caches.cache.delete` now returns ``True`` if the key was
  94. successfully deleted, ``False`` otherwise.
  95. CSRF
  96. ~~~~
  97. * ...
  98. Email
  99. ~~~~~
  100. * The :setting:`EMAIL_FILE_PATH` setting, used by the :ref:`file email backend
  101. <topic-email-file-backend>`, now supports :class:`pathlib.Path`.
  102. File Storage
  103. ~~~~~~~~~~~~
  104. * ``FileSystemStorage.save()`` method now supports :class:`pathlib.Path`.
  105. File Uploads
  106. ~~~~~~~~~~~~
  107. * ...
  108. Forms
  109. ~~~~~
  110. * ...
  111. Generic Views
  112. ~~~~~~~~~~~~~
  113. * ...
  114. Internationalization
  115. ~~~~~~~~~~~~~~~~~~~~
  116. * ...
  117. Logging
  118. ~~~~~~~
  119. * ...
  120. Management Commands
  121. ~~~~~~~~~~~~~~~~~~~
  122. * ...
  123. Migrations
  124. ~~~~~~~~~~
  125. * Migrations are now loaded also from directories without ``__init__.py``
  126. files.
  127. Models
  128. ~~~~~~
  129. * The new :class:`~django.db.models.functions.ExtractIsoWeekDay` function
  130. extracts ISO-8601 week days from :class:`~django.db.models.DateField` and
  131. :class:`~django.db.models.DateTimeField`, and the new :lookup:`iso_week_day`
  132. lookup allows querying by an ISO-8601 day of week.
  133. * :meth:`.QuerySet.explain` now supports:
  134. * ``TREE`` format on MySQL 8.0.16+,
  135. * ``analyze`` option on MySQL 8.0.18+ and MariaDB.
  136. * Added :class:`~django.db.models.PositiveBigIntegerField` which acts much like
  137. a :class:`~django.db.models.PositiveIntegerField` except that it only allows
  138. values under a certain (database-dependent) limit. Values from ``0`` to
  139. ``9223372036854775807`` are safe in all databases supported by Django.
  140. * The new :class:`~django.db.models.RESTRICT` option for
  141. :attr:`~django.db.models.ForeignKey.on_delete` argument of ``ForeignKey`` and
  142. ``OneToOneField`` emulates the behavior of the SQL constraint ``ON DELETE
  143. RESTRICT``.
  144. * :attr:`.CheckConstraint.check` now supports boolean expressions.
  145. * The :meth:`.RelatedManager.add`, :meth:`~.RelatedManager.create`, and
  146. :meth:`~.RelatedManager.set` methods now accept callables as values in the
  147. ``through_defaults`` argument.
  148. Pagination
  149. ~~~~~~~~~~
  150. * :class:`~django.core.paginator.Paginator` can now be iterated over to yield
  151. its pages.
  152. Requests and Responses
  153. ~~~~~~~~~~~~~~~~~~~~~~
  154. * If :setting:`ALLOWED_HOSTS` is empty and ``DEBUG=True``, subdomains of
  155. localhost are now allowed in the ``Host`` header, e.g. ``static.localhost``.
  156. Serialization
  157. ~~~~~~~~~~~~~
  158. * ...
  159. Signals
  160. ~~~~~~~
  161. * ...
  162. Templates
  163. ~~~~~~~~~
  164. * ...
  165. Tests
  166. ~~~~~
  167. * :class:`~django.test.SimpleTestCase` now implements the ``debug()`` method to
  168. allow running a test without collecting the result and catching exceptions.
  169. This can be used to support running tests under a debugger.
  170. * The new :setting:`MIGRATE <TEST_MIGRATE>` test database setting allows
  171. disabling of migrations during a test database creation.
  172. URLs
  173. ~~~~
  174. * ...
  175. Utilities
  176. ~~~~~~~~~
  177. * :func:`~django.utils.encoding.filepath_to_uri` now supports
  178. :class:`pathlib.Path`.
  179. * :func:`~django.utils.dateparse.parse_duration` now supports comma separators
  180. for decimal fractions in the ISO 8601 format.
  181. * :func:`~django.utils.dateparse.parse_datetime`,
  182. :func:`~django.utils.dateparse.parse_duration`, and
  183. :func:`~django.utils.dateparse.parse_time` now support comma separators for
  184. milliseconds.
  185. Validators
  186. ~~~~~~~~~~
  187. * ...
  188. Miscellaneous
  189. ~~~~~~~~~~~~~
  190. * The SQLite backend now supports :class:`pathlib.Path` for the ``NAME``
  191. setting.
  192. * The ``settings.py`` generated by the :djadmin:`startproject` command now uses
  193. :class:`pathlib.Path` instead of :mod:`os.path` for building filesystem
  194. paths.
  195. * The :setting:`TIME_ZONE <DATABASE-TIME_ZONE>` setting is now allowed on
  196. databases that support time zones.
  197. .. _backwards-incompatible-3.1:
  198. Backwards incompatible changes in 3.1
  199. =====================================
  200. Database backend API
  201. --------------------
  202. This section describes changes that may be needed in third-party database
  203. backends.
  204. * ``DatabaseOperations.fetch_returned_insert_columns()`` now requires an
  205. additional ``returning_params`` argument.
  206. * ``connection.timezone`` property is now ``'UTC'`` by default, or the
  207. :setting:`TIME_ZONE <DATABASE-TIME_ZONE>` when :setting:`USE_TZ` is ``True``
  208. on databases that support time zones. Previously, it was ``None`` on
  209. databases that support time zones.
  210. Dropped support for MariaDB 10.1
  211. --------------------------------
  212. Upstream support for MariaDB 10.1 ends in October 2020. Django 3.1 supports
  213. MariaDB 10.2 and higher.
  214. Miscellaneous
  215. -------------
  216. * The cache keys used by :ttag:`cache` and generated by
  217. :func:`~django.core.cache.utils.make_template_fragment_key` are different
  218. from the keys generated by older versions of Django. After upgrading to
  219. Django 3.1, the first request to any previously cached template fragment will
  220. be a cache miss.
  221. * The compatibility imports of ``django.core.exceptions.EmptyResultSet`` in
  222. ``django.db.models.query``, ``django.db.models.sql``, and
  223. ``django.db.models.sql.datastructures`` are removed.
  224. * The compatibility import of ``django.core.exceptions.FieldDoesNotExist`` in
  225. ``django.db.models.fields`` is removed.
  226. * The compatibility imports of ``django.forms.utils.pretty_name()`` and
  227. ``django.forms.boundfield.BoundField`` in ``django.forms.forms`` are removed.
  228. * The compatibility imports of ``Context``, ``ContextPopException``, and
  229. ``RequestContext`` in ``django.template.base`` are removed.
  230. * The compatibility import of
  231. ``django.contrib.admin.helpers.ACTION_CHECKBOX_NAME`` in
  232. ``django.contrib.admin`` is removed.
  233. * The :setting:`STATIC_URL` and :setting:`MEDIA_URL` settings set to relative
  234. paths are now prefixed by the server-provided value of ``SCRIPT_NAME`` (or
  235. ``/`` if not set). This change should not affect settings set to valid URLs
  236. or absolute paths.
  237. * :class:`~django.middleware.http.ConditionalGetMiddleware` no longer adds the
  238. ``ETag`` header to responses with an empty
  239. :attr:`~django.http.HttpResponse.content`.
  240. * ``django.utils.decorators.classproperty()`` decorator is moved to
  241. ``django.utils.functional.classproperty()``.
  242. * :tfilter:`floatformat` template filter now outputs (positive) ``0`` for
  243. negative numbers which round to zero.
  244. * :attr:`Meta.ordering <django.db.models.Options.ordering>` and
  245. :attr:`Meta.unique_together <django.db.models.Options.unique_together>`
  246. options on models in ``django.contrib`` modules that were formerly tuples are
  247. now lists.
  248. .. _deprecated-features-3.1:
  249. Features deprecated in 3.1
  250. ==========================
  251. Miscellaneous
  252. -------------
  253. * ``PASSWORD_RESET_TIMEOUT_DAYS`` setting is deprecated in favor of
  254. :setting:`PASSWORD_RESET_TIMEOUT`.
  255. * The undocumented usage of the :lookup:`isnull` lookup with non-boolean values
  256. as the right-hand side is deprecated, use ``True`` or ``False`` instead.
  257. * The barely documented ``django.db.models.query_utils.InvalidQuery`` exception
  258. class is deprecated in favor of
  259. :class:`~django.core.exceptions.FieldDoesNotExist` and
  260. :class:`~django.core.exceptions.FieldError`.
  261. * The ``django-admin.py`` entry point is deprecated in favor of
  262. ``django-admin``.
  263. .. _removed-features-3.1:
  264. Features removed in 3.1
  265. =======================
  266. These features have reached the end of their deprecation cycle and are removed
  267. in Django 3.1.
  268. See :ref:`deprecated-features-2.2` for details on these changes, including how
  269. to remove usage of these features.
  270. * ``django.utils.timezone.FixedOffset`` is removed.
  271. * ``django.core.paginator.QuerySetPaginator`` is removed.
  272. * A model's ``Meta.ordering`` doesn't affect ``GROUP BY`` queries.
  273. * ``django.contrib.postgres.fields.FloatRangeField`` and
  274. ``django.contrib.postgres.forms.FloatRangeField`` are removed.
  275. * The ``FILE_CHARSET`` setting is removed.
  276. * ``django.contrib.staticfiles.storage.CachedStaticFilesStorage`` is removed.
  277. * The ``RemoteUserBackend.configure_user()`` method requires ``request`` as the
  278. first positional argument.
  279. * Support for ``SimpleTestCase.allow_database_queries`` and
  280. ``TransactionTestCase.multi_db`` is removed.