4.2.txt 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. ============================================
  2. Django 4.2 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. *Expected April 2023*
  5. Welcome to Django 4.2!
  6. These release notes cover the :ref:`new features <whats-new-4.2>`, as well as
  7. some :ref:`backwards incompatible changes <backwards-incompatible-4.2>` you'll
  8. want to be aware of when upgrading from Django 4.1 or earlier. We've
  9. :ref:`begun the deprecation process for some features
  10. <deprecated-features-4.2>`.
  11. See the :doc:`/howto/upgrade-version` guide if you're updating an existing
  12. project.
  13. Python compatibility
  14. ====================
  15. Django 4.2 supports Python 3.8, 3.9, 3.10, and 3.11. We **highly recommend**
  16. and only officially support the latest release of each series.
  17. .. _whats-new-4.2:
  18. What's new in Django 4.2
  19. ========================
  20. Minor features
  21. --------------
  22. :mod:`django.contrib.admin`
  23. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. * The light or dark color theme of the admin can now be toggled in the UI, as
  25. well as being set to follow the system setting.
  26. * The admin's font stack now prefers system UI fonts and no longer requires
  27. downloading fonts. Additionally, CSS variables are available to more easily
  28. override the default font families.
  29. * The :source:`admin/delete_confirmation.html
  30. <django/contrib/admin/templates/admin/delete_confirmation.html>` template now
  31. has some additional blocks and scripting hooks to ease customization.
  32. * The chosen options of
  33. :attr:`~django.contrib.admin.ModelAdmin.filter_horizontal` and
  34. :attr:`~django.contrib.admin.ModelAdmin.filter_vertical` widgets are now
  35. filterable.
  36. :mod:`django.contrib.admindocs`
  37. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. * ...
  39. :mod:`django.contrib.auth`
  40. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  41. * The default iteration count for the PBKDF2 password hasher is increased from
  42. 390,000 to 480,000.
  43. :mod:`django.contrib.contenttypes`
  44. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  45. * ...
  46. :mod:`django.contrib.gis`
  47. ~~~~~~~~~~~~~~~~~~~~~~~~~
  48. * The :doc:`GeoJSON serializer </ref/contrib/gis/serializers>` now outputs the
  49. ``id`` key for serialized features, which defaults to the primary key of
  50. objects.
  51. * The :class:`~django.contrib.gis.gdal.GDALRaster` class now supports
  52. :class:`pathlib.Path`.
  53. * The :class:`~django.contrib.gis.geoip2.GeoIP2` class now supports ``.mmdb``
  54. files downloaded from DB-IP.
  55. * The OpenLayers template widget no longer includes inline CSS (which also
  56. removes the former ``map_css`` block) to better comply with a strict Content
  57. Security Policy.
  58. :mod:`django.contrib.messages`
  59. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  60. * ...
  61. :mod:`django.contrib.postgres`
  62. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  63. * The new :lookup:`trigram_strict_word_similar` lookup, and the
  64. :class:`TrigramStrictWordSimilarity()
  65. <django.contrib.postgres.search.TrigramStrictWordSimilarity>` and
  66. :class:`TrigramStrictWordDistance()
  67. <django.contrib.postgres.search.TrigramStrictWordDistance>` expressions allow
  68. using trigram strict word similarity.
  69. :mod:`django.contrib.redirects`
  70. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  71. * ...
  72. :mod:`django.contrib.sessions`
  73. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74. * ...
  75. :mod:`django.contrib.sitemaps`
  76. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77. * ...
  78. :mod:`django.contrib.sites`
  79. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80. * ...
  81. :mod:`django.contrib.staticfiles`
  82. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  83. * ...
  84. :mod:`django.contrib.syndication`
  85. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  86. * ...
  87. Cache
  88. ~~~~~
  89. * ...
  90. CSRF
  91. ~~~~
  92. * ...
  93. Decorators
  94. ~~~~~~~~~~
  95. * ...
  96. Email
  97. ~~~~~
  98. * ...
  99. Error Reporting
  100. ~~~~~~~~~~~~~~~
  101. * ...
  102. File Storage
  103. ~~~~~~~~~~~~
  104. * ...
  105. File Uploads
  106. ~~~~~~~~~~~~
  107. * ...
  108. Forms
  109. ~~~~~
  110. * :class:`~django.forms.ModelForm` now accepts the new ``Meta`` option
  111. ``formfield_callback`` to customize form fields.
  112. * :func:`~django.forms.models.modelform_factory` now respects the
  113. ``formfield_callback`` attribute of the ``form``’s ``Meta``.
  114. Generic Views
  115. ~~~~~~~~~~~~~
  116. * ...
  117. Internationalization
  118. ~~~~~~~~~~~~~~~~~~~~
  119. * Added support and translations for the Central Kurdish (Sorani) language.
  120. Logging
  121. ~~~~~~~
  122. * ...
  123. Management Commands
  124. ~~~~~~~~~~~~~~~~~~~
  125. * :djadmin:`makemessages` command now supports locales with private sub-tags
  126. such as ``nl_NL-x-informal``.
  127. * The new :option:`makemigrations --update` option merges model changes into
  128. the latest migration and optimizes the resulting operations.
  129. Migrations
  130. ~~~~~~~~~~
  131. * Migrations now support serialization of ``enum.Flag`` objects.
  132. Models
  133. ~~~~~~
  134. * ``QuerySet`` now extensively supports filtering against
  135. :ref:`window-functions` with the exception of disjunctive filter lookups
  136. against window functions when performing aggregation.
  137. * :meth:`~.QuerySet.prefetch_related` now supports
  138. :class:`~django.db.models.Prefetch` objects with sliced querysets.
  139. * :ref:`Registering lookups <lookup-registration-api>` on
  140. :class:`~django.db.models.Field` instances is now supported.
  141. * The new ``robust`` argument for :func:`~django.db.transaction.on_commit`
  142. allows performing actions that can fail after a database transaction is
  143. successfully committed.
  144. Requests and Responses
  145. ~~~~~~~~~~~~~~~~~~~~~~
  146. * ...
  147. Security
  148. ~~~~~~~~
  149. * ...
  150. Serialization
  151. ~~~~~~~~~~~~~
  152. * ...
  153. Signals
  154. ~~~~~~~
  155. * ...
  156. Templates
  157. ~~~~~~~~~
  158. * ...
  159. Tests
  160. ~~~~~
  161. * ...
  162. URLs
  163. ~~~~
  164. * ...
  165. Utilities
  166. ~~~~~~~~~
  167. * The new ``encoder`` parameter for :meth:`django.utils.html.json_script`
  168. function allows customizing a JSON encoder class.
  169. * The private internal vendored copy of ``urllib.parse.urlsplit()`` now strips
  170. ``'\r'``, ``'\n'``, and ``'\t'`` (see :cve:`2022-0391` and :bpo:`43882`).
  171. This is to protect projects that may be incorrectly using the internal
  172. ``url_has_allowed_host_and_scheme()`` function, instead of using one of the
  173. documented functions for handling URL redirects. The Django functions were
  174. not affected.
  175. Validators
  176. ~~~~~~~~~~
  177. * ...
  178. .. _backwards-incompatible-4.2:
  179. Backwards incompatible changes in 4.2
  180. =====================================
  181. Database backend API
  182. --------------------
  183. This section describes changes that may be needed in third-party database
  184. backends.
  185. * ...
  186. Dropped support for MariaDB 10.3
  187. --------------------------------
  188. Upstream support for MariaDB 10.3 ends in May 2023. Django 4.2 supports MariaDB
  189. 10.4 and higher.
  190. Dropped support for MySQL 5.7
  191. -----------------------------
  192. Upstream support for MySQL 5.7 ends in October 2023. Django 4.2 supports MySQL
  193. 8 and higher.
  194. Dropped support for PostgreSQL 11
  195. ---------------------------------
  196. Upstream support for PostgreSQL 11 ends in November 2023. Django 4.2 supports
  197. PostgreSQL 12 and higher.
  198. Miscellaneous
  199. -------------
  200. * The undocumented ``SimpleTemplateResponse.rendering_attrs`` and
  201. ``TemplateResponse.rendering_attrs`` are renamed to ``non_picklable_attrs``.
  202. * The undocumented ``django.http.multipartparser.parse_header()`` function is
  203. removed. Use ``django.utils.http.parse_header_parameters()`` instead.
  204. * :ttag:`{% blocktranslate asvar … %}<blocktranslate>` result is now marked as
  205. safe for (HTML) output purposes.
  206. .. _deprecated-features-4.2:
  207. Features deprecated in 4.2
  208. ==========================
  209. ``index_together`` option is deprecated in favor of ``indexes``
  210. ---------------------------------------------------------------
  211. The :attr:`Meta.index_together <django.db.models.Options.index_together>`
  212. option is deprecated in favor of the :attr:`~django.db.models.Options.indexes`
  213. option.
  214. Migrating existing ``index_together`` should be handled as a migration. For
  215. example::
  216. class Author(models.Model):
  217. rank = models.IntegerField()
  218. name = models.CharField(max_length=30)
  219. class Meta:
  220. index_together = [["rank", "name"]]
  221. Should become::
  222. class Author(models.Model):
  223. rank = models.IntegerField()
  224. name = models.CharField(max_length=30)
  225. class Meta:
  226. indexes = [models.Index(fields=["rank", "name"])]
  227. Running the :djadmin:`makemigrations` command will generate a migration
  228. containing a :class:`~django.db.migrations.operations.RenameIndex` operation
  229. which will rename the existing index.
  230. The ``AlterIndexTogether`` migration operation is now officially supported only
  231. for pre-Django 4.2 migration files. For backward compatibility reasons, it's
  232. still part of the public API, and there's no plan to deprecate or remove it,
  233. but it should not be used for new migrations. Use
  234. :class:`~django.db.migrations.operations.AddIndex` and
  235. :class:`~django.db.migrations.operations.RemoveIndex` operations instead.
  236. Miscellaneous
  237. -------------
  238. * The ``BaseUserManager.make_random_password()`` method is deprecated. See
  239. `recipes and best practices
  240. <https://docs.python.org/3/library/secrets.html#recipes-and-best-practices>`_
  241. for using Python's :py:mod:`secrets` module to generate passwords.
  242. * The ``length_is`` template filter is deprecated in favor of :tfilter:`length`
  243. and the ``==`` operator within an :ttag:`{% if %}<if>` tag. For example
  244. .. code-block:: html+django
  245. {% if value|length == 4 %}…{% endif %}
  246. {% if value|length == 4 %}True{% else %}False{% endif %}
  247. instead of:
  248. .. code-block:: html+django
  249. {% if value|length_is:4 %}…{% endif %}
  250. {{ value|length_is:4 }}
  251. * ``django.contrib.auth.hashers.SHA1PasswordHasher``,
  252. ``django.contrib.auth.hashers.UnsaltedSHA1PasswordHasher``, and
  253. ``django.contrib.auth.hashers.UnsaltedMD5PasswordHasher`` are deprecated.
  254. * ``django.contrib.postgres.fields.CICharField`` is deprecated in favor of
  255. ``CharField(db_collation="…")`` with a case-insensitive non-deterministic
  256. collation.
  257. * ``django.contrib.postgres.fields.CIEmailField`` is deprecated in favor of
  258. ``EmailField(db_collation="…")`` with a case-insensitive non-deterministic
  259. collation.
  260. * ``django.contrib.postgres.fields.CITextField`` is deprecated in favor of
  261. ``TextField(db_collation="…")`` with a case-insensitive non-deterministic
  262. collation.
  263. * ``django.contrib.postgres.fields.CIText`` mixin is deprecated.
  264. * The ``map_height`` and ``map_width`` attributes of ``BaseGeometryWidget`` are
  265. deprecated, use CSS to size map widgets instead.