4.1.txt 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. ============================================
  2. Django 4.1 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. *Expected August 2022*
  5. Welcome to Django 4.1!
  6. These release notes cover the :ref:`new features <whats-new-4.1>`, as well as
  7. some :ref:`backwards incompatible changes <backwards-incompatible-4.1>` you'll
  8. want to be aware of when upgrading from Django 4.0 or earlier. We've
  9. :ref:`begun the deprecation process for some features
  10. <deprecated-features-4.1>`.
  11. See the :doc:`/howto/upgrade-version` guide if you're updating an existing
  12. project.
  13. Python compatibility
  14. ====================
  15. Django 4.1 supports Python 3.8, 3.9, and 3.10. We **highly recommend** and only
  16. officially support the latest release of each series.
  17. .. _whats-new-4.1:
  18. What's new in Django 4.1
  19. ========================
  20. .. _csrf-cookie-masked-usage:
  21. ``CSRF_COOKIE_MASKED`` setting
  22. ------------------------------
  23. The new :setting:`CSRF_COOKIE_MASKED` transitional setting allows specifying
  24. whether to mask the CSRF cookie.
  25. :class:`~django.middleware.csrf.CsrfViewMiddleware` no longer masks the CSRF
  26. cookie like it does the CSRF token in the DOM. If you are upgrading multiple
  27. instances of the same project to Django 4.1, you should set
  28. :setting:`CSRF_COOKIE_MASKED` to ``True`` during the transition, in
  29. order to allow compatibility with the older versions of Django. Once the
  30. transition to 4.1 is complete you can stop overriding
  31. :setting:`CSRF_COOKIE_MASKED`.
  32. This setting is deprecated as of this release and will be removed in Django
  33. 5.0.
  34. Minor features
  35. --------------
  36. :mod:`django.contrib.admin`
  37. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. * The admin :ref:`dark mode CSS variables <admin-theming>` are now applied in a
  39. separate stylesheet and template block.
  40. * :ref:`modeladmin-list-filters` providing custom ``FieldListFilter``
  41. subclasses can now control the query string value separator when filtering
  42. for multiple values using the ``__in`` lookup.
  43. :mod:`django.contrib.admindocs`
  44. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  45. * ...
  46. :mod:`django.contrib.auth`
  47. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  48. * The default iteration count for the PBKDF2 password hasher is increased from
  49. 320,000 to 390,000.
  50. :mod:`django.contrib.contenttypes`
  51. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  52. * ...
  53. :mod:`django.contrib.gis`
  54. ~~~~~~~~~~~~~~~~~~~~~~~~~
  55. * The new :meth:`.GEOSGeometry.make_valid()` method allows converting invalid
  56. geometries to valid ones.
  57. :mod:`django.contrib.messages`
  58. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  59. * ...
  60. :mod:`django.contrib.postgres`
  61. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  62. * The new :class:`BitXor() <django.contrib.postgres.aggregates.BitXor>`
  63. aggregate function returns an ``int`` of the bitwise ``XOR`` of all non-null
  64. input values.
  65. * :class:`~django.contrib.postgres.indexes.SpGistIndex` now supports covering
  66. indexes on PostgreSQL 14+.
  67. * :class:`~django.contrib.postgres.constraints.ExclusionConstraint` now
  68. supports covering exclusion constraints using SP-GiST indexes on PostgreSQL
  69. 14+.
  70. * The new ``default_bounds`` attribute of :attr:`DateTimeRangeField
  71. <django.contrib.postgres.fields.DateTimeRangeField.default_bounds>` and
  72. :attr:`DecimalRangeField
  73. <django.contrib.postgres.fields.DecimalRangeField.default_bounds>` allows
  74. specifying bounds for list and tuple inputs.
  75. :mod:`django.contrib.redirects`
  76. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77. * ...
  78. :mod:`django.contrib.sessions`
  79. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80. * ...
  81. :mod:`django.contrib.sitemaps`
  82. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  83. * The default sitemap index template ``<sitemapindex>`` now includes the
  84. ``<lastmod>`` timestamp where available, through the new
  85. :meth:`~django.contrib.sitemaps.Sitemap.get_latest_lastmod` method. Custom
  86. sitemap index templates should be updated for the adjusted :ref:`context
  87. variables <sitemap-index-context-variables>`.
  88. :mod:`django.contrib.sites`
  89. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  90. * ...
  91. :mod:`django.contrib.staticfiles`
  92. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  93. * ...
  94. :mod:`django.contrib.syndication`
  95. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  96. * ...
  97. Cache
  98. ~~~~~
  99. * ...
  100. CSRF
  101. ~~~~
  102. * ...
  103. Decorators
  104. ~~~~~~~~~~
  105. * ...
  106. Email
  107. ~~~~~
  108. * ...
  109. Error Reporting
  110. ~~~~~~~~~~~~~~~
  111. * ...
  112. File Storage
  113. ~~~~~~~~~~~~
  114. * ...
  115. File Uploads
  116. ~~~~~~~~~~~~
  117. * ...
  118. Forms
  119. ~~~~~
  120. * The new :meth:`~django.forms.BoundField.legend_tag` allows rendering field
  121. labels in ``<legend>`` tags via the new ``tag`` argument of
  122. :meth:`~django.forms.BoundField.label_tag`.
  123. Generic Views
  124. ~~~~~~~~~~~~~
  125. * ...
  126. Internationalization
  127. ~~~~~~~~~~~~~~~~~~~~
  128. * The :func:`~django.conf.urls.i18n.i18n_patterns` function now supports
  129. languages with both scripts and regions.
  130. Logging
  131. ~~~~~~~
  132. * ...
  133. Management Commands
  134. ~~~~~~~~~~~~~~~~~~~
  135. * :option:`makemigrations --no-input` now logs default answers and reasons why
  136. migrations cannot be created.
  137. Migrations
  138. ~~~~~~~~~~
  139. * ...
  140. Models
  141. ~~~~~~
  142. * The ``order_by`` argument of the
  143. :class:`~django.db.models.expressions.Window` expression now accepts string
  144. references to fields and transforms.
  145. * The new :setting:`CONN_HEALTH_CHECKS` setting allows enabling health checks
  146. for :ref:`persistent database connections <persistent-database-connections>`
  147. in order to reduce the number of failed requests, e.g. after database server
  148. restart.
  149. Requests and Responses
  150. ~~~~~~~~~~~~~~~~~~~~~~
  151. * ...
  152. Security
  153. ~~~~~~~~
  154. * ...
  155. Serialization
  156. ~~~~~~~~~~~~~
  157. * ...
  158. Signals
  159. ~~~~~~~
  160. * ...
  161. Templates
  162. ~~~~~~~~~
  163. * :tfilter:`json_script` template filter now allows wrapping in a ``<script>``
  164. tag without the HTML ``id`` attribute.
  165. Tests
  166. ~~~~~
  167. * A nested atomic block marked as durable in :class:`django.test.TestCase` now
  168. raises a ``RuntimeError``, the same as outside of tests.
  169. URLs
  170. ~~~~
  171. * ...
  172. Utilities
  173. ~~~~~~~~~
  174. * ...
  175. Validators
  176. ~~~~~~~~~~
  177. * ...
  178. .. _backwards-incompatible-4.1:
  179. Backwards incompatible changes in 4.1
  180. =====================================
  181. Database backend API
  182. --------------------
  183. This section describes changes that may be needed in third-party database
  184. backends.
  185. * ``BaseDatabaseFeatures.has_case_insensitive_like`` is changed from ``True``
  186. to ``False`` to reflect the behavior of most databases.
  187. * ``DatabaseIntrospection.get_key_columns()`` is removed. Use
  188. ``DatabaseIntrospection.get_relations()`` instead.
  189. Dropped support for MariaDB 10.2
  190. --------------------------------
  191. Upstream support for MariaDB 10.2 ends in May 2022. Django 4.1 supports MariaDB
  192. 10.3 and higher.
  193. Admin changelist searches spanning multi-valued relationships changes
  194. ---------------------------------------------------------------------
  195. Admin changelist searches using multiple search terms are now applied in a
  196. single call to ``filter()``, rather than in sequential ``filter()`` calls.
  197. For multi-valued relationships, this means that rows from the related model
  198. must match all terms rather than any term. For example, if ``search_fields``
  199. is set to ``['child__name', 'child__age']``, and a user searches for
  200. ``'Jamal 17'``, parent rows will be returned only if there is a relationship to
  201. some 17-year-old child named Jamal, rather than also returning parents who
  202. merely have a younger or older child named Jamal in addition to some other
  203. 17-year-old.
  204. See the :ref:`spanning-multi-valued-relationships` topic for more discussion of
  205. this difference. In Django 4.0 and earlier,
  206. :meth:`~django.contrib.admin.ModelAdmin.get_search_results` followed the
  207. second example query, but this undocumented behavior led to queries with
  208. excessive joins.
  209. Miscellaneous
  210. -------------
  211. * Related managers for :class:`~django.db.models.ForeignKey`,
  212. :class:`~django.db.models.ManyToManyField`, and
  213. :class:`~django.contrib.contenttypes.fields.GenericRelation` are now cached
  214. on the :class:`~django.db.models.Model` instance to which they belong.
  215. * The Django test runner now returns a non-zero error code for unexpected
  216. successes from tests marked with :py:func:`unittest.expectedFailure`.
  217. * :class:`~django.middleware.csrf.CsrfViewMiddleware` no longer masks the CSRF
  218. cookie like it does the CSRF token in the DOM.
  219. * :class:`~django.middleware.csrf.CsrfViewMiddleware` now uses
  220. ``request.META['CSRF_COOKIE']`` for storing the unmasked CSRF secret rather
  221. than a masked version. This is an undocumented, private API.
  222. .. _deprecated-features-4.1:
  223. Features deprecated in 4.1
  224. ==========================
  225. Miscellaneous
  226. -------------
  227. * The context for sitemap index templates of a flat list of URLs is deprecated.
  228. Custom sitemap index templates should be updated for the adjusted
  229. :ref:`context variables <sitemap-index-context-variables>`, expecting a list
  230. of objects with ``location`` and optional ``lastmod`` attributes.
  231. * ``CSRF_COOKIE_MASKED`` transitional setting is deprecated.
  232. Features removed in 4.1
  233. =======================
  234. These features have reached the end of their deprecation cycle and are removed
  235. in Django 4.1.
  236. See :ref:`deprecated-features-3.2` for details on these changes, including how
  237. to remove usage of these features.
  238. * Support for assigning objects which don't support creating deep copies with
  239. ``copy.deepcopy()`` to class attributes in ``TestCase.setUpTestData()`` is
  240. removed.
  241. * Support for using a boolean value in
  242. :attr:`.BaseCommand.requires_system_checks` is removed.
  243. * The ``whitelist`` argument and ``domain_whitelist`` attribute of
  244. ``django.core.validators.EmailValidator`` are removed.
  245. * The ``default_app_config`` application configuration variable is removed.
  246. * ``TransactionTestCase.assertQuerysetEqual()`` no longer calls ``repr()`` on a
  247. queryset when compared to string values.
  248. * The ``django.core.cache.backends.memcached.MemcachedCache`` backend is
  249. removed.
  250. * Support for the pre-Django 3.2 format of messages used by
  251. ``django.contrib.messages.storage.cookie.CookieStorage`` is removed.