4.1.txt 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. Requests and Responses
  140. ~~~~~~~~~~~~~~~~~~~~~~
  141. * ...
  142. Security
  143. ~~~~~~~~
  144. * ...
  145. Serialization
  146. ~~~~~~~~~~~~~
  147. * ...
  148. Signals
  149. ~~~~~~~
  150. * ...
  151. Templates
  152. ~~~~~~~~~
  153. * :tfilter:`json_script` template filter now allows wrapping in a ``<script>``
  154. tag without the HTML ``id`` attribute.
  155. Tests
  156. ~~~~~
  157. * A nested atomic block marked as durable in :class:`django.test.TestCase` now
  158. raises a ``RuntimeError``, the same as outside of tests.
  159. URLs
  160. ~~~~
  161. * ...
  162. Utilities
  163. ~~~~~~~~~
  164. * ...
  165. Validators
  166. ~~~~~~~~~~
  167. * ...
  168. .. _backwards-incompatible-4.1:
  169. Backwards incompatible changes in 4.1
  170. =====================================
  171. Database backend API
  172. --------------------
  173. This section describes changes that may be needed in third-party database
  174. backends.
  175. * ``BaseDatabaseFeatures.has_case_insensitive_like`` is changed from ``True``
  176. to ``False`` to reflect the behavior of most databases.
  177. * ``DatabaseIntrospection.get_key_columns()`` is removed. Use
  178. ``DatabaseIntrospection.get_relations()`` instead.
  179. Dropped support for MariaDB 10.2
  180. --------------------------------
  181. Upstream support for MariaDB 10.2 ends in May 2022. Django 4.1 supports MariaDB
  182. 10.3 and higher.
  183. Miscellaneous
  184. -------------
  185. * Related managers for :class:`~django.db.models.ForeignKey`,
  186. :class:`~django.db.models.ManyToManyField`, and
  187. :class:`~django.contrib.contenttypes.fields.GenericRelation` are now cached
  188. on the :class:`~django.db.models.Model` instance to which they belong.
  189. * The Django test runner now returns a non-zero error code for unexpected
  190. successes from tests marked with :py:func:`unittest.expectedFailure`.
  191. * :class:`~django.middleware.csrf.CsrfViewMiddleware` no longer masks the CSRF
  192. cookie like it does the CSRF token in the DOM.
  193. * :class:`~django.middleware.csrf.CsrfViewMiddleware` now uses
  194. ``request.META['CSRF_COOKIE']`` for storing the unmasked CSRF secret rather
  195. than a masked version. This is an undocumented, private API.
  196. .. _deprecated-features-4.1:
  197. Features deprecated in 4.1
  198. ==========================
  199. Miscellaneous
  200. -------------
  201. * The context for sitemap index templates of a flat list of URLs is deprecated.
  202. Custom sitemap index templates should be updated for the adjusted
  203. :ref:`context variables <sitemap-index-context-variables>`, expecting a list
  204. of objects with ``location`` and optional ``lastmod`` attributes.
  205. * ``CSRF_COOKIE_MASKED`` transitional setting is deprecated.
  206. Features removed in 4.1
  207. =======================
  208. These features have reached the end of their deprecation cycle and are removed
  209. in Django 4.1.
  210. See :ref:`deprecated-features-3.2` for details on these changes, including how
  211. to remove usage of these features.
  212. * Support for assigning objects which don't support creating deep copies with
  213. ``copy.deepcopy()`` to class attributes in ``TestCase.setUpTestData()`` is
  214. removed.
  215. * Support for using a boolean value in
  216. :attr:`.BaseCommand.requires_system_checks` is removed.
  217. * The ``whitelist`` argument and ``domain_whitelist`` attribute of
  218. ``django.core.validators.EmailValidator`` are removed.
  219. * The ``default_app_config`` application configuration variable is removed.
  220. * ``TransactionTestCase.assertQuerysetEqual()`` no longer calls ``repr()`` on a
  221. queryset when compared to string values.
  222. * The ``django.core.cache.backends.memcached.MemcachedCache`` backend is
  223. removed.
  224. * Support for the pre-Django 3.2 format of messages used by
  225. ``django.contrib.messages.storage.cookie.CookieStorage`` is removed.