4.0.txt 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. ============================================
  2. Django 4.0 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. *Expected December 2021*
  5. Welcome to Django 4.0!
  6. These release notes cover the :ref:`new features <whats-new-4.0>`, as well as
  7. some :ref:`backwards incompatible changes <backwards-incompatible-4.0>` you'll
  8. want to be aware of when upgrading from Django 3.2 or earlier. We've
  9. :ref:`begun the deprecation process for some features
  10. <deprecated-features-4.0>`.
  11. See the :doc:`/howto/upgrade-version` guide if you're updating an existing
  12. project.
  13. Python compatibility
  14. ====================
  15. Django 4.0 supports Python 3.8, 3.9, and 3.10. We **highly recommend** and only
  16. officially support the latest release of each series.
  17. The Django 3.2.x series is the last to support Python 3.6 and 3.7.
  18. .. _whats-new-4.0:
  19. What's new in Django 4.0
  20. ========================
  21. Functional unique constraints
  22. -----------------------------
  23. The new :attr:`*expressions <django.db.models.UniqueConstraint.expressions>`
  24. positional argument of
  25. :class:`UniqueConstraint() <django.db.models.UniqueConstraint>` enables
  26. creating functional unique constraints on expressions and database functions.
  27. For example::
  28. from django.db import models
  29. from django.db.models import UniqueConstraint
  30. from django.db.models.functions import Lower
  31. class MyModel(models.Model):
  32. first_name = models.CharField(max_length=255)
  33. last_name = models.CharField(max_length=255)
  34. class Meta:
  35. indexes = [
  36. UniqueConstraint(
  37. Lower('first_name'),
  38. Lower('last_name').desc(),
  39. name='first_last_name_unique',
  40. ),
  41. ]
  42. Functional unique constraints are added to models using the
  43. :attr:`Meta.constraints <django.db.models.Options.constraints>` option.
  44. Minor features
  45. --------------
  46. :mod:`django.contrib.admin`
  47. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  48. * The ``admin/base.html`` template now has a new block ``header`` which
  49. contains the admin site header.
  50. * The new :meth:`.ModelAdmin.get_formset_kwargs` method allows customizing the
  51. keyword arguments passed to the constructor of a formset.
  52. :mod:`django.contrib.admindocs`
  53. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  54. * The admindocs now allows esoteric setups where :setting:`ROOT_URLCONF` is not
  55. a string.
  56. * The model section of the ``admindocs`` now shows cached properties.
  57. :mod:`django.contrib.auth`
  58. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  59. * The default iteration count for the PBKDF2 password hasher is increased from
  60. 260,000 to 320,000.
  61. * The new
  62. :attr:`LoginView.next_page <django.contrib.auth.views.LoginView.next_page>`
  63. attribute and
  64. :meth:`~django.contrib.auth.views.LoginView.get_default_redirect_url` method
  65. allow customizing the redirect after login.
  66. :mod:`django.contrib.contenttypes`
  67. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. * ...
  69. :mod:`django.contrib.gis`
  70. ~~~~~~~~~~~~~~~~~~~~~~~~~
  71. * ...
  72. :mod:`django.contrib.messages`
  73. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74. * ...
  75. :mod:`django.contrib.postgres`
  76. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77. * The PostgreSQL backend now supports connecting by a service name. See
  78. :ref:`postgresql-connection-settings` for more details.
  79. :mod:`django.contrib.redirects`
  80. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  81. * ...
  82. :mod:`django.contrib.sessions`
  83. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  84. * ...
  85. :mod:`django.contrib.sitemaps`
  86. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  87. * ...
  88. :mod:`django.contrib.sites`
  89. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  90. * ...
  91. :mod:`django.contrib.staticfiles`
  92. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  93. * ...
  94. :mod:`django.contrib.syndication`
  95. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  96. * ...
  97. Cache
  98. ~~~~~
  99. * ...
  100. CSRF
  101. ~~~~
  102. * ...
  103. Decorators
  104. ~~~~~~~~~~
  105. * ...
  106. Email
  107. ~~~~~
  108. * ...
  109. Error Reporting
  110. ~~~~~~~~~~~~~~~
  111. * ...
  112. File Storage
  113. ~~~~~~~~~~~~
  114. * ...
  115. File Uploads
  116. ~~~~~~~~~~~~
  117. * ...
  118. Forms
  119. ~~~~~
  120. * :class:`~django.forms.ModelChoiceField` now includes the provided value in
  121. the ``params`` argument of a raised
  122. :exc:`~django.core.exceptions.ValidationError` for the ``invalid_choice``
  123. error message. This allows custom error messages to use the ``%(value)s``
  124. placeholder.
  125. Generic Views
  126. ~~~~~~~~~~~~~
  127. * ...
  128. Internationalization
  129. ~~~~~~~~~~~~~~~~~~~~
  130. * ...
  131. Logging
  132. ~~~~~~~
  133. * ...
  134. Management Commands
  135. ~~~~~~~~~~~~~~~~~~~
  136. * The :djadmin:`runserver` management command now supports the
  137. :option:`--skip-checks` option.
  138. Migrations
  139. ~~~~~~~~~~
  140. * ...
  141. Models
  142. ~~~~~~
  143. * ...
  144. Requests and Responses
  145. ~~~~~~~~~~~~~~~~~~~~~~
  146. * ...
  147. Security
  148. ~~~~~~~~
  149. * ...
  150. Serialization
  151. ~~~~~~~~~~~~~
  152. * ...
  153. Signals
  154. ~~~~~~~
  155. * The new ``stdout`` argument for :func:`~django.db.models.signals.pre_migrate`
  156. and :func:`~django.db.models.signals.post_migrate` signals allows redirecting
  157. output to a stream-like object. It should be preferred over
  158. :py:data:`sys.stdout` and :py:func:`print` when emitting verbose output in
  159. order to allow proper capture when testing.
  160. Templates
  161. ~~~~~~~~~
  162. * ...
  163. Tests
  164. ~~~~~
  165. * ...
  166. URLs
  167. ~~~~
  168. * ...
  169. Utilities
  170. ~~~~~~~~~
  171. * ...
  172. Validators
  173. ~~~~~~~~~~
  174. * ...
  175. .. _backwards-incompatible-4.0:
  176. Backwards incompatible changes in 4.0
  177. =====================================
  178. Database backend API
  179. --------------------
  180. This section describes changes that may be needed in third-party database
  181. backends.
  182. * ...
  183. :mod:`django.contrib.gis`
  184. -------------------------
  185. * Support for PostGIS 2.3 is removed.
  186. Dropped support for PostgreSQL 9.6
  187. ----------------------------------
  188. Upstream support for PostgreSQL 9.6 ends in November 2021. Django 4.0 supports
  189. PostgreSQL 10 and higher.
  190. Dropped support for Oracle 12.2 and 18c
  191. ---------------------------------------
  192. Upstream support for Oracle 12.2 ends in March 2022 and for Oracle 18c it ends
  193. in June 2021. Django 3.2 will be supported until April 2024. Django 4.0
  194. officially supports Oracle 19c.
  195. Miscellaneous
  196. -------------
  197. * Support for ``cx_Oracle`` < 7.0 is removed.
  198. * To allow serving a Django site on a subpath without changing the value of
  199. :setting:`STATIC_URL`, the leading slash is removed from that setting (now
  200. ``'static/'``) in the default :djadmin:`startproject` template.
  201. .. _deprecated-features-4.0:
  202. Features deprecated in 4.0
  203. ==========================
  204. Miscellaneous
  205. -------------
  206. * ...
  207. Features removed in 4.0
  208. =======================
  209. These features have reached the end of their deprecation cycle and are removed
  210. in Django 4.0.
  211. See :ref:`deprecated-features-3.0` for details on these changes, including how
  212. to remove usage of these features.
  213. * ``django.utils.http.urlquote()``, ``urlquote_plus()``, ``urlunquote()``, and
  214. ``urlunquote_plus()`` are removed.
  215. * ``django.utils.encoding.force_text()`` and ``smart_text()`` are removed.
  216. * ``django.utils.translation.ugettext()``, ``ugettext_lazy()``,
  217. ``ugettext_noop()``, ``ungettext()``, and ``ungettext_lazy()`` are removed.
  218. * ``django.views.i18n.set_language()`` doesn't set the user language in
  219. ``request.session`` (key ``_language``).
  220. * ``alias=None`` is required in the signature of
  221. ``django.db.models.Expression.get_group_by_cols()`` subclasses.
  222. * ``django.utils.text.unescape_entities()`` is removed.
  223. * ``django.utils.http.is_safe_url()`` is removed.
  224. See :ref:`deprecated-features-3.1` for details on these changes, including how
  225. to remove usage of these features.
  226. * The ``PASSWORD_RESET_TIMEOUT_DAYS`` setting is removed.
  227. * The :lookup:`isnull` lookup no longer allows using non-boolean values as the
  228. right-hand side.
  229. * The ``django.db.models.query_utils.InvalidQuery`` exception class is removed.
  230. * The ``django-admin.py`` entry point is removed.
  231. * The ``HttpRequest.is_ajax()`` method is removed.
  232. * Support for the pre-Django 3.1 encoding format of cookies values used by
  233. ``django.contrib.messages.storage.cookie.CookieStorage`` is removed.
  234. * Support for the pre-Django 3.1 password reset tokens in the admin site (that
  235. use the SHA-1 hashing algorithm) is removed.
  236. * Support for the pre-Django 3.1 encoding format of sessions is removed.
  237. * Support for the pre-Django 3.1 ``django.core.signing.Signer`` signatures
  238. (encoded with the SHA-1 algorithm) is removed.
  239. * Support for the pre-Django 3.1 ``django.core.signing.dumps()`` signatures
  240. (encoded with the SHA-1 algorithm) in ``django.core.signing.loads()`` is
  241. removed.
  242. * Support for the pre-Django 3.1 user sessions (that use the SHA-1 algorithm)
  243. is removed.
  244. * The ``get_request`` argument for
  245. ``django.utils.deprecation.MiddlewareMixin.__init__()`` is required and
  246. doesn't accept ``None``.
  247. * The ``providing_args`` argument for ``django.dispatch.Signal`` is removed.
  248. * The ``length`` argument for ``django.utils.crypto.get_random_string()`` is
  249. required.
  250. * The ``list`` message for ``ModelMultipleChoiceField`` is removed.
  251. * Support for passing raw column aliases to ``QuerySet.order_by()`` is removed.
  252. * The ``NullBooleanField`` model field is removed, except for support in
  253. historical migrations.
  254. * ``django.conf.urls.url()`` is removed.
  255. * The ``django.contrib.postgres.fields.JSONField`` model field is removed,
  256. except for support in historical migrations.
  257. * ``django.contrib.postgres.fields.jsonb.KeyTransform`` and
  258. ``django.contrib.postgres.fields.jsonb.KeyTextTransform`` are removed.
  259. * ``django.contrib.postgres.forms.JSONField`` is removed.
  260. * The ``{% ifequal %}`` and ``{% ifnotequal %}`` template tags are removed.
  261. * The ``DEFAULT_HASHING_ALGORITHM`` transitional setting is removed.