1.10.txt 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341
  1. =============================================
  2. Django 1.10 release notes - UNDER DEVELOPMENT
  3. =============================================
  4. Welcome to Django 1.10!
  5. These release notes cover the `new features`_, as well as some `backwards
  6. incompatible changes`_ you'll want to be aware of when upgrading from Django
  7. 1.9 or older versions. We've :ref:`dropped some features<removed-features-1.10>`
  8. that have reached the end of their deprecation cycle, and we've `begun the
  9. deprecation process for some features`_.
  10. .. _`new features`: `What's new in Django 1.10`_
  11. .. _`backwards incompatible changes`: `Backwards incompatible changes in 1.10`_
  12. .. _`dropped some features`: `Features removed in 1.10`_
  13. .. _`begun the deprecation process for some features`: `Features deprecated in 1.10`_
  14. Python compatibility
  15. ====================
  16. Like Django 1.9, Django 1.10 requires Python 2.7, 3.4, or 3.5. We **highly
  17. recommend** and only officially support the latest release of each series.
  18. What's new in Django 1.10
  19. =========================
  20. Full text search for PostgreSQL
  21. -------------------------------
  22. ``django.contrib.postgres`` now includes a :doc:`collection of database
  23. functions </ref/contrib/postgres/search>` to allow the use of the full text
  24. search engine. You can search across multiple fields in your relational
  25. database, combine the searches with other lookups, use different language
  26. configurations and weightings, and rank the results by relevance.
  27. It also now includes trigram support, using the :lookup:`trigram_similar`
  28. lookup, and the :class:`~django.contrib.postgres.search.TrigramSimilarity` and
  29. :class:`~django.contrib.postgres.search.TrigramDistance` expressions.
  30. New-style middleware
  31. --------------------
  32. :doc:`A new style of middleware is introduced </topics/http/middleware>` to
  33. solve the lack of strict request/response layering of the old-style of
  34. middleware described in `DEP 0005
  35. <https://github.com/django/deps/blob/master/final/0005-improved-middleware.rst>`_.
  36. You'll need to :ref:`adapt old, custom middleware <upgrading-middleware>` and
  37. switch from the ``MIDDLEWARE_CLASSES`` setting to the new :setting:`MIDDLEWARE`
  38. setting to take advantage of the improvements.
  39. Official support for Unicode usernames
  40. --------------------------------------
  41. The :class:`~django.contrib.auth.models.User` model in ``django.contrib.auth``
  42. originally only accepted ASCII letters in usernames. Although it wasn't a
  43. deliberate choice, Unicode characters have always been accepted when using
  44. Python 3.
  45. The username validator now explicitly accepts Unicode letters by
  46. default on Python 3 only. This default behavior can be overridden by changing
  47. the :attr:`~django.contrib.auth.models.User.username_validator` attribute of
  48. the ``User`` model, or to any proxy of that model, using either
  49. :class:`~django.contrib.auth.validators.ASCIIUsernameValidator` or
  50. :class:`~django.contrib.auth.validators.UnicodeUsernameValidator`. Custom user
  51. models may also use those validators.
  52. Minor features
  53. --------------
  54. :mod:`django.contrib.admin`
  55. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  56. * For sites running on a subpath, the default :attr:`URL for the "View site"
  57. link <django.contrib.admin.AdminSite.site_url>` at the top of each admin page
  58. will now point to ``request.META['SCRIPT_NAME']`` if set, instead of ``/``.
  59. * The success message that appears after adding or editing an object now
  60. contains a link to the object's change form.
  61. * All inline JavaScript is removed so you can enable the
  62. ``Content-Security-Policy`` HTTP header if you wish.
  63. * The new :attr:`InlineModelAdmin.classes
  64. <django.contrib.admin.InlineModelAdmin.classes>` attribute allows specifying
  65. classes on inline fieldsets. Inlines with a ``collapse`` class will be
  66. initially collapsed and their header will have a small "show" link.
  67. * If a user doesn't have the add permission, the ``object-tools`` block on a
  68. model's changelist will now be rendered (without the add button, of course).
  69. This makes it easier to add custom tools in this case.
  70. * The :class:`~django.contrib.admin.models.LogEntry` model now stores change
  71. messages in a JSON structure so that the message can be dynamically translated
  72. using the current active language. A new ``LogEntry.get_change_message()``
  73. method is now the preferred way of retrieving the change message.
  74. * Selected objects for fields in ``ModelAdmin.raw_id_fields`` now have a link
  75. to object's change form.
  76. * Added "No date" and "Has date" choices for ``DateFieldListFilter`` if the
  77. field is nullable.
  78. * The jQuery library embedded in the admin is upgraded from version 2.1.4 to
  79. 2.2.3.
  80. :mod:`django.contrib.admindocs`
  81. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  82. * ...
  83. :mod:`django.contrib.auth`
  84. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  85. * Added support for the :ref:`Argon2 password hash <argon2_usage>`. It's
  86. recommended over PBKDF2, however, it's not the default as it requires a
  87. third-party library.
  88. * The default iteration count for the PBKDF2 password hasher has been increased
  89. by 25%. This backwards compatible change will not affect users who have
  90. subclassed ``django.contrib.auth.hashers.PBKDF2PasswordHasher`` to change the
  91. default value.
  92. * The :func:`~django.contrib.auth.views.logout` view sends "no-cache" headers
  93. to prevent an issue where Safari caches redirects and prevents a user from
  94. being able to log out.
  95. * Added the optional ``backend`` argument to :func:`~django.contrib.auth.login`
  96. to allow using it without credentials.
  97. * The new :setting:`LOGOUT_REDIRECT_URL` setting controls the redirect of the
  98. :func:`~django.contrib.auth.views.logout` view, if the view doesn't get a
  99. ``next_page`` argument.
  100. * The new ``redirect_authenticated_user`` parameter for the
  101. :func:`~django.contrib.auth.views.login` view allows redirecting
  102. authenticated users visiting the login page.
  103. :mod:`django.contrib.contenttypes`
  104. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  105. * ...
  106. :mod:`django.contrib.gis`
  107. ~~~~~~~~~~~~~~~~~~~~~~~~~
  108. * :ref:`Distance lookups <distance-lookups>` now accept expressions as the
  109. distance value parameter.
  110. * The new :attr:`GEOSGeometry.unary_union
  111. <django.contrib.gis.geos.GEOSGeometry.unary_union>` property computes the
  112. union of all the elements of this geometry.
  113. * Added the :meth:`GEOSGeometry.covers()
  114. <django.contrib.gis.geos.GEOSGeometry.covers>` binary predicate.
  115. * Added the :meth:`GDALBand.statistics()
  116. <django.contrib.gis.gdal.GDALBand.statistics>` method and
  117. :attr:`~django.contrib.gis.gdal.GDALBand.mean`
  118. and :attr:`~django.contrib.gis.gdal.GDALBand.std` attributes.
  119. * Added support for the :class:`~django.contrib.gis.db.models.MakeLine`
  120. aggregate and :class:`~django.contrib.gis.db.models.functions.GeoHash`
  121. function on SpatiaLite.
  122. * Added support for the
  123. :class:`~django.contrib.gis.db.models.functions.Difference`,
  124. :class:`~django.contrib.gis.db.models.functions.Intersection`, and
  125. :class:`~django.contrib.gis.db.models.functions.SymDifference`
  126. functions on MySQL.
  127. * Added support for instantiating empty GEOS geometries.
  128. * The new :attr:`~django.contrib.gis.geos.WKTWriter.trim` and
  129. :attr:`~django.contrib.gis.geos.WKTWriter.precision` properties
  130. of :class:`~django.contrib.gis.geos.WKTWriter` allow controlling
  131. output of the fractional part of the coordinates in WKT.
  132. * Added the :attr:`LineString.closed
  133. <django.contrib.gis.geos.LineString.closed>` and
  134. :attr:`MultiLineString.closed
  135. <django.contrib.gis.geos.MultiLineString.closed>` properties.
  136. * The :doc:`GeoJSON serializer </ref/contrib/gis/serializers>` now outputs the
  137. primary key of objects in the ``properties`` dictionary if specific fields
  138. aren't specified.
  139. * The ability to replicate input data on the :meth:`GDALBand.data()
  140. <django.contrib.gis.gdal.GDALBand.data>` method was added. Band data can
  141. now be updated with repeated values efficiently.
  142. * Added database functions
  143. :class:`~django.contrib.gis.db.models.functions.IsValid` and
  144. :class:`~django.contrib.gis.db.models.functions.MakeValid`, as well as the
  145. :lookup:`isvalid` lookup, all for PostGIS. This allows filtering and
  146. repairing invalid geometries on the database side.
  147. * Added raster support for all :doc:`spatial lookups
  148. </ref/contrib/gis/geoquerysets>`.
  149. :mod:`django.contrib.messages`
  150. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  151. * ...
  152. :mod:`django.contrib.postgres`
  153. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  154. * For convenience, :class:`~django.contrib.postgres.fields.HStoreField` now
  155. casts its keys and values to strings.
  156. :mod:`django.contrib.redirects`
  157. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  158. * ...
  159. :mod:`django.contrib.sessions`
  160. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  161. * The :djadmin:`clearsessions` management command now removes file-based
  162. sessions.
  163. :mod:`django.contrib.sitemaps`
  164. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  165. * ...
  166. :mod:`django.contrib.sites`
  167. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  168. * The :class:`~django.contrib.sites.models.Site` model now supports
  169. :ref:`natural keys <topics-serialization-natural-keys>`.
  170. :mod:`django.contrib.staticfiles`
  171. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  172. * The :ttag:`static` template tag now uses ``django.contrib.staticfiles``
  173. if it's in ``INSTALLED_APPS``. This is especially useful for third-party apps
  174. which can now always use ``{% load static %}`` (instead of
  175. ``{% load staticfiles %}`` or ``{% load static from staticfiles %}``) and
  176. not worry about whether or not the ``staticfiles`` app is installed.
  177. :mod:`django.contrib.syndication`
  178. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  179. * ...
  180. Cache
  181. ~~~~~
  182. * The file-based cache backend now uses the highest pickling protocol.
  183. CSRF
  184. ~~~~
  185. * The default :setting:`CSRF_FAILURE_VIEW`, ``views.csrf.csrf_failure()`` now
  186. accepts an optional ``template_name`` parameter, defaulting to
  187. ``'403_csrf.html'``, to control the template used to render the page.
  188. * To protect against `BREACH`_ attacks, the CSRF protection mechanism now
  189. changes the form token value on every request (while keeping an invariant
  190. secret which can be used to validate the different tokens).
  191. .. _BREACH: http://breachattack.com/
  192. Database backends
  193. ~~~~~~~~~~~~~~~~~
  194. * Temporal data subtraction was unified on all backends.
  195. * If the database supports it, backends can set
  196. ``DatabaseFeatures.can_return_ids_from_bulk_insert=True`` and implement
  197. ``DatabaseOperations.fetch_returned_insert_ids()`` to set primary keys
  198. on objects created using ``QuerySet.bulk_create()``.
  199. * Added keyword arguments to the ``as_sql()`` methods of various expressions
  200. (``Func``, ``When``, ``Case``, and ``OrderBy``) to allow database backends to
  201. customize them without mutating ``self``, which isn't safe when using
  202. different database backends. See the ``arg_joiner`` and ``**extra_context``
  203. parameters of :meth:`Func.as_sql() <django.db.models.Func.as_sql>` for an
  204. example.
  205. Email
  206. ~~~~~
  207. * ...
  208. File Storage
  209. ~~~~~~~~~~~~
  210. * Storage backends now present a timezone-aware API with new methods
  211. :meth:`~django.core.files.storage.Storage.get_accessed_time`,
  212. :meth:`~django.core.files.storage.Storage.get_created_time`, and
  213. :meth:`~django.core.files.storage.Storage.get_modified_time`. They return a
  214. timezone-aware ``datetime`` if :setting:`USE_TZ` is ``True`` and a naive
  215. ``datetime`` in the local timezone otherwise.
  216. * The new :meth:`Storage.generate_filename()
  217. <django.core.files.storage.Storage.generate_filename>` method makes it easier
  218. to implement custom storages that don't use the ``os.path`` calls previously
  219. in :class:`~django.db.models.FileField`.
  220. File Uploads
  221. ~~~~~~~~~~~~
  222. * ...
  223. Forms
  224. ~~~~~
  225. * Form and widget ``Media`` is now served using
  226. :mod:`django.contrib.staticfiles` if installed.
  227. * The ``<input>`` tag rendered by :class:`~django.forms.CharField` now includes
  228. a ``minlength`` attribute if the field has a ``min_length``.
  229. * Required form fields now have the ``required`` HTML attribute. Set the new
  230. :attr:`Form.use_required_attribute <django.forms.Form.use_required_attribute>`
  231. attribute to ``False`` to disable it. The ``required`` attribute isn't
  232. included on forms of formsets because the browser validation may not be
  233. correct when adding and deleting formsets.
  234. Generic Views
  235. ~~~~~~~~~~~~~
  236. * The :class:`~django.views.generic.base.View` class can now be imported from
  237. ``django.views``.
  238. Internationalization
  239. ~~~~~~~~~~~~~~~~~~~~
  240. * The :func:`~django.conf.urls.i18n.i18n_patterns` helper function can now be
  241. used in a root URLConf specified using :attr:`request.urlconf
  242. <django.http.HttpRequest.urlconf>`.
  243. * By setting the new ``prefix_default_language`` parameter for
  244. :func:`~django.conf.urls.i18n.i18n_patterns` to ``False``, you can allow
  245. accessing the default language without a URL prefix.
  246. * :func:`~django.views.i18n.set_language` now returns a 204 status code (No
  247. Content) for AJAX requests when there is no ``next`` parameter in ``POST`` or
  248. ``GET``.
  249. * The :class:`~django.views.i18n.JavaScriptCatalog` and
  250. :class:`~django.views.i18n.JSONCatalog` class-based views supersede the
  251. deprecated ``javascript_catalog()`` and ``json_catalog()`` function-based
  252. views. The new views are almost equivalent to the old ones except that by
  253. default the new views collect all JavaScript strings in the ``djangojs``
  254. translation domain from all installed apps rather than only the JavaScript
  255. strings from :setting:`LOCALE_PATHS`.
  256. Management Commands
  257. ~~~~~~~~~~~~~~~~~~~
  258. * :func:`~django.core.management.call_command` now returns the value returned
  259. from the ``command.handle()`` method.
  260. * The new :option:`check --fail-level` option allows specifying the message
  261. level that will cause the command to exit with a non-zero status.
  262. * The new :option:`makemigrations --check` option makes the command exit
  263. with a non-zero status when model changes without migrations are detected.
  264. * :djadmin:`makemigrations` now displays the path to the migration files that
  265. it generates.
  266. * The :option:`shell --interface` option now accepts ``python`` to force use of
  267. the "plain" Python interpreter.
  268. * The new :option:`shell --command` option lets you run a command as Django and
  269. exit, instead of opening the interactive shell.
  270. * Added a warning to :djadmin:`dumpdata` if a proxy model is specified (which
  271. results in no output) without its concrete parent.
  272. * The new :attr:`BaseCommand.requires_migrations_checks
  273. <django.core.management.BaseCommand.requires_migrations_checks>` attribute
  274. may be set to ``True`` if you want your command to print a warning, like
  275. :djadmin:`runserver` does, if the set of migrations on disk don't match the
  276. migrations in the database.
  277. * To assist with testing, :func:`~django.core.management.call_command` now
  278. accepts a command object as the first argument.
  279. * The :djadmin:`shell` command supports tab completion on systems using
  280. ``libedit``, e.g. Mac OSX.
  281. * The :djadmin:`inspectdb` command lets you choose what tables should be
  282. inspected by specifying their names as arguments.
  283. Migrations
  284. ~~~~~~~~~~
  285. * Added support for serialization of ``enum.Enum`` objects.
  286. * Added the ``elidable`` argument to the
  287. :class:`~django.db.migrations.operations.RunSQL` and
  288. :class:`~django.db.migrations.operations.RunPython` operations to allow them
  289. to be removed when squashing migrations.
  290. * Added support for :ref:`non-atomic migrations <non-atomic-migrations>` by
  291. setting the ``atomic`` attribute on a ``Migration``.
  292. * The ``migrate`` and ``makemigrations`` commands now check for a consistent
  293. migration history. If they find some unapplied dependencies of an applied
  294. migration, ``InconsistentMigrationHistory`` is raised.
  295. * The :func:`~django.db.models.signals.pre_migrate` and
  296. :func:`~django.db.models.signals.post_migrate` signals now dispatch their
  297. migration ``plan`` and ``apps``.
  298. Models
  299. ~~~~~~
  300. * Reverse foreign keys from proxy models are now propagated to their
  301. concrete class. The reverse relation attached by a
  302. :class:`~django.db.models.ForeignKey` pointing to a proxy model is now
  303. accessible as a descriptor on the proxied model class and may be referenced in
  304. queryset filtering.
  305. * The new :meth:`Field.rel_db_type() <django.db.models.Field.rel_db_type>`
  306. method returns the database column data type for fields such as ``ForeignKey``
  307. and ``OneToOneField`` that point to another field.
  308. * The :attr:`~django.db.models.Func.arity` class attribute is added to
  309. :class:`~django.db.models.Func`. This attribute can be used to set the number
  310. of arguments the function accepts.
  311. * Added :class:`~django.db.models.BigAutoField` which acts much like an
  312. :class:`~django.db.models.AutoField` except that it is guaranteed
  313. to fit numbers from ``1`` to ``9223372036854775807``.
  314. * :meth:`QuerySet.in_bulk() <django.db.models.query.QuerySet.in_bulk>`
  315. may be called without any arguments to return all objects in the queryset.
  316. * :attr:`~django.db.models.ForeignKey.related_query_name` now supports
  317. app label and class interpolation using the ``'%(app_label)s'`` and
  318. ``'%(class)s'`` strings.
  319. * Allowed overriding model fields inherited from abstract base classes.
  320. * The :func:`~django.db.models.prefetch_related_objects` function is now a
  321. public API.
  322. * :meth:`QuerySet.bulk_create() <django.db.models.query.QuerySet.bulk_create>`
  323. sets the primary key on objects when using PostgreSQL.
  324. * Added the :class:`~django.db.models.functions.Cast` database function.
  325. * A proxy model may now inherit multiple proxy models that share a common
  326. non-abstract parent class.
  327. * Added :class:`~django.db.models.functions.datetime.Extract` functions
  328. to extract datetime components as integers, such as year and hour.
  329. * Added :class:`~django.db.models.functions.datetime.Trunc` functions to
  330. truncate a date or datetime to a significant component. They enable queries
  331. like sales-per-day or sales-per-hour.
  332. * ``Model.__init__()`` now sets values of virtual fields from its keyword
  333. arguments.
  334. * The new :attr:`Meta.base_manager_name
  335. <django.db.models.Options.base_manager_name>` and
  336. :attr:`Meta.default_manager_name
  337. <django.db.models.Options.default_manager_name>` options allow controlling
  338. the :attr:`~django.db.models.Model._base_manager` and
  339. :attr:`~django.db.models.Model._default_manager`, respectively.
  340. Requests and Responses
  341. ~~~~~~~~~~~~~~~~~~~~~~
  342. * Added ``request.user`` to the debug view.
  343. * Added :class:`~django.http.HttpResponse` methods
  344. :meth:`~django.http.HttpResponse.readable()` and
  345. :meth:`~django.http.HttpResponse.seekable()` to make an instance a
  346. stream-like object and allow wrapping it with :py:class:`io.TextIOWrapper`.
  347. * Added the :attr:`HttpResponse.content_type
  348. <django.http.HttpRequest.content_type>` and
  349. :attr:`~django.http.HttpRequest.content_params` attributes which are
  350. parsed from the ``CONTENT_TYPE`` header.
  351. * The parser for ``request.COOKIES`` is simplified to better match the behavior
  352. of browsers. ``request.COOKIES`` may now contain cookies that are invalid
  353. according to :rfc:`6265` but are possible to set via ``document.cookie``.
  354. Serialization
  355. ~~~~~~~~~~~~~
  356. * The ``django.core.serializers.json.DjangoJSONEncoder`` now knows how to
  357. serialize lazy strings, typically used for translatable content.
  358. Signals
  359. ~~~~~~~
  360. * ...
  361. Templates
  362. ~~~~~~~~~
  363. * Added the ``autoescape`` option to the
  364. :class:`~django.template.backends.django.DjangoTemplates` backend and the
  365. :class:`~django.template.Engine` class.
  366. * Added the ``is`` and ``is not`` comparison operators to the :ttag:`if` tag.
  367. * Allowed :tfilter:`dictsort` to order a list of lists by an element at a
  368. specified index.
  369. * The :func:`~django.template.context_processors.debug` context processor
  370. contains queries for all database aliases instead of only the default alias.
  371. * Added relative path support for string arguments of the :ttag:`extends` and
  372. :ttag:`include` template tags.
  373. Tests
  374. ~~~~~
  375. * To better catch bugs, :class:`~django.test.TestCase` now checks deferrable
  376. database constraints at the end of each test.
  377. * Tests and test cases can be :ref:`marked with tags <topics-tagging-tests>`
  378. and run selectively with the new :option:`test --tag` and :option:`test
  379. --exclude-tag` options.
  380. * Added the :setting:`DATABASES['TEST']['MIGRATE'] <TEST_MIGRATE>` option to
  381. allow disabling of migrations during test database creation.
  382. * You can now login and use sessions with the test client even if
  383. :mod:`django.contrib.sessions` is not in :setting:`INSTALLED_APPS`.
  384. URLs
  385. ~~~~
  386. * An addition in :func:`django.setup()` allows URL resolving that happens
  387. outside of the request/response cycle (e.g. in management commands and
  388. standalone scripts) to take :setting:`FORCE_SCRIPT_NAME` into account when it
  389. is set.
  390. Validators
  391. ~~~~~~~~~~
  392. * :class:`~django.core.validators.URLValidator` now limits the length of
  393. domain name labels to 63 characters and the total length of domain
  394. names to 253 characters per :rfc:`1034`.
  395. * :func:`~django.core.validators.int_list_validator` now accepts an optional
  396. ``allow_negative`` boolean parameter, defaulting to ``False``, to allow
  397. negative integers.
  398. Backwards incompatible changes in 1.10
  399. ======================================
  400. .. warning::
  401. In addition to the changes outlined in this section, be sure to review the
  402. :ref:`removed-features-1.10` for the features that have reached the end of
  403. their deprecation cycle and therefore been removed. If you haven't updated
  404. your code within the deprecation timeline for a given feature, its removal
  405. may appear as a backwards incompatible change.
  406. Database backend API
  407. --------------------
  408. * GIS's ``AreaField`` uses an unspecified underlying numeric type that could in
  409. practice be any numeric Python type. ``decimal.Decimal`` values retrieved
  410. from the database are now converted to ``float`` to make it easier to combine
  411. them with values used by the GIS libraries.
  412. * In order to enable temporal subtraction you must set the
  413. ``supports_temporal_subtraction`` database feature flag to ``True`` and
  414. implement the ``DatabaseOperations.subtract_temporals()`` method. This
  415. method should return the SQL and parameters required to compute the
  416. difference in microseconds between the ``lhs`` and ``rhs`` arguments in the
  417. datatype used to store :class:`~django.db.models.DurationField`.
  418. ``select_related()`` prohibits non-relational fields for nested relations
  419. -------------------------------------------------------------------------
  420. Django 1.8 added validation for non-relational fields in ``select_related()``::
  421. >>> Book.objects.select_related('title')
  422. Traceback (most recent call last):
  423. ...
  424. FieldError: Non-relational field given in select_related: 'title'
  425. But it didn't prohibit nested non-relation fields as it does now::
  426. >>> Book.objects.select_related('author__name')
  427. Traceback (most recent call last):
  428. ...
  429. FieldError: Non-relational field given in select_related: 'name'
  430. ``_meta.get_fields()`` returns consistent reverse fields for proxy models
  431. -------------------------------------------------------------------------
  432. Before Django 1.10, the :meth:`~django.db.models.options.Options.get_fields`
  433. method returned different reverse fields when called on a proxy model compared
  434. to its proxied concrete class. This inconsistency was fixed by returning the
  435. full set of fields pointing to a concrete class or one of its proxies in both
  436. cases.
  437. :attr:`AbstractUser.username <django.contrib.auth.models.User.username>` ``max_length`` increased to 150
  438. --------------------------------------------------------------------------------------------------------
  439. A migration for :attr:`django.contrib.auth.models.User.username` is included.
  440. If you have a custom user model inheriting from ``AbstractUser``, you'll need
  441. to generate and apply a database migration for your user model.
  442. We considered an increase to 254 characters to more easily allow the use of
  443. email addresses (which are limited to 254 characters) as usernames but rejected
  444. it due to a MySQL limitation. When using the ``utf8mb4`` encoding (recommended
  445. for proper Unicode support), MySQL can only create unique indexes with 191
  446. characters by default. Therefore, if you need a longer length, please use a
  447. custom user model.
  448. If you want to preserve the 30 character limit for usernames, use a custom form
  449. when creating a user or changing usernames::
  450. from django.contrib.auth.forms import UserCreationForm
  451. class MyUserCreationForm(UserCreationForm):
  452. username = forms.CharField(
  453. max_length=30,
  454. help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.',
  455. )
  456. If you wish to keep this restriction in the admin, set ``UserAdmin.add_form``
  457. to use this form::
  458. from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
  459. from django.contrib.auth.models import User
  460. class UserAdmin(BaseUserAdmin):
  461. add_form = MyUserCreationForm
  462. admin.site.unregister(User)
  463. admin.site.register(User, UserAdmin)
  464. Dropped support for PostgreSQL 9.1
  465. ----------------------------------
  466. Upstream support for PostgreSQL 9.1 ends in September 2016. As a consequence,
  467. Django 1.10 sets PostgreSQL 9.2 as the minimum version it officially supports.
  468. ``runserver`` output goes through logging
  469. -----------------------------------------
  470. Request and response handling of the ``runserver`` command is sent to the
  471. :ref:`django-server-logger` logger instead of to ``sys.stderr``. If you
  472. disable Django's logging configuration or override it with your own, you'll
  473. need to add the appropriate logging configuration if you want to see that
  474. output::
  475. 'formatters': {
  476. 'django.server': {
  477. '()': 'django.utils.log.ServerFormatter',
  478. 'format': '[%(server_time)s] %(message)s',
  479. }
  480. },
  481. 'handlers': {
  482. 'django.server': {
  483. 'level': 'INFO',
  484. 'class': 'logging.StreamHandler',
  485. 'formatter': 'django.server',
  486. },
  487. },
  488. 'loggers': {
  489. 'django.server': {
  490. 'handlers': ['django.server'],
  491. 'level': 'INFO',
  492. 'propagate': False,
  493. }
  494. }
  495. ``auth.CustomUser`` and ``auth.ExtensionUser`` test models were removed
  496. -----------------------------------------------------------------------
  497. Since the introduction of migrations for the contrib apps in Django 1.8, the
  498. tables of these custom user test models were not created anymore making them
  499. unusable in a testing context.
  500. Apps registry is no longer auto-populated when unpickling models outside of Django
  501. ----------------------------------------------------------------------------------
  502. The apps registry is no longer auto-populated when unpickling models. This was
  503. added in Django 1.7.2 as an attempt to allow unpickling models outside of
  504. Django, such as in an RQ worker, without calling ``django.setup()``, but it
  505. creates the possibility of a deadlock. To adapt your code in the case of RQ,
  506. you can `provide your own worker script <http://python-rq.org/docs/workers/>`_
  507. that calls ``django.setup()``.
  508. Removed null assignment check for non-null foreign key fields
  509. -------------------------------------------------------------
  510. In older versions, assigning ``None`` to a non-nullable ``ForeignKey`` or
  511. ``OneToOneField`` raised ``ValueError('Cannot assign None: "model.field" does
  512. not allow null values.')``. For consistency with other model fields which don't
  513. have a similar check, this check is removed.
  514. Removed weak password hashers from the default ``PASSWORD_HASHERS`` setting
  515. ---------------------------------------------------------------------------
  516. Django 0.90 stored passwords as unsalted MD5. Django 0.91 added support for
  517. salted SHA1 with automatic upgrade of passwords when a user logs in. Django 1.4
  518. added PBKDF2 as the default password hasher.
  519. If you have an old Django project with MD5 or SHA1 (even salted) encoded
  520. passwords, be aware that these can be cracked fairly easily with today's
  521. hardware. To make Django users acknowledge continued use of weak hashers, the
  522. following hashers are removed from the default :setting:`PASSWORD_HASHERS`
  523. setting::
  524. 'django.contrib.auth.hashers.SHA1PasswordHasher'
  525. 'django.contrib.auth.hashers.MD5PasswordHasher'
  526. 'django.contrib.auth.hashers.UnsaltedSHA1PasswordHasher'
  527. 'django.contrib.auth.hashers.UnsaltedMD5PasswordHasher'
  528. 'django.contrib.auth.hashers.CryptPasswordHasher'
  529. Consider using a :ref:`wrapped password hasher <wrapping-password-hashers>` to
  530. strengthen the hashes in your database. If that's not feasible, add the
  531. :setting:`PASSWORD_HASHERS` setting to your project and add back any hashers
  532. that you need.
  533. You can check if your database has any of the removed hashers like this::
  534. from django.contrib.auth import get_user_model
  535. User = get_user_model()
  536. # Unsalted MD5/SHA1:
  537. User.objects.filter(password__startswith='md5$$')
  538. User.objects.filter(password__startswith='sha1$$')
  539. # Salted MD5/SHA1:
  540. User.objects.filter(password__startswith='md5$').exclude(password__startswith='md5$$')
  541. User.objects.filter(password__startswith='sha1$').exclude(password__startswith='sha1$$')
  542. # Crypt hasher:
  543. User.objects.filter(password__startswith='crypt$$')
  544. from django.db.models import CharField
  545. from django.db.models.functions import Length
  546. CharField.register_lookup(Length)
  547. # Unsalted MD5 passwords might not have an 'md5$$' prefix:
  548. User.objects.filter(password__length=32)
  549. ``Field.get_prep_lookup()`` and ``Field.get_db_prep_lookup()`` methods are removed
  550. ----------------------------------------------------------------------------------
  551. If you have a custom field that implements either of these methods, register a
  552. custom lookup for it. For example::
  553. from django.db.models import Field
  554. from django.db.models.lookups import Exact
  555. class MyField(Field):
  556. ...
  557. class MyFieldExact(Exact):
  558. def get_prep_lookup(self):
  559. # do_custom_stuff_for_myfield
  560. ....
  561. MyField.register_lookup(MyFieldExact)
  562. :mod:`django.contrib.gis`
  563. -------------------------
  564. * Support for SpatiaLite < 3.0 and GEOS < 3.3 is dropped.
  565. * The ``add_postgis_srs()`` backwards compatibility alias for
  566. ``django.contrib.gis.utils.add_srs_entry()`` is removed.
  567. * On Oracle/GIS, the :class:`~django.contrib.gis.db.models.functions.Area`
  568. aggregate function now returns a ``float`` instead of ``decimal.Decimal``.
  569. (It's still wrapped in a measure of square meters.)
  570. * The default :class:`~django.contrib.gis.geos.GEOSGeometry` representation (WKT
  571. output) is trimmed by default. That is, instead of
  572. ``POINT (23.0000000000000000 5.5000000000000000)``, you'll get
  573. ``POINT (23 5.5)``.
  574. Maximum size of a request body and the number of GET/POST parameters is limited
  575. -------------------------------------------------------------------------------
  576. Two new settings help mitigate denial-of-service attacks via large requests:
  577. * :setting:`DATA_UPLOAD_MAX_MEMORY_SIZE` limits the size that a request body
  578. may be. File uploads don't count towards this limit.
  579. * :setting:`DATA_UPLOAD_MAX_NUMBER_FIELDS` limits the number of GET/POST
  580. parameters that are parsed.
  581. Applications that receive unusually large form posts may need to tune these
  582. settings.
  583. Miscellaneous
  584. -------------
  585. * The ``repr()`` of a ``QuerySet`` is wrapped in ``<QuerySet >`` to
  586. disambiguate it from a plain list when debugging.
  587. * ``utils.version.get_version()`` returns :pep:`440` compliant release
  588. candidate versions (e.g. '1.10rc1' instead of '1.10c1').
  589. * CSRF token values are now required to be strings of 64 alphanumerics; values
  590. of 32 alphanumerics, as set by older versions of Django by default, are
  591. automatically replaced by strings of 64 characters. Other values are
  592. considered invalid. This should only affect developers or users who replace
  593. these tokens.
  594. * The ``LOGOUT_URL`` setting is removed as Django hasn't made use of it
  595. since pre-1.0. If you use it in your project, you can add it to your
  596. project's settings. The default value was ``'/accounts/logout/'``.
  597. * Objects with a ``close()`` method such as files and generators passed to
  598. :class:`~django.http.HttpResponse` are now closed immediately instead of when
  599. the WSGI server calls ``close()`` on the response.
  600. * A redundant ``transaction.atomic()`` call in ``QuerySet.update_or_create()``
  601. is removed. This may affect query counts tested by
  602. ``TransactionTestCase.assertNumQueries()``.
  603. * Support for ``skip_validation`` in ``BaseCommand.execute(**options)`` is
  604. removed. Use ``skip_checks`` (added in Django 1.7) instead.
  605. * :djadmin:`loaddata` now raises a ``CommandError`` instead of showing a
  606. warning when the specified fixture file is not found.
  607. * Instead of directly accessing the ``LogEntry.change_message`` attribute, it's
  608. now better to call the ``LogEntry.get_change_message()`` method which will
  609. provide the message in the current language.
  610. * The default error views now raise ``TemplateDoesNotExist`` if a nonexistent
  611. ``template_name`` is specified.
  612. * The unused ``choices`` keyword argument of the ``Select`` and
  613. ``SelectMultiple`` widgets' ``render()`` method is removed. The ``choices``
  614. argument of the ``render_options()`` method is also removed, making
  615. ``selected_choices`` the first argument.
  616. * Tests that violate deferrable database constraints will now error when run on
  617. a database that supports deferrable constraints.
  618. * Built-in management commands now use indexing of keys in ``options``, e.g.
  619. ``options['verbosity']``, instead of ``options.get()`` and no longer perform
  620. any type coercion. This could be a problem if you're calling commands using
  621. ``Command.execute()`` (which bypasses the argument parser that sets a default
  622. value) instead of :func:`~django.core.management.call_command`. Instead of
  623. calling ``Command.execute()``, pass the command object as the first argument
  624. to ``call_command()``.
  625. * :class:`~django.contrib.auth.backends.ModelBackend` and
  626. :class:`~django.contrib.auth.backends.RemoteUserBackend` now reject inactive
  627. users. This means that inactive users can't login and will be logged
  628. out if they are switched from ``is_active=True`` to ``False``. If you need
  629. the previous behavior, use the new
  630. :class:`~django.contrib.auth.backends.AllowAllUsersModelBackend` or
  631. :class:`~django.contrib.auth.backends.AllowAllUsersRemoteUserBackend`
  632. in :setting:`AUTHENTICATION_BACKENDS` instead.
  633. * In light of the previous change, the test client's
  634. :meth:`~django.test.Client.login()` method no longer always rejects inactive
  635. users but instead delegates this decision to the authentication backend.
  636. * :func:`django.views.i18n.set_language` may now return a 204 status code for
  637. AJAX requests.
  638. * The ``base_field`` attribute of
  639. :class:`~django.contrib.postgres.fields.RangeField` is now a type of field,
  640. not an instance of a field. If you have created a custom subclass of
  641. :class:`~django.contrib.postgres.fields.RangeField`, you should change the
  642. ``base_field`` attribute.
  643. * Middleware classes are now initialized when the server starts rather than
  644. during the first request.
  645. * If you override ``is_authenticated()`` or ``is_anonymous()`` in a custom user
  646. model, you must convert them to attributes or properties as described in
  647. :ref:`the deprecation note <user-is-auth-anon-deprecation>`.
  648. * When using :attr:`ModelAdmin.save_as=True
  649. <django.contrib.admin.ModelAdmin.save_as>`, the "Save as new" button now
  650. redirects to the change view for the new object instead of to the model's
  651. changelist. If you need the previous behavior, set the new
  652. :attr:`ModelAdmin.save_as_continue
  653. <django.contrib.admin.ModelAdmin.save_as_continue>` attribute to ``False``.
  654. * Required form fields now have the ``required`` HTML attribute. Set the
  655. :attr:`Form.use_required_attribute <django.forms.Form.use_required_attribute>`
  656. attribute to ``False`` to disable it. You could also add the ``novalidate``
  657. attribute to ``<form>`` if you don't want browser validation.
  658. * The WSGI handler no longer removes content of responses from ``HEAD``
  659. requests or responses with a ``status_code`` of 100-199, 204, or 304. Most
  660. Web servers already implement this behavior. Responses retrieved using the
  661. Django test client continue to have these "response fixes" applied.
  662. * ``Model.__init__()`` now receives ``django.db.models.DEFERRED`` as the value
  663. of deferred fields.
  664. * The ``Model._deferred`` attribute is removed as dynamic model classes when
  665. using ``QuerySet.defer()`` and ``only()`` is removed.
  666. * :meth:`Storage.save() <django.core.files.storage.Storage.save>` no longer
  667. replaces ``'\'`` with ``'/'``. This behavior is moved to
  668. :class:`~django.core.files.storage.FileSystemStorage` since this is a storage
  669. specific implementation detail. Any Windows user with a custom storage
  670. implementation that relies on this behavior will need to implement it in the
  671. custom storage's ``save()`` method.
  672. * Private :class:`~django.db.models.FileField` methods ``get_directory_name()``
  673. and ``get_filename()`` are no longer called (and are now deprecated) which is
  674. a backwards incompatible change for users overriding those methods on custom
  675. fields. To adapt such code, override ``FileField.generate_filename()`` or
  676. :meth:`Storage.generate_filename()
  677. <django.core.files.storage.Storage.generate_filename>` instead. It
  678. might be possible to use :attr:`~django.db.models.FileField.upload_to` also.
  679. * The subject of mail sent by ``AdminEmailHandler`` is no longer truncated at
  680. 989 characters. If you were counting on a limited length, truncate the subject
  681. yourself.
  682. * Private expressions ``django.db.models.expressions.Date`` and ``DateTime``
  683. are removed. The new :class:`~django.db.models.functions.datetime.Trunc`
  684. expressions provide the same functionality.
  685. .. _deprecated-features-1.10:
  686. Features deprecated in 1.10
  687. ===========================
  688. Direct assignment to a reverse foreign key or many-to-many relation
  689. -------------------------------------------------------------------
  690. Instead of assigning related objects using direct assignment::
  691. >>> new_list = [obj1, obj2, obj3]
  692. >>> e.related_set = new_list
  693. Use the :meth:`~django.db.models.fields.related.RelatedManager.set` method
  694. added in Django 1.9::
  695. >>> e.related_set.set([obj1, obj2, obj3])
  696. This prevents confusion about an assignment resulting in an implicit save.
  697. Non-timezone-aware :class:`~django.core.files.storage.Storage` API
  698. ------------------------------------------------------------------
  699. The old, non-timezone-aware methods ``accessed_time()``, ``created_time()``,
  700. and ``modified_time()`` are deprecated in favor of the new ``get_*_time()``
  701. methods.
  702. Third-party storage backends should implement the new methods and mark the old
  703. ones as deprecated. Until then, the new ``get_*_time()`` methods on the base
  704. :class:`~django.core.files.storage.Storage` class convert ``datetime``\s from
  705. the old methods as required and emit a deprecation warning as they do so.
  706. Third-party storage backends may retain the old methods as long as they
  707. wish to support earlier versions of Django.
  708. :mod:`django.contrib.gis`
  709. -------------------------
  710. * The ``get_srid()`` and ``set_srid()`` methods of
  711. :class:`~django.contrib.gis.geos.GEOSGeometry` are deprecated in favor
  712. of the :attr:`~django.contrib.gis.geos.GEOSGeometry.srid` property.
  713. * The ``get_x()``, ``set_x()``, ``get_y()``, ``set_y()``, ``get_z()``, and
  714. ``set_z()`` methods of :class:`~django.contrib.gis.geos.Point` are deprecated
  715. in favor of the ``x``, ``y``, and ``z`` properties.
  716. * The ``get_coords()`` and ``set_coords()`` methods of
  717. :class:`~django.contrib.gis.geos.Point` are deprecated in favor of the
  718. ``tuple`` property.
  719. * The ``cascaded_union`` property of
  720. :class:`~django.contrib.gis.geos.MultiPolygon` is deprecated in favor of the
  721. :attr:`~django.contrib.gis.geos.GEOSGeometry.unary_union` property.
  722. * The ``django.contrib.gis.utils.precision_wkt()`` function is deprecated in
  723. favor of :class:`~django.contrib.gis.geos.WKTWriter`.
  724. ``CommaSeparatedIntegerField`` model field
  725. ------------------------------------------
  726. ``CommaSeparatedIntegerField`` is deprecated in favor of
  727. :class:`~django.db.models.CharField` with the
  728. :func:`~django.core.validators.validate_comma_separated_integer_list`
  729. validator::
  730. from django.core.validators import validate_comma_separated_integer_list
  731. from django.db import models
  732. class MyModel(models.Model):
  733. numbers = models.CharField(..., validators=[validate_comma_separated_integer_list])
  734. If you're using Oracle, ``CharField`` uses a different database field type
  735. (``NVARCHAR2``) than ``CommaSeparatedIntegerField`` (``VARCHAR2``). Depending
  736. on your database settings, this might imply a different encoding, and thus a
  737. different length (in bytes) for the same contents. If your stored values are
  738. longer than the 4000 byte limit of ``NVARCHAR2``, you should use ``TextField``
  739. (``NCLOB``) instead. In this case, if you have any queries that group by the
  740. field (e.g. annotating the model with an aggregation or using ``distinct()``)
  741. you'll need to change them (to defer the field).
  742. Using a model name as a query lookup when ``default_related_name`` is set
  743. -------------------------------------------------------------------------
  744. Assume the following models::
  745. from django.db import models
  746. class Foo(models.Model):
  747. pass
  748. class Bar(models.Model):
  749. foo = models.ForeignKey(Foo)
  750. class Meta:
  751. default_related_name = 'bars'
  752. In older versions, :attr:`~django.db.models.Options.default_related_name`
  753. couldn't be used as a query lookup. This is fixed and support for the old
  754. lookup name is deprecated. For example, since ``default_related_name`` is set
  755. in model ``Bar``, instead of using the model name ``bar`` as the lookup::
  756. >>> bar = Bar.objects.get(pk=1)
  757. >>> Foo.objects.get(bar=bar)
  758. use the default_related_name ``bars``::
  759. >>> Foo.objects.get(bars=bar)
  760. .. _search-lookup-replacement:
  761. ``__search`` query lookup
  762. -------------------------
  763. The ``search`` lookup, which supports MySQL only and is extremely limited in
  764. features, is deprecated. Replace it with a custom lookup::
  765. from django.db import models
  766. class Search(models.Lookup):
  767. lookup_name = 'search'
  768. def as_mysql(self, compiler, connection):
  769. lhs, lhs_params = self.process_lhs(compiler, connection)
  770. rhs, rhs_params = self.process_rhs(compiler, connection)
  771. params = lhs_params + rhs_params
  772. return 'MATCH (%s) AGAINST (%s IN BOOLEAN MODE)' % (lhs, rhs), params
  773. models.CharField.register_lookup(Search)
  774. models.TextField.register_lookup(Search)
  775. .. _user-is-auth-anon-deprecation:
  776. Using ``User.is_authenticated()`` and ``User.is_anonymous()`` as methods
  777. ------------------------------------------------------------------------
  778. The ``is_authenticated()`` and ``is_anonymous()`` methods of
  779. :class:`~django.contrib.auth.models.AbstractBaseUser` and
  780. :class:`~django.contrib.auth.models.AnonymousUser` classes are now
  781. properties. They will still work as methods until Django 2.0, but all usage
  782. in Django now uses attribute access.
  783. For example, if you use
  784. :class:`~django.contrib.auth.middleware.AuthenticationMiddleware` and want
  785. to know whether the user is currently logged-in you would use::
  786. if request.user.is_authenticated:
  787. ... # Do something for logged-in users.
  788. else:
  789. ... # Do something for anonymous users.
  790. instead of ``request.user.is_authenticated()``.
  791. This change avoids accidental information leakage if you forget to call the
  792. method, e.g.::
  793. if request.user.is_authenticated:
  794. return sensitive_information
  795. If you override these methods in a custom user model, you must change them to
  796. properties or attributes.
  797. Custom manager classes available through ``prefetch_related`` must define a ``_apply_rel_filters()`` method
  798. -----------------------------------------------------------------------------------------------------------
  799. If you defined a custom manager class available through
  800. :meth:`~django.db.models.query.QuerySet.prefetch_related` you must make sure
  801. it defines a ``_apply_rel_filters()`` method.
  802. This method must accept a :class:`~django.db.models.query.QuerySet` instance
  803. as its single argument and return a filtered version of the queryset for the
  804. model instance the manager is bound to.
  805. The "escape" half of ``django.utils.safestring``
  806. ------------------------------------------------
  807. The ``mark_for_escaping()`` function and the classes it uses: ``EscapeData``,
  808. ``EscapeBytes``, ``EscapeText``, ``EscapeString``, and ``EscapeUnicode`` are
  809. deprecated.
  810. As a result, the "lazy" behavior of the ``escape`` filter (where it would
  811. always be applied as the last filter no matter where in the filter chain it
  812. appeared) is deprecated. The filter will change to immediately apply
  813. :func:`~django.utils.html.conditional_escape` in Django 2.0.
  814. ``Manager.use_for_related_fields`` and inheritance changes
  815. ----------------------------------------------------------
  816. ``Manager.use_for_related_fields`` is deprecated in favor of setting
  817. :attr:`Meta.base_manager_name <django.db.models.Options.base_manager_name>` on
  818. the model.
  819. Model ``Manager`` inheritance will follow MRO inheritance rules in Django 2.0,
  820. changing the current behavior where managers defined on non-abstract base
  821. classes aren't inherited by child classes. A deprecating warning with
  822. instructions on how to adapt your code is raised if you have any affected
  823. managers. You'll either redeclare a manager from an abstract model on the child
  824. class to override the manager from the concrete model, or you'll set the
  825. model's ``Meta.manager_inheritance_from_future=True`` option to opt-in to the
  826. new inheritance behavior.
  827. Miscellaneous
  828. -------------
  829. * The ``makemigrations --exit`` option is deprecated in favor of the
  830. :option:`makemigrations --check` option.
  831. * ``django.utils.functional.allow_lazy()`` is deprecated in favor of the new
  832. :func:`~django.utils.functional.keep_lazy` function which can be used with a
  833. more natural decorator syntax.
  834. * The ``shell --plain`` option is deprecated in favor of ``-i python`` or
  835. ``--interface python``.
  836. * Importing from the ``django.core.urlresolvers`` module is deprecated in
  837. favor of its new location, :mod:`django.urls`.
  838. * The template ``Context.has_key()`` method is deprecated in favor of ``in``.
  839. * The private attribute ``virtual_fields`` of ``Model._meta`` is
  840. deprecated in favor of ``private_fields``.
  841. * The private keyword arguments ``virtual_only`` in
  842. ``Field.contribute_to_class()`` and ``virtual`` in
  843. ``Model._meta.add_field()`` are deprecated in favor of ``private_only``
  844. and ``private``, respectively.
  845. * The ``javascript_catalog()`` and ``json_catalog()`` views are deprecated in
  846. favor of class-based views :class:`~django.views.i18n.JavaScriptCatalog`
  847. and :class:`~django.views.i18n.JSONCatalog`.
  848. * In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a
  849. ``parent_link`` is deprecated. Add ``parent_link=True`` to such fields.
  850. * The private API ``Widget._format_value()`` is made public and renamed to
  851. :meth:`~django.forms.Widget.format_value`. The old name will work
  852. through a deprecation period.
  853. * Private ``FileField`` methods ``get_directory_name()`` and ``get_filename()``
  854. are deprecated in favor of performing this work in
  855. :meth:`Storage.generate_filename()
  856. <django.core.files.storage.Storage.generate_filename>`).
  857. * Old-style middleware that uses ``settings.MIDDLEWARE_CLASSES`` are
  858. deprecated. :ref:`Adapt old, custom middleware <upgrading-middleware>` and
  859. use the new :setting:`MIDDLEWARE` setting.
  860. .. _removed-features-1.10:
  861. Features removed in 1.10
  862. ========================
  863. These features have reached the end of their deprecation cycle and so have been
  864. removed in Django 1.10 (please see the :ref:`deprecation timeline
  865. <deprecation-removed-in-1.10>` for more details):
  866. * Support for calling a ``SQLCompiler`` directly as an alias for calling its
  867. ``quote_name_unless_alias`` method is removed.
  868. * The ``cycle`` and ``firstof`` template tags are removed from the ``future``
  869. template tag library.
  870. * ``django.conf.urls.patterns()`` is removed.
  871. * Support for the ``prefix`` argument to
  872. ``django.conf.urls.i18n.i18n_patterns()`` is removed.
  873. * ``SimpleTestCase.urls`` is removed.
  874. * Using an incorrect count of unpacked values in the ``for`` template tag
  875. raises an exception rather than failing silently.
  876. * The ability to :func:`~django.urls.reverse` URLs using a dotted Python path
  877. is removed.
  878. * The ability to use a dotted Python path for the ``LOGIN_URL`` and
  879. ``LOGIN_REDIRECT_URL`` settings is removed.
  880. * Support for ``optparse`` is dropped for custom management commands.
  881. * The class ``django.core.management.NoArgsCommand`` is removed.
  882. * ``django.core.context_processors`` module is removed.
  883. * ``django.db.models.sql.aggregates`` module is removed.
  884. * ``django.contrib.gis.db.models.sql.aggregates`` module is removed.
  885. * The following methods and properties of ``django.db.sql.query.Query`` are
  886. removed:
  887. * Properties: ``aggregates`` and ``aggregate_select``
  888. * Methods: ``add_aggregate``, ``set_aggregate_mask``, and
  889. ``append_aggregate_mask``.
  890. * ``django.template.resolve_variable`` is removed.
  891. * The following private APIs are removed from
  892. :class:`django.db.models.options.Options` (``Model._meta``):
  893. * ``get_field_by_name()``
  894. * ``get_all_field_names()``
  895. * ``get_fields_with_model()``
  896. * ``get_concrete_fields_with_model()``
  897. * ``get_m2m_with_model()``
  898. * ``get_all_related_objects()``
  899. * ``get_all_related_objects_with_model()``
  900. * ``get_all_related_many_to_many_objects()``
  901. * ``get_all_related_m2m_objects_with_model()``
  902. * The ``error_message`` argument of ``django.forms.RegexField`` is removed.
  903. * The ``unordered_list`` filter no longer supports old style lists.
  904. * Support for string ``view`` arguments to ``url()`` is removed.
  905. * The backward compatible shim to rename ``django.forms.Form._has_changed()``
  906. to ``has_changed()`` is removed.
  907. * The ``removetags`` template filter is removed.
  908. * The ``remove_tags()`` and ``strip_entities()`` functions in
  909. ``django.utils.html`` is removed.
  910. * The ``is_admin_site`` argument to
  911. ``django.contrib.auth.views.password_reset()`` is removed.
  912. * ``django.db.models.field.subclassing.SubfieldBase`` is removed.
  913. * ``django.utils.checksums`` is removed.
  914. * The ``original_content_type_id`` attribute on
  915. ``django.contrib.admin.helpers.InlineAdminForm`` is removed.
  916. * The backwards compatibility shim to allow ``FormMixin.get_form()`` to be
  917. defined with no default value for its ``form_class`` argument is removed.
  918. * The following settings are removed:
  919. * ``ALLOWED_INCLUDE_ROOTS``
  920. * ``TEMPLATE_CONTEXT_PROCESSORS``
  921. * ``TEMPLATE_DEBUG``
  922. * ``TEMPLATE_DIRS``
  923. * ``TEMPLATE_LOADERS``
  924. * ``TEMPLATE_STRING_IF_INVALID``
  925. * The backwards compatibility alias ``django.template.loader.BaseLoader`` is
  926. removed.
  927. * Django template objects returned by
  928. :func:`~django.template.loader.get_template` and
  929. :func:`~django.template.loader.select_template` no longer accept a
  930. :class:`~django.template.Context` in their
  931. :meth:`~django.template.backends.base.Template.render()` method.
  932. * :doc:`Template response APIs </ref/template-response>` enforce the use of
  933. :class:`dict` and backend-dependent template objects instead of
  934. :class:`~django.template.Context` and :class:`~django.template.Template`
  935. respectively.
  936. * The ``current_app`` parameter for the following function and classes is
  937. removed:
  938. * ``django.shortcuts.render()``
  939. * ``django.template.Context()``
  940. * ``django.template.RequestContext()``
  941. * ``django.template.response.TemplateResponse()``
  942. * The ``dictionary`` and ``context_instance`` parameters for the following
  943. functions are removed:
  944. * ``django.shortcuts.render()``
  945. * ``django.shortcuts.render_to_response()``
  946. * ``django.template.loader.render_to_string()``
  947. * The ``dirs`` parameter for the following functions is removed:
  948. * ``django.template.loader.get_template()``
  949. * ``django.template.loader.select_template()``
  950. * ``django.shortcuts.render()``
  951. * ``django.shortcuts.render_to_response()``
  952. * Session verification is enabled regardless of whether or not
  953. ``'django.contrib.auth.middleware.SessionAuthenticationMiddleware'`` is in
  954. ``MIDDLEWARE_CLASSES``. ``SessionAuthenticationMiddleware`` no longer has
  955. any purpose and can be removed from ``MIDDLEWARE_CLASSES``. It's kept as
  956. a stub until Django 2.0 as a courtesy for users who don't read this note.
  957. * Private attribute ``django.db.models.Field.related`` is removed.
  958. * The ``--list`` option of the ``migrate`` management command is removed.
  959. * The ``ssi`` template tag is removed.
  960. * Support for the ``=`` comparison operator in the ``if`` template tag is
  961. removed.
  962. * The backwards compatibility shims to allow ``Storage.get_available_name()``
  963. and ``Storage.save()`` to be defined without a ``max_length`` argument are
  964. removed.
  965. * Support for the legacy ``%(<foo>)s`` syntax in ``ModelFormMixin.success_url``
  966. is removed.
  967. * ``GeoQuerySet`` aggregate methods ``collect()``, ``extent()``, ``extent3d()``,
  968. ``make_line()``, and ``unionagg()`` are removed.
  969. * The ability to specify ``ContentType.name`` when creating a content type
  970. instance is removed.
  971. * Support for the old signature of ``allow_migrate`` is removed.
  972. * Support for the syntax of ``{% cycle %}`` that uses comma-separated arguments
  973. is removed.
  974. * The warning that :class:`~django.core.signing.Signer` issued when given an
  975. invalid separator is now a ``ValueError``.