1.10.txt 54 KB

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