4.2.txt 7.4 KB

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