5.2.txt 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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 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. * The :djadmin:`makemigrations` and :djadmin:`migrate` commands have a new
  162. ``Command.autodetector`` attribute for subclasses to override in order to use
  163. a custom autodetector class.
  164. Migrations
  165. ~~~~~~~~~~
  166. * ...
  167. Models
  168. ~~~~~~
  169. * The ``SELECT`` clause generated when using
  170. :meth:`QuerySet.values()<django.db.models.query.QuerySet.values>` and
  171. :meth:`~django.db.models.query.QuerySet.values_list` now matches the
  172. specified order of the referenced expressions. Previously the order was based
  173. of a set of counterintuitive rules which made query combination through
  174. methods such as
  175. :meth:`QuerySet.union()<django.db.models.query.QuerySet.union>` unpredictable.
  176. * Added support for validation of model constraints which use a
  177. :class:`~django.db.models.GeneratedField`.
  178. * The new :attr:`.Expression.set_returning` attribute specifies that the
  179. expression contains a set-returning function, enforcing subquery evaluation.
  180. This is necessary for many Postgres set-returning functions.
  181. * :attr:`CharField.max_length <django.db.models.CharField.max_length>` is no
  182. longer required to be set on SQLite, which supports unlimited ``VARCHAR``
  183. columns.
  184. Requests and Responses
  185. ~~~~~~~~~~~~~~~~~~~~~~
  186. * The new :meth:`.HttpRequest.get_preferred_type` method can be used to query
  187. the preferred media type the client accepts.
  188. Security
  189. ~~~~~~~~
  190. * ...
  191. Serialization
  192. ~~~~~~~~~~~~~
  193. * Each serialization format now defines a ``Deserializer`` class, rather than a
  194. function, to improve extensibility when defining a
  195. :ref:`custom serialization format <custom-serialization-formats>`.
  196. Signals
  197. ~~~~~~~
  198. * ...
  199. Templates
  200. ~~~~~~~~~
  201. * ...
  202. Tests
  203. ~~~~~
  204. * Stack frames from Django's custom assertions are now hidden. This makes test
  205. failures easier to read and enables :option:`test --pdb` to directly enter
  206. into the failing test method.
  207. * Data loaded from :attr:`~django.test.TransactionTestCase.fixtures` and from
  208. migrations enabled with :ref:`serialized_rollback=True
  209. <test-case-serialized-rollback>` are now available during
  210. ``TransactionTestCase.setUpClass()``.
  211. URLs
  212. ~~~~
  213. * ...
  214. Utilities
  215. ~~~~~~~~~
  216. * :class:`~django.utils.safestring.SafeString` now returns
  217. :py:data:`NotImplemented` in ``__add__`` for non-string right-hand side
  218. values. This aligns with the :py:class:`str` addition behavior and allows
  219. ``__radd__`` to be used if available.
  220. * :func:`~django.utils.html.format_html_join` now supports taking an iterable
  221. of mappings, passing their contents as keyword arguments to
  222. :func:`~django.utils.html.format_html`.
  223. Validators
  224. ~~~~~~~~~~
  225. * ...
  226. .. _backwards-incompatible-5.2:
  227. Backwards incompatible changes in 5.2
  228. =====================================
  229. Database backend API
  230. --------------------
  231. This section describes changes that may be needed in third-party database
  232. backends.
  233. * The new :meth:`Model._is_pk_set() <django.db.models.Model._is_pk_set>` method
  234. allows checking if a Model instance's primary key is defined.
  235. :mod:`django.contrib.gis`
  236. -------------------------
  237. * Support for PostGIS 3.0 is removed.
  238. * Support for GDAL 3.0 is removed.
  239. Dropped support for PostgreSQL 13
  240. ---------------------------------
  241. Upstream support for PostgreSQL 13 ends in November 2025. Django 5.2 supports
  242. PostgreSQL 14 and higher.
  243. Miscellaneous
  244. -------------
  245. * Adding :attr:`.EmailMultiAlternatives.alternatives` is now only supported via
  246. the :meth:`~.EmailMultiAlternatives.attach_alternative` method.
  247. * The minimum supported version of ``gettext`` is increased from 0.15 to 0.19.
  248. * ``HttpRequest.accepted_types`` is now sorted by the client's preference, based
  249. on the request's ``Accept`` header.
  250. * :attr:`.UniqueConstraint.violation_error_code` and
  251. :attr:`.UniqueConstraint.violation_error_message` are now always used when
  252. provided. Previously, these were ignored when :attr:`.UniqueConstraint.fields`
  253. were set without a :attr:`.UniqueConstraint.condition`.
  254. * The :func:`~django.template.context_processors.debug` context processor is no
  255. longer included in the default project template.
  256. .. _deprecated-features-5.2:
  257. Features deprecated in 5.2
  258. ==========================
  259. Miscellaneous
  260. -------------
  261. * The ``all`` argument for the ``django.contrib.staticfiles.finders.find()``
  262. function is deprecated in favor of the ``find_all`` argument.