3.0.txt 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. ========================
  2. Django 3.0 release notes
  3. ========================
  4. *December 2, 2019*
  5. Welcome to Django 3.0!
  6. These release notes cover the :ref:`new features <whats-new-3.0>`, as well as
  7. some :ref:`backwards incompatible changes <backwards-incompatible-3.0>` you'll
  8. want to be aware of when upgrading from Django 2.2 or earlier. We've
  9. :ref:`dropped some features<removed-features-3.0>` that have reached the end of
  10. their deprecation cycle, and we've :ref:`begun the deprecation process for
  11. some features <deprecated-features-3.0>`.
  12. See the :doc:`/howto/upgrade-version` guide if you're updating an existing
  13. project.
  14. Python compatibility
  15. ====================
  16. Django 3.0 supports Python 3.6, 3.7, 3.8, and 3.9 (as of 3.0.11). We **highly
  17. recommend** and only officially support the latest release of each series.
  18. The Django 2.2.x series is the last to support Python 3.5.
  19. Third-party library support for older version of Django
  20. =======================================================
  21. Following the release of Django 3.0, we suggest that third-party app authors
  22. drop support for all versions of Django prior to 2.2. At that time, you should
  23. be able to run your package's tests using ``python -Wd`` so that deprecation
  24. warnings appear. After making the deprecation warning fixes, your app should be
  25. compatible with Django 3.0.
  26. .. _whats-new-3.0:
  27. What's new in Django 3.0
  28. ========================
  29. MariaDB support
  30. ---------------
  31. Django now officially supports `MariaDB <https://mariadb.org/>`_ 10.1 and
  32. higher. See :ref:`MariaDB notes <mariadb-notes>` for more details.
  33. ASGI support
  34. ------------
  35. Django 3.0 begins our journey to making Django fully async-capable by providing
  36. support for running as an `ASGI <https://asgi.readthedocs.io/>`_ application.
  37. This is in addition to our existing WSGI support. Django intends to support
  38. both for the foreseeable future. Async features will only be available to
  39. applications that run under ASGI, however.
  40. At this stage async support only applies to the outer ASGI application.
  41. Internally everything remains synchronous. Asynchronous middleware, views, etc.
  42. are not yet supported. You can, however, use ASGI middleware around Django's
  43. application, allowing you to combine Django with other ASGI frameworks.
  44. There is no need to switch your applications over unless you want to start
  45. experimenting with asynchronous code, but we have
  46. :doc:`documentation on deploying with ASGI </howto/deployment/asgi/index>` if
  47. you want to learn more.
  48. Note that as a side-effect of this change, Django is now aware of asynchronous
  49. event loops and will block you calling code marked as "async unsafe" - such as
  50. ORM operations - from an asynchronous context. If you were using Django from
  51. async code before, this may trigger if you were doing it incorrectly. If you
  52. see a ``SynchronousOnlyOperation`` error, then closely examine your code and
  53. move any database operations to be in a synchronous child thread.
  54. Exclusion constraints on PostgreSQL
  55. -----------------------------------
  56. The new :class:`~django.contrib.postgres.constraints.ExclusionConstraint` class
  57. enable adding exclusion constraints on PostgreSQL. Constraints are added to
  58. models using the
  59. :attr:`Meta.constraints <django.db.models.Options.constraints>` option.
  60. Filter expressions
  61. ------------------
  62. Expressions that output :class:`~django.db.models.BooleanField` may now be
  63. used directly in ``QuerySet`` filters, without having to first annotate and
  64. then filter against the annotation.
  65. Enumerations for model field choices
  66. ------------------------------------
  67. Custom enumeration types ``TextChoices``, ``IntegerChoices``, and ``Choices``
  68. are now available as a way to define :attr:`.Field.choices`. ``TextChoices``
  69. and ``IntegerChoices`` types are provided for text and integer fields. The
  70. ``Choices`` class allows defining a compatible enumeration for other concrete
  71. data types. These custom enumeration types support human-readable labels that
  72. can be translated and accessed via a property on the enumeration or its
  73. members. See :ref:`Enumeration types <field-choices-enum-types>` for more
  74. details and examples.
  75. Minor features
  76. --------------
  77. :mod:`django.contrib.admin`
  78. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  79. * Added support for the ``admin_order_field`` attribute on properties in
  80. :attr:`.ModelAdmin.list_display`.
  81. * The new :meth:`ModelAdmin.get_inlines()
  82. <django.contrib.admin.ModelAdmin.get_inlines>` method allows specifying the
  83. inlines based on the request or model instance.
  84. * Select2 library is upgraded from version 4.0.3 to 4.0.7.
  85. * jQuery is upgraded from version 3.3.1 to 3.4.1.
  86. :mod:`django.contrib.auth`
  87. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  88. * The new ``reset_url_token`` attribute in
  89. :class:`~django.contrib.auth.views.PasswordResetConfirmView` allows
  90. specifying a token parameter displayed as a component of password reset
  91. URLs.
  92. * Added :class:`~django.contrib.auth.backends.BaseBackend` class to ease
  93. customization of authentication backends.
  94. * Added :meth:`~django.contrib.auth.models.User.get_user_permissions()` method
  95. to mirror the existing
  96. :meth:`~django.contrib.auth.models.User.get_group_permissions()` method.
  97. * Added HTML ``autocomplete`` attribute to widgets of username, email, and
  98. password fields in :mod:`django.contrib.auth.forms` for better interaction
  99. with browser password managers.
  100. * :djadmin:`createsuperuser` now falls back to environment variables for
  101. password and required fields, when a corresponding command line argument
  102. isn't provided in non-interactive mode.
  103. * :attr:`~django.contrib.auth.models.CustomUser.REQUIRED_FIELDS` now supports
  104. :class:`~django.db.models.ManyToManyField`\s.
  105. * The new :meth:`.UserManager.with_perm` method returns users that have the
  106. specified permission.
  107. * The default iteration count for the PBKDF2 password hasher is increased from
  108. 150,000 to 180,000.
  109. :mod:`django.contrib.gis`
  110. ~~~~~~~~~~~~~~~~~~~~~~~~~
  111. * Allowed MySQL spatial lookup functions to operate on real geometries.
  112. Previous support was limited to bounding boxes.
  113. * Added the :class:`~django.contrib.gis.db.models.functions.GeometryDistance`
  114. function, supported on PostGIS.
  115. * Added support for the ``furlong`` unit in
  116. :class:`~django.contrib.gis.measure.Distance`.
  117. * The :setting:`GEOIP_PATH` setting now supports :class:`pathlib.Path`.
  118. * The :class:`~django.contrib.gis.geoip2.GeoIP2` class now accepts
  119. :class:`pathlib.Path` ``path``.
  120. :mod:`django.contrib.postgres`
  121. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  122. * The new :class:`~django.contrib.postgres.fields.RangeOperators` helps to
  123. avoid typos in SQL operators that can be used together with
  124. :class:`~django.contrib.postgres.fields.RangeField`.
  125. * The new :class:`~django.contrib.postgres.fields.RangeBoundary` expression
  126. represents the range boundaries.
  127. * The new :class:`~django.contrib.postgres.operations.AddIndexConcurrently`
  128. and :class:`~django.contrib.postgres.operations.RemoveIndexConcurrently`
  129. classes allow creating and dropping indexes ``CONCURRENTLY`` on PostgreSQL.
  130. :mod:`django.contrib.sessions`
  131. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  132. * The new
  133. :meth:`~django.contrib.sessions.backends.base.SessionBase.get_session_cookie_age()`
  134. method allows dynamically specifying the session cookie age.
  135. :mod:`django.contrib.syndication`
  136. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  137. * Added the ``language`` class attribute to the
  138. :class:`django.contrib.syndication.views.Feed` to customize a feed language.
  139. The default value is :func:`~django.utils.translation.get_language()` instead
  140. of :setting:`LANGUAGE_CODE`.
  141. Cache
  142. ~~~~~
  143. * :func:`~django.utils.cache.add_never_cache_headers` and
  144. :func:`~django.views.decorators.cache.never_cache` now add the ``private``
  145. directive to ``Cache-Control`` headers.
  146. File Storage
  147. ~~~~~~~~~~~~
  148. * The new :meth:`.Storage.get_alternative_name` method allows customizing the
  149. algorithm for generating filenames if a file with the uploaded name already
  150. exists.
  151. Forms
  152. ~~~~~
  153. * Formsets may control the widget used when ordering forms via
  154. :attr:`~django.forms.formsets.BaseFormSet.can_order` by setting the
  155. :attr:`~django.forms.formsets.BaseFormSet.ordering_widget` attribute or
  156. overriding :attr:`~django.forms.formsets.BaseFormSet.get_ordering_widget()`.
  157. Internationalization
  158. ~~~~~~~~~~~~~~~~~~~~
  159. * Added the :setting:`LANGUAGE_COOKIE_HTTPONLY`,
  160. :setting:`LANGUAGE_COOKIE_SAMESITE`, and :setting:`LANGUAGE_COOKIE_SECURE`
  161. settings to set the ``HttpOnly``, ``SameSite``, and ``Secure`` flags on
  162. language cookies. The default values of these settings preserve the previous
  163. behavior.
  164. * Added support and translations for the Uzbek language.
  165. Logging
  166. ~~~~~~~
  167. * The new ``reporter_class`` parameter of
  168. :class:`~django.utils.log.AdminEmailHandler` allows providing an
  169. ``django.views.debug.ExceptionReporter`` subclass to customize the traceback
  170. text sent to site :setting:`ADMINS` when :setting:`DEBUG` is ``False``.
  171. Management Commands
  172. ~~~~~~~~~~~~~~~~~~~
  173. * The new :option:`compilemessages --ignore` option allows ignoring specific
  174. directories when searching for ``.po`` files to compile.
  175. * :option:`showmigrations --list` now shows the applied datetimes when
  176. ``--verbosity`` is 2 and above.
  177. * On PostgreSQL, :djadmin:`dbshell` now supports client-side TLS certificates.
  178. * :djadmin:`inspectdb` now introspects :class:`~django.db.models.OneToOneField`
  179. when a foreign key has a unique or primary key constraint.
  180. * The new :option:`--skip-checks` option skips running system checks prior to
  181. running the command.
  182. * The :option:`startapp --template` and :option:`startproject --template`
  183. options now support templates stored in XZ archives (``.tar.xz``, ``.txz``)
  184. and LZMA archives (``.tar.lzma``, ``.tlz``).
  185. Models
  186. ~~~~~~
  187. * Added hash database functions :class:`~django.db.models.functions.MD5`,
  188. :class:`~django.db.models.functions.SHA1`,
  189. :class:`~django.db.models.functions.SHA224`,
  190. :class:`~django.db.models.functions.SHA256`,
  191. :class:`~django.db.models.functions.SHA384`, and
  192. :class:`~django.db.models.functions.SHA512`.
  193. * Added the :class:`~django.db.models.functions.Sign` database function.
  194. * The new ``is_dst`` parameter of the
  195. :class:`~django.db.models.functions.Trunc` database functions determines the
  196. treatment of nonexistent and ambiguous datetimes.
  197. * ``connection.queries`` now shows ``COPY … TO`` statements on PostgreSQL.
  198. * :class:`~django.db.models.FilePathField` now accepts a callable for ``path``.
  199. * Allowed symmetrical intermediate table for self-referential
  200. :class:`~django.db.models.ManyToManyField`.
  201. * The ``name`` attributes of :class:`~django.db.models.CheckConstraint`,
  202. :class:`~django.db.models.UniqueConstraint`, and
  203. :class:`~django.db.models.Index` now support app label and class
  204. interpolation using the ``'%(app_label)s'`` and ``'%(class)s'`` placeholders.
  205. * The new :attr:`.Field.descriptor_class` attribute allows model fields to
  206. customize the get and set behavior by overriding their
  207. :py:ref:`descriptors <descriptors>`.
  208. * :class:`~django.db.models.Avg` and :class:`~django.db.models.Sum` now support
  209. the ``distinct`` argument.
  210. * Added :class:`~django.db.models.SmallAutoField` which acts much like an
  211. :class:`~django.db.models.AutoField` except that it only allows values under
  212. a certain (database-dependent) limit. Values from ``1`` to ``32767`` are safe
  213. in all databases supported by Django.
  214. * :class:`~django.db.models.AutoField`,
  215. :class:`~django.db.models.BigAutoField`, and
  216. :class:`~django.db.models.SmallAutoField` now inherit from
  217. ``IntegerField``, ``BigIntegerField`` and ``SmallIntegerField`` respectively.
  218. System checks and validators are now also properly inherited.
  219. * :attr:`.FileField.upload_to` now supports :class:`pathlib.Path`.
  220. * :class:`~django.db.models.CheckConstraint` is now supported on MySQL 8.0.16+.
  221. * The new ``allows_group_by_selected_pks_on_model()`` method of
  222. ``django.db.backends.base.BaseDatabaseFeatures`` allows optimization of
  223. ``GROUP BY`` clauses to require only the selected models' primary keys. By
  224. default, it's supported only for managed models on PostgreSQL.
  225. To enable the ``GROUP BY`` primary key-only optimization for unmanaged
  226. models, you have to subclass the PostgreSQL database engine, overriding the
  227. features class ``allows_group_by_selected_pks_on_model()`` method as you
  228. require. See :ref:`Subclassing the built-in database backends
  229. <subclassing-database-backends>` for an example.
  230. Requests and Responses
  231. ~~~~~~~~~~~~~~~~~~~~~~
  232. * Allowed :class:`~django.http.HttpResponse` to be initialized with
  233. :class:`memoryview` content.
  234. * For use in, for example, Django templates, :attr:`.HttpRequest.headers` now
  235. allows lookups using underscores (e.g. ``user_agent``) in place of hyphens.
  236. .. _whats-new-security-3.0:
  237. Security
  238. ~~~~~~~~
  239. * :setting:`X_FRAME_OPTIONS` now defaults to ``'DENY'``. In older versions, the
  240. :setting:`X_FRAME_OPTIONS` setting defaults to ``'SAMEORIGIN'``. If your site
  241. uses frames of itself, you will need to explicitly set ``X_FRAME_OPTIONS =
  242. 'SAMEORIGIN'`` for them to continue working.
  243. * :setting:`SECURE_CONTENT_TYPE_NOSNIFF` now defaults to ``True``. With this
  244. enabled, :class:`~django.middleware.security.SecurityMiddleware` sets the
  245. :ref:`x-content-type-options` header on all responses that do not already
  246. have it.
  247. * :class:`~django.middleware.security.SecurityMiddleware` can now send the
  248. :ref:`Referrer-Policy <referrer-policy>` header.
  249. Tests
  250. ~~~~~
  251. * The new test :class:`~django.test.Client` argument
  252. ``raise_request_exception`` allows controlling whether or not exceptions
  253. raised during the request should also be raised in the test. The value
  254. defaults to ``True`` for backwards compatibility. If it is ``False`` and an
  255. exception occurs, the test client will return a 500 response with the
  256. attribute :attr:`~django.test.Response.exc_info`, a tuple providing
  257. information of the exception that occurred.
  258. * Tests and test cases to run can be selected by test name pattern using the
  259. new :option:`test -k` option.
  260. * HTML comparison, as used by
  261. :meth:`~django.test.SimpleTestCase.assertHTMLEqual`, now treats text, character
  262. references, and entity references that refer to the same character as
  263. equivalent.
  264. * Django test runner now supports headless mode for selenium tests on supported
  265. browsers. Add the ``--headless`` option to enable this mode.
  266. * Django test runner now supports ``--start-at`` and ``--start-after`` options
  267. to run tests starting from a specific top-level module.
  268. * Django test runner now supports a ``--pdb`` option to spawn a debugger at
  269. each error or failure.
  270. .. _backwards-incompatible-3.0:
  271. Backwards incompatible changes in 3.0
  272. =====================================
  273. ``Model.save()`` when providing a default for the primary key
  274. -------------------------------------------------------------
  275. :meth:`.Model.save` no longer attempts to find a row when saving a new
  276. ``Model`` instance and a default value for the primary key is provided, and
  277. always performs a single ``INSERT`` query. In older Django versions,
  278. ``Model.save()`` performed either an ``INSERT`` or an ``UPDATE`` based on
  279. whether or not the row exists.
  280. This makes calling ``Model.save()`` while providing a default primary key value
  281. equivalent to passing :ref:`force_insert=True <ref-models-force-insert>` to
  282. model's ``save()``. Attempts to use a new ``Model`` instance to update an
  283. existing row will result in an ``IntegrityError``.
  284. In order to update an existing model for a specific primary key value, use the
  285. :meth:`~django.db.models.query.QuerySet.update_or_create` method or
  286. ``QuerySet.filter(pk=…).update(…)`` instead. For example:
  287. .. code-block:: pycon
  288. >>> MyModel.objects.update_or_create(pk=existing_pk, defaults={"name": "new name"})
  289. >>> MyModel.objects.filter(pk=existing_pk).update(name="new name")
  290. Database backend API
  291. --------------------
  292. This section describes changes that may be needed in third-party database
  293. backends.
  294. * The second argument of ``DatabaseIntrospection.get_geometry_type()`` is now
  295. the row description instead of the column name.
  296. * ``DatabaseIntrospection.get_field_type()`` may no longer return tuples.
  297. * If the database can create foreign keys in the same SQL statement that adds a
  298. field, add ``SchemaEditor.sql_create_column_inline_fk`` with the appropriate
  299. SQL; otherwise, set ``DatabaseFeatures.can_create_inline_fk = False``.
  300. * ``DatabaseFeatures.can_return_id_from_insert`` and
  301. ``can_return_ids_from_bulk_insert`` are renamed to
  302. ``can_return_columns_from_insert`` and ``can_return_rows_from_bulk_insert``.
  303. * Database functions now handle :class:`datetime.timezone` formats when created
  304. using :class:`datetime.timedelta` instances (e.g.
  305. ``timezone(timedelta(hours=5))``, which would output ``'UTC+05:00'``).
  306. Third-party backends should handle this format when preparing
  307. :class:`~django.db.models.DateTimeField` in ``datetime_cast_date_sql()``,
  308. ``datetime_extract_sql()``, etc.
  309. * Entries for ``AutoField``, ``BigAutoField``, and ``SmallAutoField`` are added
  310. to ``DatabaseOperations.integer_field_ranges`` to support the integer range
  311. validators on these field types. Third-party backends may need to customize
  312. the default entries.
  313. * ``DatabaseOperations.fetch_returned_insert_id()`` is replaced by
  314. ``fetch_returned_insert_columns()`` which returns a list of values returned
  315. by the ``INSERT … RETURNING`` statement, instead of a single value.
  316. * ``DatabaseOperations.return_insert_id()`` is replaced by
  317. ``return_insert_columns()`` that accepts a ``fields``
  318. argument, which is an iterable of fields to be returned after insert. Usually
  319. this is only the auto-generated primary key.
  320. :mod:`django.contrib.admin`
  321. ---------------------------
  322. * Admin's model history change messages now prefers more readable field labels
  323. instead of field names.
  324. :mod:`django.contrib.gis`
  325. -------------------------
  326. * Support for PostGIS 2.1 is removed.
  327. * Support for SpatiaLite 4.1 and 4.2 is removed.
  328. * Support for GDAL 1.11 and GEOS 3.4 is removed.
  329. Dropped support for PostgreSQL 9.4
  330. ----------------------------------
  331. Upstream support for PostgreSQL 9.4 ends in December 2019. Django 3.0 supports
  332. PostgreSQL 9.5 and higher.
  333. Dropped support for Oracle 12.1
  334. -------------------------------
  335. Upstream support for Oracle 12.1 ends in July 2021. Django 2.2 will be
  336. supported until April 2022. Django 3.0 officially supports Oracle 12.2 and 18c.
  337. Removed private Python 2 compatibility APIs
  338. -------------------------------------------
  339. While Python 2 support was removed in Django 2.0, some private APIs weren't
  340. removed from Django so that third party apps could continue using them until
  341. the Python 2 end-of-life.
  342. Since we expect apps to drop Python 2 compatibility when adding support for
  343. Django 3.0, we're removing these APIs at this time.
  344. * ``django.test.utils.str_prefix()`` - Strings don't have 'u' prefixes in
  345. Python 3.
  346. * ``django.test.utils.patch_logger()`` - Use
  347. :meth:`unittest.TestCase.assertLogs` instead.
  348. * ``django.utils.lru_cache.lru_cache()`` - Alias of
  349. :func:`functools.lru_cache`.
  350. * ``django.utils.decorators.available_attrs()`` - This function returns
  351. ``functools.WRAPPER_ASSIGNMENTS``.
  352. * ``django.utils.decorators.ContextDecorator`` - Alias of
  353. :class:`contextlib.ContextDecorator`.
  354. * ``django.utils._os.abspathu()`` - Alias of :func:`os.path.abspath`.
  355. * ``django.utils._os.upath()`` and ``npath()`` - These functions do nothing on
  356. Python 3.
  357. * ``django.utils.six`` - Remove usage of this vendored library or switch to
  358. :pypi:`six`.
  359. * ``django.utils.encoding.python_2_unicode_compatible()`` - Alias of
  360. ``six.python_2_unicode_compatible()``.
  361. * ``django.utils.functional.curry()`` - Use :func:`functools.partial` or
  362. :class:`functools.partialmethod`. See
  363. :commit:`5b1c389603a353625ae1603ba345147356336afb`.
  364. * ``django.utils.safestring.SafeBytes`` - Unused since Django 2.0.
  365. New default value for the ``FILE_UPLOAD_PERMISSIONS`` setting
  366. -------------------------------------------------------------
  367. In older versions, the :setting:`FILE_UPLOAD_PERMISSIONS` setting defaults to
  368. ``None``. With the default :setting:`FILE_UPLOAD_HANDLERS`, this results in
  369. uploaded files having different permissions depending on their size and which
  370. upload handler is used.
  371. ``FILE_UPLOAD_PERMISSIONS`` now defaults to ``0o644`` to avoid this
  372. inconsistency.
  373. New default values for security settings
  374. ----------------------------------------
  375. To make Django projects more secure by default, some security settings now have
  376. more secure default values:
  377. * :setting:`X_FRAME_OPTIONS` now defaults to ``'DENY'``.
  378. * :setting:`SECURE_CONTENT_TYPE_NOSNIFF` now defaults to ``True``.
  379. See the *What's New* :ref:`Security section <whats-new-security-3.0>` above for
  380. more details on these changes.
  381. Miscellaneous
  382. -------------
  383. * ``ContentType.__str__()`` now includes the model's ``app_label`` to
  384. disambiguate models with the same name in different apps.
  385. * Because accessing the language in the session rather than in the cookie is
  386. deprecated, ``LocaleMiddleware`` no longer looks for the user's language in
  387. the session and :func:`django.contrib.auth.logout` no longer preserves the
  388. session's language after logout.
  389. * :func:`django.utils.html.escape` now uses :func:`html.escape` to escape HTML.
  390. This converts ``'`` to ``&#x27;`` instead of the previous equivalent decimal
  391. code ``&#39;``.
  392. * The ``django-admin test -k`` option now works as the :option:`unittest
  393. -k<unittest.-k>` option rather than as a shortcut for ``--keepdb``.
  394. * Support for ``pywatchman`` < 1.2.0 is removed.
  395. * :func:`~django.utils.http.urlencode` now encodes iterable values as they are
  396. when ``doseq=False``, rather than iterating them, bringing it into line with
  397. the standard library :func:`urllib.parse.urlencode` function.
  398. * ``intword`` template filter now translates ``1.0`` as a singular phrase and
  399. all other numeric values as plural. This may be incorrect for some languages.
  400. * Assigning a value to a model's :class:`~django.db.models.ForeignKey` or
  401. :class:`~django.db.models.OneToOneField` ``'_id'`` attribute now unsets the
  402. corresponding field. Accessing the field afterward will result in a query.
  403. * :func:`~django.utils.cache.patch_vary_headers` now handles an asterisk
  404. ``'*'`` according to :rfc:`7231#section-7.1.4`, i.e. if a list of header
  405. field names contains an asterisk, then the ``Vary`` header will consist of a
  406. single asterisk ``'*'``.
  407. * On MySQL 8.0.16+, ``PositiveIntegerField`` and ``PositiveSmallIntegerField``
  408. now include a check constraint to prevent negative values in the database.
  409. * ``alias=None`` is added to the signature of
  410. :meth:`.Expression.get_group_by_cols`.
  411. * ``RegexPattern``, used by :func:`~django.urls.re_path`, no longer returns
  412. keyword arguments with ``None`` values to be passed to the view for the
  413. optional named groups that are missing.
  414. .. _deprecated-features-3.0:
  415. Features deprecated in 3.0
  416. ==========================
  417. ``django.utils.encoding.force_text()`` and ``smart_text()``
  418. -----------------------------------------------------------
  419. The ``smart_text()`` and ``force_text()`` aliases (since Django 2.0) of
  420. ``smart_str()`` and ``force_str()`` are deprecated. Ignore this deprecation if
  421. your code supports Python 2 as the behavior of ``smart_str()`` and
  422. ``force_str()`` is different there.
  423. Miscellaneous
  424. -------------
  425. * ``django.utils.http.urlquote()``, ``urlquote_plus()``, ``urlunquote()``, and
  426. ``urlunquote_plus()`` are deprecated in favor of the functions that they're
  427. aliases for: :func:`urllib.parse.quote`, :func:`~urllib.parse.quote_plus`,
  428. :func:`~urllib.parse.unquote`, and :func:`~urllib.parse.unquote_plus`.
  429. * ``django.utils.translation.ugettext()``, ``ugettext_lazy()``,
  430. ``ugettext_noop()``, ``ungettext()``, and ``ungettext_lazy()`` are deprecated
  431. in favor of the functions that they're aliases for:
  432. :func:`django.utils.translation.gettext`,
  433. :func:`~django.utils.translation.gettext_lazy`,
  434. :func:`~django.utils.translation.gettext_noop`,
  435. :func:`~django.utils.translation.ngettext`, and
  436. :func:`~django.utils.translation.ngettext_lazy`.
  437. * To limit creation of sessions and hence favor some caching strategies,
  438. :func:`django.views.i18n.set_language` will stop setting the user's language
  439. in the session in Django 4.0. Since Django 2.1, the language is always stored
  440. in the :setting:`LANGUAGE_COOKIE_NAME` cookie.
  441. * ``django.utils.text.unescape_entities()`` is deprecated in favor of
  442. :func:`html.unescape`. Note that unlike ``unescape_entities()``,
  443. ``html.unescape()`` evaluates lazy strings immediately.
  444. * To avoid possible confusion as to effective scope, the private internal
  445. utility ``is_safe_url()`` is renamed to
  446. ``url_has_allowed_host_and_scheme()``. That a URL has an allowed host and
  447. scheme doesn't in general imply that it's "safe". It may still be quoted
  448. incorrectly, for example. Ensure to also use
  449. :func:`~django.utils.encoding.iri_to_uri` on the path component of untrusted
  450. URLs.
  451. .. _removed-features-3.0:
  452. Features removed in 3.0
  453. =======================
  454. These features have reached the end of their deprecation cycle and are removed
  455. in Django 3.0.
  456. See :ref:`deprecated-features-2.0` for details on these changes, including how
  457. to remove usage of these features.
  458. * The ``django.db.backends.postgresql_psycopg2`` module is removed.
  459. * ``django.shortcuts.render_to_response()`` is removed.
  460. * The ``DEFAULT_CONTENT_TYPE`` setting is removed.
  461. * ``HttpRequest.xreadlines()`` is removed.
  462. * Support for the ``context`` argument of ``Field.from_db_value()`` and
  463. ``Expression.convert_value()`` is removed.
  464. * The ``field_name`` keyword argument of ``QuerySet.earliest()`` and
  465. ``latest()`` is removed.
  466. See :ref:`deprecated-features-2.1` for details on these changes, including how
  467. to remove usage of these features.
  468. * The ``ForceRHR`` GIS function is removed.
  469. * ``django.utils.http.cookie_date()`` is removed.
  470. * The ``staticfiles`` and ``admin_static`` template tag libraries are removed.
  471. * ``django.contrib.staticfiles.templatetags.staticfiles.static()`` is removed.