3.1.txt 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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. :mod:`django.contrib.messages`
  47. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  48. * ...
  49. :mod:`django.contrib.postgres`
  50. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  51. * The new :class:`~django.contrib.postgres.indexes.BloomIndex` class allows
  52. creating ``bloom`` indexes in the database. The new
  53. :class:`~django.contrib.postgres.operations.BloomExtension` migration
  54. operation installs the ``bloom`` extension to add support for this index.
  55. * :meth:`~django.db.models.Model.get_FOO_display` now supports
  56. :class:`~django.contrib.postgres.fields.ArrayField` and
  57. :class:`~django.contrib.postgres.fields.RangeField`.
  58. * The new :lookup:`rangefield.lower_inc`, :lookup:`rangefield.lower_inf`,
  59. :lookup:`rangefield.upper_inc`, and :lookup:`rangefield.upper_inf` allows
  60. querying :class:`~django.contrib.postgres.fields.RangeField` by a bound type.
  61. :mod:`django.contrib.redirects`
  62. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  63. * ...
  64. :mod:`django.contrib.sessions`
  65. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  66. * ...
  67. :mod:`django.contrib.sitemaps`
  68. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  69. * ...
  70. :mod:`django.contrib.sites`
  71. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  72. * ...
  73. :mod:`django.contrib.staticfiles`
  74. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  75. * The :setting:`STATICFILES_DIRS` setting now supports :class:`pathlib.Path`.
  76. :mod:`django.contrib.syndication`
  77. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  78. * ...
  79. Cache
  80. ~~~~~
  81. * The :func:`~django.views.decorators.cache.cache_control` decorator and
  82. :func:`~django.utils.cache.patch_cache_control` method now support multiple
  83. field names in the ``no-cache`` directive for the ``Cache-Control`` header,
  84. according to :rfc:`7234#section-5.2.2.2`.
  85. * :meth:`~django.core.caches.cache.delete` now returns ``True`` if the key was
  86. successfully deleted, ``False`` otherwise.
  87. CSRF
  88. ~~~~
  89. * ...
  90. Email
  91. ~~~~~
  92. * The :setting:`EMAIL_FILE_PATH` setting, used by the :ref:`file email backend
  93. <topic-email-file-backend>`, now supports :class:`pathlib.Path`.
  94. File Storage
  95. ~~~~~~~~~~~~
  96. * ``FileSystemStorage.save()`` method now supports :class:`pathlib.Path`.
  97. File Uploads
  98. ~~~~~~~~~~~~
  99. * ...
  100. Forms
  101. ~~~~~
  102. * ...
  103. Generic Views
  104. ~~~~~~~~~~~~~
  105. * ...
  106. Internationalization
  107. ~~~~~~~~~~~~~~~~~~~~
  108. * ...
  109. Logging
  110. ~~~~~~~
  111. * ...
  112. Management Commands
  113. ~~~~~~~~~~~~~~~~~~~
  114. * ...
  115. Migrations
  116. ~~~~~~~~~~
  117. * Migrations are now loaded also from directories without ``__init__.py``
  118. files.
  119. Models
  120. ~~~~~~
  121. * The new :class:`~django.db.models.functions.ExtractIsoWeekDay` function
  122. extracts ISO-8601 week days from :class:`~django.db.models.DateField` and
  123. :class:`~django.db.models.DateTimeField`, and the new :lookup:`iso_week_day`
  124. lookup allows querying by an ISO-8601 day of week.
  125. * :meth:`.QuerySet.explain` now supports:
  126. * ``TREE`` format on MySQL 8.0.16+,
  127. * ``analyze`` option on MySQL 8.0.18+ and MariaDB.
  128. * Added :class:`~django.db.models.PositiveBigIntegerField` which acts much like
  129. a :class:`~django.db.models.PositiveIntegerField` except that it only allows
  130. values under a certain (database-dependent) limit. Values from ``0`` to
  131. ``9223372036854775807`` are safe in all databases supported by Django.
  132. Pagination
  133. ~~~~~~~~~~
  134. * :class:`~django.core.paginator.Paginator` can now be iterated over to yield
  135. its pages.
  136. Requests and Responses
  137. ~~~~~~~~~~~~~~~~~~~~~~
  138. * ...
  139. Serialization
  140. ~~~~~~~~~~~~~
  141. * ...
  142. Signals
  143. ~~~~~~~
  144. * ...
  145. Templates
  146. ~~~~~~~~~
  147. * ...
  148. Tests
  149. ~~~~~
  150. * :class:`~django.test.SimpleTestCase` now implements the ``debug()`` method to
  151. allow running a test without collecting the result and catching exceptions.
  152. This can be used to support running tests under a debugger.
  153. URLs
  154. ~~~~
  155. * ...
  156. Utilities
  157. ~~~~~~~~~
  158. * :func:`~django.utils.encoding.filepath_to_uri` now supports
  159. :class:`pathlib.Path`.
  160. Validators
  161. ~~~~~~~~~~
  162. * ...
  163. Miscellaneous
  164. ~~~~~~~~~~~~~
  165. * The SQLite backend now supports :class:`pathlib.Path` for the ``NAME``
  166. setting.
  167. * The ``settings.py`` generated by the :djadmin:`startproject` command now uses
  168. :class:`pathlib.Path` instead of :mod:`os.path` for building filesystem
  169. paths.
  170. .. _backwards-incompatible-3.1:
  171. Backwards incompatible changes in 3.1
  172. =====================================
  173. Database backend API
  174. --------------------
  175. This section describes changes that may be needed in third-party database
  176. backends.
  177. * ``DatabaseOperations.fetch_returned_insert_columns()`` now requires an
  178. additional ``returning_params`` argument.
  179. Dropped support for MariaDB 10.1
  180. --------------------------------
  181. Upstream support for MariaDB 10.1 ends in October 2020. Django 3.1 supports
  182. MariaDB 10.2 and higher.
  183. Miscellaneous
  184. -------------
  185. * The cache keys used by :ttag:`cache` and generated by
  186. :func:`~django.core.cache.utils.make_template_fragment_key` are different
  187. from the keys generated by older versions of Django. After upgrading to
  188. Django 3.1, the first request to any previously cached template fragment will
  189. be a cache miss.
  190. * The compatibility imports of ``django.core.exceptions.EmptyResultSet`` in
  191. ``django.db.models.query``, ``django.db.models.sql``, and
  192. ``django.db.models.sql.datastructures`` are removed.
  193. * The compatibility import of ``django.core.exceptions.FieldDoesNotExist`` in
  194. ``django.db.models.fields`` is removed.
  195. * The compatibility imports of ``django.forms.utils.pretty_name()`` and
  196. ``django.forms.boundfield.BoundField`` in ``django.forms.forms`` are removed.
  197. * The compatibility imports of ``Context``, ``ContextPopException``, and
  198. ``RequestContext`` in ``django.template.base`` are removed.
  199. * The compatibility import of
  200. ``django.contrib.admin.helpers.ACTION_CHECKBOX_NAME`` in
  201. ``django.contrib.admin`` is removed.
  202. * The :setting:`STATIC_URL` and :setting:`MEDIA_URL` settings set to relative
  203. paths are now prefixed by the server-provided value of ``SCRIPT_NAME`` (or
  204. ``/`` if not set). This change should not affect settings set to valid URLs
  205. or absolute paths.
  206. * :class:`~django.middleware.http.ConditionalGetMiddleware` no longer adds the
  207. ``ETag`` header to responses with an empty
  208. :attr:`~django.http.HttpResponse.content`.
  209. * ``django.utils.decorators.classproperty()`` decorator is moved to
  210. ``django.utils.functional.classproperty()``.
  211. * :tfilter:`floatformat` template filter now outputs (positive) ``0`` for
  212. negative numbers which round to zero.
  213. * :attr:`Meta.ordering <django.db.models.Options.ordering>` and
  214. :attr:`Meta.unique_together <django.db.models.Options.unique_together>`
  215. options on models in ``django.contrib`` modules that were formerly tuples are
  216. now lists.
  217. .. _deprecated-features-3.1:
  218. Features deprecated in 3.1
  219. ==========================
  220. Miscellaneous
  221. -------------
  222. * ``PASSWORD_RESET_TIMEOUT_DAYS`` setting is deprecated in favor of
  223. :setting:`PASSWORD_RESET_TIMEOUT`.
  224. * The undocumented usage of the :lookup:`isnull` lookup with non-boolean values
  225. as the right-hand side is deprecated, use ``True`` or ``False`` instead.
  226. * The barely documented ``django.db.models.query_utils.InvalidQuery`` exception
  227. class is deprecated in favor of
  228. :class:`~django.core.exceptions.FieldDoesNotExist` and
  229. :class:`~django.core.exceptions.FieldError`.
  230. .. _removed-features-3.1:
  231. Features removed in 3.1
  232. =======================
  233. These features have reached the end of their deprecation cycle and are removed
  234. in Django 3.1.
  235. See :ref:`deprecated-features-2.2` for details on these changes, including how
  236. to remove usage of these features.
  237. * ``django.utils.timezone.FixedOffset`` is removed.
  238. * ``django.core.paginator.QuerySetPaginator`` is removed.
  239. * A model's ``Meta.ordering`` doesn't affect ``GROUP BY`` queries.
  240. * ``django.contrib.postgres.fields.FloatRangeField`` and
  241. ``django.contrib.postgres.forms.FloatRangeField`` are removed.
  242. * The ``FILE_CHARSET`` setting is removed.
  243. * ``django.contrib.staticfiles.storage.CachedStaticFilesStorage`` is removed.
  244. * The ``RemoteUserBackend.configure_user()`` method requires ``request`` as the
  245. first positional argument.
  246. * Support for ``SimpleTestCase.allow_database_queries`` and
  247. ``TransactionTestCase.multi_db`` is removed.