2.2.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. ============================================
  2. Django 2.2 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. *Expected April 2019*
  5. Welcome to Django 2.2!
  6. These release notes cover the :ref:`new features <whats-new-2.2>`, as well as
  7. some :ref:`backwards incompatible changes <backwards-incompatible-2.2>` you'll
  8. want to be aware of when upgrading from Django 2.1 or earlier. We've
  9. :ref:`begun the deprecation process for some features
  10. <deprecated-features-2.2>`.
  11. See the :doc:`/howto/upgrade-version` guide if you're updating an existing
  12. project.
  13. Django 2.2 is designated as a :term:`long-term support release`. It will
  14. receive security updates for at least three years after its release. Support
  15. for the previous LTS, Django 1.11, will end in April 2020.
  16. Python compatibility
  17. ====================
  18. Django 2.2 supports Python 3.5, 3.6, and 3.7. We **highly recommend** and only
  19. officially support the latest release of each series.
  20. .. _whats-new-2.2:
  21. What's new in Django 2.2
  22. ========================
  23. Constraints
  24. -----------
  25. The new :class:`~django.db.models.CheckConstraint` and
  26. :class:`~django.db.models.UniqueConstraint` classes enable adding custom
  27. database constraints. Constraints are added to models using the
  28. :attr:`Meta.constraints <django.db.models.Options.constraints>` option.
  29. Minor features
  30. --------------
  31. :mod:`django.contrib.admin`
  32. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33. * ...
  34. :mod:`django.contrib.admindocs`
  35. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  36. * ...
  37. :mod:`django.contrib.auth`
  38. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  39. * ...
  40. :mod:`django.contrib.contenttypes`
  41. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  42. * ...
  43. :mod:`django.contrib.gis`
  44. ~~~~~~~~~~~~~~~~~~~~~~~~~
  45. * Added Oracle support for the
  46. :class:`~django.contrib.gis.db.models.functions.Envelope` function.
  47. * Added SpatiaLite support for the :lookup:`coveredby` and :lookup:`covers`
  48. lookups.
  49. :mod:`django.contrib.messages`
  50. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  51. * ...
  52. :mod:`django.contrib.postgres`
  53. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  54. * The new ``ordering`` argument for
  55. :class:`~django.contrib.postgres.aggregates.ArrayAgg` and
  56. :class:`~django.contrib.postgres.aggregates.StringAgg` determines the
  57. ordering of the aggregated elements.
  58. * The new :class:`~django.contrib.postgres.indexes.BTreeIndex`,
  59. :class:`~django.contrib.postgres.indexes.HashIndex` and
  60. :class:`~django.contrib.postgres.indexes.SpGistIndex` classes allow
  61. creating ``B-Tree``, ``hash``, and ``SP-GiST`` indexes in the database.
  62. * :class:`~django.contrib.postgres.indexes.BrinIndex` now has the
  63. ``autosummarize`` parameter.
  64. * The new ``search_type`` parameter of
  65. :class:`~django.contrib.postgres.search.SearchQuery` allows searching for
  66. a phrase or raw expression.
  67. :mod:`django.contrib.redirects`
  68. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  69. * ...
  70. :mod:`django.contrib.sessions`
  71. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  72. * ...
  73. :mod:`django.contrib.sitemaps`
  74. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  75. * ...
  76. :mod:`django.contrib.sites`
  77. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  78. * ...
  79. :mod:`django.contrib.staticfiles`
  80. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  81. * Added path matching to the :option:`collectstatic --ignore` option so that
  82. patterns like ``/vendor/*.js`` can be used.
  83. :mod:`django.contrib.syndication`
  84. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  85. * ...
  86. Cache
  87. ~~~~~
  88. * ...
  89. CSRF
  90. ~~~~
  91. * ...
  92. Database backends
  93. ~~~~~~~~~~~~~~~~~
  94. * Added result streaming for :meth:`.QuerySet.iterator` on SQLite.
  95. Email
  96. ~~~~~
  97. * ...
  98. File Storage
  99. ~~~~~~~~~~~~
  100. * ...
  101. File Uploads
  102. ~~~~~~~~~~~~
  103. * ...
  104. Forms
  105. ~~~~~
  106. * ...
  107. Generic Views
  108. ~~~~~~~~~~~~~
  109. * ...
  110. Internationalization
  111. ~~~~~~~~~~~~~~~~~~~~
  112. * ...
  113. Management Commands
  114. ~~~~~~~~~~~~~~~~~~~
  115. * The new :option:`--force-color` option forces colorization of the command
  116. output.
  117. * :djadmin:`inspectdb` now creates models for foreign tables on PostgreSQL.
  118. * :option:`inspectdb --include-views` now creates models for materialized views
  119. on PostgreSQL.
  120. * :djadmin:`inspectdb` now introspects :class:`~django.db.models.DurationField`
  121. for Oracle and PostgreSQL.
  122. * On Oracle, :djadmin:`dbshell` is wrapped with ``rlwrap``, if available.
  123. ``rlwrap`` provides a command history and editing of keyboard input.
  124. Migrations
  125. ~~~~~~~~~~
  126. * The new :option:`migrate --plan` option prints the list of migration
  127. operations that will be performed.
  128. * ``NoneType`` can now be serialized in migrations.
  129. Models
  130. ~~~~~~
  131. * Added support for PostgreSQL operator classes (:attr:`.Index.opclasses`).
  132. * Added support for partial indexes (:attr:`.Index.condition`).
  133. * Added many :ref:`math database functions <math-functions>`.
  134. * Setting the new ``ignore_conflicts`` parameter of
  135. :meth:`.QuerySet.bulk_create` to ``True`` tells the database to ignore
  136. failure to insert rows that fail uniqueness constraints or other checks.
  137. * The new :class:`~django.db.models.functions.ExtractIsoYear` function extracts
  138. ISO-8601 week-numbering years from :class:`~django.db.models.DateField` and
  139. :class:`~django.db.models.DateTimeField`, and the new :lookup:`iso_year`
  140. lookup allows querying by an ISO-8601 week-numbering year.
  141. * The new :meth:`.QuerySet.bulk_update` method allows efficiently updating
  142. specific fields on multiple model instances.
  143. * Django no longer always starts a transaction when a single query is being
  144. performed, such as ``Model.save()``, ``QuerySet.update()``, and
  145. ``Model.delete()``. This improves the performance of autocommit by reducing
  146. the number of database round trips.
  147. Requests and Responses
  148. ~~~~~~~~~~~~~~~~~~~~~~
  149. * ...
  150. Serialization
  151. ~~~~~~~~~~~~~
  152. * You can now deserialize data using natural keys containing :ref:`forward
  153. references <natural-keys-and-forward-references>` by passing
  154. ``handle_forward_references=True`` to ``serializers.deserialize()``.
  155. Additionally, :djadmin:`loaddata` handles forward references automatically.
  156. Signals
  157. ~~~~~~~
  158. * ...
  159. Templates
  160. ~~~~~~~~~
  161. * ...
  162. Tests
  163. ~~~~~
  164. * The new :meth:`.SimpleTestCase.assertURLEqual` assertion checks for a given
  165. URL, ignoring the ordering of the query string.
  166. :meth:`~.SimpleTestCase.assertRedirects` uses the new assertion.
  167. * The test :class:`~.django.test.Client` now supports automatic JSON
  168. serialization of list and tuple ``data`` when
  169. ``content_type='application/json'``.
  170. * The new :setting:`ORACLE_MANAGED_FILES <TEST_ORACLE_MANAGED_FILES>` test
  171. database setting allows using Oracle Managed Files (OMF) tablespaces.
  172. URLs
  173. ~~~~
  174. * ...
  175. Validators
  176. ~~~~~~~~~~
  177. * :class:`.MaxValueValidator`, :class:`.MinValueValidator`,
  178. :class:`.MinLengthValidator`, and :class:`.MaxLengthValidator` now accept
  179. a callable ``limit_value``.
  180. .. _backwards-incompatible-2.2:
  181. Backwards incompatible changes in 2.2
  182. =====================================
  183. Database backend API
  184. --------------------
  185. * Third-party database backends must implement support for table check
  186. constraints or set ``DatabaseFeatures.supports_table_check_constraints`` to
  187. ``False``.
  188. * Third party database backends must implement support for ignoring
  189. constraints or uniqueness errors while inserting or set
  190. ``DatabaseFeatures.supports_ignore_conflicts`` to ``False``.
  191. * Third party database backends must implement introspection for
  192. ``DurationField`` or set ``DatabaseFeatures.can_introspect_duration_field``
  193. to ``False``.
  194. * ``DatabaseFeatures.uses_savepoints`` now defaults to ``True``.
  195. * Third party database backends must implement support for partial indexes or
  196. set ``DatabaseFeatures.supports_partial_indexes`` to ``False``.
  197. * Several ``SchemaEditor`` attributes are changed:
  198. * ``sql_create_check`` is replaced with ``sql_create_constraint``.
  199. * ``sql_delete_check`` is replaced with ``sql_delete_constraint``.
  200. * ``sql_create_fk`` is replaced with ``sql_foreign_key_constraint``,
  201. ``sql_constraint``, and ``sql_create_constraint``.
  202. Admin actions are no longer collected from base ``ModelAdmin`` classes
  203. ----------------------------------------------------------------------
  204. For example, in older versions of Django::
  205. from django.contrib import admin
  206. class BaseAdmin(admin.ModelAdmin):
  207. actions = ['a']
  208. class SubAdmin(BaseAdmin):
  209. actions = ['b']
  210. ``SubAdmin`` will have actions ``'a'`` and ``'b'``.
  211. Now ``actions`` follows standard Python inheritance. To get the same result as
  212. before::
  213. class SubAdmin(BaseAdmin):
  214. actions = BaseAdmin.actions + ['b']
  215. :mod:`django.contrib.gis`
  216. -------------------------
  217. * Support for GDAL 1.9 and 1.10 is dropped.
  218. ``TransactionTestCase`` serialized data loading
  219. -----------------------------------------------
  220. Initial data migrations are now loaded in
  221. :class:`~django.test.TransactionTestCase` at the end of the test, after the
  222. database flush. In older versions, this data was loaded at the beginning of the
  223. test, but this prevents the :option:`test --keepdb` option from working
  224. properly (the database was empty at the end of the whole test suite). This
  225. change shouldn't have an impact on your tests unless you've customized
  226. :class:`~django.test.TransactionTestCase`'s internals.
  227. ``sqlparse`` is required dependency
  228. -----------------------------------
  229. To simplify a few parts of Django's database handling, `sqlparse
  230. <https://pypi.org/project/sqlparse/>`_ is now a required dependency. It's
  231. automatically installed along with Django.
  232. Miscellaneous
  233. -------------
  234. * To improve readability, the ``UUIDField`` form field now displays values with
  235. dashes, e.g. ``550e8400-e29b-41d4-a716-446655440000`` instead of
  236. ``550e8400e29b41d4a716446655440000``.
  237. * On SQLite, ``PositiveIntegerField`` and ``PositiveSmallIntegerField`` now
  238. include a check constraint to prevent negative values in the database. If you
  239. have existing invalid data and run a migration that recreates a table, you'll
  240. see ``CHECK constraint failed``.
  241. * For consistency with WSGI servers, the test client now sets the
  242. ``Content-Length`` header to a string rather than an integer.
  243. * The return value of :func:`django.utils.text.slugify` is no longer marked as
  244. HTML safe.
  245. * The default truncation character used by the :tfilter:`urlizetrunc`,
  246. :tfilter:`truncatechars`, :tfilter:`truncatechars_html`,
  247. :tfilter:`truncatewords`, and :tfilter:`truncatewords_html` template filters
  248. is now the real ellipsis character (``…``) instead of 3 dots. You may have to
  249. adapt some test output comparisons.
  250. * Support for bytestring paths in the template filesystem loader is removed.
  251. * :func:`django.utils.http.urlsafe_base64_encode` now returns a string instead
  252. of a bytestring, and :func:`django.utils.http.urlsafe_base64_decode` may no
  253. longer be passed a bytestring.
  254. * Support for ``cx_Oracle`` < 6.0 is removed.
  255. * In an attempt to provide more semantic query data, ``NullBooleanSelect`` now
  256. renders ``<option>`` values of ``unknown``, ``true``, and ``false`` instead
  257. of ``1``, ``2``, and ``3``. For backwards compatibility, the old values are
  258. still accepted as data.
  259. * :attr:`Group.name <django.contrib.auth.models.Group.name>` ``max_length``
  260. is increased from 80 to 150 characters.
  261. .. _deprecated-features-2.2:
  262. Features deprecated in 2.2
  263. ==========================
  264. Model ``Meta.ordering`` will no longer affect ``GROUP BY`` queries
  265. ------------------------------------------------------------------
  266. A model's ``Meta.ordering`` affecting ``GROUP BY`` queries (such as
  267. ``.annotate().values()``) is a common source of confusion. Such queries now
  268. issue a deprecation warning with the advice to add an ``order_by()`` to retain
  269. the current query. ``Meta.ordering`` will be ignored in such queries starting
  270. in Django 3.1.
  271. Miscellaneous
  272. -------------
  273. * ``django.utils.timezone.FixedOffset`` is deprecated in favor of
  274. :class:`datetime.timezone`.
  275. * The undocumented ``QuerySetPaginator`` alias of
  276. ``django.core.paginator.Paginator`` is deprecated.
  277. * The ``FloatRangeField`` model and form fields in ``django.contrib.postgres``
  278. are deprecated in favor of a new name, ``DecimalRangeField``, to match the
  279. underlying ``numrange`` data type used in the database.
  280. * The ``FILE_CHARSET`` setting is deprecated. Starting with Django 3.1, files
  281. read from disk must be UTF-8 encoded.
  282. * ``django.contrib.staticfiles.storage.CachedStaticFilesStorage`` is
  283. deprecated due to the intractable problems that is has. Use
  284. :class:`.ManifestStaticFilesStorage` or a third-party cloud storage instead.