4.1.txt 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. ============================================
  2. Django 4.1 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. *Expected August 2022*
  5. Welcome to Django 4.1!
  6. These release notes cover the :ref:`new features <whats-new-4.1>`, as well as
  7. some :ref:`backwards incompatible changes <backwards-incompatible-4.1>` you'll
  8. want to be aware of when upgrading from Django 4.0 or earlier. We've
  9. :ref:`begun the deprecation process for some features
  10. <deprecated-features-4.1>`.
  11. See the :doc:`/howto/upgrade-version` guide if you're updating an existing
  12. project.
  13. Python compatibility
  14. ====================
  15. Django 4.1 supports Python 3.8, 3.9, and 3.10. We **highly recommend** and only
  16. officially support the latest release of each series.
  17. .. _whats-new-4.1:
  18. What's new in Django 4.1
  19. ========================
  20. Asynchronous handlers for class-based views
  21. -------------------------------------------
  22. View subclasses may now define async HTTP method handlers::
  23. import asyncio
  24. from django.http import HttpResponse
  25. from django.views import View
  26. class AsyncView(View):
  27. async def get(self, request, *args, **kwargs):
  28. # Perform view logic using await.
  29. await asyncio.sleep(1)
  30. return HttpResponse("Hello async world!")
  31. See :ref:`async-class-based-views` for more details.
  32. Asynchronous ORM interface
  33. --------------------------
  34. ``QuerySet`` now provides an asynchronous interface for all data access
  35. operations. These are named as-per the existing synchronous operations but with
  36. an ``a`` prefix, for example ``acreate()``, ``aget()``, and so on.
  37. The new interface allows you to write asynchronous code without needing to wrap
  38. ORM operations in ``sync_to_async()``::
  39. async for author in Author.objects.filter(name__startswith="A"):
  40. book = await author.books.afirst()
  41. Note that, at this stage, the underlying database operations remain
  42. synchronous, with contributions ongoing to push asynchronous support down into
  43. the SQL compiler, and integrate asynchronous database drivers. The new
  44. asynchronous queryset interface currently encapsulates the necessary
  45. ``sync_to_async()`` operations for you, and will allow your code to take
  46. advantage of developments in the ORM's asynchronous support as it evolves.
  47. See :ref:`async-queries` for details and limitations.
  48. Validation of Constraints
  49. -------------------------
  50. :class:`Check <django.db.models.CheckConstraint>`,
  51. :class:`unique <django.db.models.UniqueConstraint>`, and :class:`exclusion
  52. <django.contrib.postgres.constraints.ExclusionConstraint>` constraints defined
  53. in the :attr:`Meta.constraints <django.db.models.Options.constraints>` option
  54. are now checked during :ref:`model validation <validating-objects>`.
  55. .. _csrf-cookie-masked-usage:
  56. ``CSRF_COOKIE_MASKED`` setting
  57. ------------------------------
  58. The new :setting:`CSRF_COOKIE_MASKED` transitional setting allows specifying
  59. whether to mask the CSRF cookie.
  60. :class:`~django.middleware.csrf.CsrfViewMiddleware` no longer masks the CSRF
  61. cookie like it does the CSRF token in the DOM. If you are upgrading multiple
  62. instances of the same project to Django 4.1, you should set
  63. :setting:`CSRF_COOKIE_MASKED` to ``True`` during the transition, in
  64. order to allow compatibility with the older versions of Django. Once the
  65. transition to 4.1 is complete you can stop overriding
  66. :setting:`CSRF_COOKIE_MASKED`.
  67. This setting is deprecated as of this release and will be removed in Django
  68. 5.0.
  69. Minor features
  70. --------------
  71. :mod:`django.contrib.admin`
  72. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  73. * The admin :ref:`dark mode CSS variables <admin-theming>` are now applied in a
  74. separate stylesheet and template block.
  75. * :ref:`modeladmin-list-filters` providing custom ``FieldListFilter``
  76. subclasses can now control the query string value separator when filtering
  77. for multiple values using the ``__in`` lookup.
  78. * The admin :meth:`history view <django.contrib.admin.ModelAdmin.history_view>`
  79. is now paginated.
  80. * Related widget wrappers now have a link to object's change form.
  81. * The :meth:`.AdminSite.get_app_list` method now allows changing the order of
  82. apps and models on the admin index page.
  83. :mod:`django.contrib.admindocs`
  84. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  85. * ...
  86. :mod:`django.contrib.auth`
  87. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  88. * The default iteration count for the PBKDF2 password hasher is increased from
  89. 320,000 to 390,000.
  90. * The :meth:`.RemoteUserBackend.configure_user` method now allows synchronizing
  91. user attributes with attributes in a remote system such as an LDAP directory.
  92. :mod:`django.contrib.contenttypes`
  93. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  94. * ...
  95. :mod:`django.contrib.gis`
  96. ~~~~~~~~~~~~~~~~~~~~~~~~~
  97. * The new :meth:`.GEOSGeometry.make_valid()` method allows converting invalid
  98. geometries to valid ones.
  99. :mod:`django.contrib.messages`
  100. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  101. * ...
  102. :mod:`django.contrib.postgres`
  103. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  104. * The new :class:`BitXor() <django.contrib.postgres.aggregates.BitXor>`
  105. aggregate function returns an ``int`` of the bitwise ``XOR`` of all non-null
  106. input values.
  107. * :class:`~django.contrib.postgres.indexes.SpGistIndex` now supports covering
  108. indexes on PostgreSQL 14+.
  109. * :class:`~django.contrib.postgres.constraints.ExclusionConstraint` now
  110. supports covering exclusion constraints using SP-GiST indexes on PostgreSQL
  111. 14+.
  112. * The new ``default_bounds`` attribute of :attr:`DateTimeRangeField
  113. <django.contrib.postgres.fields.DateTimeRangeField.default_bounds>` and
  114. :attr:`DecimalRangeField
  115. <django.contrib.postgres.fields.DecimalRangeField.default_bounds>` allows
  116. specifying bounds for list and tuple inputs.
  117. * :class:`~django.contrib.postgres.constraints.ExclusionConstraint` now allows
  118. specifying operator classes with the
  119. :class:`OpClass() <django.contrib.postgres.indexes.OpClass>` expression.
  120. :mod:`django.contrib.redirects`
  121. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  122. * ...
  123. :mod:`django.contrib.sessions`
  124. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  125. * ...
  126. :mod:`django.contrib.sitemaps`
  127. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  128. * The default sitemap index template ``<sitemapindex>`` now includes the
  129. ``<lastmod>`` timestamp where available, through the new
  130. :meth:`~django.contrib.sitemaps.Sitemap.get_latest_lastmod` method. Custom
  131. sitemap index templates should be updated for the adjusted :ref:`context
  132. variables <sitemap-index-context-variables>`.
  133. :mod:`django.contrib.sites`
  134. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  135. * ...
  136. :mod:`django.contrib.staticfiles`
  137. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  138. * :class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage` now
  139. replaces paths to CSS source map references with their hashed counterparts.
  140. :mod:`django.contrib.syndication`
  141. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  142. * ...
  143. Cache
  144. ~~~~~
  145. * ...
  146. CSRF
  147. ~~~~
  148. * ...
  149. Database backends
  150. ~~~~~~~~~~~~~~~~~
  151. * Third-party database backends can now specify the minimum required version of
  152. the database using the ``DatabaseFeatures.minimum_database_version``
  153. attribute which is a tuple (e.g. ``(10, 0)`` means "10.0"). If a minimum
  154. version is specified, backends must also implement
  155. ``DatabaseWrapper.get_database_version()``, which returns a tuple of the
  156. current database version. The backend's
  157. ``DatabaseWrapper.init_connection_state()`` method must call ``super()`` in
  158. order for the check to run.
  159. Decorators
  160. ~~~~~~~~~~
  161. * ...
  162. Email
  163. ~~~~~
  164. * ...
  165. Error Reporting
  166. ~~~~~~~~~~~~~~~
  167. * ...
  168. File Storage
  169. ~~~~~~~~~~~~
  170. * ...
  171. File Uploads
  172. ~~~~~~~~~~~~
  173. * ...
  174. Forms
  175. ~~~~~
  176. * The default template used to render forms when cast to a string, e.g. in
  177. templates as ``{{ form }}``, is now configurable at the project-level by
  178. setting :attr:`~django.forms.renderers.BaseRenderer.form_template_name` on
  179. the class provided for :setting:`FORM_RENDERER`.
  180. :attr:`.Form.template_name` is now a property deferring to the renderer, but
  181. may be overridden with a string value to specify the template name per-form
  182. class.
  183. Similarly, the default template used to render formsets can be specified via
  184. the matching
  185. :attr:`~django.forms.renderers.BaseRenderer.formset_template_name` renderer
  186. attribute.
  187. * The new ``div.html`` form template, referencing
  188. :attr:`.Form.template_name_div` attribute, and matching :meth:`.Form.as_div`
  189. method, render forms using HTML ``<div>`` elements.
  190. This new output style is recommended over the existing
  191. :meth:`~.Form.as_table`, :meth:`~.Form.as_p` and :meth:`~.Form.as_ul` styles,
  192. as the template implements ``<fieldset>`` and ``<legend>`` to group related
  193. inputs and is easier for screen reader users to navigate.
  194. * The new :meth:`~django.forms.BoundField.legend_tag` allows rendering field
  195. labels in ``<legend>`` tags via the new ``tag`` argument of
  196. :meth:`~django.forms.BoundField.label_tag`.
  197. * The new ``edit_only`` argument for :func:`.modelformset_factory` and
  198. :func:`.inlineformset_factory` allows preventing new objects creation.
  199. * The ``js`` and ``css`` class attributes of :doc:`Media </topics/forms/media>`
  200. now allow using hashable objects, not only path strings, as long as those
  201. objects implement the ``__html__()`` method (typically when decorated with
  202. the :func:`~django.utils.html.html_safe` decorator).
  203. * The new :attr:`.BoundField.use_fieldset` and :attr:`.Widget.use_fieldset`
  204. attributes help to identify widgets where its inputs should be grouped in a
  205. ``<fieldset>`` with a ``<legend>``.
  206. * The :ref:`formsets-error-messages` argument for
  207. :class:`~django.forms.formsets.BaseFormSet` now allows customizing
  208. error messages for invalid number of forms by passing ``'too_few_forms'``
  209. and ``'too_many_forms'`` keys.
  210. * :class:`~django.forms.IntegerField`, :class:`~django.forms.FloatField`, and
  211. :class:`~django.forms.DecimalField` now optionally accept a ``step_size``
  212. argument. This is used to set the ``step`` HTML attribute, and is validated
  213. on form submission.
  214. Generic Views
  215. ~~~~~~~~~~~~~
  216. * ...
  217. Internationalization
  218. ~~~~~~~~~~~~~~~~~~~~
  219. * The :func:`~django.conf.urls.i18n.i18n_patterns` function now supports
  220. languages with both scripts and regions.
  221. Logging
  222. ~~~~~~~
  223. * ...
  224. Management Commands
  225. ~~~~~~~~~~~~~~~~~~~
  226. * :option:`makemigrations --no-input` now logs default answers and reasons why
  227. migrations cannot be created.
  228. * The new :option:`makemigrations --scriptable` option diverts log output and
  229. input prompts to ``stderr``, writing only paths of generated migration files
  230. to ``stdout``.
  231. * The new :option:`migrate --prune` option allows deleting nonexistent
  232. migrations from the ``django_migrations`` table.
  233. * Python files created by :djadmin:`startproject`, :djadmin:`startapp`,
  234. :djadmin:`optimizemigration`, :djadmin:`makemigrations`, and
  235. :djadmin:`squashmigrations` are now formatted using the ``black`` command if
  236. it is present on your ``PATH``.
  237. * The new :djadmin:`optimizemigration` command allows optimizing operations for
  238. a migration.
  239. Migrations
  240. ~~~~~~~~~~
  241. * The new :class:`~django.db.migrations.operations.RenameIndex` operation
  242. allows renaming indexes defined in the
  243. :attr:`Meta.indexes <django.db.models.Options.indexes>` or
  244. :attr:`~django.db.models.Options.index_together` options.
  245. Models
  246. ~~~~~~
  247. * The ``order_by`` argument of the
  248. :class:`~django.db.models.expressions.Window` expression now accepts string
  249. references to fields and transforms.
  250. * The new :setting:`CONN_HEALTH_CHECKS` setting allows enabling health checks
  251. for :ref:`persistent database connections <persistent-database-connections>`
  252. in order to reduce the number of failed requests, e.g. after database server
  253. restart.
  254. * :meth:`.QuerySet.bulk_create` now supports updating fields when a row
  255. insertion fails uniqueness constraints. This is supported on MariaDB, MySQL,
  256. PostgreSQL, and SQLite 3.24+.
  257. * :meth:`.QuerySet.iterator` now supports prefetching related objects as long
  258. as the ``chunk_size`` argument is provided. In older versions, no prefetching
  259. was done.
  260. * :class:`~django.db.models.Q` objects and querysets can now be combined using
  261. ``^`` as the exclusive or (``XOR``) operator. ``XOR`` is natively supported
  262. on MariaDB and MySQL. For databases that do not support ``XOR``, the query
  263. will be converted to an equivalent using ``AND``, ``OR``, and ``NOT``.
  264. * The new :ref:`Field.non_db_attrs <custom-field-non_db_attrs>` attribute
  265. allows customizing attributes of fields that don't affect a column
  266. definition.
  267. * On PostgreSQL, ``AutoField``, ``BigAutoField``, and ``SmallAutoField`` are
  268. now created as identity columns rather than serial columns with sequences.
  269. Requests and Responses
  270. ~~~~~~~~~~~~~~~~~~~~~~
  271. * :meth:`.HttpResponse.set_cookie` now supports :class:`~datetime.timedelta`
  272. objects for the ``max_age`` argument.
  273. Security
  274. ~~~~~~~~
  275. * The new :setting:`SECRET_KEY_FALLBACKS` setting allows providing a list of
  276. values for secret key rotation.
  277. * The :setting:`SECURE_PROXY_SSL_HEADER` setting now supports a comma-separated
  278. list of protocols in the header value.
  279. Serialization
  280. ~~~~~~~~~~~~~
  281. * ...
  282. Signals
  283. ~~~~~~~
  284. * The :data:`~django.db.models.signals.pre_delete` and
  285. :data:`~django.db.models.signals.post_delete` signals now dispatch the
  286. ``origin`` of the deletion.
  287. .. _templates-4.1:
  288. Templates
  289. ~~~~~~~~~
  290. * :tfilter:`json_script` template filter now allows wrapping in a ``<script>``
  291. tag without the HTML ``id`` attribute.
  292. * The :class:`cached template loader <django.template.loaders.cached.Loader>`
  293. is now enabled in development, when :setting:`DEBUG` is ``True``, and
  294. :setting:`OPTIONS['loaders'] <TEMPLATES-OPTIONS>` isn't specified. You may
  295. specify ``OPTIONS['loaders']`` to override this, if necessary.
  296. Tests
  297. ~~~~~
  298. * The :class:`.DiscoverRunner` now supports running tests in parallel on
  299. macOS, Windows, and any other systems where the default
  300. :mod:`multiprocessing` start method is ``spawn``.
  301. * A nested atomic block marked as durable in :class:`django.test.TestCase` now
  302. raises a ``RuntimeError``, the same as outside of tests.
  303. * :meth:`.SimpleTestCase.assertFormError` and
  304. :meth:`~.SimpleTestCase.assertFormsetError` now support passing a
  305. form/formset object directly.
  306. URLs
  307. ~~~~
  308. * The new :attr:`.ResolverMatch.captured_kwargs` attribute stores the captured
  309. keyword arguments, as parsed from the URL.
  310. * The new :attr:`.ResolverMatch.extra_kwargs` attribute stores the additional
  311. keyword arguments passed to the view function.
  312. Utilities
  313. ~~~~~~~~~
  314. * ``SimpleLazyObject`` now supports addition operations.
  315. * :func:`~django.utils.safestring.mark_safe` now preserves lazy objects.
  316. Validators
  317. ~~~~~~~~~~
  318. * The new :class:`~django.core.validators.StepValueValidator` checks if a value
  319. is an integral multiple of a given step size. This new validator is used for
  320. the new ``step_size`` argument added to form fields representing numeric
  321. values.
  322. .. _backwards-incompatible-4.1:
  323. Backwards incompatible changes in 4.1
  324. =====================================
  325. Database backend API
  326. --------------------
  327. This section describes changes that may be needed in third-party database
  328. backends.
  329. * ``BaseDatabaseFeatures.has_case_insensitive_like`` is changed from ``True``
  330. to ``False`` to reflect the behavior of most databases.
  331. * ``DatabaseIntrospection.get_key_columns()`` is removed. Use
  332. ``DatabaseIntrospection.get_relations()`` instead.
  333. * ``DatabaseOperations.ignore_conflicts_suffix_sql()`` method is replaced by
  334. ``DatabaseOperations.on_conflict_suffix_sql()`` that accepts the ``fields``,
  335. ``on_conflict``, ``update_fields``, and ``unique_fields`` arguments.
  336. * The ``ignore_conflicts`` argument of the
  337. ``DatabaseOperations.insert_statement()`` method is replaced by
  338. ``on_conflict`` that accepts ``django.db.models.constants.OnConflict``.
  339. :mod:`django.contrib.gis`
  340. -------------------------
  341. * Support for GDAL 2.1 is removed.
  342. * Support for PostGIS 2.4 is removed.
  343. Dropped support for PostgreSQL 10
  344. ---------------------------------
  345. Upstream support for PostgreSQL 10 ends in November 2022. Django 4.1 supports
  346. PostgreSQL 11 and higher.
  347. Dropped support for MariaDB 10.2
  348. --------------------------------
  349. Upstream support for MariaDB 10.2 ends in May 2022. Django 4.1 supports MariaDB
  350. 10.3 and higher.
  351. Admin changelist searches spanning multi-valued relationships changes
  352. ---------------------------------------------------------------------
  353. Admin changelist searches using multiple search terms are now applied in a
  354. single call to ``filter()``, rather than in sequential ``filter()`` calls.
  355. For multi-valued relationships, this means that rows from the related model
  356. must match all terms rather than any term. For example, if ``search_fields``
  357. is set to ``['child__name', 'child__age']``, and a user searches for
  358. ``'Jamal 17'``, parent rows will be returned only if there is a relationship to
  359. some 17-year-old child named Jamal, rather than also returning parents who
  360. merely have a younger or older child named Jamal in addition to some other
  361. 17-year-old.
  362. See the :ref:`spanning-multi-valued-relationships` topic for more discussion of
  363. this difference. In Django 4.0 and earlier,
  364. :meth:`~django.contrib.admin.ModelAdmin.get_search_results` followed the
  365. second example query, but this undocumented behavior led to queries with
  366. excessive joins.
  367. Reverse foreign key changes for unsaved model instances
  368. -------------------------------------------------------
  369. In order to unify the behavior with many-to-many relations for unsaved model
  370. instances, a reverse foreign key now raises ``ValueError`` when calling
  371. :class:`related managers <django.db.models.fields.related.RelatedManager>` for
  372. unsaved objects.
  373. Miscellaneous
  374. -------------
  375. * Related managers for :class:`~django.db.models.ForeignKey`,
  376. :class:`~django.db.models.ManyToManyField`, and
  377. :class:`~django.contrib.contenttypes.fields.GenericRelation` are now cached
  378. on the :class:`~django.db.models.Model` instance to which they belong.
  379. * The Django test runner now returns a non-zero error code for unexpected
  380. successes from tests marked with :py:func:`unittest.expectedFailure`.
  381. * :class:`~django.middleware.csrf.CsrfViewMiddleware` no longer masks the CSRF
  382. cookie like it does the CSRF token in the DOM.
  383. * :class:`~django.middleware.csrf.CsrfViewMiddleware` now uses
  384. ``request.META['CSRF_COOKIE']`` for storing the unmasked CSRF secret rather
  385. than a masked version. This is an undocumented, private API.
  386. * The :attr:`.ModelAdmin.actions` and
  387. :attr:`~django.contrib.admin.ModelAdmin.inlines` attributes now default to an
  388. empty tuple rather than an empty list to discourage unintended mutation.
  389. * The ``type="text/css"`` attribute is no longer included in ``<link>`` tags
  390. for CSS :doc:`form media </topics/forms/media>`.
  391. * ``formset:added`` and ``formset:removed`` JavaScript events are now pure
  392. JavaScript events and don't depend on jQuery. See
  393. :ref:`admin-javascript-inline-form-events` for more details on the change.
  394. * The ``exc_info`` argument of the undocumented
  395. ``django.utils.log.log_response()`` function is replaced by ``exception``.
  396. * The ``size`` argument of the undocumented
  397. ``django.views.static.was_modified_since()`` function is removed.
  398. * The admin log out UI now uses ``POST`` requests.
  399. * The undocumented ``InlineAdminFormSet.non_form_errors`` property is replaced
  400. by the ``non_form_errors()`` method. This is consistent with ``BaseFormSet``.
  401. * As per :ref:`above<templates-4.1>`, the cached template loader is now
  402. enabled in development. You may specify ``OPTIONS['loaders']`` to override
  403. this, if necessary.
  404. * The undocumented ``django.contrib.auth.views.SuccessURLAllowedHostsMixin``
  405. mixin is replaced by ``RedirectURLMixin``.
  406. * :class:`~django.db.models.BaseConstraint` subclasses must implement
  407. :meth:`~django.db.models.BaseConstraint.validate` method to allow those
  408. constraints to be used for validation.
  409. .. _deprecated-features-4.1:
  410. Features deprecated in 4.1
  411. ==========================
  412. Log out via GET
  413. ---------------
  414. Logging out via ``GET`` requests to the :py:class:`built-in logout view
  415. <django.contrib.auth.views.LogoutView>` is deprecated. Use ``POST`` requests
  416. instead.
  417. If you want to retain the user experience of an HTML link, you can use a form
  418. that is styled to appear as a link:
  419. .. code-block:: html
  420. <form id="logout-form" method="post" action="{% url 'admin:logout' %}">
  421. {% csrf_token %}
  422. <button type="submit">{% translate "Log out" %}</button>
  423. </form>
  424. .. code-block:: css
  425. #logout-form {
  426. display: inline;
  427. }
  428. #logout-form button {
  429. background: none;
  430. border: none;
  431. cursor: pointer;
  432. padding: 0;
  433. text-decoration: underline;
  434. }
  435. Miscellaneous
  436. -------------
  437. * The context for sitemap index templates of a flat list of URLs is deprecated.
  438. Custom sitemap index templates should be updated for the adjusted
  439. :ref:`context variables <sitemap-index-context-variables>`, expecting a list
  440. of objects with ``location`` and optional ``lastmod`` attributes.
  441. * ``CSRF_COOKIE_MASKED`` transitional setting is deprecated.
  442. * The ``name`` argument of :func:`django.utils.functional.cached_property` is
  443. deprecated as it's unnecessary as of Python 3.6.
  444. * The ``opclasses`` argument of
  445. ``django.contrib.postgres.constraints.ExclusionConstraint`` is deprecated in
  446. favor of using :class:`OpClass() <django.contrib.postgres.indexes.OpClass>`
  447. in :attr:`.ExclusionConstraint.expressions`. To use it, you need to add
  448. ``'django.contrib.postgres'`` in your :setting:`INSTALLED_APPS`.
  449. After making this change, :djadmin:`makemigrations` will generate a new
  450. migration with two operations: ``RemoveConstraint`` and ``AddConstraint``.
  451. Since this change has no effect on the database schema,
  452. the :class:`~django.db.migrations.operations.SeparateDatabaseAndState`
  453. operation can be used to only update the migration state without running any
  454. SQL. Move the generated operations into the ``state_operations`` argument of
  455. :class:`~django.db.migrations.operations.SeparateDatabaseAndState`. For
  456. example::
  457. class Migration(migrations.Migration):
  458. ...
  459. operations = [
  460. migrations.SeparateDatabaseAndState(
  461. database_operations=[],
  462. state_operations=[
  463. migrations.RemoveConstraint(
  464. ...
  465. ),
  466. migrations.AddConstraint(
  467. ...
  468. ),
  469. ],
  470. ),
  471. ]
  472. * The undocumented ability to pass ``errors=None`` to
  473. :meth:`.SimpleTestCase.assertFormError` and
  474. :meth:`~.SimpleTestCase.assertFormsetError` is deprecated. Use ``errors=[]``
  475. instead.
  476. * ``django.contrib.sessions.serializers.PickleSerializer`` is deprecated due to
  477. the risk of remote code execution.
  478. * The usage of ``QuerySet.iterator()`` on a queryset that prefetches related
  479. objects without providing the ``chunk_size`` argument is deprecated. In older
  480. versions, no prefetching was done. Providing a value for ``chunk_size``
  481. signifies that the additional query per chunk needed to prefetch is desired.
  482. * Passing unsaved model instances to related filters is deprecated. In Django
  483. 5.0, the exception will be raised.
  484. * ``created=True`` is added to the signature of
  485. :meth:`.RemoteUserBackend.configure_user`. Support for ``RemoteUserBackend``
  486. subclasses that do not accept this argument is deprecated.
  487. * The :data:`django.utils.timezone.utc` alias to :attr:`datetime.timezone.utc`
  488. is deprecated. Use :attr:`datetime.timezone.utc` directly.
  489. * Passing a response object and a form/formset name to
  490. ``SimpleTestCase.assertFormError()`` and ``assertFormsetError()`` is
  491. deprecated. Use::
  492. assertFormError(response.context['form_name'], …)
  493. assertFormsetError(response.context['formset_name'], …)
  494. or pass the form/formset object directly instead.
  495. * The undocumented ``django.contrib.gis.admin.OpenLayersWidget`` is deprecated.
  496. * ``django.contrib.auth.hashers.CryptPasswordHasher`` is deprecated.
  497. * The ability to pass ``nulls_first=False`` or ``nulls_last=False`` to
  498. ``Expression.asc()`` and ``Expression.desc()`` methods, and the ``OrderBy``
  499. expression is deprecated. Use ``None`` instead.
  500. Features removed in 4.1
  501. =======================
  502. These features have reached the end of their deprecation cycle and are removed
  503. in Django 4.1.
  504. See :ref:`deprecated-features-3.2` for details on these changes, including how
  505. to remove usage of these features.
  506. * Support for assigning objects which don't support creating deep copies with
  507. ``copy.deepcopy()`` to class attributes in ``TestCase.setUpTestData()`` is
  508. removed.
  509. * Support for using a boolean value in
  510. :attr:`.BaseCommand.requires_system_checks` is removed.
  511. * The ``whitelist`` argument and ``domain_whitelist`` attribute of
  512. ``django.core.validators.EmailValidator`` are removed.
  513. * The ``default_app_config`` application configuration variable is removed.
  514. * ``TransactionTestCase.assertQuerysetEqual()`` no longer calls ``repr()`` on a
  515. queryset when compared to string values.
  516. * The ``django.core.cache.backends.memcached.MemcachedCache`` backend is
  517. removed.
  518. * Support for the pre-Django 3.2 format of messages used by
  519. ``django.contrib.messages.storage.cookie.CookieStorage`` is removed.