4.1.txt 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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. :mod:`django.contrib.admindocs`
  41. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  42. * ...
  43. :mod:`django.contrib.auth`
  44. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  45. * The default iteration count for the PBKDF2 password hasher is increased from
  46. 320,000 to 390,000.
  47. :mod:`django.contrib.contenttypes`
  48. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49. * ...
  50. :mod:`django.contrib.gis`
  51. ~~~~~~~~~~~~~~~~~~~~~~~~~
  52. * The new :meth:`.GEOSGeometry.make_valid()` method allows converting invalid
  53. geometries to valid ones.
  54. :mod:`django.contrib.messages`
  55. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  56. * ...
  57. :mod:`django.contrib.postgres`
  58. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  59. * The new :class:`BitXor() <django.contrib.postgres.aggregates.BitXor>`
  60. aggregate function returns an ``int`` of the bitwise ``XOR`` of all non-null
  61. input values.
  62. * :class:`~django.contrib.postgres.indexes.SpGistIndex` now supports covering
  63. indexes on PostgreSQL 14+.
  64. * :class:`~django.contrib.postgres.constraints.ExclusionConstraint` now
  65. supports covering exclusion constraints using SP-GiST indexes on PostgreSQL
  66. 14+.
  67. * The new ``default_bounds`` attribute of :attr:`DateTimeRangeField
  68. <django.contrib.postgres.fields.DateTimeRangeField.default_bounds>` and
  69. :attr:`DecimalRangeField
  70. <django.contrib.postgres.fields.DecimalRangeField.default_bounds>` allows
  71. specifying bounds for list and tuple inputs.
  72. :mod:`django.contrib.redirects`
  73. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74. * ...
  75. :mod:`django.contrib.sessions`
  76. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77. * ...
  78. :mod:`django.contrib.sitemaps`
  79. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80. * The default sitemap index template ``<sitemapindex>`` now includes the
  81. ``<lastmod>`` timestamp where available, through the new
  82. :meth:`~django.contrib.sitemaps.Sitemap.get_latest_lastmod` method. Custom
  83. sitemap index templates should be updated for the adjusted :ref:`context
  84. variables <sitemap-index-context-variables>`.
  85. :mod:`django.contrib.sites`
  86. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  87. * ...
  88. :mod:`django.contrib.staticfiles`
  89. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  90. * ...
  91. :mod:`django.contrib.syndication`
  92. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  93. * ...
  94. Cache
  95. ~~~~~
  96. * ...
  97. CSRF
  98. ~~~~
  99. * ...
  100. Decorators
  101. ~~~~~~~~~~
  102. * ...
  103. Email
  104. ~~~~~
  105. * ...
  106. Error Reporting
  107. ~~~~~~~~~~~~~~~
  108. * ...
  109. File Storage
  110. ~~~~~~~~~~~~
  111. * ...
  112. File Uploads
  113. ~~~~~~~~~~~~
  114. * ...
  115. Forms
  116. ~~~~~
  117. * ...
  118. Generic Views
  119. ~~~~~~~~~~~~~
  120. * ...
  121. Internationalization
  122. ~~~~~~~~~~~~~~~~~~~~
  123. * ...
  124. Logging
  125. ~~~~~~~
  126. * ...
  127. Management Commands
  128. ~~~~~~~~~~~~~~~~~~~
  129. * :option:`makemigrations --no-input` now logs default answers and reasons why
  130. migrations cannot be created.
  131. Migrations
  132. ~~~~~~~~~~
  133. * ...
  134. Models
  135. ~~~~~~
  136. * The ``order_by`` argument of the
  137. :class:`~django.db.models.expressions.Window` expression now accepts string
  138. references to fields and transforms.
  139. * The new :setting:`CONN_HEALTH_CHECKS` setting allows enabling health checks
  140. for :ref:`persistent database connections <persistent-database-connections>`
  141. in order to reduce the number of failed requests, e.g. after database server
  142. restart.
  143. Requests and Responses
  144. ~~~~~~~~~~~~~~~~~~~~~~
  145. * ...
  146. Security
  147. ~~~~~~~~
  148. * ...
  149. Serialization
  150. ~~~~~~~~~~~~~
  151. * ...
  152. Signals
  153. ~~~~~~~
  154. * ...
  155. Templates
  156. ~~~~~~~~~
  157. * :tfilter:`json_script` template filter now allows wrapping in a ``<script>``
  158. tag without the HTML ``id`` attribute.
  159. Tests
  160. ~~~~~
  161. * A nested atomic block marked as durable in :class:`django.test.TestCase` now
  162. raises a ``RuntimeError``, the same as outside of tests.
  163. URLs
  164. ~~~~
  165. * ...
  166. Utilities
  167. ~~~~~~~~~
  168. * ...
  169. Validators
  170. ~~~~~~~~~~
  171. * ...
  172. .. _backwards-incompatible-4.1:
  173. Backwards incompatible changes in 4.1
  174. =====================================
  175. Database backend API
  176. --------------------
  177. This section describes changes that may be needed in third-party database
  178. backends.
  179. * ``BaseDatabaseFeatures.has_case_insensitive_like`` is changed from ``True``
  180. to ``False`` to reflect the behavior of most databases.
  181. * ``DatabaseIntrospection.get_key_columns()`` is removed. Use
  182. ``DatabaseIntrospection.get_relations()`` instead.
  183. Dropped support for MariaDB 10.2
  184. --------------------------------
  185. Upstream support for MariaDB 10.2 ends in May 2022. Django 4.1 supports MariaDB
  186. 10.3 and higher.
  187. Miscellaneous
  188. -------------
  189. * Related managers for :class:`~django.db.models.ForeignKey`,
  190. :class:`~django.db.models.ManyToManyField`, and
  191. :class:`~django.contrib.contenttypes.fields.GenericRelation` are now cached
  192. on the :class:`~django.db.models.Model` instance to which they belong.
  193. * The Django test runner now returns a non-zero error code for unexpected
  194. successes from tests marked with :py:func:`unittest.expectedFailure`.
  195. * :class:`~django.middleware.csrf.CsrfViewMiddleware` no longer masks the CSRF
  196. cookie like it does the CSRF token in the DOM.
  197. * :class:`~django.middleware.csrf.CsrfViewMiddleware` now uses
  198. ``request.META['CSRF_COOKIE']`` for storing the unmasked CSRF secret rather
  199. than a masked version. This is an undocumented, private API.
  200. .. _deprecated-features-4.1:
  201. Features deprecated in 4.1
  202. ==========================
  203. Miscellaneous
  204. -------------
  205. * The context for sitemap index templates of a flat list of URLs is deprecated.
  206. Custom sitemap index templates should be updated for the adjusted
  207. :ref:`context variables <sitemap-index-context-variables>`, expecting a list
  208. of objects with ``location`` and optional ``lastmod`` attributes.
  209. * ``CSRF_COOKIE_MASKED`` transitional setting is deprecated.
  210. Features removed in 4.1
  211. =======================
  212. These features have reached the end of their deprecation cycle and are removed
  213. in Django 4.1.
  214. See :ref:`deprecated-features-3.2` for details on these changes, including how
  215. to remove usage of these features.
  216. * Support for assigning objects which don't support creating deep copies with
  217. ``copy.deepcopy()`` to class attributes in ``TestCase.setUpTestData()`` is
  218. removed.
  219. * Support for using a boolean value in
  220. :attr:`.BaseCommand.requires_system_checks` is removed.
  221. * The ``whitelist`` argument and ``domain_whitelist`` attribute of
  222. ``django.core.validators.EmailValidator`` are removed.
  223. * The ``default_app_config`` application configuration variable is removed.
  224. * ``TransactionTestCase.assertQuerysetEqual()`` no longer calls ``repr()`` on a
  225. queryset when compared to string values.
  226. * The ``django.core.cache.backends.memcached.MemcachedCache`` backend is
  227. removed.
  228. * Support for the pre-Django 3.2 format of messages used by
  229. ``django.contrib.messages.storage.cookie.CookieStorage`` is removed.