4.2.txt 8.8 KB

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