2.0.txt 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. ============================================
  2. Django 2.0 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. Welcome to Django 2.0!
  5. These release notes cover the :ref:`new features <whats-new-2.0>`, as well as
  6. some :ref:`backwards incompatible changes <backwards-incompatible-2.0>` you'll
  7. want to be aware of when upgrading from Django 1.11 or earlier. We've
  8. :ref:`dropped some features<removed-features-2.0>` that have reached the end of
  9. their deprecation cycle, and we've :ref:`begun the deprecation process for some
  10. features <deprecated-features-2.0>`.
  11. See the :doc:`/howto/upgrade-version` guide if you're updating an existing
  12. project.
  13. Python compatibility
  14. ====================
  15. Django 2.0 supports Python 3.5+. Since Django 1.11, support for Python 2.7 and
  16. 3.4 is removed. We **highly recommend** and only officially support the latest
  17. release of each series.
  18. Third-party library support for older version of Django
  19. =======================================================
  20. Following the release of Django 2.0, we suggest that third-party app authors
  21. drop support for all versions of Django prior to 1.11. At that time, you should
  22. be able run your package's tests using ``python -Wd`` so that deprecation
  23. warnings do appear. After making the deprecation warning fixes, your app should
  24. be compatible with Django 2.0.
  25. .. _whats-new-2.0:
  26. What's new in Django 2.0
  27. ========================
  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. * The default iteration count for the PBKDF2 password hasher is increased from
  39. 36,000 to 100,000.
  40. :mod:`django.contrib.contenttypes`
  41. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  42. * ...
  43. :mod:`django.contrib.gis`
  44. ~~~~~~~~~~~~~~~~~~~~~~~~~
  45. * Added MySQL support for the
  46. :class:`~django.contrib.gis.db.models.functions.AsGeoJSON` function,
  47. :class:`~django.contrib.gis.db.models.functions.GeoHash` function,
  48. :class:`~django.contrib.gis.db.models.functions.IsValid` function, and
  49. :lookup:`isvalid` lookup.
  50. * Added the :class:`~django.contrib.gis.db.models.functions.Azimuth` and
  51. :class:`~django.contrib.gis.db.models.functions.LineLocatePoint` functions,
  52. supported on PostGIS and SpatiaLite.
  53. * Any :class:`~django.contrib.gis.geos.GEOSGeometry` imported from GeoJSON now
  54. has its SRID set.
  55. :mod:`django.contrib.messages`
  56. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  57. * ...
  58. :mod:`django.contrib.postgres`
  59. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  60. * The new ``distinct`` argument for
  61. :class:`~django.contrib.postgres.aggregates.ArrayAgg` determines if
  62. concatenated values will be distinct.
  63. * The new :class:`~django.contrib.postgres.functions.RandomUUID` database
  64. function returns a version 4 UUID. It requires use of PostgreSQL's
  65. ``pgcrypto`` extension which can be activated using the new
  66. :class:`~django.contrib.postgres.operations.CryptoExtension` migration
  67. operation.
  68. :mod:`django.contrib.redirects`
  69. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  70. * ...
  71. :mod:`django.contrib.sessions`
  72. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  73. * ...
  74. :mod:`django.contrib.sitemaps`
  75. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  76. * Added the ``protocol`` keyword argument to the
  77. :class:`~django.contrib.sitemaps.GenericSitemap` constructor.
  78. :mod:`django.contrib.sites`
  79. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80. * ...
  81. :mod:`django.contrib.staticfiles`
  82. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  83. * ...
  84. :mod:`django.contrib.syndication`
  85. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  86. * ...
  87. Cache
  88. ~~~~~
  89. * ...
  90. CSRF
  91. ~~~~
  92. * ...
  93. Database backends
  94. ~~~~~~~~~~~~~~~~~
  95. * ...
  96. Email
  97. ~~~~~
  98. * ...
  99. File Storage
  100. ~~~~~~~~~~~~
  101. * ...
  102. File Uploads
  103. ~~~~~~~~~~~~
  104. * ...
  105. Forms
  106. ~~~~~
  107. * The new ``date_attrs`` and ``time_attrs`` arguments for
  108. :class:`~django.forms.SplitDateTimeWidget` and
  109. :class:`~django.forms.SplitHiddenDateTimeWidget` allow specifying different
  110. HTML attributes for the ``DateInput`` and ``TimeInput`` (or hidden)
  111. subwidgets.
  112. Generic Views
  113. ~~~~~~~~~~~~~
  114. * ...
  115. Internationalization
  116. ~~~~~~~~~~~~~~~~~~~~
  117. * ...
  118. Management Commands
  119. ~~~~~~~~~~~~~~~~~~~
  120. * :djadmin:`inspectdb` now translates MySQL's unsigned integer columns to
  121. ``PositiveIntegerField`` or ``PositiveSmallIntegerField``.
  122. Migrations
  123. ~~~~~~~~~~
  124. * ...
  125. Models
  126. ~~~~~~
  127. * The new :class:`~django.db.models.functions.StrIndex` database function
  128. finds the starting index of a string inside another string.
  129. Requests and Responses
  130. ~~~~~~~~~~~~~~~~~~~~~~
  131. * The :djadmin:`runserver` Web server supports HTTP 1.1.
  132. Serialization
  133. ~~~~~~~~~~~~~
  134. * ...
  135. Signals
  136. ~~~~~~~
  137. * ...
  138. Templates
  139. ~~~~~~~~~
  140. * To increase the usefulness of :meth:`.Engine.get_default` in third-party
  141. apps, it now returns the first engine if multiple ``DjangoTemplates`` engines
  142. are configured in ``TEMPLATES`` rather than raising ``ImproperlyConfigured``.
  143. Tests
  144. ~~~~~
  145. * Added threading support to :class:`~django.test.LiveServerTestCase`.
  146. URLs
  147. ~~~~
  148. * ...
  149. Validators
  150. ~~~~~~~~~~
  151. * ...
  152. .. _backwards-incompatible-2.0:
  153. Backwards incompatible changes in 2.0
  154. =====================================
  155. Removed support for bytestrings in some places
  156. ----------------------------------------------
  157. To support native Python 2 strings, older Django versions had to accept both
  158. bytestrings and unicode strings. Now that Python 2 support is dropped,
  159. bytestrings should only be encountered around input/output boundaries (handling
  160. of binary fields or HTTP streams, for example). You might have to update your
  161. code to limit bytestring usage to a minimum, as Django no longer accepts
  162. bytestrings in certain code paths.
  163. Database backend API
  164. --------------------
  165. * The ``DatabaseOperations.datetime_cast_date_sql()``,
  166. ``datetime_cast_time_sql()``, ``datetime_trunc_sql()``, and
  167. ``datetime_extract_sql()`` methods now return only the SQL to perform the
  168. operation instead of SQL and a list of parameters.
  169. Dropped support for Oracle 11.2
  170. -------------------------------
  171. The end of upstream support for Oracle 11.2 is Dec. 2020. Django 1.11 will be
  172. supported until April 2020 which almost reaches this date. Django 2.0
  173. officially supports Oracle 12.1+.
  174. Default MySQL isolation level is read committed
  175. -----------------------------------------------
  176. MySQL's default isolation level, repeatable read, may cause data loss in
  177. typical Django usage. To prevent that and for consistency with other databases,
  178. the default isolation level is now read committed. You can use the
  179. :setting:`DATABASES` setting to :ref:`use a different isolation level
  180. <mysql-isolation-level>`, if needed.
  181. :attr:`AbstractUser.last_name <django.contrib.auth.models.User.last_name>` ``max_length`` increased to 150
  182. ----------------------------------------------------------------------------------------------------------
  183. A migration for :attr:`django.contrib.auth.models.User.last_name` is included.
  184. If you have a custom user model inheriting from ``AbstractUser``, you'll need
  185. to generate and apply a database migration for your user model.
  186. If you want to preserve the 30 character limit for last names, use a custom
  187. form::
  188. from django.contrib.auth.forms import UserChangeForm
  189. class MyUserChangeForm(UserChangeForm):
  190. last_name = forms.CharField(max_length=30, required=False)
  191. If you wish to keep this restriction in the admin when editing users, set
  192. ``UserAdmin.form`` to use this form::
  193. from django.contrib.auth.admin import UserAdmin
  194. from django.contrib.auth.models import User
  195. class MyUserAdmin(UserAdmin):
  196. form = MyUserChangeForm
  197. admin.site.unregister(User)
  198. admin.site.register(User, MyUserAdmin)
  199. Miscellaneous
  200. -------------
  201. * The ``SessionAuthenticationMiddleware`` class is removed. It provided no
  202. functionality since session authentication is unconditionally enabled in
  203. Django 1.10.
  204. * The default HTTP error handlers (``handler404``, etc.) are now callables
  205. instead of dotted Python path strings. Django favors callable references
  206. since they provide better performance and debugging experience.
  207. * :class:`~django.views.generic.base.RedirectView` no longer silences
  208. ``NoReverseMatch`` if the ``pattern_name`` doesn't exist.
  209. * When :setting:`USE_L10N` is off, :class:`~django.forms.FloatField` and
  210. :class:`~django.forms.DecimalField` now respect :setting:`DECIMAL_SEPARATOR`
  211. and :setting:`THOUSAND_SEPARATOR` during validation. For example, with the
  212. settings::
  213. USE_L10N = False
  214. USE_THOUSAND_SEPARATOR = True
  215. DECIMAL_SEPARATOR = ','
  216. THOUSAND_SEPARATOR = '.'
  217. an input of ``"1.345"`` is now converted to ``1345`` instead of ``1.345``.
  218. .. _deprecated-features-2.0:
  219. Features deprecated in 2.0
  220. ==========================
  221. Miscellaneous
  222. -------------
  223. * The ``django.db.backends.postgresql_psycopg2`` module is deprecated in favor
  224. of ``django.db.backends.postgresql``. It's been an alias since Django 1.9.
  225. This only affects code that imports from the module directly. The
  226. ``DATABASES`` setting can still use
  227. ``'django.db.backends.postgresql_psycopg2'``, though you can simplify that by
  228. using the ``'django.db.backends.postgresql'`` name added in Django 1.9.
  229. * ``django.shortcuts.render_to_response()`` is deprecated in favor of
  230. :func:`django.shortcuts.render`. ``render()`` takes the same arguments
  231. except that is also requires a ``request``.
  232. * The ``DEFAULT_CONTENT_TYPE`` setting is deprecated. It doesn't interact well
  233. well with third-party apps and is obsolete since HTML5 has mostly superseded
  234. XHTML.
  235. * ``HttpRequest.xreadlines()`` is deprecated in favor of iterating over the
  236. request.
  237. .. _removed-features-2.0:
  238. Features removed in 2.0
  239. =======================
  240. These features have reached the end of their deprecation cycle and are removed
  241. in Django 2.0. See :ref:`deprecated-features-1.9` and
  242. :ref:`deprecated-features-1.10` for details, including how to remove usage of
  243. these features.
  244. * The ``weak`` argument to ``django.dispatch.signals.Signal.disconnect()`` is
  245. removed.
  246. * ``django.db.backends.base.BaseDatabaseOperations.check_aggregate_support()``
  247. is removed.
  248. * The ``django.forms.extras`` package is removed.
  249. * The ``assignment_tag`` helper is removed.
  250. * The ``host`` argument to ``SimpleTestCase.assertsRedirects()`` is removed.
  251. The compatibility layer which allows absolute URLs to be considered equal to
  252. relative ones when the path is identical is also removed.
  253. * ``Field.rel`` and ``Field.remote_field.to`` are removed.
  254. * The ``on_delete`` argument for ``ForeignKey`` and ``OneToOneField`` are now
  255. required.
  256. * ``django.db.models.fields.add_lazy_relation()`` is removed.
  257. * When time zone support is enabled, database backends that don't support time
  258. zones no longer convert aware datetimes to naive values in UTC anymore when
  259. such values are passed as parameters to SQL queries executed outside of the
  260. ORM, e.g. with ``cursor.execute()``.
  261. * ``django.contrib.auth.tests.utils.skipIfCustomUser()`` is removed.
  262. * The ``GeoManager`` and ``GeoQuerySet`` classes are removed.
  263. * The ``django.contrib.gis.geoip`` module is removed.
  264. * The ``supports_recursion`` check for template loaders is removed from:
  265. * ``django.template.engine.Engine.find_template()``
  266. * ``django.template.loader_tags.ExtendsNode.find_template()``
  267. * ``django.template.loaders.base.Loader.supports_recursion()``
  268. * ``django.template.loaders.cached.Loader.supports_recursion()``
  269. * The ``load_template`` and ``load_template_sources`` template loader methods
  270. are removed.
  271. * The ``template_dirs`` argument for template loaders is removed:
  272. * ``django.template.loaders.base.Loader.get_template()``
  273. * ``django.template.loaders.cached.Loader.cache_key()``
  274. * ``django.template.loaders.cached.Loader.get_template()``
  275. * ``django.template.loaders.cached.Loader.get_template_sources()``
  276. * ``django.template.loaders.filesystem.Loader.get_template_sources()``
  277. * ``django.template.loaders.base.Loader.__call__()`` is removed.
  278. * Support for custom error views that don't accept an ``exception`` parameter
  279. is removed.
  280. * The ``mime_type`` attribute of ``django.utils.feedgenerator.Atom1Feed`` and
  281. ``django.utils.feedgenerator.RssFeed`` is removed.
  282. * The ``app_name`` argument to ``include()`` is removed.
  283. * Support for passing a 3-tuple (including ``admin.site.urls``) as the first
  284. argument to ``include()`` is removed.
  285. * Support for setting a URL instance namespace without an application namespace
  286. is removed.
  287. * ``Field._get_val_from_obj()`` is removed.
  288. * ``django.template.loaders.eggs.Loader`` is removed.
  289. * The ``current_app`` parameter to the ``contrib.auth`` function-based views is
  290. removed.
  291. * The ``callable_obj`` keyword argument to
  292. ``SimpleTestCase.assertRaisesMessage()`` is removed.
  293. * Support for the ``allow_tags`` attribute on ``ModelAdmin`` methods is
  294. removed.
  295. * The ``enclosure`` keyword argument to ``SyndicationFeed.add_item()`` is
  296. removed.
  297. * The ``django.template.loader.LoaderOrigin`` and
  298. ``django.template.base.StringOrigin`` aliases for
  299. ``django.template.base.Origin`` are removed.
  300. * The ``makemigrations --exit`` option is removed.
  301. * Support for direct assignment to a reverse foreign key or many-to-many
  302. relation is removed.
  303. * The ``get_srid()`` and ``set_srid()`` methods of
  304. ``django.contrib.gis.geos.GEOSGeometry`` are removed.
  305. * The ``get_x()``, ``set_x()``, ``get_y()``, ``set_y()``, ``get_z()``, and
  306. ``set_z()`` methods of ``django.contrib.gis.geos.Point`` are removed.
  307. * The ``get_coords()`` and ``set_coords()`` methods of
  308. ``django.contrib.gis.geos.Point`` are removed.
  309. * The ``cascaded_union`` property of ``django.contrib.gis.geos.MultiPolygon``
  310. is removed.
  311. * ``django.utils.functional.allow_lazy()`` is removed.
  312. * The ``shell --plain`` option is removed.
  313. * The ``django.core.urlresolvers`` module is removed.
  314. * ``CommaSeparatedIntegerField`` is removed, except for support in historical
  315. migrations.
  316. * The template ``Context.has_key()`` method is removed.
  317. * Support for the ``django.core.files.storage.Storage.accessed_time()``,
  318. ``created_time()``, and ``modified_time()`` methods is removed.
  319. * Support for query lookups using the model name when
  320. ``Meta.default_related_name`` is set is removed.
  321. * The MySQL ``__search`` lookup is removed.
  322. * The shim for supporting custom related manager classes without a
  323. ``_apply_rel_filters()`` method is removed.
  324. * Using ``User.is_authenticated()`` and ``User.is_anonymous()`` as methods
  325. rather than properties is no longer supported.
  326. * The ``Model._meta.virtual_fields`` attribute is removed.
  327. * The keyword arguments ``virtual_only`` in ``Field.contribute_to_class()`` and
  328. ``virtual`` in ``Model._meta.add_field()`` are removed.
  329. * The ``javascript_catalog()`` and ``json_catalog()`` views are removed.
  330. * ``django.contrib.gis.utils.precision_wkt()`` is removed.
  331. * In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a
  332. ``parent_link`` is removed.
  333. * Support for ``Widget._format_value()`` is removed.
  334. * ``FileField`` methods ``get_directory_name()`` and ``get_filename()`` are
  335. removed.
  336. * The ``mark_for_escaping()`` function and the classes it uses: ``EscapeData``,
  337. ``EscapeBytes``, ``EscapeText``, ``EscapeString``, and ``EscapeUnicode`` are
  338. removed.
  339. * The ``escape`` filter now uses ``django.utils.html.conditional_escape()``.
  340. * ``Manager.use_for_related_fields`` is removed.
  341. * Model ``Manager`` inheritance follows MRO inheritance rules. The requirement
  342. to use ``Meta.manager_inheritance_from_future`` to opt-in to the behavior is
  343. removed.
  344. * Support for old-style middleware using ``settings.MIDDLEWARE_CLASSES`` is
  345. removed.