5.2.txt 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. ============================================
  2. Django 5.2 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. *Expected April 2025*
  5. Welcome to Django 5.2!
  6. These release notes cover the :ref:`new features <whats-new-5.2>`, as well as
  7. some :ref:`backwards incompatible changes <backwards-incompatible-5.2>` you
  8. should be aware of when upgrading from Django 5.1 or earlier. We've
  9. :ref:`begun the deprecation process for some features
  10. <deprecated-features-5.2>`.
  11. See the :doc:`/howto/upgrade-version` guide if you're updating an existing
  12. project.
  13. Django 5.2 is designated as a :term:`long-term support release
  14. <Long-term support release>`. It will receive security updates for at least
  15. three years after its release. Support for the previous LTS, Django 4.2, will
  16. end in April 2026.
  17. Python compatibility
  18. ====================
  19. Django 5.2 supports Python 3.10, 3.11, 3.12, and 3.13. We **highly recommend**
  20. and only officially support the latest release of each series.
  21. .. _whats-new-5.2:
  22. What's new in Django 5.2
  23. ========================
  24. Minor features
  25. --------------
  26. :mod:`django.contrib.admin`
  27. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. * The ``admin/base.html`` template now has a new block
  29. :ref:`extrabody <extrabody>` for adding custom code before the closing
  30. ``</body>`` tag.
  31. :mod:`django.contrib.admindocs`
  32. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33. * ...
  34. :mod:`django.contrib.auth`
  35. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  36. * The default iteration count for the PBKDF2 password hasher is increased from
  37. 870,000 to 1,000,000.
  38. * The following new asynchronous methods on are now provided, using an ``a``
  39. prefix:
  40. * :meth:`.UserManager.acreate_user`
  41. * :meth:`.UserManager.acreate_superuser`
  42. * :meth:`.BaseUserManager.aget_by_natural_key`
  43. * :meth:`.User.aget_user_permissions()`
  44. * :meth:`.User.aget_all_permissions()`
  45. * :meth:`.User.aget_group_permissions()`
  46. * :meth:`.User.ahas_perm()`
  47. * :meth:`.User.ahas_perms()`
  48. * :meth:`.User.ahas_module_perms()`
  49. * :meth:`.User.aget_user_permissions()`
  50. * :meth:`.User.aget_group_permissions()`
  51. * :meth:`.User.ahas_perm()`
  52. * :meth:`.ModelBackend.aauthenticate()`
  53. * :meth:`.ModelBackend.aget_user_permissions()`
  54. * :meth:`.ModelBackend.aget_group_permissions()`
  55. * :meth:`.ModelBackend.aget_all_permissions()`
  56. * :meth:`.ModelBackend.ahas_perm()`
  57. * :meth:`.ModelBackend.ahas_module_perms()`
  58. * :meth:`.RemoteUserBackend.aauthenticate()`
  59. * :meth:`.RemoteUserBackend.aconfigure_user()`
  60. * Auth backends can now provide async implementations which are used when
  61. calling async auth functions (e.g.
  62. :func:`~.django.contrib.auth.aauthenticate`) to reduce context-switching which
  63. improves performance. See :ref:`adding an async interface
  64. <writing-authentication-backends-async-interface>` for more details.
  65. :mod:`django.contrib.contenttypes`
  66. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  67. * ...
  68. :mod:`django.contrib.gis`
  69. ~~~~~~~~~~~~~~~~~~~~~~~~~
  70. * ...
  71. :mod:`django.contrib.messages`
  72. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  73. * ...
  74. :mod:`django.contrib.postgres`
  75. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  76. * ...
  77. :mod:`django.contrib.redirects`
  78. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  79. * ...
  80. :mod:`django.contrib.sessions`
  81. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  82. * ...
  83. :mod:`django.contrib.sitemaps`
  84. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  85. * ...
  86. :mod:`django.contrib.sites`
  87. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  88. * ...
  89. :mod:`django.contrib.staticfiles`
  90. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  91. * ...
  92. :mod:`django.contrib.syndication`
  93. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  94. * All :class:`~django.utils.feedgenerator.SyndicationFeed` classes now support
  95. a ``stylesheets`` attribute. If specified, an ``<? xml-stylesheet ?>``
  96. processing instruction will be added to the top of the document for each
  97. stylesheet in the given list. See :ref:`feed-stylesheets` for more details.
  98. Asynchronous views
  99. ~~~~~~~~~~~~~~~~~~
  100. * ...
  101. Cache
  102. ~~~~~
  103. * ...
  104. CSRF
  105. ~~~~
  106. * ...
  107. Database backends
  108. ~~~~~~~~~~~~~~~~~
  109. * ...
  110. Decorators
  111. ~~~~~~~~~~
  112. * :func:`~django.utils.decorators.method_decorator` now supports wrapping
  113. asynchronous view methods.
  114. Email
  115. ~~~~~
  116. * Tuple items of :class:`EmailMessage.attachments
  117. <django.core.mail.EmailMessage>` and
  118. :class:`EmailMultiAlternatives.attachments
  119. <django.core.mail.EmailMultiAlternatives>` are now named tuples, as opposed
  120. to regular tuples.
  121. * :attr:`EmailMultiAlternatives.alternatives
  122. <django.core.mail.EmailMultiAlternatives.alternatives>` is now a list of
  123. named tuples, as opposed to regular tuples.
  124. * The new :meth:`~django.core.mail.EmailMultiAlternatives.body_contains` method
  125. returns a boolean indicating whether a provided text is contained in the
  126. email ``body`` and in all attached MIME type ``text/*`` alternatives.
  127. Error Reporting
  128. ~~~~~~~~~~~~~~~
  129. * The attribute :attr:`.SafeExceptionReporterFilter.hidden_settings` now
  130. treats values as sensitive if their name includes ``AUTH``.
  131. File Storage
  132. ~~~~~~~~~~~~
  133. * ...
  134. File Uploads
  135. ~~~~~~~~~~~~
  136. * ...
  137. Forms
  138. ~~~~~
  139. * The new :class:`~django.forms.ColorInput` form widget is for entering a color
  140. in ``rrggbb`` hexadecimal format and renders as ``<input type="color" ...>``.
  141. Some browsers support a visual color picker interface for this input type.
  142. * The new :class:`~django.forms.SearchInput` form widget is for entering search
  143. queries and renders as ``<input type="search" ...>``.
  144. * The new :class:`~django.forms.TelInput` form widget is for entering telephone
  145. numbers and renders as ``<input type="tel" ...>``.
  146. Generic Views
  147. ~~~~~~~~~~~~~
  148. * ...
  149. Internationalization
  150. ~~~~~~~~~~~~~~~~~~~~
  151. * ...
  152. Logging
  153. ~~~~~~~
  154. * ...
  155. Management Commands
  156. ~~~~~~~~~~~~~~~~~~~
  157. * A new warning is printed to the console when running :djadmin:`runserver` that
  158. ``runserver`` is unsuitable for production. This warning can be hidden by
  159. setting the :envvar:`HIDE_PRODUCTION_WARNING` environment variable to
  160. ``"true"``.
  161. Migrations
  162. ~~~~~~~~~~
  163. * ...
  164. Models
  165. ~~~~~~
  166. * The ``SELECT`` clause generated when using
  167. :meth:`QuerySet.values()<django.db.models.query.QuerySet.values>` and
  168. :meth:`~django.db.models.query.QuerySet.values_list` now matches the
  169. specified order of the referenced expressions. Previously the order was based
  170. of a set of counterintuitive rules which made query combination through
  171. methods such as
  172. :meth:`QuerySet.union()<django.db.models.query.QuerySet.union>` unpredictable.
  173. * Added support for validation of model constraints which use a
  174. :class:`~django.db.models.GeneratedField`.
  175. * The new :attr:`.Expression.set_returning` attribute specifies that the
  176. expression contains a set-returning function, enforcing subquery evaluation.
  177. This is necessary for many Postgres set-returning functions.
  178. * :attr:`CharField.max_length <django.db.models.CharField.max_length>` is no
  179. longer required to be set on SQLite, which supports unlimited ``VARCHAR``
  180. columns.
  181. Requests and Responses
  182. ~~~~~~~~~~~~~~~~~~~~~~
  183. * The new :meth:`.HttpRequest.get_preferred_type` method can be used to query
  184. the preferred media type the client accepts.
  185. Security
  186. ~~~~~~~~
  187. * ...
  188. Serialization
  189. ~~~~~~~~~~~~~
  190. * Each serialization format now defines a ``Deserializer`` class, rather than a
  191. function, to improve extensibility when defining a
  192. :ref:`custom serialization format <custom-serialization-formats>`.
  193. Signals
  194. ~~~~~~~
  195. * ...
  196. Templates
  197. ~~~~~~~~~
  198. * ...
  199. Tests
  200. ~~~~~
  201. * Stack frames from Django's custom assertions are now hidden. This makes test
  202. failures easier to read and enables :option:`test --pdb` to directly enter
  203. into the failing test method.
  204. * Data loaded from :attr:`~django.test.TransactionTestCase.fixtures` and from
  205. migrations enabled with :ref:`serialized_rollback=True
  206. <test-case-serialized-rollback>` are now available during
  207. ``TransactionTestCase.setUpClass()``.
  208. URLs
  209. ~~~~
  210. * ...
  211. Utilities
  212. ~~~~~~~~~
  213. * :class:`~django.utils.safestring.SafeString` now returns
  214. :py:data:`NotImplemented` in ``__add__`` for non-string right-hand side
  215. values. This aligns with the :py:class:`str` addition behavior and allows
  216. ``__radd__`` to be used if available.
  217. * :func:`~django.utils.html.format_html_join` now supports taking an iterable
  218. of mappings, passing their contents as keyword arguments to
  219. :func:`~django.utils.html.format_html`.
  220. Validators
  221. ~~~~~~~~~~
  222. * ...
  223. .. _backwards-incompatible-5.2:
  224. Backwards incompatible changes in 5.2
  225. =====================================
  226. Database backend API
  227. --------------------
  228. This section describes changes that may be needed in third-party database
  229. backends.
  230. * The new :meth:`Model._is_pk_set() <django.db.models.Model._is_pk_set>` method
  231. allows checking if a Model instance's primary key is defined.
  232. :mod:`django.contrib.gis`
  233. -------------------------
  234. * Support for PostGIS 3.0 is removed.
  235. * Support for GDAL 3.0 is removed.
  236. Dropped support for PostgreSQL 13
  237. ---------------------------------
  238. Upstream support for PostgreSQL 13 ends in November 2025. Django 5.2 supports
  239. PostgreSQL 14 and higher.
  240. Miscellaneous
  241. -------------
  242. * Adding :attr:`.EmailMultiAlternatives.alternatives` is now only supported via
  243. the :meth:`~.EmailMultiAlternatives.attach_alternative` method.
  244. * The minimum supported version of ``gettext`` is increased from 0.15 to 0.19.
  245. * ``HttpRequest.accepted_types`` is now sorted by the client's preference, based
  246. on the request's ``Accept`` header.
  247. * The :func:`~django.template.context_processors.debug` context processor is no
  248. longer included in the default project template.
  249. .. _deprecated-features-5.2:
  250. Features deprecated in 5.2
  251. ==========================
  252. Miscellaneous
  253. -------------
  254. * The ``all`` argument for the ``django.contrib.staticfiles.finders.find()``
  255. function is deprecated in favor of the ``find_all`` argument.