5.2.txt 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. * The :ref:`password validator classes <included-password-validators>`
  66. now have a new method ``get_error_message()``, which can be overridden in
  67. subclasses to customize the error messages.
  68. :mod:`django.contrib.contenttypes`
  69. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  70. * ...
  71. :mod:`django.contrib.gis`
  72. ~~~~~~~~~~~~~~~~~~~~~~~~~
  73. * ...
  74. :mod:`django.contrib.messages`
  75. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  76. * ...
  77. :mod:`django.contrib.postgres`
  78. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  79. * ...
  80. :mod:`django.contrib.redirects`
  81. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  82. * ...
  83. :mod:`django.contrib.sessions`
  84. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  85. * ...
  86. :mod:`django.contrib.sitemaps`
  87. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  88. * ...
  89. :mod:`django.contrib.sites`
  90. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  91. * ...
  92. :mod:`django.contrib.staticfiles`
  93. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  94. * ...
  95. :mod:`django.contrib.syndication`
  96. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  97. * All :class:`~django.utils.feedgenerator.SyndicationFeed` classes now support
  98. a ``stylesheets`` attribute. If specified, an ``<? xml-stylesheet ?>``
  99. processing instruction will be added to the top of the document for each
  100. stylesheet in the given list. See :ref:`feed-stylesheets` for more details.
  101. Asynchronous views
  102. ~~~~~~~~~~~~~~~~~~
  103. * ...
  104. Cache
  105. ~~~~~
  106. * ...
  107. CSRF
  108. ~~~~
  109. * ...
  110. Database backends
  111. ~~~~~~~~~~~~~~~~~
  112. * ...
  113. Decorators
  114. ~~~~~~~~~~
  115. * :func:`~django.utils.decorators.method_decorator` now supports wrapping
  116. asynchronous view methods.
  117. Email
  118. ~~~~~
  119. * Tuple items of :class:`EmailMessage.attachments
  120. <django.core.mail.EmailMessage>` and
  121. :class:`EmailMultiAlternatives.attachments
  122. <django.core.mail.EmailMultiAlternatives>` are now named tuples, as opposed
  123. to regular tuples.
  124. * :attr:`EmailMultiAlternatives.alternatives
  125. <django.core.mail.EmailMultiAlternatives.alternatives>` is now a list of
  126. named tuples, as opposed to regular tuples.
  127. * The new :meth:`~django.core.mail.EmailMultiAlternatives.body_contains` method
  128. returns a boolean indicating whether a provided text is contained in the
  129. email ``body`` and in all attached MIME type ``text/*`` alternatives.
  130. Error Reporting
  131. ~~~~~~~~~~~~~~~
  132. * The attribute :attr:`.SafeExceptionReporterFilter.hidden_settings` now
  133. treats values as sensitive if their name includes ``AUTH``.
  134. File Storage
  135. ~~~~~~~~~~~~
  136. * ...
  137. File Uploads
  138. ~~~~~~~~~~~~
  139. * ...
  140. Forms
  141. ~~~~~
  142. * The new :class:`~django.forms.ColorInput` form widget is for entering a color
  143. in ``rrggbb`` hexadecimal format and renders as ``<input type="color" ...>``.
  144. Some browsers support a visual color picker interface for this input type.
  145. * The new :class:`~django.forms.SearchInput` form widget is for entering search
  146. queries and renders as ``<input type="search" ...>``.
  147. * The new :class:`~django.forms.TelInput` form widget is for entering telephone
  148. numbers and renders as ``<input type="tel" ...>``.
  149. Generic Views
  150. ~~~~~~~~~~~~~
  151. * ...
  152. Internationalization
  153. ~~~~~~~~~~~~~~~~~~~~
  154. * ...
  155. Logging
  156. ~~~~~~~
  157. * ...
  158. Management Commands
  159. ~~~~~~~~~~~~~~~~~~~
  160. * A new warning is printed to the console when running :djadmin:`runserver` that
  161. ``runserver`` is unsuitable for production. This warning can be hidden by
  162. setting the :envvar:`HIDE_PRODUCTION_WARNING` environment variable to
  163. ``"true"``.
  164. * The :djadmin:`makemigrations` and :djadmin:`migrate` commands have a new
  165. ``Command.autodetector`` attribute for subclasses to override in order to use
  166. a custom autodetector class.
  167. Migrations
  168. ~~~~~~~~~~
  169. * ...
  170. Models
  171. ~~~~~~
  172. * The ``SELECT`` clause generated when using
  173. :meth:`QuerySet.values()<django.db.models.query.QuerySet.values>` and
  174. :meth:`~django.db.models.query.QuerySet.values_list` now matches the
  175. specified order of the referenced expressions. Previously the order was based
  176. of a set of counterintuitive rules which made query combination through
  177. methods such as
  178. :meth:`QuerySet.union()<django.db.models.query.QuerySet.union>` unpredictable.
  179. * Added support for validation of model constraints which use a
  180. :class:`~django.db.models.GeneratedField`.
  181. * The new :attr:`.Expression.set_returning` attribute specifies that the
  182. expression contains a set-returning function, enforcing subquery evaluation.
  183. This is necessary for many Postgres set-returning functions.
  184. * :attr:`CharField.max_length <django.db.models.CharField.max_length>` is no
  185. longer required to be set on SQLite, which supports unlimited ``VARCHAR``
  186. columns.
  187. Requests and Responses
  188. ~~~~~~~~~~~~~~~~~~~~~~
  189. * The new :meth:`.HttpRequest.get_preferred_type` method can be used to query
  190. the preferred media type the client accepts.
  191. Security
  192. ~~~~~~~~
  193. * ...
  194. Serialization
  195. ~~~~~~~~~~~~~
  196. * Each serialization format now defines a ``Deserializer`` class, rather than a
  197. function, to improve extensibility when defining a
  198. :ref:`custom serialization format <custom-serialization-formats>`.
  199. Signals
  200. ~~~~~~~
  201. * ...
  202. Templates
  203. ~~~~~~~~~
  204. * ...
  205. Tests
  206. ~~~~~
  207. * Stack frames from Django's custom assertions are now hidden. This makes test
  208. failures easier to read and enables :option:`test --pdb` to directly enter
  209. into the failing test method.
  210. * Data loaded from :attr:`~django.test.TransactionTestCase.fixtures` and from
  211. migrations enabled with :ref:`serialized_rollback=True
  212. <test-case-serialized-rollback>` are now available during
  213. ``TransactionTestCase.setUpClass()``.
  214. URLs
  215. ~~~~
  216. * ...
  217. Utilities
  218. ~~~~~~~~~
  219. * :class:`~django.utils.safestring.SafeString` now returns
  220. :py:data:`NotImplemented` in ``__add__`` for non-string right-hand side
  221. values. This aligns with the :py:class:`str` addition behavior and allows
  222. ``__radd__`` to be used if available.
  223. * :func:`~django.utils.html.format_html_join` now supports taking an iterable
  224. of mappings, passing their contents as keyword arguments to
  225. :func:`~django.utils.html.format_html`.
  226. Validators
  227. ~~~~~~~~~~
  228. * ...
  229. .. _backwards-incompatible-5.2:
  230. Backwards incompatible changes in 5.2
  231. =====================================
  232. Database backend API
  233. --------------------
  234. This section describes changes that may be needed in third-party database
  235. backends.
  236. * The new :meth:`Model._is_pk_set() <django.db.models.Model._is_pk_set>` method
  237. allows checking if a Model instance's primary key is defined.
  238. :mod:`django.contrib.gis`
  239. -------------------------
  240. * Support for PostGIS 3.0 is removed.
  241. * Support for GDAL 3.0 is removed.
  242. Dropped support for PostgreSQL 13
  243. ---------------------------------
  244. Upstream support for PostgreSQL 13 ends in November 2025. Django 5.2 supports
  245. PostgreSQL 14 and higher.
  246. Miscellaneous
  247. -------------
  248. * Adding :attr:`.EmailMultiAlternatives.alternatives` is now only supported via
  249. the :meth:`~.EmailMultiAlternatives.attach_alternative` method.
  250. * The minimum supported version of ``gettext`` is increased from 0.15 to 0.19.
  251. * ``HttpRequest.accepted_types`` is now sorted by the client's preference, based
  252. on the request's ``Accept`` header.
  253. * :attr:`.UniqueConstraint.violation_error_code` and
  254. :attr:`.UniqueConstraint.violation_error_message` are now always used when
  255. provided. Previously, these were ignored when :attr:`.UniqueConstraint.fields`
  256. were set without a :attr:`.UniqueConstraint.condition`.
  257. * The :func:`~django.template.context_processors.debug` context processor is no
  258. longer included in the default project template.
  259. .. _deprecated-features-5.2:
  260. Features deprecated in 5.2
  261. ==========================
  262. Miscellaneous
  263. -------------
  264. * The ``all`` argument for the ``django.contrib.staticfiles.finders.find()``
  265. function is deprecated in favor of the ``find_all`` argument.