2.0.txt 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900
  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. This release starts Django's use of a :ref:`loose form of semantic versioning
  12. <internal-release-cadence>`, however, there aren't any major backwards
  13. incompatible changes that might be expected of a 2.0 release. Upgrading should
  14. be a similar amount of effort as past feature releases.
  15. See the :doc:`/howto/upgrade-version` guide if you're updating an existing
  16. project.
  17. Python compatibility
  18. ====================
  19. Django 2.0 supports Python 3.4, 3.5, and 3.6. We **highly recommend** and only
  20. officially support the latest release of each series.
  21. The Django 1.11.x series is the last to support Python 2.7.
  22. Django 2.0 will be the last release series to support Python 3.4. If you plan
  23. a deployment of Python 3.4 beyond the end-of-life for Django 2.0 (April 2019),
  24. stick with Django 1.11 LTS (supported until April 2020) instead. Note, however,
  25. that the end-of-life for Python 3.4 is March 2019.
  26. Third-party library support for older version of Django
  27. =======================================================
  28. Following the release of Django 2.0, we suggest that third-party app authors
  29. drop support for all versions of Django prior to 1.11. At that time, you should
  30. be able to run your package's tests using ``python -Wd`` so that deprecation
  31. warnings do appear. After making the deprecation warning fixes, your app should
  32. be compatible with Django 2.0.
  33. .. _whats-new-2.0:
  34. What's new in Django 2.0
  35. ========================
  36. Simplified URL routing syntax
  37. -----------------------------
  38. The new :func:`django.urls.path()` function allows a simpler, more readable URL
  39. routing syntax. For example, this example from previous Django releases::
  40. url(r'^articles/(?P<year>[0-9]{4})/$', views.year_archive),
  41. could be written as::
  42. path('articles/<int:year>/', views.year_archive),
  43. The new syntax supports type coercion of URL parameters. In the example, the
  44. view will receive the ``year`` keyword argument as an integer rather than as
  45. a string.
  46. The ``django.conf.urls.url()`` function from previous versions is now available
  47. as :func:`django.urls.re_path`, however, the old location remains for backwards
  48. compatibility, without an imminent deprecation. The old
  49. ``django.conf.urls.include()`` function is now importable from ``django.urls``
  50. so you can use ``from django.urls import include, path, re_path`` in your
  51. URLconfs.
  52. The :doc:`/topics/http/urls` document is rewritten to feature the new syntax
  53. and provide more details.
  54. Mobile-friendly ``contrib.admin``
  55. ---------------------------------
  56. The admin is now responsive and supports all major mobile devices.
  57. Older browser may experience varying levels of graceful degradation.
  58. Window expressions
  59. ------------------
  60. The new :class:`~django.db.models.expressions.Window` expression allows
  61. adding an ``OVER`` clause to querysets. You can use :ref:`window functions
  62. <window-functions>` and :ref:`aggregate functions <aggregation-functions>` in
  63. the expression.
  64. Minor features
  65. --------------
  66. :mod:`django.contrib.admin`
  67. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. * The new :attr:`.ModelAdmin.autocomplete_fields` attribute and
  69. :meth:`.ModelAdmin.get_autocomplete_fields` method allow using an
  70. `Select2 <https://select2.org>`_ search widget for ``ForeignKey`` and
  71. ``ManyToManyField``.
  72. :mod:`django.contrib.admindocs`
  73. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74. * ...
  75. :mod:`django.contrib.auth`
  76. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  77. * The default iteration count for the PBKDF2 password hasher is increased from
  78. 36,000 to 100,000.
  79. :mod:`django.contrib.contenttypes`
  80. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  81. * ...
  82. :mod:`django.contrib.gis`
  83. ~~~~~~~~~~~~~~~~~~~~~~~~~
  84. * Added MySQL support for the
  85. :class:`~django.contrib.gis.db.models.functions.AsGeoJSON` function,
  86. :class:`~django.contrib.gis.db.models.functions.GeoHash` function,
  87. :class:`~django.contrib.gis.db.models.functions.IsValid` function,
  88. :lookup:`isvalid` lookup, and :ref:`distance lookups <distance-lookups>`.
  89. * Added the :class:`~django.contrib.gis.db.models.functions.Azimuth` and
  90. :class:`~django.contrib.gis.db.models.functions.LineLocatePoint` functions,
  91. supported on PostGIS and SpatiaLite.
  92. * Any :class:`~django.contrib.gis.geos.GEOSGeometry` imported from GeoJSON now
  93. has its SRID set.
  94. * Added the :attr:`.OSMWidget.default_zoom` attribute to customize the map's
  95. default zoom level.
  96. * Made metadata readable and editable on rasters through the
  97. :attr:`~django.contrib.gis.gdal.GDALRaster.metadata`,
  98. :attr:`~django.contrib.gis.gdal.GDALRaster.info`, and
  99. :attr:`~django.contrib.gis.gdal.GDALBand.metadata` attributes.
  100. * Allowed passing driver-specific creation options to
  101. :class:`~django.contrib.gis.gdal.GDALRaster` objects using ``papsz_options``.
  102. * Allowed creating :class:`~django.contrib.gis.gdal.GDALRaster` objects in
  103. GDAL's internal virtual filesystem. Rasters can now be :ref:`created from and
  104. converted to binary data <gdal-raster-vsimem>` in-memory.
  105. :mod:`django.contrib.messages`
  106. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  107. * ...
  108. :mod:`django.contrib.postgres`
  109. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  110. * The new ``distinct`` argument for
  111. :class:`~django.contrib.postgres.aggregates.ArrayAgg` determines if
  112. concatenated values will be distinct.
  113. * The new :class:`~django.contrib.postgres.functions.RandomUUID` database
  114. function returns a version 4 UUID. It requires use of PostgreSQL's
  115. ``pgcrypto`` extension which can be activated using the new
  116. :class:`~django.contrib.postgres.operations.CryptoExtension` migration
  117. operation.
  118. * :class:`django.contrib.postgres.indexes.GinIndex` now supports the
  119. ``fastupdate`` and ``gin_pending_list_limit`` parameters.
  120. * The new :class:`~django.contrib.postgres.indexes.GistIndex` class allows
  121. creating ``GiST`` indexes in the database. The new
  122. :class:`~django.contrib.postgres.operations.BtreeGistExtension` migration
  123. operation installs the ``btree_gist`` extension to add support for operator
  124. classes that aren't built-in.
  125. * :djadmin:`inspectdb` can now introspect ``JSONField`` and various
  126. ``RangeField``\s (``django.contrib.postgres`` must be in ``INSTALLED_APPS``).
  127. :mod:`django.contrib.redirects`
  128. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  129. * ...
  130. :mod:`django.contrib.sessions`
  131. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  132. * ...
  133. :mod:`django.contrib.sitemaps`
  134. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  135. * Added the ``protocol`` keyword argument to the
  136. :class:`~django.contrib.sitemaps.GenericSitemap` constructor.
  137. :mod:`django.contrib.sites`
  138. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139. * ...
  140. :mod:`django.contrib.staticfiles`
  141. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  142. * ...
  143. :mod:`django.contrib.syndication`
  144. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  145. * ...
  146. Cache
  147. ~~~~~
  148. * On memcached, ``cache.set_many()`` returns a list of keys that failed to be
  149. inserted.
  150. CSRF
  151. ~~~~
  152. * ...
  153. Database backends
  154. ~~~~~~~~~~~~~~~~~
  155. * ...
  156. Email
  157. ~~~~~
  158. * ...
  159. File Storage
  160. ~~~~~~~~~~~~
  161. * :meth:`File.open() <django.core.files.File.open>` can be used as a context
  162. manager, e.g. ``with file.open() as f:``.
  163. File Uploads
  164. ~~~~~~~~~~~~
  165. * ...
  166. Forms
  167. ~~~~~
  168. * The new ``date_attrs`` and ``time_attrs`` arguments for
  169. :class:`~django.forms.SplitDateTimeWidget` and
  170. :class:`~django.forms.SplitHiddenDateTimeWidget` allow specifying different
  171. HTML attributes for the ``DateInput`` and ``TimeInput`` (or hidden)
  172. subwidgets.
  173. * The new :meth:`Form.errors.get_json_data()
  174. <django.forms.Form.errors.get_json_data>` method returns form errors as
  175. a dictionary suitable for including in a JSON response.
  176. Generic Views
  177. ~~~~~~~~~~~~~
  178. * The new :attr:`.ContextMixin.extra_context` attribute allows adding context
  179. in ``View.as_view()``.
  180. Internationalization
  181. ~~~~~~~~~~~~~~~~~~~~
  182. * ...
  183. Management Commands
  184. ~~~~~~~~~~~~~~~~~~~
  185. * :djadmin:`inspectdb` now translates MySQL's unsigned integer columns to
  186. ``PositiveIntegerField`` or ``PositiveSmallIntegerField``.
  187. * The new :option:`makemessages --add-location` option controls the comment
  188. format in PO files.
  189. * :djadmin:`loaddata` can now :ref:`read from stdin <loading-fixtures-stdin>`.
  190. * The new :option:`diffsettings --output` option allows formatting the output
  191. in a unified diff format.
  192. * On Oracle, :djadmin:`inspectdb` can now introspect ``AutoField`` if the
  193. column is created as an identity column.
  194. * On MySQL, :djadmin:`dbshell` now supports client-side TLS certificates.
  195. Migrations
  196. ~~~~~~~~~~
  197. * The new :option:`squashmigrations --squashed-name` option allows naming
  198. the squashed migration.
  199. Models
  200. ~~~~~~
  201. * The new :class:`~django.db.models.functions.StrIndex` database function
  202. finds the starting index of a string inside another string.
  203. * On Oracle, ``AutoField`` and ``BigAutoField`` are now created as `identity
  204. columns`_.
  205. .. _`identity columns`: https://docs.oracle.com/database/121/DRDAA/migr_tools_feat.htm#DRDAA109
  206. * The new ``chunk_size`` parameter of :meth:`.QuerySet.iterator` controls the
  207. number of rows fetched by the Python database client when streaming results
  208. from the database. For databases that don't support server-side cursors, it
  209. controls the number of results Django fetches from the database adapter.
  210. * :meth:`.QuerySet.earliest`, :meth:`.QuerySet.latest`, and
  211. :attr:`Meta.get_latest_by <django.db.models.Options.get_latest_by>` now
  212. allow ordering by several fields.
  213. * Added the :class:`~django.db.models.functions.datetime.ExtractQuarter`
  214. function to extract the quarter from :class:`~django.db.models.DateField` and
  215. :class:`~django.db.models.DateTimeField`, and exposed it through the
  216. :lookup:`quarter` lookup.
  217. * Added the :class:`~django.db.models.functions.datetime.TruncQuarter`
  218. function to truncate :class:`~django.db.models.DateField` and
  219. :class:`~django.db.models.DateTimeField` to the first day of a quarter.
  220. * Added the :attr:`~django.db.models.Index.db_tablespace` parameter to
  221. class-based indexes.
  222. * If the database supports a native duration field (Oracle and PostgreSQL),
  223. :class:`~django.db.models.functions.datetime.Extract` now works with
  224. :class:`~django.db.models.DurationField`.
  225. * Added the ``of`` argument to :meth:`.QuerySet.select_for_update()`, supported
  226. on PostgreSQL and Oracle, to lock only rows from specific tables rather than
  227. all selected tables. It may be helpful particularly when
  228. :meth:`~.QuerySet.select_for_update()` is used in conjunction with
  229. :meth:`~.QuerySet.select_related()`.
  230. * The new ``field_name`` parameter of :meth:`.QuerySet.in_bulk` allows fetching
  231. results based on any unique model field.
  232. * :meth:`.CursorWrapper.callproc()` now takes an optional dictionary of keyword
  233. parameters, if the backend supports this feature. Of Django's built-in
  234. backends, only Oracle supports it.
  235. * The new ``filter`` argument for built-in aggregates allows :ref:`adding
  236. different conditionals <conditional-aggregation>` to multiple aggregations
  237. over the same fields or relations.
  238. * Added support for expressions in :attr:`Meta.ordering
  239. <django.db.models.Options.ordering>`.
  240. * The new ``named`` parameter of :meth:`.QuerySet.values_list` allows fetching
  241. results as named tuples.
  242. Pagination
  243. ~~~~~~~~~~
  244. * Added :meth:`Paginator.get_page() <django.core.paginator.Paginator.get_page>`
  245. to provide the documented pattern of handling invalid page numbers.
  246. Requests and Responses
  247. ~~~~~~~~~~~~~~~~~~~~~~
  248. * The :djadmin:`runserver` Web server supports HTTP 1.1.
  249. Serialization
  250. ~~~~~~~~~~~~~
  251. * ...
  252. Signals
  253. ~~~~~~~
  254. * ...
  255. Templates
  256. ~~~~~~~~~
  257. * To increase the usefulness of :meth:`.Engine.get_default` in third-party
  258. apps, it now returns the first engine if multiple ``DjangoTemplates`` engines
  259. are configured in ``TEMPLATES`` rather than raising ``ImproperlyConfigured``.
  260. * Custom template tags may now accept keyword-only arguments.
  261. Tests
  262. ~~~~~
  263. * Added threading support to :class:`~django.test.LiveServerTestCase`.
  264. * Added settings that allow customizing the test tablespace parameters for
  265. Oracle: :setting:`DATAFILE_SIZE`, :setting:`DATAFILE_TMP_SIZE`,
  266. :setting:`DATAFILE_EXTSIZE`, and :setting:`DATAFILE_TMP_EXTSIZE`.
  267. URLs
  268. ~~~~
  269. * ...
  270. Validators
  271. ~~~~~~~~~~
  272. * The new :class:`.ProhibitNullCharactersValidator` disallows the null
  273. character in the input of the :class:`~django.forms.CharField` form field
  274. and its subclasses. Null character input was observed from vulnerability
  275. scanning tools. Most databases silently discard null characters, but
  276. psycopg2 2.7+ raises an exception when trying to save a null character to
  277. a char/text field with PostgreSQL.
  278. .. _backwards-incompatible-2.0:
  279. Backwards incompatible changes in 2.0
  280. =====================================
  281. Removed support for bytestrings in some places
  282. ----------------------------------------------
  283. To support native Python 2 strings, older Django versions had to accept both
  284. bytestrings and unicode strings. Now that Python 2 support is dropped,
  285. bytestrings should only be encountered around input/output boundaries (handling
  286. of binary fields or HTTP streams, for example). You might have to update your
  287. code to limit bytestring usage to a minimum, as Django no longer accepts
  288. bytestrings in certain code paths.
  289. Database backend API
  290. --------------------
  291. This section describes changes that may be needed in third-party database
  292. backends.
  293. * The ``DatabaseOperations.datetime_cast_date_sql()``,
  294. ``datetime_cast_time_sql()``, ``datetime_trunc_sql()``,
  295. ``datetime_extract_sql()``, and ``date_interval_sql()`` methods now return
  296. only the SQL to perform the operation instead of SQL and a list of
  297. parameters.
  298. * Third-party database backends should add a ``DatabaseWrapper.display_name``
  299. attribute with the name of the database that your backend works with. Django
  300. may use it in various messages, such as in system checks.
  301. * The first argument of ``SchemaEditor._alter_column_type_sql()`` is now
  302. ``model`` rather than ``table``.
  303. * The first argument of ``SchemaEditor._create_index_name()`` is now
  304. ``table_name`` rather than ``model``.
  305. * To enable ``FOR UPDATE OF`` support, set
  306. ``DatabaseFeatures.has_select_for_update_of = True``. If the database
  307. requires that the arguments to ``OF`` be columns rather than tables, set
  308. ``DatabaseFeatures.select_for_update_of_column = True``.
  309. * To enable support for :class:`~django.db.models.expressions.Window`
  310. expressions, set ``DatabaseFeatures.supports_over_clause`` to ``True``. You
  311. may need to customize the ``DatabaseOperations.window_start_rows_start_end()``
  312. and/or ``window_start_range_start_end()`` methods.
  313. * Third-party database backends should add a
  314. ``DatabaseOperations.cast_char_field_without_max_length`` attribute with the
  315. database data type that will be used in the
  316. :class:`~django.db.models.functions.Cast` function for a ``CharField`` if the
  317. ``max_length`` argument isn't provided.
  318. * The first argument of ``DatabaseCreation._clone_test_db()`` and
  319. ``get_test_db_clone_settings()`` is now ``suffix`` rather
  320. than ``number`` (in case you want to rename the signatures in your backend
  321. for consistency). ``django.test`` also now passes those values as strings
  322. rather than as integers.
  323. * Third-party database backends should add a
  324. ``DatabaseIntrospection.get_sequences()`` method based on the stub in
  325. ``BaseDatabaseIntrospection``.
  326. Dropped support for Oracle 11.2
  327. -------------------------------
  328. The end of upstream support for Oracle 11.2 is Dec. 2020. Django 1.11 will be
  329. supported until April 2020 which almost reaches this date. Django 2.0
  330. officially supports Oracle 12.1+.
  331. Default MySQL isolation level is read committed
  332. -----------------------------------------------
  333. MySQL's default isolation level, repeatable read, may cause data loss in
  334. typical Django usage. To prevent that and for consistency with other databases,
  335. the default isolation level is now read committed. You can use the
  336. :setting:`DATABASES` setting to :ref:`use a different isolation level
  337. <mysql-isolation-level>`, if needed.
  338. :attr:`AbstractUser.last_name <django.contrib.auth.models.User.last_name>` ``max_length`` increased to 150
  339. ----------------------------------------------------------------------------------------------------------
  340. A migration for :attr:`django.contrib.auth.models.User.last_name` is included.
  341. If you have a custom user model inheriting from ``AbstractUser``, you'll need
  342. to generate and apply a database migration for your user model.
  343. If you want to preserve the 30 character limit for last names, use a custom
  344. form::
  345. from django.contrib.auth.forms import UserChangeForm
  346. class MyUserChangeForm(UserChangeForm):
  347. last_name = forms.CharField(max_length=30, required=False)
  348. If you wish to keep this restriction in the admin when editing users, set
  349. ``UserAdmin.form`` to use this form::
  350. from django.contrib.auth.admin import UserAdmin
  351. from django.contrib.auth.models import User
  352. class MyUserAdmin(UserAdmin):
  353. form = MyUserChangeForm
  354. admin.site.unregister(User)
  355. admin.site.register(User, MyUserAdmin)
  356. ``QuerySet.reverse()`` and ``last()`` are prohibited after slicing
  357. ------------------------------------------------------------------
  358. Calling ``QuerySet.reverse()`` or ``last()`` on a sliced queryset leads to
  359. unexpected results due to the slice being applied after reordering. This is
  360. now prohibited, e.g.::
  361. >>> Model.objects.all()[:2].reverse()
  362. Traceback (most recent call last):
  363. ...
  364. TypeError: Cannot reverse a query once a slice has been taken.
  365. Form fields no longer accept optional arguments as positional arguments
  366. -----------------------------------------------------------------------
  367. To help prevent runtime errors due to incorrect ordering of form field
  368. arguments, optional arguments of built-in form fields are no longer accepted
  369. as positional arguments. For example::
  370. forms.IntegerField(25, 10)
  371. raises an exception and should be replaced with::
  372. forms.IntegerField(max_value=25, min_value=10)
  373. ``call_command()`` validates the options it receives
  374. ----------------------------------------------------
  375. ``call_command()`` now validates that the argument parser of the command being
  376. called defines all of the options passed to ``call_command()``.
  377. For custom management commands that use options not created using
  378. ``parser.add_argument()``, add a ``stealth_options`` attribute on the command::
  379. class MyCommand(BaseCommand):
  380. stealth_options = ('option_name', ...)
  381. Indexes no longer accept positional arguments
  382. ---------------------------------------------
  383. For example::
  384. models.Index(['headline', '-pub_date'], 'index_name')
  385. raises an exception and should be replaced with::
  386. models.Index(fields=['headline', '-pub_date'], name='index_name')
  387. Foreign key constraints are now enabled on SQLite
  388. -------------------------------------------------
  389. This will appear as a backwards-incompatible change (``IntegrityError:
  390. FOREIGN KEY constraint failed``) if attempting to save an existing model
  391. instance that's violating a foreign key constraint.
  392. Foreign keys are now created with ``DEFERRABLE INITIALLY DEFERRED`` instead of
  393. ``DEFERRABLE IMMEDIATE``. Thus, tables may need to be rebuilt to recreate
  394. foreign keys with the new definition, particularly if you're using a pattern
  395. like this::
  396. from django.db import transaction
  397. with transaction.atomic():
  398. Book.objects.create(author_id=1)
  399. Author.objects.create(id=1)
  400. If you don't recreate the foreign key as ``DEFERRED``, the first ``create()``
  401. would fail now that foreign key constraints are enforced.
  402. Backup your database first! After upgrading to Django 2.0, you can then
  403. rebuild tables using a script similar to this::
  404. from django.apps import apps
  405. from django.db import connection
  406. for app in apps.get_app_configs():
  407. for model in app.get_models(include_auto_created=True):
  408. if model._meta.managed and not (model._meta.proxy or model._meta.swapped):
  409. for base in model.__bases__:
  410. if hasattr(base, '_meta'):
  411. base._meta.local_many_to_many = []
  412. model._meta.local_many_to_many = []
  413. with connection.schema_editor() as editor:
  414. editor._remake_table(model)
  415. This script hasn't received extensive testing and needs adaption for various
  416. cases such as multiple databases. Feel free to contribute improvements.
  417. Miscellaneous
  418. -------------
  419. * The ``SessionAuthenticationMiddleware`` class is removed. It provided no
  420. functionality since session authentication is unconditionally enabled in
  421. Django 1.10.
  422. * The default HTTP error handlers (``handler404``, etc.) are now callables
  423. instead of dotted Python path strings. Django favors callable references
  424. since they provide better performance and debugging experience.
  425. * :class:`~django.views.generic.base.RedirectView` no longer silences
  426. ``NoReverseMatch`` if the ``pattern_name`` doesn't exist.
  427. * When :setting:`USE_L10N` is off, :class:`~django.forms.FloatField` and
  428. :class:`~django.forms.DecimalField` now respect :setting:`DECIMAL_SEPARATOR`
  429. and :setting:`THOUSAND_SEPARATOR` during validation. For example, with the
  430. settings::
  431. USE_L10N = False
  432. USE_THOUSAND_SEPARATOR = True
  433. DECIMAL_SEPARATOR = ','
  434. THOUSAND_SEPARATOR = '.'
  435. an input of ``"1.345"`` is now converted to ``1345`` instead of ``1.345``.
  436. * Subclasses of :class:`~django.contrib.auth.models.AbstractBaseUser` are no
  437. longer required to implement ``get_short_name()`` and ``get_full_name()``.
  438. (The base implementations that raise ``NotImplementedError`` are removed.)
  439. ``django.contrib.admin`` uses these methods if implemented but doesn't
  440. require them. Third-party apps that use these methods may want to adopt a
  441. similar approach.
  442. * The ``FIRST_DAY_OF_WEEK`` and ``NUMBER_GROUPING`` format settings are now
  443. kept as integers in JavaScript and JSON i18n view outputs.
  444. * :meth:`~django.test.TransactionTestCase.assertNumQueries` now ignores
  445. connection configuration queries. Previously, if a test opened a new database
  446. connection, those queries could be included as part of the
  447. ``assertNumQueries()`` count.
  448. * The ``PASSWORD_RESET_TIMEOUT_DAYS`` setting is more properly respected in
  449. ``contrib.auth`` password reset. Previously, resets were allowed for one day
  450. longer than expected. For example, with the default of
  451. ``PASSWORD_RESET_TIMEOUT_DAYS = 3``, password reset tokens are now valid for
  452. 72 hours rather than 96 hours.
  453. * The default size of the Oracle test tablespace is increased from 20M to 50M
  454. and the default autoextend size is increased from 10M to 25M.
  455. * To improve performance when streaming large result sets from the database,
  456. :meth:`.QuerySet.iterator` now fetches 2000 rows at a time instead of 100.
  457. The old behavior can be restored using the ``chunk_size`` parameter. For
  458. example::
  459. Book.objects.iterator(chunk_size=100)
  460. * Providing unknown package names in the ``packages`` argument of the
  461. :class:`~django.views.i18n.JavaScriptCatalog` view now raises ``ValueError``
  462. instead of passing silently.
  463. * A model instance's primary key now appears in the default ``Model.__str__()``
  464. method, e.g. ``Question object (1)``.
  465. * ``makemigrations`` now detects changes to the model field ``limit_choices_to``
  466. option. Add this to your existing migrations or accept an auto-generated
  467. migration for fields that use it.
  468. * Performing queries that require :ref:`automatic spatial transformations
  469. <automatic-spatial-transformations>` now raises ``NotImplementedError``
  470. on MySQL instead of silently using non-transformed geometries.
  471. * ``django.core.exceptions.DjangoRuntimeWarning`` is removed. It was only used
  472. in the cache backend as an intermediate class in ``CacheKeyWarning``'s
  473. inheritance of ``RuntimeWarning``.
  474. * Renamed ``BaseExpression._output_field`` to ``output_field``. You may need
  475. to update custom expressions.
  476. * In older versions, forms and formsets combine their ``Media`` with widget
  477. ``Media`` by concatenating the two. The combining now tries to :ref:`preserve
  478. the relative order of elements in each list <form-media-asset-order>`.
  479. ``MediaOrderConflictWarning`` is issued if the order can't be preserved.
  480. * ``django.contrib.gis.gdal.OGRException`` is removed. It's been an alias for
  481. ``GDALException`` since Django 1.8.
  482. * Support for GEOS 3.3.x is dropped.
  483. .. _deprecated-features-2.0:
  484. Features deprecated in 2.0
  485. ==========================
  486. ``context`` argument of ``Field.from_db_value()`` and ``Expression.convert_value()``
  487. ------------------------------------------------------------------------------------
  488. The ``context`` argument of ``Field.from_db_value()`` and
  489. ``Expression.convert_value()`` is unused as it's always an empty dictionary.
  490. The signature of both methods is now::
  491. (self, value, expression, connection)
  492. instead of::
  493. (self, value, expression, connection, context)
  494. Support for the old signature in custom fields and expressions remains until
  495. Django 3.0.
  496. Miscellaneous
  497. -------------
  498. * The ``django.db.backends.postgresql_psycopg2`` module is deprecated in favor
  499. of ``django.db.backends.postgresql``. It's been an alias since Django 1.9.
  500. This only affects code that imports from the module directly. The
  501. ``DATABASES`` setting can still use
  502. ``'django.db.backends.postgresql_psycopg2'``, though you can simplify that by
  503. using the ``'django.db.backends.postgresql'`` name added in Django 1.9.
  504. * ``django.shortcuts.render_to_response()`` is deprecated in favor of
  505. :func:`django.shortcuts.render`. ``render()`` takes the same arguments
  506. except that is also requires a ``request``.
  507. * The ``DEFAULT_CONTENT_TYPE`` setting is deprecated. It doesn't interact well
  508. well with third-party apps and is obsolete since HTML5 has mostly superseded
  509. XHTML.
  510. * ``HttpRequest.xreadlines()`` is deprecated in favor of iterating over the
  511. request.
  512. * The ``field_name`` keyword argument to :meth:`.QuerySet.earliest` and
  513. :meth:`.QuerySet.latest` is deprecated in favor of passing the field
  514. names as arguments. Write ``.earliest('pub_date')`` instead of
  515. ``.earliest(field_name='pub_date')``.
  516. .. _removed-features-2.0:
  517. Features removed in 2.0
  518. =======================
  519. These features have reached the end of their deprecation cycle and are removed
  520. in Django 2.0. See :ref:`deprecated-features-1.9` and
  521. :ref:`deprecated-features-1.10` for details, including how to remove usage of
  522. these features.
  523. * The ``weak`` argument to ``django.dispatch.signals.Signal.disconnect()`` is
  524. removed.
  525. * ``django.db.backends.base.BaseDatabaseOperations.check_aggregate_support()``
  526. is removed.
  527. * The ``django.forms.extras`` package is removed.
  528. * The ``assignment_tag`` helper is removed.
  529. * The ``host`` argument to ``SimpleTestCase.assertsRedirects()`` is removed.
  530. The compatibility layer which allows absolute URLs to be considered equal to
  531. relative ones when the path is identical is also removed.
  532. * ``Field.rel`` and ``Field.remote_field.to`` are removed.
  533. * The ``on_delete`` argument for ``ForeignKey`` and ``OneToOneField`` are now
  534. required.
  535. * ``django.db.models.fields.add_lazy_relation()`` is removed.
  536. * When time zone support is enabled, database backends that don't support time
  537. zones no longer convert aware datetimes to naive values in UTC anymore when
  538. such values are passed as parameters to SQL queries executed outside of the
  539. ORM, e.g. with ``cursor.execute()``.
  540. * ``django.contrib.auth.tests.utils.skipIfCustomUser()`` is removed.
  541. * The ``GeoManager`` and ``GeoQuerySet`` classes are removed.
  542. * The ``django.contrib.gis.geoip`` module is removed.
  543. * The ``supports_recursion`` check for template loaders is removed from:
  544. * ``django.template.engine.Engine.find_template()``
  545. * ``django.template.loader_tags.ExtendsNode.find_template()``
  546. * ``django.template.loaders.base.Loader.supports_recursion()``
  547. * ``django.template.loaders.cached.Loader.supports_recursion()``
  548. * The ``load_template`` and ``load_template_sources`` template loader methods
  549. are removed.
  550. * The ``template_dirs`` argument for template loaders is removed:
  551. * ``django.template.loaders.base.Loader.get_template()``
  552. * ``django.template.loaders.cached.Loader.cache_key()``
  553. * ``django.template.loaders.cached.Loader.get_template()``
  554. * ``django.template.loaders.cached.Loader.get_template_sources()``
  555. * ``django.template.loaders.filesystem.Loader.get_template_sources()``
  556. * ``django.template.loaders.base.Loader.__call__()`` is removed.
  557. * Support for custom error views that don't accept an ``exception`` parameter
  558. is removed.
  559. * The ``mime_type`` attribute of ``django.utils.feedgenerator.Atom1Feed`` and
  560. ``django.utils.feedgenerator.RssFeed`` is removed.
  561. * The ``app_name`` argument to ``include()`` is removed.
  562. * Support for passing a 3-tuple (including ``admin.site.urls``) as the first
  563. argument to ``include()`` is removed.
  564. * Support for setting a URL instance namespace without an application namespace
  565. is removed.
  566. * ``Field._get_val_from_obj()`` is removed.
  567. * ``django.template.loaders.eggs.Loader`` is removed.
  568. * The ``current_app`` parameter to the ``contrib.auth`` function-based views is
  569. removed.
  570. * The ``callable_obj`` keyword argument to
  571. ``SimpleTestCase.assertRaisesMessage()`` is removed.
  572. * Support for the ``allow_tags`` attribute on ``ModelAdmin`` methods is
  573. removed.
  574. * The ``enclosure`` keyword argument to ``SyndicationFeed.add_item()`` is
  575. removed.
  576. * The ``django.template.loader.LoaderOrigin`` and
  577. ``django.template.base.StringOrigin`` aliases for
  578. ``django.template.base.Origin`` are removed.
  579. * The ``makemigrations --exit`` option is removed.
  580. * Support for direct assignment to a reverse foreign key or many-to-many
  581. relation is removed.
  582. * The ``get_srid()`` and ``set_srid()`` methods of
  583. ``django.contrib.gis.geos.GEOSGeometry`` are removed.
  584. * The ``get_x()``, ``set_x()``, ``get_y()``, ``set_y()``, ``get_z()``, and
  585. ``set_z()`` methods of ``django.contrib.gis.geos.Point`` are removed.
  586. * The ``get_coords()`` and ``set_coords()`` methods of
  587. ``django.contrib.gis.geos.Point`` are removed.
  588. * The ``cascaded_union`` property of ``django.contrib.gis.geos.MultiPolygon``
  589. is removed.
  590. * ``django.utils.functional.allow_lazy()`` is removed.
  591. * The ``shell --plain`` option is removed.
  592. * The ``django.core.urlresolvers`` module is removed.
  593. * ``CommaSeparatedIntegerField`` is removed, except for support in historical
  594. migrations.
  595. * The template ``Context.has_key()`` method is removed.
  596. * Support for the ``django.core.files.storage.Storage.accessed_time()``,
  597. ``created_time()``, and ``modified_time()`` methods is removed.
  598. * Support for query lookups using the model name when
  599. ``Meta.default_related_name`` is set is removed.
  600. * The MySQL ``__search`` lookup is removed.
  601. * The shim for supporting custom related manager classes without a
  602. ``_apply_rel_filters()`` method is removed.
  603. * Using ``User.is_authenticated()`` and ``User.is_anonymous()`` as methods
  604. rather than properties is no longer supported.
  605. * The ``Model._meta.virtual_fields`` attribute is removed.
  606. * The keyword arguments ``virtual_only`` in ``Field.contribute_to_class()`` and
  607. ``virtual`` in ``Model._meta.add_field()`` are removed.
  608. * The ``javascript_catalog()`` and ``json_catalog()`` views are removed.
  609. * ``django.contrib.gis.utils.precision_wkt()`` is removed.
  610. * In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a
  611. ``parent_link`` is removed.
  612. * Support for ``Widget._format_value()`` is removed.
  613. * ``FileField`` methods ``get_directory_name()`` and ``get_filename()`` are
  614. removed.
  615. * The ``mark_for_escaping()`` function and the classes it uses: ``EscapeData``,
  616. ``EscapeBytes``, ``EscapeText``, ``EscapeString``, and ``EscapeUnicode`` are
  617. removed.
  618. * The ``escape`` filter now uses ``django.utils.html.conditional_escape()``.
  619. * ``Manager.use_for_related_fields`` is removed.
  620. * Model ``Manager`` inheritance follows MRO inheritance rules. The requirement
  621. to use ``Meta.manager_inheritance_from_future`` to opt-in to the behavior is
  622. removed.
  623. * Support for old-style middleware using ``settings.MIDDLEWARE_CLASSES`` is
  624. removed.