1.10.txt 51 KB

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