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