3.0.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. ============================================
  2. Django 3.0 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. *Expected December 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, and 3.8. We **highly recommend** and only
  17. 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. Minor features
  30. --------------
  31. :mod:`django.contrib.admin`
  32. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33. * Added support for the ``admin_order_field`` attribute on properties in
  34. :attr:`.ModelAdmin.list_display`.
  35. * The new :meth:`ModelAdmin.get_inlines()
  36. <django.contrib.admin.ModelAdmin.get_inlines>` method allows specifying the
  37. inlines based on the request or model instance.
  38. :mod:`django.contrib.admindocs`
  39. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  40. * ...
  41. :mod:`django.contrib.auth`
  42. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  43. * ...
  44. :mod:`django.contrib.contenttypes`
  45. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  46. * ...
  47. :mod:`django.contrib.gis`
  48. ~~~~~~~~~~~~~~~~~~~~~~~~~
  49. * Allowed MySQL spatial lookup functions to operate on real geometries.
  50. Previous support was limited to bounding boxes.
  51. * Added the :class:`~django.contrib.gis.db.models.functions.GeometryDistance`
  52. function, supported on PostGIS.
  53. * Added support for the ``furlong`` unit in
  54. :class:`~django.contrib.gis.measure.Distance`.
  55. :mod:`django.contrib.messages`
  56. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  57. * ...
  58. :mod:`django.contrib.postgres`
  59. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  60. * ...
  61. :mod:`django.contrib.redirects`
  62. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  63. * ...
  64. :mod:`django.contrib.sessions`
  65. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  66. * The new
  67. :meth:`~django.contrib.sessions.backends.base.SessionBase.get_session_cookie_age()`
  68. methods allows dynamically specifying the session cookie age.
  69. :mod:`django.contrib.sitemaps`
  70. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  71. * ...
  72. :mod:`django.contrib.sites`
  73. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74. * ...
  75. :mod:`django.contrib.staticfiles`
  76. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77. * ...
  78. :mod:`django.contrib.syndication`
  79. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80. * Added the ``language`` class attribute to the
  81. :class:`django.contrib.syndication.views.Feed` to customize a feed language.
  82. The default value is :func:`~django.utils.translation.get_language()` instead
  83. of :setting:`LANGUAGE_CODE`.
  84. Cache
  85. ~~~~~
  86. * ...
  87. CSRF
  88. ~~~~
  89. * ...
  90. Email
  91. ~~~~~
  92. * ...
  93. File Storage
  94. ~~~~~~~~~~~~
  95. * ...
  96. File Uploads
  97. ~~~~~~~~~~~~
  98. * ...
  99. Forms
  100. ~~~~~
  101. * Formsets may control the widget used when ordering forms via
  102. :attr:`~django.forms.formsets.BaseFormSet.can_order` by setting the
  103. :attr:`~django.forms.formsets.BaseFormSet.ordering_widget` attribute or
  104. overriding :attr:`~django.forms.formsets.BaseFormSet.get_ordering_widget()`.
  105. Generic Views
  106. ~~~~~~~~~~~~~
  107. * ...
  108. Internationalization
  109. ~~~~~~~~~~~~~~~~~~~~
  110. * Added the :setting:`LANGUAGE_COOKIE_HTTPONLY`,
  111. :setting:`LANGUAGE_COOKIE_SAMESITE`, and :setting:`LANGUAGE_COOKIE_SECURE`
  112. settings to set the ``HttpOnly``, ``SameSite``, and ``Secure`` flags on
  113. language cookies. The default values of these settings preserve the previous
  114. behavior.
  115. Management Commands
  116. ~~~~~~~~~~~~~~~~~~~
  117. * The new :option:`compilemessages --ignore` option allows ignoring specific
  118. directories when searching for ``.po`` files to compile.
  119. * :option:`showmigrations --list` now shows the applied datetimes when
  120. ``--verbosity`` is 2 and above.
  121. * On PostgreSQL, :djadmin:`dbshell` now supports client-side TLS certificates.
  122. * :djadmin:`inspectdb` now introspects :class:`~django.db.models.OneToOneField`
  123. when a foreign key has a unique or primary key constraint.
  124. * The new :option:`--skip-checks` option skips running system checks prior to
  125. running the command.
  126. Migrations
  127. ~~~~~~~~~~
  128. * ...
  129. Models
  130. ~~~~~~
  131. * Added hash database functions :class:`~django.db.models.functions.MD5`,
  132. :class:`~django.db.models.functions.SHA1`,
  133. :class:`~django.db.models.functions.SHA224`,
  134. :class:`~django.db.models.functions.SHA256`,
  135. :class:`~django.db.models.functions.SHA384`, and
  136. :class:`~django.db.models.functions.SHA512`.
  137. * Added the :class:`~django.db.models.functions.Sign` database function.
  138. * The new ``is_dst`` parameter of the
  139. :class:`~django.db.models.functions.Trunc` database functions determines the
  140. treatment of nonexistent and ambiguous datetimes.
  141. * ``connection.queries`` now shows ``COPY … TO`` statements on PostgreSQL.
  142. * :class:`~django.db.models.FilePathField` now accepts a callable ``path``.
  143. Requests and Responses
  144. ~~~~~~~~~~~~~~~~~~~~~~
  145. * Allowed :class:`~django.http.HttpResponse` to be initialized with
  146. :class:`memoryview` content.
  147. * For use in, for example, Django templates, :attr:`.HttpRequest.headers` now
  148. allows look ups using underscores (e.g. ``user_agent``) in place of hyphens.
  149. Serialization
  150. ~~~~~~~~~~~~~
  151. * ...
  152. Signals
  153. ~~~~~~~
  154. * ...
  155. Templates
  156. ~~~~~~~~~
  157. * ...
  158. Tests
  159. ~~~~~
  160. * The new test :class:`~django.test.Client` argument
  161. ``raise_request_exception`` allows controlling whether or not exceptions
  162. raised during the request should also be raised in the test. The value
  163. defaults to ``True`` for backwards compatibility. If it is ``False`` and an
  164. exception occurs, the test client will return a 500 response with the
  165. attribute :attr:`~django.test.Response.exc_info`, a tuple providing
  166. information of the exception that occurred.
  167. * Tests and test cases to run can be selected by test name pattern using the
  168. new :option:`test -k` option.
  169. * HTML comparison, as used by
  170. :meth:`~django.test.SimpleTestCase.assertHTMLEqual`, now treats text, character
  171. references, and entity references that refer to the same character as
  172. equivalent.
  173. * Django test runner now supports headless mode for selenium tests on supported
  174. browsers. Add the ``--headless`` option to enable this mode.
  175. URLs
  176. ~~~~
  177. * ...
  178. Validators
  179. ~~~~~~~~~~
  180. * ...
  181. .. _backwards-incompatible-3.0:
  182. Backwards incompatible changes in 3.0
  183. =====================================
  184. Database backend API
  185. --------------------
  186. This section describes changes that may be needed in third-party database
  187. backends.
  188. * The second argument of ``DatabaseIntrospection.get_geometry_type()`` is now
  189. the row description instead of the column name.
  190. * ``DatabaseIntrospection.get_field_type()`` may no longer return tuples.
  191. * If the database can create foreign keys in the same SQL statement that adds a
  192. field, add ``SchemaEditor.sql_create_column_inline_fk`` with the appropriate
  193. SQL; otherwise, set ``DatabaseFeatures.can_create_inline_fk = False``.
  194. * ``DatabaseFeatures.can_return_id_from_insert`` and
  195. ``can_return_ids_from_bulk_insert`` are renamed to
  196. ``can_return_columns_from_insert`` and ``can_return_rows_from_bulk_insert``.
  197. :mod:`django.contrib.gis`
  198. -------------------------
  199. * Support for PostGIS 2.1 is removed.
  200. * Support for SpatiaLite 4.1 and 4.2 is removed.
  201. * Support for GDAL 1.11 and GEOS 3.4 is removed.
  202. Dropped support for PostgreSQL 9.4
  203. ----------------------------------
  204. Upstream support for PostgreSQL 9.4 ends in December 2019. Django 3.0 supports
  205. PostgreSQL 9.5 and higher.
  206. Dropped support for Oracle 12.1
  207. -------------------------------
  208. Upstream support for Oracle 12.1 ends in July 2021. Django 2.2 will be
  209. supported until April 2022. Django 3.0 officially supports Oracle 12.2 and 18c.
  210. Removed private Python 2 compatibility APIs
  211. -------------------------------------------
  212. While Python 2 support was removed in Django 2.0, some private APIs weren't
  213. removed from Django so that third party apps could continue using them until
  214. the Python 2 end-of-life.
  215. Since we expect apps to drop Python 2 compatibility when adding support for
  216. Django 3.0, we're removing these APIs at this time.
  217. * ``django.test.utils.str_prefix()`` - Strings don't have 'u' prefixes in
  218. Python 3.
  219. * ``django.test.utils.patch_logger()`` - Use
  220. :meth:`unittest.TestCase.assertLogs` instead.
  221. * ``django.utils.lru_cache.lru_cache()`` - Alias of
  222. :func:`functools.lru_cache`.
  223. * ``django.utils.decorators.available_attrs()`` - This function returns
  224. ``functools.WRAPPER_ASSIGNMENTS``.
  225. * ``django.utils.decorators.ContextDecorator`` - Alias of
  226. :class:`contextlib.ContextDecorator`.
  227. * ``django.utils._os.abspathu()`` - Alias of :func:`os.path.abspath`.
  228. * ``django.utils._os.upath()`` and ``npath()`` - These functions do nothing on
  229. Python 3.
  230. * ``django.utils.six`` - Remove usage of this vendored library or switch to
  231. `six <https://pypi.org/project/six/>`_.
  232. * ``django.utils.encoding.python_2_unicode_compatible()`` - Alias of
  233. ``six.python_2_unicode_compatible()``.
  234. * ``django.utils.functional.curry()`` - Use :func:`functools.partial` or
  235. :class:`functools.partialmethod`. See :commit:`5b1c389603a353625ae1603`.
  236. * ``django.utils.safestring.SafeBytes`` - Unused since Django 2.0.
  237. New default value for the ``FILE_UPLOAD_PERMISSIONS`` setting
  238. -------------------------------------------------------------
  239. In older versions, the :setting:`FILE_UPLOAD_PERMISSIONS` setting defaults to
  240. ``None``. With the default :setting:`FILE_UPLOAD_HANDLERS`, this results in
  241. uploaded files having different permissions depending on their size and which
  242. upload handler is used.
  243. ``FILE_UPLOAD_PERMISSION`` now defaults to ``0o644`` to avoid this
  244. inconsistency.
  245. Miscellaneous
  246. -------------
  247. * ``ContentType.__str__()`` now includes the model's ``app_label`` to
  248. disambiguate model's with the same name in different apps.
  249. * Because accessing the language in the session rather than in the cookie is
  250. deprecated, ``LocaleMiddleware`` no longer looks for the user's language in
  251. the session and :func:`django.contrib.auth.logout` no longer preserves the
  252. session's language after logout.
  253. * :func:`django.utils.html.escape` now uses :func:`html.escape` to escape HTML.
  254. This converts ``'`` to ``&#x27;`` instead of the previous equivalent decimal
  255. code ``&#39;``.
  256. * The ``django-admin test -k`` option now works as the :option:`unittest
  257. -k<unittest.-k>` option rather than as a shortcut for ``--keepdb``.
  258. * Support for ``pywatchman`` < 1.2.0 is removed.
  259. * HTML rendered by :class:`~django.forms.SelectDateWidget` for required fields
  260. now have the ``placeholder`` attribute, which mainly may require some
  261. adjustments in tests that compare HTML.
  262. .. _deprecated-features-3.0:
  263. Features deprecated in 3.0
  264. ==========================
  265. ``django.utils.encoding.force_text()`` and ``smart_text()``
  266. -----------------------------------------------------------
  267. The ``smart_text()`` and ``force_text()`` aliases (since Django 2.0) of
  268. ``smart_str()`` and ``force_str()`` are deprecated. Ignore this deprecation if
  269. your code supports Python 2 as the behavior of ``smart_str()`` and
  270. ``force_str()`` is different there.
  271. Miscellaneous
  272. -------------
  273. * ``django.utils.http.urlquote()``, ``urlquote_plus()``, ``urlunquote()``, and
  274. ``urlunquote_plus()`` are deprecated in favor of the functions that they're
  275. aliases for: :func:`urllib.parse.quote`, :func:`~urllib.parse.quote_plus`,
  276. :func:`~urllib.parse.unquote`, and :func:`~urllib.parse.unquote_plus`.
  277. * ``django.utils.translation.ugettext()``, ``ugettext_lazy()``,
  278. ``ugettext_noop()``, ``ungettext()``, and ``ungettext_lazy()`` are deprecated
  279. in favor of the functions that they're aliases for:
  280. :func:`django.utils.translation.gettext`,
  281. :func:`~django.utils.translation.gettext_lazy`,
  282. :func:`~django.utils.translation.gettext_noop`,
  283. :func:`~django.utils.translation.ngettext`, and
  284. :func:`~django.utils.translation.ngettext_lazy`.
  285. * To limit creation of sessions and hence favor some caching strategies,
  286. :func:`django.views.i18n.set_language` will stop setting the user's language
  287. in the session in Django 4.0. Since Django 2.1, the language is always stored
  288. in the :setting:`LANGUAGE_COOKIE_NAME` cookie.
  289. * ``alias=None`` is added to the signature of
  290. :meth:`.Expression.get_group_by_cols`.
  291. * ``django.utils.text.unescape_entities()`` is deprecated in favor of
  292. :func:`html.unescape`. Note that unlike ``unescape_entities()``,
  293. ``html.unescape()`` evaluates lazy strings immediately.
  294. .. _removed-features-3.0:
  295. Features removed in 3.0
  296. =======================
  297. These features have reached the end of their deprecation cycle and are removed
  298. in Django 3.0.
  299. See :ref:`deprecated-features-2.0` for details on these changes, including how
  300. to remove usage of these features.
  301. * The ``django.db.backends.postgresql_psycopg2`` module is removed.
  302. * ``django.shortcuts.render_to_response()`` is removed.
  303. * The ``DEFAULT_CONTENT_TYPE`` setting is removed.
  304. * ``HttpRequest.xreadlines()`` is removed.
  305. * Support for the ``context`` argument of ``Field.from_db_value()`` and
  306. ``Expression.convert_value()`` is removed.
  307. * The ``field_name`` keyword argument of ``QuerySet.earliest()`` and
  308. ``latest()`` is removed.
  309. See :ref:`deprecated-features-2.1` for details on these changes, including how
  310. to remove usage of these features.
  311. * The ``ForceRHR`` GIS function is removed.
  312. * ``django.utils.http.cookie_date()`` is removed.
  313. * The ``staticfiles`` and ``admin_static`` template tag libraries are removed.
  314. * ``django.contrib.staticfiles.templatetags.staticfiles.static()`` is removed.