3.1.txt 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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. * :class:`~django.contrib.postgres.search.SearchQuery` now supports
  70. ``'websearch'`` search type on PostgreSQL 11+.
  71. :mod:`django.contrib.redirects`
  72. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  73. * ...
  74. :mod:`django.contrib.sessions`
  75. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  76. * The :setting:`SESSION_COOKIE_SAMESITE` setting now allows ``'None'`` (string)
  77. value to explicitly state that the cookie is sent with all same-site and
  78. cross-site requests.
  79. :mod:`django.contrib.sitemaps`
  80. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  81. * ...
  82. :mod:`django.contrib.sites`
  83. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  84. * ...
  85. :mod:`django.contrib.staticfiles`
  86. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  87. * The :setting:`STATICFILES_DIRS` setting now supports :class:`pathlib.Path`.
  88. :mod:`django.contrib.syndication`
  89. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  90. * ...
  91. Cache
  92. ~~~~~
  93. * The :func:`~django.views.decorators.cache.cache_control` decorator and
  94. :func:`~django.utils.cache.patch_cache_control` method now support multiple
  95. field names in the ``no-cache`` directive for the ``Cache-Control`` header,
  96. according to :rfc:`7234#section-5.2.2.2`.
  97. * :meth:`~django.core.caches.cache.delete` now returns ``True`` if the key was
  98. successfully deleted, ``False`` otherwise.
  99. CSRF
  100. ~~~~
  101. * The :setting:`CSRF_COOKIE_SAMESITE` setting now allows ``'None'`` (string)
  102. value to explicitly state that the cookie is sent with all same-site and
  103. cross-site requests.
  104. Email
  105. ~~~~~
  106. * The :setting:`EMAIL_FILE_PATH` setting, used by the :ref:`file email backend
  107. <topic-email-file-backend>`, now supports :class:`pathlib.Path`.
  108. File Storage
  109. ~~~~~~~~~~~~
  110. * ``FileSystemStorage.save()`` method now supports :class:`pathlib.Path`.
  111. File Uploads
  112. ~~~~~~~~~~~~
  113. * ...
  114. Forms
  115. ~~~~~
  116. * :class:`~django.forms.ModelChoiceIterator`, used by
  117. :class:`~django.forms.ModelChoiceField` and
  118. :class:`~django.forms.ModelMultipleChoiceField`, now uses
  119. :class:`~django.forms.ModelChoiceIteratorValue` that can be used by widgets
  120. to access model instances. See :ref:`iterating-relationship-choices` for
  121. details.
  122. Generic Views
  123. ~~~~~~~~~~~~~
  124. * ...
  125. Internationalization
  126. ~~~~~~~~~~~~~~~~~~~~
  127. * The :setting:`LANGUAGE_COOKIE_SAMESITE` setting now allows ``'None'``
  128. (string) value to explicitly state that the cookie is sent with all same-site
  129. and cross-site requests.
  130. * Added support and translations for the Algerian Arabic language.
  131. Logging
  132. ~~~~~~~
  133. * ...
  134. Management Commands
  135. ~~~~~~~~~~~~~~~~~~~
  136. * ...
  137. Migrations
  138. ~~~~~~~~~~
  139. * Migrations are now loaded also from directories without ``__init__.py``
  140. files.
  141. Models
  142. ~~~~~~
  143. * The new :class:`~django.db.models.functions.ExtractIsoWeekDay` function
  144. extracts ISO-8601 week days from :class:`~django.db.models.DateField` and
  145. :class:`~django.db.models.DateTimeField`, and the new :lookup:`iso_week_day`
  146. lookup allows querying by an ISO-8601 day of week.
  147. * :meth:`.QuerySet.explain` now supports:
  148. * ``TREE`` format on MySQL 8.0.16+,
  149. * ``analyze`` option on MySQL 8.0.18+ and MariaDB.
  150. * Added :class:`~django.db.models.PositiveBigIntegerField` which acts much like
  151. a :class:`~django.db.models.PositiveIntegerField` except that it only allows
  152. values under a certain (database-dependent) limit. Values from ``0`` to
  153. ``9223372036854775807`` are safe in all databases supported by Django.
  154. * The new :class:`~django.db.models.RESTRICT` option for
  155. :attr:`~django.db.models.ForeignKey.on_delete` argument of ``ForeignKey`` and
  156. ``OneToOneField`` emulates the behavior of the SQL constraint ``ON DELETE
  157. RESTRICT``.
  158. * :attr:`.CheckConstraint.check` now supports boolean expressions.
  159. * The :meth:`.RelatedManager.add`, :meth:`~.RelatedManager.create`, and
  160. :meth:`~.RelatedManager.set` methods now accept callables as values in the
  161. ``through_defaults`` argument.
  162. Pagination
  163. ~~~~~~~~~~
  164. * :class:`~django.core.paginator.Paginator` can now be iterated over to yield
  165. its pages.
  166. Requests and Responses
  167. ~~~~~~~~~~~~~~~~~~~~~~
  168. * If :setting:`ALLOWED_HOSTS` is empty and ``DEBUG=True``, subdomains of
  169. localhost are now allowed in the ``Host`` header, e.g. ``static.localhost``.
  170. * :meth:`.HttpResponse.set_cookie` and :meth:`.HttpResponse.set_signed_cookie`
  171. now allow using ``samesite='None'`` (string) to explicitly state that the
  172. cookie is sent with all same-site and cross-site requests.
  173. Serialization
  174. ~~~~~~~~~~~~~
  175. * ...
  176. Signals
  177. ~~~~~~~
  178. * ...
  179. Templates
  180. ~~~~~~~~~
  181. * The renamed :ttag:`translate` and :ttag:`blocktranslate` template tags are
  182. introduced for internationalization in template code. The older :ttag:`trans`
  183. and :ttag:`blocktrans` template tags aliases continue to work, and will be
  184. retained for the foreseeable future.
  185. Tests
  186. ~~~~~
  187. * :class:`~django.test.SimpleTestCase` now implements the ``debug()`` method to
  188. allow running a test without collecting the result and catching exceptions.
  189. This can be used to support running tests under a debugger.
  190. * The new :setting:`MIGRATE <TEST_MIGRATE>` test database setting allows
  191. disabling of migrations during a test database creation.
  192. * Django test runner now supports a :option:`test --buffer` option to discard
  193. output for passing tests.
  194. URLs
  195. ~~~~
  196. * ...
  197. Utilities
  198. ~~~~~~~~~
  199. * :func:`~django.utils.encoding.filepath_to_uri` now supports
  200. :class:`pathlib.Path`.
  201. * :func:`~django.utils.dateparse.parse_duration` now supports comma separators
  202. for decimal fractions in the ISO 8601 format.
  203. * :func:`~django.utils.dateparse.parse_datetime`,
  204. :func:`~django.utils.dateparse.parse_duration`, and
  205. :func:`~django.utils.dateparse.parse_time` now support comma separators for
  206. milliseconds.
  207. Validators
  208. ~~~~~~~~~~
  209. * ...
  210. Miscellaneous
  211. ~~~~~~~~~~~~~
  212. * The SQLite backend now supports :class:`pathlib.Path` for the ``NAME``
  213. setting.
  214. * The ``settings.py`` generated by the :djadmin:`startproject` command now uses
  215. :class:`pathlib.Path` instead of :mod:`os.path` for building filesystem
  216. paths.
  217. * The :setting:`TIME_ZONE <DATABASE-TIME_ZONE>` setting is now allowed on
  218. databases that support time zones.
  219. .. _backwards-incompatible-3.1:
  220. Backwards incompatible changes in 3.1
  221. =====================================
  222. Database backend API
  223. --------------------
  224. This section describes changes that may be needed in third-party database
  225. backends.
  226. * ``DatabaseOperations.fetch_returned_insert_columns()`` now requires an
  227. additional ``returning_params`` argument.
  228. * ``connection.timezone`` property is now ``'UTC'`` by default, or the
  229. :setting:`TIME_ZONE <DATABASE-TIME_ZONE>` when :setting:`USE_TZ` is ``True``
  230. on databases that support time zones. Previously, it was ``None`` on
  231. databases that support time zones.
  232. Dropped support for MariaDB 10.1
  233. --------------------------------
  234. Upstream support for MariaDB 10.1 ends in October 2020. Django 3.1 supports
  235. MariaDB 10.2 and higher.
  236. Miscellaneous
  237. -------------
  238. * The cache keys used by :ttag:`cache` and generated by
  239. :func:`~django.core.cache.utils.make_template_fragment_key` are different
  240. from the keys generated by older versions of Django. After upgrading to
  241. Django 3.1, the first request to any previously cached template fragment will
  242. be a cache miss.
  243. * The compatibility imports of ``django.core.exceptions.EmptyResultSet`` in
  244. ``django.db.models.query``, ``django.db.models.sql``, and
  245. ``django.db.models.sql.datastructures`` are removed.
  246. * The compatibility import of ``django.core.exceptions.FieldDoesNotExist`` in
  247. ``django.db.models.fields`` is removed.
  248. * The compatibility imports of ``django.forms.utils.pretty_name()`` and
  249. ``django.forms.boundfield.BoundField`` in ``django.forms.forms`` are removed.
  250. * The compatibility imports of ``Context``, ``ContextPopException``, and
  251. ``RequestContext`` in ``django.template.base`` are removed.
  252. * The compatibility import of
  253. ``django.contrib.admin.helpers.ACTION_CHECKBOX_NAME`` in
  254. ``django.contrib.admin`` is removed.
  255. * The :setting:`STATIC_URL` and :setting:`MEDIA_URL` settings set to relative
  256. paths are now prefixed by the server-provided value of ``SCRIPT_NAME`` (or
  257. ``/`` if not set). This change should not affect settings set to valid URLs
  258. or absolute paths.
  259. * :class:`~django.middleware.http.ConditionalGetMiddleware` no longer adds the
  260. ``ETag`` header to responses with an empty
  261. :attr:`~django.http.HttpResponse.content`.
  262. * ``django.utils.decorators.classproperty()`` decorator is moved to
  263. ``django.utils.functional.classproperty()``.
  264. * :tfilter:`floatformat` template filter now outputs (positive) ``0`` for
  265. negative numbers which round to zero.
  266. * :attr:`Meta.ordering <django.db.models.Options.ordering>` and
  267. :attr:`Meta.unique_together <django.db.models.Options.unique_together>`
  268. options on models in ``django.contrib`` modules that were formerly tuples are
  269. now lists.
  270. * The admin calendar widget now handles two-digit years according to the Open
  271. Group Specification, i.e. values between 69 and 99 are mapped to the previous
  272. century, and values between 0 and 68 are mapped to the current century.
  273. .. _deprecated-features-3.1:
  274. Features deprecated in 3.1
  275. ==========================
  276. Miscellaneous
  277. -------------
  278. * ``PASSWORD_RESET_TIMEOUT_DAYS`` setting is deprecated in favor of
  279. :setting:`PASSWORD_RESET_TIMEOUT`.
  280. * The undocumented usage of the :lookup:`isnull` lookup with non-boolean values
  281. as the right-hand side is deprecated, use ``True`` or ``False`` instead.
  282. * The barely documented ``django.db.models.query_utils.InvalidQuery`` exception
  283. class is deprecated in favor of
  284. :class:`~django.core.exceptions.FieldDoesNotExist` and
  285. :class:`~django.core.exceptions.FieldError`.
  286. * The ``django-admin.py`` entry point is deprecated in favor of
  287. ``django-admin``.
  288. .. _removed-features-3.1:
  289. Features removed in 3.1
  290. =======================
  291. These features have reached the end of their deprecation cycle and are removed
  292. in Django 3.1.
  293. See :ref:`deprecated-features-2.2` for details on these changes, including how
  294. to remove usage of these features.
  295. * ``django.utils.timezone.FixedOffset`` is removed.
  296. * ``django.core.paginator.QuerySetPaginator`` is removed.
  297. * A model's ``Meta.ordering`` doesn't affect ``GROUP BY`` queries.
  298. * ``django.contrib.postgres.fields.FloatRangeField`` and
  299. ``django.contrib.postgres.forms.FloatRangeField`` are removed.
  300. * The ``FILE_CHARSET`` setting is removed.
  301. * ``django.contrib.staticfiles.storage.CachedStaticFilesStorage`` is removed.
  302. * The ``RemoteUserBackend.configure_user()`` method requires ``request`` as the
  303. first positional argument.
  304. * Support for ``SimpleTestCase.allow_database_queries`` and
  305. ``TransactionTestCase.multi_db`` is removed.