2.2.txt 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. Check Constraints
  24. -----------------
  25. The new :class:`~django.db.models.CheckConstraint` class enables adding custom
  26. database constraints. Constraints are added to models using the
  27. :attr:`Meta.constraints <django.db.models.Options.constraints>` option.
  28. Minor features
  29. --------------
  30. :mod:`django.contrib.admin`
  31. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  32. * ...
  33. :mod:`django.contrib.admindocs`
  34. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. * ...
  36. :mod:`django.contrib.auth`
  37. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. * ...
  39. :mod:`django.contrib.contenttypes`
  40. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  41. * ...
  42. :mod:`django.contrib.gis`
  43. ~~~~~~~~~~~~~~~~~~~~~~~~~
  44. * Added Oracle support for the
  45. :class:`~django.contrib.gis.db.models.functions.Envelope` function.
  46. * Added SpatiaLite support for the :lookup:`coveredby` and :lookup:`covers`
  47. lookups.
  48. :mod:`django.contrib.messages`
  49. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  50. * ...
  51. :mod:`django.contrib.postgres`
  52. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  53. * The new ``ordering`` argument for
  54. :class:`~django.contrib.postgres.aggregates.ArrayAgg` and
  55. :class:`~django.contrib.postgres.aggregates.StringAgg` determines the
  56. ordering of the aggregated elements.
  57. * The new :class:`~django.contrib.postgres.indexes.BTreeIndex`,
  58. :class:`~django.contrib.postgres.indexes.HashIndex` and
  59. :class:`~django.contrib.postgres.indexes.SpGistIndex` classes allow
  60. creating ``B-Tree``, ``hash``, and ``SP-GiST`` indexes in the database.
  61. * :class:`~django.contrib.postgres.indexes.BrinIndex` now has the
  62. ``autosummarize`` parameter.
  63. * The new ``search_type`` parameter of
  64. :class:`~django.contrib.postgres.search.SearchQuery` allows searching for
  65. a phrase or raw expression.
  66. :mod:`django.contrib.redirects`
  67. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. * ...
  69. :mod:`django.contrib.sessions`
  70. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  71. * ...
  72. :mod:`django.contrib.sitemaps`
  73. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74. * ...
  75. :mod:`django.contrib.sites`
  76. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77. * ...
  78. :mod:`django.contrib.staticfiles`
  79. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80. * Added path matching to the :option:`collectstatic --ignore` option so that
  81. patterns like ``/vendor/*.js`` can be used.
  82. :mod:`django.contrib.syndication`
  83. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  84. * ...
  85. Cache
  86. ~~~~~
  87. * ...
  88. CSRF
  89. ~~~~
  90. * ...
  91. Database backends
  92. ~~~~~~~~~~~~~~~~~
  93. * Added result streaming for :meth:`.QuerySet.iterator` on SQLite.
  94. Email
  95. ~~~~~
  96. * ...
  97. File Storage
  98. ~~~~~~~~~~~~
  99. * ...
  100. File Uploads
  101. ~~~~~~~~~~~~
  102. * ...
  103. Forms
  104. ~~~~~
  105. * ...
  106. Generic Views
  107. ~~~~~~~~~~~~~
  108. * ...
  109. Internationalization
  110. ~~~~~~~~~~~~~~~~~~~~
  111. * ...
  112. Management Commands
  113. ~~~~~~~~~~~~~~~~~~~
  114. * The new :option:`--force-color` option forces colorization of the command
  115. output.
  116. * :djadmin:`inspectdb` now creates models for foreign tables on PostgreSQL.
  117. * :option:`inspectdb --include-views` now creates models for materialized views
  118. on PostgreSQL.
  119. * :djadmin:`inspectdb` now introspects :class:`~django.db.models.DurationField`
  120. for Oracle and PostgreSQL.
  121. Migrations
  122. ~~~~~~~~~~
  123. * The new :option:`migrate --plan` option prints the list of migration
  124. operations that will be performed.
  125. * ``NoneType`` can now be serialized in migrations.
  126. Models
  127. ~~~~~~
  128. * Added support for PostgreSQL operator classes (:attr:`.Index.opclasses`).
  129. * Added many :ref:`math database functions <math-functions>`.
  130. * Setting the new ``ignore_conflicts`` parameter of
  131. :meth:`.QuerySet.bulk_create` to ``True`` tells the database to ignore
  132. failure to insert rows that fail uniqueness constraints or other checks.
  133. * The new :class:`~django.db.models.functions.ExtractIsoYear` function extracts
  134. ISO-8601 week-numbering years from :class:`~django.db.models.DateField` and
  135. :class:`~django.db.models.DateTimeField`, and the new :lookup:`iso_year`
  136. lookup allows querying by an ISO-8601 week-numbering year.
  137. * The new :meth:`.QuerySet.bulk_update` method allows efficiently updating
  138. specific fields on multiple model instances.
  139. * Django no longer always starts a transaction when a single query is being
  140. performed, such as ``Model.save()``, ``QuerySet.update()``, and
  141. ``Model.delete()``. This improves the performance of autocommit by reducing
  142. the number of database round trips.
  143. Requests and Responses
  144. ~~~~~~~~~~~~~~~~~~~~~~
  145. * ...
  146. Serialization
  147. ~~~~~~~~~~~~~
  148. * You can now deserialize data using natural keys containing :ref:`forward
  149. references <natural-keys-and-forward-references>` by passing
  150. ``handle_forward_references=True`` to ``serializers.deserialize()``.
  151. Additionally, :djadmin:`loaddata` handles forward references automatically.
  152. Signals
  153. ~~~~~~~
  154. * ...
  155. Templates
  156. ~~~~~~~~~
  157. * ...
  158. Tests
  159. ~~~~~
  160. * The new :meth:`.SimpleTestCase.assertURLEqual` assertion checks for a given
  161. URL, ignoring the ordering of the query string.
  162. :meth:`~.SimpleTestCase.assertRedirects` uses the new assertion.
  163. * The test :class:`~.django.test.Client` now supports automatic JSON
  164. serialization of list and tuple ``data`` when
  165. ``content_type='application/json'``.
  166. URLs
  167. ~~~~
  168. * ...
  169. Validators
  170. ~~~~~~~~~~
  171. * ...
  172. .. _backwards-incompatible-2.2:
  173. Backwards incompatible changes in 2.2
  174. =====================================
  175. Database backend API
  176. --------------------
  177. * Third-party database backends must implement support for table check
  178. constraints or set ``DatabaseFeatures.supports_table_check_constraints`` to
  179. ``False``.
  180. * Third party database backends must implement support for ignoring
  181. constraints or uniqueness errors while inserting or set
  182. ``DatabaseFeatures.supports_ignore_conflicts`` to ``False``.
  183. * Third party database backends must implement introspection for
  184. ``DurationField`` or set ``DatabaseFeatures.can_introspect_duration_field``
  185. to ``False``.
  186. :mod:`django.contrib.gis`
  187. -------------------------
  188. * Support for GDAL 1.9 and 1.10 is dropped.
  189. Miscellaneous
  190. -------------
  191. * To improve readability, the ``UUIDField`` form field now displays values with
  192. dashes, e.g. ``550e8400-e29b-41d4-a716-446655440000`` instead of
  193. ``550e8400e29b41d4a716446655440000``.
  194. * On SQLite, ``PositiveIntegerField`` and ``PositiveSmallIntegerField`` now
  195. include a check constraint to prevent negative values in the database. If you
  196. have existing invalid data and run a migration that recreates a table, you'll
  197. see ``CHECK constraint failed``.
  198. * For consistency with WSGI servers, the test client now sets the
  199. ``Content-Length`` header to a string rather than an integer.
  200. * The return value of :func:`django.utils.text.slugify` is no longer marked as
  201. HTML safe.
  202. * The default truncation character used by the :tfilter:`urlizetrunc`,
  203. :tfilter:`truncatechars`, :tfilter:`truncatechars_html`,
  204. :tfilter:`truncatewords`, and :tfilter:`truncatewords_html` template filters
  205. is now the real ellipsis character (``…``) instead of 3 dots. You may have to
  206. adapt some test output comparisons.
  207. * Support for bytestring paths in the template filesystem loader is removed.
  208. * :func:`django.utils.http.urlsafe_base64_encode` now returns a string instead
  209. of a bytestring, and :func:`django.utils.http.urlsafe_base64_decode` may no
  210. longer be passed a bytestring.
  211. * Support for ``cx_Oracle`` < 6.0 is removed.
  212. .. _deprecated-features-2.2:
  213. Features deprecated in 2.2
  214. ==========================
  215. Model ``Meta.ordering`` will no longer affect ``GROUP BY`` queries
  216. ------------------------------------------------------------------
  217. A model's ``Meta.ordering`` affecting ``GROUP BY`` queries (such as
  218. ``.annotate().values()``) is a common source of confusion. Such queries now
  219. issue a deprecation warning with the advice to add an ``order_by()`` to retain
  220. the current query. ``Meta.ordering`` will be ignored in such queries starting
  221. in Django 3.1.
  222. Miscellaneous
  223. -------------
  224. * ``django.utils.timezone.FixedOffset`` is deprecated in favor of
  225. :class:`datetime.timezone`.
  226. * The undocumented ``QuerySetPaginator`` alias of
  227. ``django.core.paginator.Paginator`` is deprecated.
  228. * The ``FloatRangeField`` model and form fields in ``django.contrib.postgres``
  229. are deprecated in favor of a new name, ``DecimalRangeField``, to match the
  230. underlying ``numrange`` data type used in the database.
  231. * The ``FILE_CHARSET`` setting is deprecated. Starting with Django 3.1, files
  232. read from disk must be UTF-8 encoded.