1. ========================
    
  2. Django 1.9 release notes
    
  3. ========================
    
  4. 
    
  5. *December 1, 2015*
    
  6. 
    
  7. Welcome to Django 1.9!
    
  8. 
    
  9. These release notes cover the :ref:`new features <whats-new-1.9>`, as well as
    
  10. some :ref:`backwards incompatible changes <backwards-incompatible-1.9>` you'll
    
  11. want to be aware of when upgrading from Django 1.8 or older versions. We've
    
  12. :ref:`dropped some features<removed-features-1.9>` that have reached the end of
    
  13. their deprecation cycle, and we've :ref:`begun the deprecation process for some
    
  14. features <deprecated-features-1.9>`.
    
  15. 
    
  16. See the :doc:`/howto/upgrade-version` guide if you're updating an existing
    
  17. project.
    
  18. 
    
  19. Python compatibility
    
  20. ====================
    
  21. 
    
  22. Django 1.9 requires Python 2.7, 3.4, or 3.5. We **highly recommend** and only
    
  23. officially support the latest release of each series.
    
  24. 
    
  25. The Django 1.8 series is the last to support Python 3.2 and 3.3.
    
  26. 
    
  27. .. _whats-new-1.9:
    
  28. 
    
  29. What's new in Django 1.9
    
  30. ========================
    
  31. 
    
  32. Performing actions after a transaction commit
    
  33. ---------------------------------------------
    
  34. 
    
  35. The new :func:`~django.db.transaction.on_commit` hook allows performing actions
    
  36. after a database transaction is successfully committed. This is useful for
    
  37. tasks such as sending notification emails, creating queued tasks, or
    
  38. invalidating caches.
    
  39. 
    
  40. This functionality from the `django-transaction-hooks`_ package has been
    
  41. integrated into Django.
    
  42. 
    
  43. .. _django-transaction-hooks: https://pypi.org/project/django-transaction-hooks/
    
  44. 
    
  45. Password validation
    
  46. -------------------
    
  47. 
    
  48. Django now offers password validation to help prevent the usage of weak
    
  49. passwords by users. The validation is integrated in the included password
    
  50. change and reset forms and is simple to integrate in any other code.
    
  51. Validation is performed by one or more validators, configured in the new
    
  52. :setting:`AUTH_PASSWORD_VALIDATORS` setting.
    
  53. 
    
  54. Four validators are included in Django, which can enforce a minimum length,
    
  55. compare the password to the user's attributes like their name, ensure
    
  56. passwords aren't entirely numeric, or check against an included list of common
    
  57. passwords. You can combine multiple validators, and some validators have
    
  58. custom configuration options. For example, you can choose to provide a custom
    
  59. list of common passwords. Each validator provides a help text to explain its
    
  60. requirements to the user.
    
  61. 
    
  62. By default, no validation is performed and all passwords are accepted, so if
    
  63. you don't set :setting:`AUTH_PASSWORD_VALIDATORS`, you will not see any
    
  64. change. In new projects created with the default :djadmin:`startproject`
    
  65. template, a simple set of validators is enabled. To enable basic validation in
    
  66. the included auth forms for your project, you could set, for example::
    
  67. 
    
  68.     AUTH_PASSWORD_VALIDATORS = [
    
  69.         {
    
  70.             'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    
  71.         },
    
  72.         {
    
  73.             'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    
  74.         },
    
  75.         {
    
  76.             'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    
  77.         },
    
  78.         {
    
  79.             'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    
  80.         },
    
  81.     ]
    
  82. 
    
  83. See :ref:`password-validation` for more details.
    
  84. 
    
  85. Permission mixins for class-based views
    
  86. ---------------------------------------
    
  87. 
    
  88. Django now ships with the mixins
    
  89. :class:`~django.contrib.auth.mixins.AccessMixin`,
    
  90. :class:`~django.contrib.auth.mixins.LoginRequiredMixin`,
    
  91. :class:`~django.contrib.auth.mixins.PermissionRequiredMixin`, and
    
  92. :class:`~django.contrib.auth.mixins.UserPassesTestMixin` to provide the
    
  93. functionality of the ``django.contrib.auth.decorators`` for class-based views.
    
  94. These mixins have been taken from, or are at least inspired by, the
    
  95. `django-braces`_ project.
    
  96. 
    
  97. There are a few differences between Django's and ``django-braces``\'
    
  98. implementation, though:
    
  99. 
    
  100. * The :attr:`~django.contrib.auth.mixins.AccessMixin.raise_exception` attribute
    
  101.   can only be ``True`` or ``False``. Custom exceptions or callables are not
    
  102.   supported.
    
  103. 
    
  104. * The :meth:`~django.contrib.auth.mixins.AccessMixin.handle_no_permission`
    
  105.   method does not take a ``request`` argument. The current request is available
    
  106.   in ``self.request``.
    
  107. 
    
  108. * The custom ``test_func()`` of :class:`~django.contrib.auth.mixins.UserPassesTestMixin`
    
  109.   does not take a ``user`` argument. The current user is available in
    
  110.   ``self.request.user``.
    
  111. 
    
  112. * The :attr:`permission_required <django.contrib.auth.mixins.PermissionRequiredMixin>`
    
  113.   attribute supports a string (defining one permission) or a list/tuple of
    
  114.   strings (defining multiple permissions) that need to be fulfilled to grant
    
  115.   access.
    
  116. 
    
  117. * The new :attr:`~django.contrib.auth.mixins.AccessMixin.permission_denied_message`
    
  118.   attribute allows passing a message to the ``PermissionDenied`` exception.
    
  119. 
    
  120. .. _django-braces: https://django-braces.readthedocs.io/en/latest/index.html
    
  121. 
    
  122. New styling for ``contrib.admin``
    
  123. ---------------------------------
    
  124. 
    
  125. The admin sports a modern, flat design with new SVG icons which look perfect
    
  126. on HiDPI screens. It still provides a fully-functional experience to `YUI's
    
  127. A-grade`_ browsers. Older browser may experience varying levels of graceful
    
  128. degradation.
    
  129. 
    
  130. .. _YUI's A-grade: https://github.com/yui/yui3/wiki/Graded-Browser-Support
    
  131. 
    
  132. Running tests in parallel
    
  133. -------------------------
    
  134. 
    
  135. The :djadmin:`test` command now supports a :option:`--parallel <test
    
  136. --parallel>` option to run a project's tests in multiple processes in parallel.
    
  137. 
    
  138. Each process gets its own database. You must ensure that different test cases
    
  139. don't access the same resources. For instance, test cases that touch the
    
  140. filesystem should create a temporary directory for their own use.
    
  141. 
    
  142. This option is enabled by default for Django's own test suite provided:
    
  143. 
    
  144. - the OS supports it (all but Windows)
    
  145. - the database backend supports it (all the built-in backends but Oracle)
    
  146. 
    
  147. Minor features
    
  148. --------------
    
  149. 
    
  150. :mod:`django.contrib.admin`
    
  151. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  152. 
    
  153. * Admin views now have ``model_admin`` or ``admin_site`` attributes.
    
  154. 
    
  155. * The URL of the admin change view has been changed (was at
    
  156.   ``/admin/<app>/<model>/<pk>/`` by default and is now at
    
  157.   ``/admin/<app>/<model>/<pk>/change/``). This should not affect your
    
  158.   application unless you have hardcoded admin URLs. In that case, replace those
    
  159.   links by :ref:`reversing admin URLs <admin-reverse-urls>` instead. Note that
    
  160.   the old URL still redirects to the new one for backwards compatibility, but
    
  161.   it may be removed in a future version.
    
  162. 
    
  163. * :meth:`ModelAdmin.get_list_select_related()
    
  164.   <django.contrib.admin.ModelAdmin.get_list_select_related>` was added to allow
    
  165.   changing the ``select_related()`` values used in the admin's changelist query
    
  166.   based on the request.
    
  167. 
    
  168. * The ``available_apps`` context variable, which lists the available
    
  169.   applications for the current user, has been added to the
    
  170.   :meth:`AdminSite.each_context() <django.contrib.admin.AdminSite.each_context>`
    
  171.   method.
    
  172. 
    
  173. * :attr:`AdminSite.empty_value_display
    
  174.   <django.contrib.admin.AdminSite.empty_value_display>` and
    
  175.   :attr:`ModelAdmin.empty_value_display
    
  176.   <django.contrib.admin.ModelAdmin.empty_value_display>` were added to override
    
  177.   the display of empty values in admin change list. You can also customize the
    
  178.   value for each field.
    
  179. 
    
  180. * Added jQuery events :ref:`when an inline form is added or removed
    
  181.   <admin-javascript-inline-form-events>` on the change form page.
    
  182. 
    
  183. * The time picker widget includes a '6 p.m' option for consistency of having
    
  184.   predefined options every 6 hours.
    
  185. 
    
  186. * JavaScript slug generation now supports Romanian characters.
    
  187. 
    
  188. :mod:`django.contrib.admindocs`
    
  189. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  190. 
    
  191. * The model section of the ``admindocs`` now also describes methods that take
    
  192.   arguments, rather than ignoring them.
    
  193. 
    
  194. :mod:`django.contrib.auth`
    
  195. ~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  196. 
    
  197. * The default iteration count for the PBKDF2 password hasher has been increased
    
  198.   by 20%. This backwards compatible change will not affect users who have
    
  199.   subclassed ``django.contrib.auth.hashers.PBKDF2PasswordHasher`` to change the
    
  200.   default value.
    
  201. 
    
  202. * The ``BCryptSHA256PasswordHasher`` will now update passwords if its
    
  203.   ``rounds`` attribute is changed.
    
  204. 
    
  205. * ``AbstractBaseUser`` and ``BaseUserManager`` were moved to a new
    
  206.   ``django.contrib.auth.base_user`` module so that they can be imported without
    
  207.   including ``django.contrib.auth`` in :setting:`INSTALLED_APPS` (doing so
    
  208.   raised a deprecation warning in older versions and is no longer supported in
    
  209.   Django 1.9).
    
  210. 
    
  211. * The permission argument of
    
  212.   :func:`~django.contrib.auth.decorators.permission_required()` accepts all
    
  213.   kinds of iterables, not only list and tuples.
    
  214. 
    
  215. * The new :class:`~django.contrib.auth.middleware.PersistentRemoteUserMiddleware`
    
  216.   makes it possible to use ``REMOTE_USER`` for setups where the header is only
    
  217.   populated on login pages instead of every request in the session.
    
  218. 
    
  219. * The ``django.contrib.auth.views.password_reset()`` view accepts an
    
  220.   ``extra_email_context`` parameter.
    
  221. 
    
  222. :mod:`django.contrib.contenttypes`
    
  223. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  224. 
    
  225. * It's now possible to use
    
  226.   :attr:`~django.db.models.Options.order_with_respect_to` with a
    
  227.   ``GenericForeignKey``.
    
  228. 
    
  229. :mod:`django.contrib.gis`
    
  230. ~~~~~~~~~~~~~~~~~~~~~~~~~
    
  231. 
    
  232. * All ``GeoQuerySet`` methods have been deprecated and replaced by
    
  233.   :doc:`equivalent database functions </ref/contrib/gis/functions>`. As soon
    
  234.   as the legacy methods have been replaced in your code, you should even be
    
  235.   able to remove the special ``GeoManager`` from your GIS-enabled classes.
    
  236. 
    
  237. * The GDAL interface now supports instantiating file-based and in-memory
    
  238.   :ref:`GDALRaster objects <raster-data-source-objects>` from raw data.
    
  239.   Setters for raster properties such as projection or pixel values have
    
  240.   been added.
    
  241. 
    
  242. * For PostGIS users, the new :class:`~django.contrib.gis.db.models.RasterField`
    
  243.   allows :ref:`storing GDALRaster objects <creating-and-saving-raster-models>`.
    
  244.   It supports automatic spatial index creation and reprojection when saving a
    
  245.   model. It does not yet support spatial querying.
    
  246. 
    
  247. * The new :meth:`GDALRaster.warp() <django.contrib.gis.gdal.GDALRaster.warp>`
    
  248.   method allows warping a raster by specifying target raster properties such as
    
  249.   origin, width, height, or pixel size (among others).
    
  250. 
    
  251. * The new :meth:`GDALRaster.transform()
    
  252.   <django.contrib.gis.gdal.GDALRaster.transform>` method allows transforming a
    
  253.   raster into a different spatial reference system by specifying a target
    
  254.   ``srid``.
    
  255. 
    
  256. * The new :class:`~django.contrib.gis.geoip2.GeoIP2` class allows using
    
  257.   MaxMind's GeoLite2 databases which includes support for IPv6 addresses.
    
  258. 
    
  259. * The default OpenLayers library version included in widgets has been updated
    
  260.   from 2.13 to 2.13.1.
    
  261. 
    
  262. :mod:`django.contrib.postgres`
    
  263. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  264. 
    
  265. * Added support for the :lookup:`rangefield.contained_by` lookup for some built
    
  266.   in fields which correspond to the range fields.
    
  267. 
    
  268. * Added ``django.contrib.postgres.fields.JSONField``.
    
  269. 
    
  270. * Added :doc:`/ref/contrib/postgres/aggregates`.
    
  271. 
    
  272. * Added the :class:`~django.contrib.postgres.functions.TransactionNow` database
    
  273.   function.
    
  274. 
    
  275. :mod:`django.contrib.sessions`
    
  276. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  277. 
    
  278. * The session model and ``SessionStore`` classes for the ``db`` and
    
  279.   ``cached_db`` backends are refactored to allow a custom database session
    
  280.   backend to build upon them. See
    
  281.   :ref:`extending-database-backed-session-engines` for more details.
    
  282. 
    
  283. :mod:`django.contrib.sites`
    
  284. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  285. 
    
  286. * :func:`~django.contrib.sites.shortcuts.get_current_site` now handles the case
    
  287.   where ``request.get_host()`` returns ``domain:port``, e.g.
    
  288.   ``example.com:80``. If the lookup fails because the host does not match a
    
  289.   record in the database and the host has a port, the port is stripped and the
    
  290.   lookup is retried with the domain part only.
    
  291. 
    
  292. :mod:`django.contrib.syndication`
    
  293. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  294. 
    
  295. * Support for multiple enclosures per feed item has been added. If multiple
    
  296.   enclosures are defined on a RSS feed, an exception is raised as RSS feeds,
    
  297.   unlike Atom feeds, do not support multiple enclosures per feed item.
    
  298. 
    
  299. Cache
    
  300. ~~~~~
    
  301. 
    
  302. * ``django.core.cache.backends.base.BaseCache`` now has a ``get_or_set()``
    
  303.   method.
    
  304. 
    
  305. * :func:`django.views.decorators.cache.never_cache` now sends more persuasive
    
  306.   headers (added ``no-cache, no-store, must-revalidate`` to ``Cache-Control``)
    
  307.   to better prevent caching. This was also added in Django 1.8.8.
    
  308. 
    
  309. CSRF
    
  310. ~~~~
    
  311. 
    
  312. * The request header's name used for CSRF authentication can be customized
    
  313.   with :setting:`CSRF_HEADER_NAME`.
    
  314. 
    
  315. * The CSRF referer header is now validated against the
    
  316.   :setting:`CSRF_COOKIE_DOMAIN` setting if set. See :ref:`how-csrf-works` for
    
  317.   details.
    
  318. 
    
  319. * The new :setting:`CSRF_TRUSTED_ORIGINS` setting provides a way to allow
    
  320.   cross-origin unsafe requests (e.g. ``POST``) over HTTPS.
    
  321. 
    
  322. Database backends
    
  323. ~~~~~~~~~~~~~~~~~
    
  324. 
    
  325. * The PostgreSQL backend (``django.db.backends.postgresql_psycopg2``) is also
    
  326.   available as ``django.db.backends.postgresql``. The old name will continue to
    
  327.   be available for backwards compatibility.
    
  328. 
    
  329. File Storage
    
  330. ~~~~~~~~~~~~
    
  331. 
    
  332. * :meth:`Storage.get_valid_name()
    
  333.   <django.core.files.storage.Storage.get_valid_name>` is now called when
    
  334.   the :attr:`~django.db.models.FileField.upload_to` is a callable.
    
  335. 
    
  336. * :class:`~django.core.files.File` now has the ``seekable()`` method when using
    
  337.   Python 3.
    
  338. 
    
  339. Forms
    
  340. ~~~~~
    
  341. 
    
  342. * :class:`~django.forms.ModelForm` accepts the new ``Meta`` option
    
  343.   ``field_classes`` to customize the type of the fields. See
    
  344.   :ref:`modelforms-overriding-default-fields` for details.
    
  345. 
    
  346. * You can now specify the order in which form fields are rendered with the
    
  347.   :attr:`~django.forms.Form.field_order` attribute, the ``field_order``
    
  348.   constructor argument , or the :meth:`~django.forms.Form.order_fields` method.
    
  349. 
    
  350. * A form prefix can be specified inside a form class, not only when
    
  351.   instantiating a form. See :ref:`form-prefix` for details.
    
  352. 
    
  353. * You can now :ref:`specify keyword arguments <custom-formset-form-kwargs>`
    
  354.   that you want to pass to the constructor of forms in a formset.
    
  355. 
    
  356. * :class:`~django.forms.SlugField` now accepts an
    
  357.   :attr:`~django.forms.SlugField.allow_unicode` argument to allow Unicode
    
  358.   characters in slugs.
    
  359. 
    
  360. * :class:`~django.forms.CharField` now accepts a
    
  361.   :attr:`~django.forms.CharField.strip` argument to strip input data of leading
    
  362.   and trailing whitespace.  As this defaults to ``True`` this is different
    
  363.   behavior from previous releases.
    
  364. 
    
  365. * Form fields now support the :attr:`~django.forms.Field.disabled` argument,
    
  366.   allowing the field widget to be displayed disabled by browsers.
    
  367. 
    
  368. * It's now possible to customize bound fields by overriding a field's
    
  369.   :meth:`~django.forms.Field.get_bound_field()` method.
    
  370. 
    
  371. Generic Views
    
  372. ~~~~~~~~~~~~~
    
  373. 
    
  374. * Class-based views generated using ``as_view()`` now have ``view_class``
    
  375.   and ``view_initkwargs`` attributes.
    
  376. 
    
  377. * :func:`~django.utils.decorators.method_decorator` can now be used with a list
    
  378.   or tuple of decorators. It can also be used to :ref:`decorate classes instead
    
  379.   of methods <decorating-class-based-views>`.
    
  380. 
    
  381. Internationalization
    
  382. ~~~~~~~~~~~~~~~~~~~~
    
  383. 
    
  384. * The :func:`django.views.i18n.set_language` view now properly redirects to
    
  385.   :ref:`translated URLs <url-internationalization>`, when available.
    
  386. 
    
  387. * The ``django.views.i18n.javascript_catalog()`` view now works correctly
    
  388.   if used multiple times with different configurations on the same page.
    
  389. 
    
  390. * The :func:`django.utils.timezone.make_aware` function gained an ``is_dst``
    
  391.   argument to help resolve ambiguous times during DST transitions.
    
  392. 
    
  393. * You can now use locale variants supported by gettext. These are usually used
    
  394.   for languages which can be written in different scripts, for example Latin
    
  395.   and Cyrillic (e.g. ``be@latin``).
    
  396. 
    
  397. * Added the ``django.views.i18n.json_catalog()`` view to help build a custom
    
  398.   client-side i18n library upon Django translations. It returns a JSON object
    
  399.   containing a translations catalog, formatting settings, and a plural rule.
    
  400. 
    
  401. * Added the ``name_translated`` attribute to the object returned by the
    
  402.   :ttag:`get_language_info` template tag. Also added a corresponding template
    
  403.   filter: :tfilter:`language_name_translated`.
    
  404. 
    
  405. * You can now run :djadmin:`compilemessages` from the root directory of your
    
  406.   project and it will find all the app message files that were created by
    
  407.   :djadmin:`makemessages`.
    
  408. 
    
  409. * :djadmin:`makemessages` now calls ``xgettext`` once per locale directory
    
  410.   rather than once per translatable file. This speeds up localization builds.
    
  411. 
    
  412. * :ttag:`blocktrans` supports assigning its output to a variable using
    
  413.   ``asvar``.
    
  414. 
    
  415. * Two new languages are available: Colombian Spanish and Scottish Gaelic.
    
  416. 
    
  417. Management Commands
    
  418. ~~~~~~~~~~~~~~~~~~~
    
  419. 
    
  420. * The new :djadmin:`sendtestemail` command lets you send a test email to
    
  421.   easily confirm that email sending through Django is working.
    
  422. 
    
  423. * To increase the readability of the SQL code generated by
    
  424.   :djadmin:`sqlmigrate`, the SQL code generated for each migration operation is
    
  425.   preceded by the operation's description.
    
  426. 
    
  427. * The :djadmin:`dumpdata` command output is now deterministically ordered.
    
  428.   Moreover, when the ``--output`` option is specified, it also shows a progress
    
  429.   bar in the terminal.
    
  430. 
    
  431. * The :djadmin:`createcachetable` command now has a ``--dry-run`` flag to
    
  432.   print out the SQL rather than execute it.
    
  433. 
    
  434. * The :djadmin:`startapp` command creates an ``apps.py`` file. Since it doesn't
    
  435.   use ``default_app_config`` (:ref:`a discouraged API
    
  436.   <configuring-applications-ref>`), you must specify the app config's path,
    
  437.   e.g. ``'polls.apps.PollsConfig'``, in :setting:`INSTALLED_APPS` for it to be
    
  438.   used (instead of just ``'polls'``).
    
  439. 
    
  440. * When using the PostgreSQL backend, the :djadmin:`dbshell` command can connect
    
  441.   to the database using the password from your settings file (instead of
    
  442.   requiring it to be manually entered).
    
  443. 
    
  444. * The ``django`` package may be run as a script, i.e. ``python -m django``,
    
  445.   which will behave the same as ``django-admin``.
    
  446. 
    
  447. * Management commands that have the ``--noinput`` option now also take
    
  448.   ``--no-input`` as an alias for that option.
    
  449. 
    
  450. Migrations
    
  451. ~~~~~~~~~~
    
  452. 
    
  453. * Initial migrations are now marked with an :attr:`initial = True
    
  454.   <django.db.migrations.Migration.initial>` class attribute which allows
    
  455.   :option:`migrate --fake-initial` to more easily detect initial migrations.
    
  456. 
    
  457. * Added support for serialization of ``functools.partial`` and ``LazyObject``
    
  458.   instances.
    
  459. 
    
  460. * When supplying ``None`` as a value in :setting:`MIGRATION_MODULES`, Django
    
  461.   will consider the app an app without migrations.
    
  462. 
    
  463. * When applying migrations, the "Rendering model states" step that's displayed
    
  464.   when running migrate with verbosity 2 or higher now computes only the states
    
  465.   for the migrations that have already been applied. The model states for
    
  466.   migrations being applied are generated on demand, drastically reducing the
    
  467.   amount of required memory.
    
  468. 
    
  469.   However, this improvement is not available when unapplying migrations and
    
  470.   therefore still requires the precomputation and storage of the intermediate
    
  471.   migration states.
    
  472. 
    
  473.   This improvement also requires that Django no longer supports mixed migration
    
  474.   plans. Mixed plans consist of a list of migrations where some are being
    
  475.   applied and others are being unapplied. This was never officially supported
    
  476.   and never had a public API that supports this behavior.
    
  477. 
    
  478. * The :djadmin:`squashmigrations` command now supports specifying the starting
    
  479.   migration from which migrations will be squashed.
    
  480. 
    
  481. Models
    
  482. ~~~~~~
    
  483. 
    
  484. * :meth:`QuerySet.bulk_create() <django.db.models.query.QuerySet.bulk_create>`
    
  485.   now works on proxy models.
    
  486. 
    
  487. * Database configuration gained a :setting:`TIME_ZONE <DATABASE-TIME_ZONE>`
    
  488.   option for interacting with databases that store datetimes in local time and
    
  489.   don't support time zones when :setting:`USE_TZ` is ``True``.
    
  490. 
    
  491. * Added the :meth:`RelatedManager.set()
    
  492.   <django.db.models.fields.related.RelatedManager.set()>` method to the related
    
  493.   managers created by ``ForeignKey``, ``GenericForeignKey``, and
    
  494.   ``ManyToManyField``.
    
  495. 
    
  496. * The :meth:`~django.db.models.fields.related.RelatedManager.add` method on
    
  497.   a reverse foreign key now has a ``bulk`` parameter to allow executing one
    
  498.   query regardless of the number of objects being added rather than one query
    
  499.   per object.
    
  500. 
    
  501. * Added the ``keep_parents`` parameter to :meth:`Model.delete()
    
  502.   <django.db.models.Model.delete>` to allow deleting only a child's data in a
    
  503.   model that uses multi-table inheritance.
    
  504. 
    
  505. * :meth:`Model.delete() <django.db.models.Model.delete>`
    
  506.   and :meth:`QuerySet.delete() <django.db.models.query.QuerySet.delete>` return
    
  507.   the number of objects deleted.
    
  508. 
    
  509. * Added a system check to prevent defining both ``Meta.ordering`` and
    
  510.   ``order_with_respect_to`` on the same model.
    
  511. 
    
  512. * :lookup:`Date and time <year>` lookups can be chained with other lookups
    
  513.   (such as :lookup:`exact`, :lookup:`gt`, :lookup:`lt`, etc.). For example:
    
  514.   ``Entry.objects.filter(pub_date__month__gt=6)``.
    
  515. 
    
  516. * Time lookups (hour, minute, second) are now supported by
    
  517.   :class:`~django.db.models.TimeField` for all database backends. Support for
    
  518.   backends other than SQLite was added but undocumented in Django 1.7.
    
  519. 
    
  520. * You can specify the ``output_field`` parameter of the
    
  521.   :class:`~django.db.models.Avg` aggregate in order to aggregate over
    
  522.   non-numeric columns, such as ``DurationField``.
    
  523. 
    
  524. * Added the :lookup:`date` lookup to :class:`~django.db.models.DateTimeField`
    
  525.   to allow querying the field by only the date portion.
    
  526. 
    
  527. * Added the :class:`~django.db.models.functions.Greatest` and
    
  528.   :class:`~django.db.models.functions.Least` database functions.
    
  529. 
    
  530. * Added the :class:`~django.db.models.functions.Now` database function, which
    
  531.   returns the current date and time.
    
  532. 
    
  533. * :class:`~django.db.models.Transform` is now a subclass of
    
  534.   :ref:`Func() <func-expressions>` which allows ``Transform``\s to be used on
    
  535.   the right hand side of an expression, just like regular ``Func``\s. This
    
  536.   allows registering some database functions like
    
  537.   :class:`~django.db.models.functions.Length`,
    
  538.   :class:`~django.db.models.functions.Lower`, and
    
  539.   :class:`~django.db.models.functions.Upper` as transforms.
    
  540. 
    
  541. * :class:`~django.db.models.SlugField` now accepts an
    
  542.   :attr:`~django.db.models.SlugField.allow_unicode` argument to allow Unicode
    
  543.   characters in slugs.
    
  544. 
    
  545. * Added support for referencing annotations in ``QuerySet.distinct()``.
    
  546. 
    
  547. * ``connection.queries`` shows queries with substituted parameters on SQLite.
    
  548. 
    
  549. * :doc:`Query expressions </ref/models/expressions>` can now be used when
    
  550.   creating new model instances using ``save()``, ``create()``, and
    
  551.   ``bulk_create()``.
    
  552. 
    
  553. Requests and Responses
    
  554. ~~~~~~~~~~~~~~~~~~~~~~
    
  555. 
    
  556. * Unless :attr:`HttpResponse.reason_phrase
    
  557.   <django.http.HttpResponse.reason_phrase>` is explicitly set, it now is
    
  558.   determined by the current value of :attr:`HttpResponse.status_code
    
  559.   <django.http.HttpResponse.status_code>`. Modifying the value of
    
  560.   ``status_code`` outside of the constructor will also modify the value of
    
  561.   ``reason_phrase``.
    
  562. 
    
  563. * The debug view now shows details of chained exceptions on Python 3.
    
  564. 
    
  565. * The default 40x error views now accept a second positional parameter, the
    
  566.   exception that triggered the view.
    
  567. 
    
  568. * View error handlers now support
    
  569.   :class:`~django.template.response.TemplateResponse`, commonly used with
    
  570.   class-based views.
    
  571. 
    
  572. * Exceptions raised by the ``render()`` method are now passed to the
    
  573.   ``process_exception()`` method of each middleware.
    
  574. 
    
  575. * Request middleware can now set :attr:`HttpRequest.urlconf
    
  576.   <django.http.HttpRequest.urlconf>` to ``None`` to revert any changes made
    
  577.   by previous middleware and return to using the :setting:`ROOT_URLCONF`.
    
  578. 
    
  579. * The :setting:`DISALLOWED_USER_AGENTS` check in
    
  580.   :class:`~django.middleware.common.CommonMiddleware` now raises a
    
  581.   :class:`~django.core.exceptions.PermissionDenied` exception as opposed to
    
  582.   returning an :class:`~django.http.HttpResponseForbidden` so that
    
  583.   :data:`~django.conf.urls.handler403` is invoked.
    
  584. 
    
  585. * Added :meth:`HttpRequest.get_port() <django.http.HttpRequest.get_port>` to
    
  586.   fetch the originating port of the request.
    
  587. 
    
  588. * Added the ``json_dumps_params`` parameter to
    
  589.   :class:`~django.http.JsonResponse` to allow passing keyword arguments to the
    
  590.   ``json.dumps()`` call used to generate the response.
    
  591. 
    
  592. * The :class:`~django.middleware.common.BrokenLinkEmailsMiddleware` now
    
  593.   ignores 404s when the referer is equal to the requested URL. To circumvent
    
  594.   the empty referer check already implemented, some web bots set the referer to
    
  595.   the requested URL.
    
  596. 
    
  597. Templates
    
  598. ~~~~~~~~~
    
  599. 
    
  600. * Template tags created with the :meth:`~django.template.Library.simple_tag`
    
  601.   helper can now store results in a template variable by using the ``as``
    
  602.   argument.
    
  603. 
    
  604. * Added a :meth:`Context.setdefault() <django.template.Context.setdefault>`
    
  605.   method.
    
  606. 
    
  607. * The :ref:`django.template <django-template-logger>` logger was added and
    
  608.   includes the following messages:
    
  609. 
    
  610.   * A ``DEBUG`` level message for missing context variables.
    
  611. 
    
  612.   * A ``WARNING`` level message for uncaught exceptions raised
    
  613.     during the rendering of an ``{% include %}`` when debug mode is off
    
  614.     (helpful since ``{% include %}`` silences the exception and returns an
    
  615.     empty string).
    
  616. 
    
  617. * The :ttag:`firstof` template tag supports storing the output in a variable
    
  618.   using 'as'.
    
  619. 
    
  620. * :meth:`Context.update() <django.template.Context.update>` can now be used as
    
  621.   a context manager.
    
  622. 
    
  623. * Django template loaders can now extend templates recursively.
    
  624. 
    
  625. * The debug page template postmortem now include output from each engine that
    
  626.   is installed.
    
  627. 
    
  628. * :ref:`Debug page integration <template-debug-integration>` for custom
    
  629.   template engines was added.
    
  630. 
    
  631. * The :class:`~django.template.backends.django.DjangoTemplates` backend gained
    
  632.   the ability to register libraries and builtins explicitly through the
    
  633.   template :setting:`OPTIONS <TEMPLATES-OPTIONS>`.
    
  634. 
    
  635. * The ``timesince`` and ``timeuntil`` filters were improved to deal with leap
    
  636.   years when given large time spans.
    
  637. 
    
  638. * The ``include`` tag now caches parsed templates objects during template
    
  639.   rendering, speeding up reuse in places such as for loops.
    
  640. 
    
  641. Tests
    
  642. ~~~~~
    
  643. 
    
  644. * Added the :meth:`json() <django.test.Response.json>` method to test client
    
  645.   responses to give access to the response body as JSON.
    
  646. 
    
  647. * Added the :meth:`~django.test.Client.force_login()` method to the test
    
  648.   client. Use this method to simulate the effect of a user logging into the
    
  649.   site while skipping the authentication and verification steps of
    
  650.   :meth:`~django.test.Client.login()`.
    
  651. 
    
  652. URLs
    
  653. ~~~~
    
  654. 
    
  655. * Regular expression lookaround assertions are now allowed in URL patterns.
    
  656. 
    
  657. * The application namespace can now be set using an ``app_name`` attribute
    
  658.   on the included module or object. It can also be set by passing a 2-tuple
    
  659.   of (<list of patterns>, <application namespace>) as the first argument to
    
  660.   ``include()``.
    
  661. 
    
  662. * System checks have been added for common URL pattern mistakes.
    
  663. 
    
  664. Validators
    
  665. ~~~~~~~~~~
    
  666. 
    
  667. * Added :func:`django.core.validators.int_list_validator` to generate
    
  668.   validators of strings containing integers separated with a custom character.
    
  669. 
    
  670. * :class:`~django.core.validators.EmailValidator` now limits the length of
    
  671.   domain name labels to 63 characters per :rfc:`1034`.
    
  672. 
    
  673. * Added :func:`~django.core.validators.validate_unicode_slug` to validate slugs
    
  674.   that may contain Unicode characters.
    
  675. 
    
  676. .. _backwards-incompatible-1.9:
    
  677. 
    
  678. Backwards incompatible changes in 1.9
    
  679. =====================================
    
  680. 
    
  681. .. warning::
    
  682. 
    
  683.     In addition to the changes outlined in this section, be sure to review the
    
  684.     :ref:`removed-features-1.9` for the features that have reached the end of
    
  685.     their deprecation cycle and therefore been removed. If you haven't updated
    
  686.     your code within the deprecation timeline for a given feature, its removal
    
  687.     may appear as a backwards incompatible change.
    
  688. 
    
  689. Database backend API
    
  690. --------------------
    
  691. 
    
  692. * A couple of new tests rely on the ability of the backend to introspect column
    
  693.   defaults (returning the result as ``Field.default``). You can set the
    
  694.   ``can_introspect_default`` database feature to ``False`` if your backend
    
  695.   doesn't implement this. You may want to review the implementation on the
    
  696.   backends that Django includes for reference (:ticket:`24245`).
    
  697. 
    
  698. * Registering a global adapter or converter at the level of the DB-API module
    
  699.   to handle time zone information of :class:`~datetime.datetime` values passed
    
  700.   as query parameters or returned as query results on databases that don't
    
  701.   support time zones is discouraged. It can conflict with other libraries.
    
  702. 
    
  703.   The recommended way to add a time zone to :class:`~datetime.datetime` values
    
  704.   fetched from the database is to register a converter for ``DateTimeField``
    
  705.   in ``DatabaseOperations.get_db_converters()``.
    
  706. 
    
  707.   The ``needs_datetime_string_cast`` database feature was removed. Database
    
  708.   backends that set it must register a converter instead, as explained above.
    
  709. 
    
  710. * The ``DatabaseOperations.value_to_db_<type>()`` methods were renamed to
    
  711.   ``adapt_<type>field_value()`` to mirror the ``convert_<type>field_value()``
    
  712.   methods.
    
  713. 
    
  714. * To use the new ``date`` lookup, third-party database backends may need to
    
  715.   implement the ``DatabaseOperations.datetime_cast_date_sql()`` method.
    
  716. 
    
  717. * The ``DatabaseOperations.time_extract_sql()`` method was added. It calls the
    
  718.   existing ``date_extract_sql()`` method. This method is overridden by the
    
  719.   SQLite backend to add time lookups (hour, minute, second) to
    
  720.   :class:`~django.db.models.TimeField`, and may be needed by third-party
    
  721.   database backends.
    
  722. 
    
  723. * The ``DatabaseOperations.datetime_cast_sql()`` method (not to be confused
    
  724.   with ``DatabaseOperations.datetime_cast_date_sql()`` mentioned above)
    
  725.   has been removed. This method served to format dates on Oracle long
    
  726.   before 1.0, but hasn't been overridden by any core backend in years
    
  727.   and hasn't been called anywhere in Django's code or tests.
    
  728. 
    
  729. * In order to support test parallelization, you must implement the
    
  730.   ``DatabaseCreation._clone_test_db()`` method and set
    
  731.   ``DatabaseFeatures.can_clone_databases = True``. You may have to adjust
    
  732.   ``DatabaseCreation.get_test_db_clone_settings()``.
    
  733. 
    
  734. Default settings that were tuples are now lists
    
  735. -----------------------------------------------
    
  736. 
    
  737. The default settings in ``django.conf.global_settings`` were a combination of
    
  738. lists and tuples. All settings that were formerly tuples are now lists.
    
  739. 
    
  740. ``is_usable`` attribute on template loaders is removed
    
  741. ------------------------------------------------------
    
  742. 
    
  743. Django template loaders previously required an ``is_usable`` attribute to be
    
  744. defined. If a loader was configured in the template settings and this attribute
    
  745. was ``False``, the loader would be silently ignored. In practice, this was only
    
  746. used by the egg loader to detect if setuptools was installed. The ``is_usable``
    
  747. attribute is now removed and the egg loader instead fails at runtime if
    
  748. setuptools is not installed.
    
  749. 
    
  750. Related set direct assignment
    
  751. -----------------------------
    
  752. 
    
  753. Direct assignment of related objects in the ORM used to perform a ``clear()``
    
  754. followed by a call to ``add()``. This caused needlessly large data changes and
    
  755. prevented using the :data:`~django.db.models.signals.m2m_changed` signal to
    
  756. track individual changes in many-to-many relations.
    
  757. 
    
  758. Direct assignment now relies on the new
    
  759. :meth:`~django.db.models.fields.related.RelatedManager.set` method on related
    
  760. managers which by default only processes changes between the existing related
    
  761. set and the one that's newly assigned. The previous behavior can be restored by
    
  762. replacing direct assignment by a call to ``set()`` with the keyword argument
    
  763. ``clear=True``.
    
  764. 
    
  765. ``ModelForm``, and therefore ``ModelAdmin``, internally rely on direct
    
  766. assignment for many-to-many relations and as a consequence now use the new
    
  767. behavior.
    
  768. 
    
  769. Filesystem-based template loaders catch more specific exceptions
    
  770. ----------------------------------------------------------------
    
  771. 
    
  772. When using the :class:`filesystem.Loader <django.template.loaders.filesystem.Loader>`
    
  773. or :class:`app_directories.Loader <django.template.loaders.app_directories.Loader>`
    
  774. template loaders, earlier versions of Django raised a
    
  775. :exc:`~django.template.TemplateDoesNotExist` error if a template source existed
    
  776. but was unreadable. This could happen under many circumstances, such as if
    
  777. Django didn't have permissions to open the file, or if the template source was
    
  778. a directory. Now, Django only silences the exception if the template source
    
  779. does not exist. All other situations result in the original ``IOError`` being
    
  780. raised.
    
  781. 
    
  782. HTTP redirects no longer forced to absolute URIs
    
  783. ------------------------------------------------
    
  784. 
    
  785. Relative redirects are no longer converted to absolute URIs. :rfc:`2616`
    
  786. required the ``Location`` header in redirect responses to be an absolute URI,
    
  787. but it has been superseded by :rfc:`7231` which allows relative URIs in
    
  788. ``Location``, recognizing the actual practice of user agents, almost all of
    
  789. which support them.
    
  790. 
    
  791. Consequently, the expected URLs passed to ``assertRedirects`` should generally
    
  792. no longer include the scheme and domain part of the URLs. For example,
    
  793. ``self.assertRedirects(response, 'http://testserver/some-url/')`` should be
    
  794. replaced by ``self.assertRedirects(response, '/some-url/')`` (unless the
    
  795. redirection specifically contained an absolute URL).
    
  796. 
    
  797. In the rare case that you need the old behavior (discovered with an ancient
    
  798. version of Apache with ``mod_scgi`` that interprets a relative redirect as an
    
  799. "internal redirect"), you can restore it by writing a custom middleware::
    
  800. 
    
  801.     class LocationHeaderFix(object):
    
  802.         def process_response(self, request, response):
    
  803.             if 'Location' in response:
    
  804.                 response['Location'] = request.build_absolute_uri(response['Location'])
    
  805.             return response
    
  806. 
    
  807. Dropped support for PostgreSQL 9.0
    
  808. ----------------------------------
    
  809. 
    
  810. Upstream support for PostgreSQL 9.0 ended in September 2015. As a consequence,
    
  811. Django 1.9 sets 9.1 as the minimum PostgreSQL version it officially supports.
    
  812. 
    
  813. Dropped support for Oracle 11.1
    
  814. -------------------------------
    
  815. 
    
  816. Upstream support for Oracle 11.1 ended in August 2015. As a consequence, Django
    
  817. 1.9 sets 11.2 as the minimum Oracle version it officially supports.
    
  818. 
    
  819. Bulk behavior of ``add()`` method of related managers
    
  820. -----------------------------------------------------
    
  821. 
    
  822. To improve performance, the ``add()`` methods of the related managers created
    
  823. by ``ForeignKey`` and ``GenericForeignKey`` changed from a series of
    
  824. ``Model.save()`` calls to a single ``QuerySet.update()`` call. The change means
    
  825. that ``pre_save`` and ``post_save`` signals aren't sent anymore. You can use
    
  826. the ``bulk=False`` keyword argument to revert to the previous behavior.
    
  827. 
    
  828. Template ``LoaderOrigin`` and ``StringOrigin`` are removed
    
  829. ----------------------------------------------------------
    
  830. 
    
  831. In previous versions of Django, when a template engine was initialized with
    
  832. debug as ``True``, an instance of ``django.template.loader.LoaderOrigin`` or
    
  833. ``django.template.base.StringOrigin`` was set as the origin attribute on the
    
  834. template object. These classes have been combined into
    
  835. :class:`~django.template.base.Origin` and is now always set regardless of the
    
  836. engine debug setting. For a minimal level of backwards compatibility, the old
    
  837. class names will be kept as aliases to the new ``Origin`` class until
    
  838. Django 2.0.
    
  839. 
    
  840. .. _default-logging-changes-19:
    
  841. 
    
  842. Changes to the default logging configuration
    
  843. --------------------------------------------
    
  844. 
    
  845. To make it easier to write custom logging configurations, Django's default
    
  846. logging configuration no longer defines ``django.request`` and
    
  847. ``django.security`` loggers. Instead, it defines a single ``django`` logger,
    
  848. filtered at the ``INFO`` level, with two handlers:
    
  849. 
    
  850. * ``console``: filtered at the ``INFO`` level and only active if ``DEBUG=True``.
    
  851. * ``mail_admins``: filtered at the ``ERROR`` level and only active if
    
  852.   ``DEBUG=False``.
    
  853. 
    
  854. If you aren't overriding Django's default logging, you should see minimal
    
  855. changes in behavior, but you might see some new logging to the ``runserver``
    
  856. console, for example.
    
  857. 
    
  858. If you are overriding Django's default logging, you should check to see how
    
  859. your configuration merges with the new defaults.
    
  860. 
    
  861. ``HttpRequest`` details in error reporting
    
  862. ------------------------------------------
    
  863. 
    
  864. It was redundant to display the full details of the
    
  865. :class:`~django.http.HttpRequest` each time it appeared as a stack frame
    
  866. variable in the HTML version of the debug page and error email. Thus, the HTTP
    
  867. request will now display the same standard representation as other variables
    
  868. (``repr(request)``). As a result, the
    
  869. ``ExceptionReporterFilter.get_request_repr()`` method and the undocumented
    
  870. ``django.http.build_request_repr()`` function were removed.
    
  871. 
    
  872. The contents of the text version of the email were modified to provide a
    
  873. traceback of the same structure as in the case of AJAX requests. The traceback
    
  874. details are rendered by the ``ExceptionReporter.get_traceback_text()`` method.
    
  875. 
    
  876. Removal of time zone aware global adapters and converters for datetimes
    
  877. -----------------------------------------------------------------------
    
  878. 
    
  879. Django no longer registers global adapters and converters for managing time
    
  880. zone information on :class:`~datetime.datetime` values sent to the database as
    
  881. query parameters or read from the database in query results. This change
    
  882. affects projects that meet all the following conditions:
    
  883. 
    
  884. * The :setting:`USE_TZ` setting is ``True``.
    
  885. * The database is SQLite, MySQL, Oracle, or a third-party database that
    
  886.   doesn't support time zones. In doubt, you can check the value of
    
  887.   ``connection.features.supports_timezones``.
    
  888. * The code queries the database outside of the ORM, typically with
    
  889.   ``cursor.execute(sql, params)``.
    
  890. 
    
  891. If you're passing aware :class:`~datetime.datetime` parameters to such
    
  892. queries, you should turn them into naive datetimes in UTC::
    
  893. 
    
  894.     from django.utils import timezone
    
  895.     param = timezone.make_naive(param, timezone.utc)
    
  896. 
    
  897. If you fail to do so, the conversion will be performed as in earlier versions
    
  898. (with a deprecation warning) up until Django 1.11. Django 2.0 won't perform any
    
  899. conversion, which may result in data corruption.
    
  900. 
    
  901. If you're reading :class:`~datetime.datetime` values from the results, they
    
  902. will be naive instead of aware. You can compensate as follows::
    
  903. 
    
  904.     from django.utils import timezone
    
  905.     value = timezone.make_aware(value, timezone.utc)
    
  906. 
    
  907. You don't need any of this if you're querying the database through the ORM,
    
  908. even if you're using :meth:`raw() <django.db.models.query.QuerySet.raw>`
    
  909. queries. The ORM takes care of managing time zone information.
    
  910. 
    
  911. Template tag modules are imported when templates are configured
    
  912. ---------------------------------------------------------------
    
  913. 
    
  914. The :class:`~django.template.backends.django.DjangoTemplates` backend now
    
  915. performs discovery on installed template tag modules when instantiated. This
    
  916. update enables libraries to be provided explicitly via the ``'libraries'``
    
  917. key of :setting:`OPTIONS <TEMPLATES-OPTIONS>` when defining a
    
  918. :class:`~django.template.backends.django.DjangoTemplates` backend. Import
    
  919. or syntax errors in template tag modules now fail early at instantiation time
    
  920. rather than when a template with a :ttag:`{% load %}<load>` tag is first
    
  921. compiled.
    
  922. 
    
  923. ``django.template.base.add_to_builtins()`` is removed
    
  924. -----------------------------------------------------
    
  925. 
    
  926. Although it was a private API, projects commonly used ``add_to_builtins()`` to
    
  927. make template tags and filters available without using the
    
  928. :ttag:`{% load %}<load>` tag. This API has been formalized. Projects should now
    
  929. define built-in libraries via the ``'builtins'`` key of :setting:`OPTIONS
    
  930. <TEMPLATES-OPTIONS>` when defining a
    
  931. :class:`~django.template.backends.django.DjangoTemplates` backend.
    
  932. 
    
  933. .. _simple-tag-conditional-escape-fix:
    
  934. 
    
  935. ``simple_tag`` now wraps tag output in ``conditional_escape``
    
  936. -------------------------------------------------------------
    
  937. 
    
  938. In general, template tags do not autoescape their contents, and this behavior is
    
  939. :ref:`documented <tags-auto-escaping>`. For tags like
    
  940. :class:`~django.template.Library.inclusion_tag`, this is not a problem because
    
  941. the included template will perform autoescaping. For ``assignment_tag()``,
    
  942. the output will be escaped when it is used as a variable in the template.
    
  943. 
    
  944. For the intended use cases of :class:`~django.template.Library.simple_tag`,
    
  945. however, it is very easy to end up with incorrect HTML and possibly an XSS
    
  946. exploit. For example::
    
  947. 
    
  948.     @register.simple_tag(takes_context=True)
    
  949.     def greeting(context):
    
  950.         return "Hello {0}!".format(context['request'].user.first_name)
    
  951. 
    
  952. In older versions of Django, this will be an XSS issue because
    
  953. ``user.first_name`` is not escaped.
    
  954. 
    
  955. In Django 1.9, this is fixed: if the template context has ``autoescape=True``
    
  956. set (the default), then ``simple_tag`` will wrap the output of the tag function
    
  957. with :func:`~django.utils.html.conditional_escape`.
    
  958. 
    
  959. To fix your ``simple_tag``\s, it is best to apply the following practices:
    
  960. 
    
  961. * Any code that generates HTML should use either the template system or
    
  962.   :func:`~django.utils.html.format_html`.
    
  963. 
    
  964. * If the output of a ``simple_tag`` needs escaping, use
    
  965.   :func:`~django.utils.html.escape` or
    
  966.   :func:`~django.utils.html.conditional_escape`.
    
  967. 
    
  968. * If you are absolutely certain that you are outputting HTML from a trusted
    
  969.   source (e.g. a CMS field that stores HTML entered by admins), you can mark it
    
  970.   as such using :func:`~django.utils.safestring.mark_safe`.
    
  971. 
    
  972. Tags that follow these rules will be correct and safe whether they are run on
    
  973. Django 1.9+ or earlier.
    
  974. 
    
  975. ``Paginator.page_range``
    
  976. ------------------------
    
  977. 
    
  978. :attr:`Paginator.page_range <django.core.paginator.Paginator.page_range>` is
    
  979. now an iterator instead of a list.
    
  980. 
    
  981. In versions of Django previous to 1.8, ``Paginator.page_range`` returned a
    
  982. ``list`` in Python 2 and a ``range`` in Python 3. Django 1.8 consistently
    
  983. returned a list, but an iterator is more efficient.
    
  984. 
    
  985. Existing code that depends on ``list`` specific features, such as indexing,
    
  986. can be ported by converting the iterator into a ``list`` using ``list()``.
    
  987. 
    
  988. Implicit ``QuerySet`` ``__in`` lookup removed
    
  989. ---------------------------------------------
    
  990. 
    
  991. In earlier versions, queries such as::
    
  992. 
    
  993.     Model.objects.filter(related_id=RelatedModel.objects.all())
    
  994. 
    
  995. would implicitly convert to::
    
  996. 
    
  997.     Model.objects.filter(related_id__in=RelatedModel.objects.all())
    
  998. 
    
  999. resulting in SQL like ``"related_id IN (SELECT id FROM ...)"``.
    
  1000. 
    
  1001. This implicit ``__in`` no longer happens so the "IN" SQL is now "=", and if the
    
  1002. subquery returns multiple results, at least some databases will throw an error.
    
  1003. 
    
  1004. .. _admin-browser-support-19:
    
  1005. 
    
  1006. ``contrib.admin`` browser support
    
  1007. ---------------------------------
    
  1008. 
    
  1009. The admin no longer supports Internet Explorer 8 and below, as these browsers
    
  1010. have reached end-of-life.
    
  1011. 
    
  1012. CSS and images to support Internet Explorer 6 and 7 have been removed. PNG and
    
  1013. GIF icons have been replaced with SVG icons, which are not supported by
    
  1014. Internet Explorer 8 and earlier.
    
  1015. 
    
  1016. The jQuery library embedded in the admin has been upgraded from version 1.11.2
    
  1017. to 2.1.4. jQuery 2.x has the same API as jQuery 1.x, but does not support
    
  1018. Internet Explorer 6, 7, or 8, allowing for better performance and a smaller
    
  1019. file size. If you need to support IE8 and must also use the latest version of
    
  1020. Django, you can override the admin's copy of jQuery with your own by creating
    
  1021. a Django application with this structure::
    
  1022. 
    
  1023.     app/static/admin/js/vendor/
    
  1024.         jquery.js
    
  1025.         jquery.min.js
    
  1026. 
    
  1027. .. _syntax-error-old-setuptools-django-19:
    
  1028. 
    
  1029. ``SyntaxError`` when installing Django setuptools 5.5.x
    
  1030. -------------------------------------------------------
    
  1031. 
    
  1032. When installing Django 1.9 or 1.9.1 with setuptools 5.5.x, you'll see::
    
  1033. 
    
  1034.     Compiling django/conf/app_template/apps.py ...
    
  1035.       File "django/conf/app_template/apps.py", line 4
    
  1036.         class {{ camel_case_app_name }}Config(AppConfig):
    
  1037.               ^
    
  1038.     SyntaxError: invalid syntax
    
  1039. 
    
  1040.     Compiling django/conf/app_template/models.py ...
    
  1041.       File "django/conf/app_template/models.py", line 1
    
  1042.         {{ unicode_literals }}from django.db import models
    
  1043.                                  ^
    
  1044.     SyntaxError: invalid syntax
    
  1045. 
    
  1046. It's safe to ignore these errors (Django will still install just fine), but you
    
  1047. can avoid them by upgrading setuptools to a more recent version. If you're
    
  1048. using pip, you can upgrade pip using ``python -m pip install -U pip`` which
    
  1049. will also upgrade setuptools. This is resolved in later versions of Django as
    
  1050. described in the :doc:`/releases/1.9.2`.
    
  1051. 
    
  1052. Miscellaneous
    
  1053. -------------
    
  1054. 
    
  1055. * The jQuery static files in ``contrib.admin`` have been moved into a
    
  1056.   ``vendor/jquery`` subdirectory.
    
  1057. 
    
  1058. * The text displayed for null columns in the admin changelist ``list_display``
    
  1059.   cells has changed from ``(None)`` (or its translated equivalent) to ``-`` (a
    
  1060.   dash).
    
  1061. 
    
  1062. * ``django.http.responses.REASON_PHRASES`` and
    
  1063.   ``django.core.handlers.wsgi.STATUS_CODE_TEXT`` have been removed. Use
    
  1064.   Python's Standard Library instead: :data:`http.client.responses` for Python
    
  1065.   3 and `httplib.responses`_ for Python 2.
    
  1066. 
    
  1067.   .. _`httplib.responses`: https://docs.python.org/2/library/httplib.html#httplib.responses
    
  1068. 
    
  1069. * ``ValuesQuerySet`` and ``ValuesListQuerySet`` have been removed.
    
  1070. 
    
  1071. * The ``admin/base.html`` template no longer sets
    
  1072.   ``window.__admin_media_prefix__`` or ``window.__admin_utc_offset__``. Image
    
  1073.   references in JavaScript that used that value to construct absolute URLs have
    
  1074.   been moved to CSS for easier customization. The UTC offset is stored on a
    
  1075.   data attribute of the ``<body>`` tag.
    
  1076. 
    
  1077. * ``CommaSeparatedIntegerField`` validation has been refined to forbid values
    
  1078.   like ``','``, ``',1'``, and ``'1,,2'``.
    
  1079. 
    
  1080. * Form initialization was moved from the :meth:`ProcessFormView.get()
    
  1081.   <django.views.generic.edit.ProcessFormView.get>` method to the new
    
  1082.   :meth:`FormMixin.get_context_data()
    
  1083.   <django.views.generic.edit.FormMixin.get_context_data>` method. This may be
    
  1084.   backwards incompatible if you have overridden the ``get_context_data()``
    
  1085.   method without calling ``super()``.
    
  1086. 
    
  1087. * Support for PostGIS 1.5 has been dropped.
    
  1088. 
    
  1089. * The ``django.contrib.sites.models.Site.domain`` field was changed to be
    
  1090.   :attr:`~django.db.models.Field.unique`.
    
  1091. 
    
  1092. * In order to enforce test isolation, database queries are not allowed
    
  1093.   by default in :class:`~django.test.SimpleTestCase` tests anymore. You
    
  1094.   can disable this behavior by setting the ``allow_database_queries`` class
    
  1095.   attribute to ``True`` on your test class.
    
  1096. 
    
  1097. * ``ResolverMatch.app_name`` was changed to contain the full namespace path in
    
  1098.   the case of nested namespaces. For consistency with
    
  1099.   ``ResolverMatch.namespace``, the empty value is now an empty string instead
    
  1100.   of ``None``.
    
  1101. 
    
  1102. * For security hardening, session keys must be at least 8 characters.
    
  1103. 
    
  1104. * Private function ``django.utils.functional.total_ordering()`` has been
    
  1105.   removed. It contained a workaround for a ``functools.total_ordering()`` bug
    
  1106.   in Python versions older than 2.7.3.
    
  1107. 
    
  1108. * XML serialization (either through :djadmin:`dumpdata` or the syndication
    
  1109.   framework) used to output any characters it received. Now if the content to
    
  1110.   be serialized contains any control characters not allowed in the XML 1.0
    
  1111.   standard, the serialization will fail with a :exc:`ValueError`.
    
  1112. 
    
  1113. * :class:`~django.forms.CharField` now strips input of leading and trailing
    
  1114.   whitespace by default. This can be disabled by setting the new
    
  1115.   :attr:`~django.forms.CharField.strip` argument to ``False``.
    
  1116. 
    
  1117. * Template text that is translated and uses two or more consecutive percent
    
  1118.   signs, e.g. ``"%%"``, may have a new ``msgid`` after ``makemessages`` is run
    
  1119.   (most likely the translation will be marked fuzzy). The new ``msgid`` will be
    
  1120.   marked ``"#, python-format"``.
    
  1121. 
    
  1122. * If neither :attr:`request.current_app <django.http.HttpRequest.current_app>`
    
  1123.   nor :class:`Context.current_app <django.template.Context>` are set, the
    
  1124.   :ttag:`url` template tag will now use the namespace of the current request.
    
  1125.   Set ``request.current_app`` to ``None`` if you don't want to use a namespace
    
  1126.   hint.
    
  1127. 
    
  1128. * The :setting:`SILENCED_SYSTEM_CHECKS` setting now silences messages of all
    
  1129.   levels. Previously, messages of ``ERROR`` level or higher were printed to the
    
  1130.   console.
    
  1131. 
    
  1132. * The ``FlatPage.enable_comments`` field is removed from the ``FlatPageAdmin``
    
  1133.   as it's unused by the application. If your project or a third-party app makes
    
  1134.   use of it, :ref:`create a custom ModelAdmin <flatpages-admin>` to add it back.
    
  1135. 
    
  1136. * The return value of
    
  1137.   :meth:`~django.test.runner.DiscoverRunner.setup_databases` and the first
    
  1138.   argument of :meth:`~django.test.runner.DiscoverRunner.teardown_databases`
    
  1139.   changed. They used to be ``(old_names, mirrors)`` tuples. Now they're just
    
  1140.   the first item, ``old_names``.
    
  1141. 
    
  1142. * By default :class:`~django.test.LiveServerTestCase` attempts to find an
    
  1143.   available port in the 8081-8179 range instead of just trying port 8081.
    
  1144. 
    
  1145. * The system checks for :class:`~django.contrib.admin.ModelAdmin` now check
    
  1146.   instances rather than classes.
    
  1147. 
    
  1148. * The private API to apply mixed migration plans has been dropped for
    
  1149.   performance reasons. Mixed plans consist of a list of migrations where some
    
  1150.   are being applied and others are being unapplied.
    
  1151. 
    
  1152. * The related model object descriptor classes in
    
  1153.   ``django.db.models.fields.related`` (private API) are moved from the
    
  1154.   ``related`` module to ``related_descriptors`` and renamed as follows:
    
  1155. 
    
  1156.   * ``ReverseSingleRelatedObjectDescriptor`` is ``ForwardManyToOneDescriptor``
    
  1157.   * ``SingleRelatedObjectDescriptor`` is ``ReverseOneToOneDescriptor``
    
  1158.   * ``ForeignRelatedObjectsDescriptor`` is ``ReverseManyToOneDescriptor``
    
  1159.   * ``ManyRelatedObjectsDescriptor`` is ``ManyToManyDescriptor``
    
  1160. 
    
  1161. * If you implement a custom :data:`~django.conf.urls.handler404` view, it must
    
  1162.   return a response with an HTTP 404 status code. Use
    
  1163.   :class:`~django.http.HttpResponseNotFound` or pass ``status=404`` to the
    
  1164.   :class:`~django.http.HttpResponse`. Otherwise, :setting:`APPEND_SLASH` won't
    
  1165.   work correctly with ``DEBUG=False``.
    
  1166. 
    
  1167. .. _deprecated-features-1.9:
    
  1168. 
    
  1169. Features deprecated in 1.9
    
  1170. ==========================
    
  1171. 
    
  1172. ``assignment_tag()``
    
  1173. --------------------
    
  1174. 
    
  1175. Django 1.4 added the ``assignment_tag`` helper to ease the creation of
    
  1176. template tags that store results in a template variable. The
    
  1177. :meth:`~django.template.Library.simple_tag` helper has gained this same
    
  1178. ability, making the ``assignment_tag`` obsolete. Tags that use
    
  1179. ``assignment_tag`` should be updated to use ``simple_tag``.
    
  1180. 
    
  1181. ``{% cycle %}`` syntax with comma-separated arguments
    
  1182. -----------------------------------------------------
    
  1183. 
    
  1184. The :ttag:`cycle` tag supports an inferior old syntax from previous Django
    
  1185. versions:
    
  1186. 
    
  1187. .. code-block:: html+django
    
  1188. 
    
  1189.     {% cycle row1,row2,row3 %}
    
  1190. 
    
  1191. Its parsing caused bugs with the current syntax, so support for the old syntax
    
  1192. will be removed in Django 1.10 following an accelerated deprecation.
    
  1193. 
    
  1194. ``ForeignKey`` and ``OneToOneField`` ``on_delete`` argument
    
  1195. -----------------------------------------------------------
    
  1196. 
    
  1197. In order to increase awareness about cascading model deletion, the
    
  1198. ``on_delete`` argument of ``ForeignKey`` and ``OneToOneField`` will be required
    
  1199. in Django 2.0.
    
  1200. 
    
  1201. Update models and existing migrations to explicitly set the argument. Since the
    
  1202. default is ``models.CASCADE``, add ``on_delete=models.CASCADE`` to all
    
  1203. ``ForeignKey`` and ``OneToOneField``\s that don't use a different option. You
    
  1204. can also pass it as the second positional argument if you don't care about
    
  1205. compatibility with older versions of Django.
    
  1206. 
    
  1207. ``Field.rel`` changes
    
  1208. ---------------------
    
  1209. 
    
  1210. ``Field.rel`` and its methods and attributes have changed to match the related
    
  1211. fields API. The ``Field.rel`` attribute is renamed to ``remote_field`` and many
    
  1212. of its methods and attributes are either changed or renamed.
    
  1213. 
    
  1214. The aim of these changes is to provide a documented API for relation fields.
    
  1215. 
    
  1216. ``GeoManager`` and ``GeoQuerySet`` custom methods
    
  1217. -------------------------------------------------
    
  1218. 
    
  1219. All custom ``GeoQuerySet`` methods (``area()``, ``distance()``, ``gml()``, ...)
    
  1220. have been replaced by equivalent geographic expressions in annotations (see in
    
  1221. new features). Hence the need to set a custom ``GeoManager`` to GIS-enabled
    
  1222. models is now obsolete. As soon as your code doesn't call any of the deprecated
    
  1223. methods, you can simply remove the ``objects = GeoManager()`` lines from your
    
  1224. models.
    
  1225. 
    
  1226. Template loader APIs have changed
    
  1227. ---------------------------------
    
  1228. 
    
  1229. Django template loaders have been updated to allow recursive template
    
  1230. extending. This change necessitated a new template loader API. The old
    
  1231. ``load_template()`` and ``load_template_sources()`` methods are now deprecated.
    
  1232. Details about the new API can be found :ref:`in the template loader
    
  1233. documentation <custom-template-loaders>`.
    
  1234. 
    
  1235. Passing a 3-tuple or an ``app_name`` to ``include()``
    
  1236. -----------------------------------------------------
    
  1237. 
    
  1238. The instance namespace part of passing a tuple as an argument to ``include()``
    
  1239. has been replaced by passing the ``namespace`` argument to ``include()``. For
    
  1240. example::
    
  1241. 
    
  1242.     polls_patterns = [
    
  1243.          url(...),
    
  1244.     ]
    
  1245. 
    
  1246.     urlpatterns = [
    
  1247.         url(r'^polls/', include((polls_patterns, 'polls', 'author-polls'))),
    
  1248.     ]
    
  1249. 
    
  1250. becomes::
    
  1251. 
    
  1252.     polls_patterns = ([
    
  1253.          url(...),
    
  1254.     ], 'polls')  # 'polls' is the app_name
    
  1255. 
    
  1256.     urlpatterns = [
    
  1257.         url(r'^polls/', include(polls_patterns, namespace='author-polls')),
    
  1258.     ]
    
  1259. 
    
  1260. The ``app_name`` argument to ``include()`` has been replaced by passing a
    
  1261. 2-tuple (as above), or passing an object or module with an ``app_name``
    
  1262. attribute (as below). If the ``app_name`` is set in this new way, the
    
  1263. ``namespace`` argument is no longer required. It will default to the value of
    
  1264. ``app_name``. For example, the URL patterns in the tutorial are changed from:
    
  1265. 
    
  1266. .. code-block:: python
    
  1267.     :caption: ``mysite/urls.py``
    
  1268. 
    
  1269.     urlpatterns = [
    
  1270.         url(r'^polls/', include('polls.urls', namespace="polls")),
    
  1271.         ...
    
  1272.     ]
    
  1273. 
    
  1274. to:
    
  1275. 
    
  1276. .. code-block:: python
    
  1277.     :caption: ``mysite/urls.py``
    
  1278. 
    
  1279.     urlpatterns = [
    
  1280.         url(r'^polls/', include('polls.urls')),  # 'namespace="polls"' removed
    
  1281.         ...
    
  1282.     ]
    
  1283. 
    
  1284. .. code-block:: python
    
  1285.     :caption: ``polls/urls.py``
    
  1286. 
    
  1287.     app_name = 'polls'  # added
    
  1288.     urlpatterns = [...]
    
  1289. 
    
  1290. This change also means that the old way of including an ``AdminSite`` instance
    
  1291. is deprecated. Instead, pass ``admin.site.urls`` directly to
    
  1292. ``django.conf.urls.url()``:
    
  1293. 
    
  1294. .. code-block:: python
    
  1295.     :caption: ``urls.py``
    
  1296. 
    
  1297.     from django.conf.urls import url
    
  1298.     from django.contrib import admin
    
  1299. 
    
  1300.     urlpatterns = [
    
  1301.         url(r'^admin/', admin.site.urls),
    
  1302.     ]
    
  1303. 
    
  1304. URL application namespace required if setting an instance namespace
    
  1305. -------------------------------------------------------------------
    
  1306. 
    
  1307. In the past, an instance namespace without an application namespace
    
  1308. would serve the same purpose as the application namespace, but it was
    
  1309. impossible to reverse the patterns if there was an application namespace
    
  1310. with the same name. Includes that specify an instance namespace require that
    
  1311. the included URLconf sets an application namespace.
    
  1312. 
    
  1313. ``current_app`` parameter to ``contrib.auth`` views
    
  1314. ---------------------------------------------------
    
  1315. 
    
  1316. All views in ``django.contrib.auth.views`` have the following structure::
    
  1317. 
    
  1318.     def view(request, ..., current_app=None, ...):
    
  1319. 
    
  1320.         ...
    
  1321. 
    
  1322.         if current_app is not None:
    
  1323.             request.current_app = current_app
    
  1324. 
    
  1325.         return TemplateResponse(request, template_name, context)
    
  1326. 
    
  1327. As of Django 1.8, ``current_app`` is set on the ``request`` object. For
    
  1328. consistency, these views will require the caller to set ``current_app`` on the
    
  1329. ``request`` instead of passing it in a separate argument.
    
  1330. 
    
  1331. ``django.contrib.gis.geoip``
    
  1332. ----------------------------
    
  1333. 
    
  1334. The :mod:`django.contrib.gis.geoip2` module supersedes
    
  1335. ``django.contrib.gis.geoip``. The new module provides a similar API except that
    
  1336. it doesn't provide the legacy GeoIP-Python API compatibility methods.
    
  1337. 
    
  1338. Miscellaneous
    
  1339. -------------
    
  1340. 
    
  1341. * The ``weak`` argument to ``django.dispatch.signals.Signal.disconnect()`` has
    
  1342.   been deprecated as it has no effect.
    
  1343. 
    
  1344. * The ``check_aggregate_support()`` method of
    
  1345.   ``django.db.backends.base.BaseDatabaseOperations`` has been deprecated and
    
  1346.   will be removed in Django 2.0. The more general ``check_expression_support()``
    
  1347.   should be used instead.
    
  1348. 
    
  1349. * ``django.forms.extras`` is deprecated. You can find
    
  1350.   :class:`~django.forms.SelectDateWidget` in ``django.forms.widgets``
    
  1351.   (or simply ``django.forms``) instead.
    
  1352. 
    
  1353. * Private API ``django.db.models.fields.add_lazy_relation()`` is deprecated.
    
  1354. 
    
  1355. * The ``django.contrib.auth.tests.utils.skipIfCustomUser()`` decorator is
    
  1356.   deprecated. With the test discovery changes in Django 1.6, the tests for
    
  1357.   ``django.contrib`` apps are no longer run as part of the user's project.
    
  1358.   Therefore, the ``@skipIfCustomUser`` decorator is no longer needed to
    
  1359.   decorate tests in ``django.contrib.auth``.
    
  1360. 
    
  1361. * If you customized some :ref:`error handlers <error-views>`, the view
    
  1362.   signatures with only one request parameter are deprecated. The views should
    
  1363.   now also accept a second ``exception`` positional parameter.
    
  1364. 
    
  1365. * The ``django.utils.feedgenerator.Atom1Feed.mime_type`` and
    
  1366.   ``django.utils.feedgenerator.RssFeed.mime_type`` attributes are deprecated in
    
  1367.   favor of ``content_type``.
    
  1368. 
    
  1369. * :class:`~django.core.signing.Signer` now issues a warning if an invalid
    
  1370.   separator is used. This will become an exception in Django 1.10.
    
  1371. 
    
  1372. * ``django.db.models.Field._get_val_from_obj()`` is deprecated in favor of
    
  1373.   ``Field.value_from_object()``.
    
  1374. 
    
  1375. * ``django.template.loaders.eggs.Loader`` is deprecated as distributing
    
  1376.   applications as eggs is not recommended.
    
  1377. 
    
  1378. * The ``callable_obj`` keyword argument to
    
  1379.   ``SimpleTestCase.assertRaisesMessage()`` is deprecated. Pass the callable as
    
  1380.   a positional argument instead.
    
  1381. 
    
  1382. * The ``allow_tags`` attribute on methods of ``ModelAdmin`` has been
    
  1383.   deprecated. Use :func:`~django.utils.html.format_html`,
    
  1384.   :func:`~django.utils.html.format_html_join`, or
    
  1385.   :func:`~django.utils.safestring.mark_safe` when constructing the method's
    
  1386.   return value instead.
    
  1387. 
    
  1388. * The ``enclosure`` keyword argument to ``SyndicationFeed.add_item()`` is
    
  1389.   deprecated. Use the new ``enclosures`` argument which accepts a list of
    
  1390.   ``Enclosure`` objects instead of a single one.
    
  1391. 
    
  1392. * The ``django.template.loader.LoaderOrigin`` and
    
  1393.   ``django.template.base.StringOrigin`` aliases for
    
  1394.   ``django.template.base.Origin`` are deprecated.
    
  1395. 
    
  1396. .. _removed-features-1.9:
    
  1397. 
    
  1398. Features removed in 1.9
    
  1399. =======================
    
  1400. 
    
  1401. These features have reached the end of their deprecation cycle and are removed
    
  1402. in Django 1.9. See :ref:`deprecated-features-1.7` for details, including how to
    
  1403. remove usage of these features.
    
  1404. 
    
  1405. * ``django.utils.dictconfig`` is removed.
    
  1406. 
    
  1407. * ``django.utils.importlib`` is removed.
    
  1408. 
    
  1409. * ``django.utils.tzinfo`` is removed.
    
  1410. 
    
  1411. * ``django.utils.unittest`` is removed.
    
  1412. 
    
  1413. * The ``syncdb`` command is removed.
    
  1414. 
    
  1415. * ``django.db.models.signals.pre_syncdb`` and
    
  1416.   ``django.db.models.signals.post_syncdb`` is removed.
    
  1417. 
    
  1418. * Support for ``allow_syncdb`` on database routers is removed.
    
  1419. 
    
  1420. * Automatic syncing of apps without migrations is removed. Migrations are
    
  1421.   compulsory for all apps unless you pass the :option:`migrate --run-syncdb`
    
  1422.   option.
    
  1423. 
    
  1424. * The SQL management commands for apps without migrations, ``sql``, ``sqlall``,
    
  1425.   ``sqlclear``, ``sqldropindexes``, and ``sqlindexes``, are removed.
    
  1426. 
    
  1427. * Support for automatic loading of ``initial_data`` fixtures and initial SQL
    
  1428.   data is removed.
    
  1429. 
    
  1430. * All models need to be defined inside an installed application or declare an
    
  1431.   explicit :attr:`~django.db.models.Options.app_label`. Furthermore, it isn't
    
  1432.   possible to import them before their application is loaded. In particular, it
    
  1433.   isn't possible to import models inside the root package of an application.
    
  1434. 
    
  1435. * The model and form ``IPAddressField`` is removed. A stub field remains for
    
  1436.   compatibility with historical migrations.
    
  1437. 
    
  1438. * ``AppCommand.handle_app()`` is no longer supported.
    
  1439. 
    
  1440. * ``RequestSite`` and ``get_current_site()`` are no longer importable from
    
  1441.   ``django.contrib.sites.models``.
    
  1442. 
    
  1443. * FastCGI support via the ``runfcgi`` management command is removed.
    
  1444. 
    
  1445. * ``django.utils.datastructures.SortedDict`` is removed.
    
  1446. 
    
  1447. * ``ModelAdmin.declared_fieldsets`` is removed.
    
  1448. 
    
  1449. * The ``util`` modules that provided backwards compatibility are removed:
    
  1450. 
    
  1451.   * ``django.contrib.admin.util``
    
  1452.   * ``django.contrib.gis.db.backends.util``
    
  1453.   * ``django.db.backends.util``
    
  1454.   * ``django.forms.util``
    
  1455. 
    
  1456. * ``ModelAdmin.get_formsets`` is removed.
    
  1457. 
    
  1458. * The backward compatible shims introduced to rename the
    
  1459.   ``BaseMemcachedCache._get_memcache_timeout()`` method to
    
  1460.   ``get_backend_timeout()`` is removed.
    
  1461. 
    
  1462. * The ``--natural`` and ``-n`` options for :djadmin:`dumpdata` are removed.
    
  1463. 
    
  1464. * The ``use_natural_keys`` argument for ``serializers.serialize()`` is removed.
    
  1465. 
    
  1466. * Private API ``django.forms.forms.get_declared_fields()`` is removed.
    
  1467. 
    
  1468. * The ability to use a ``SplitDateTimeWidget`` with ``DateTimeField`` is
    
  1469.   removed.
    
  1470. 
    
  1471. * The ``WSGIRequest.REQUEST`` property is removed.
    
  1472. 
    
  1473. * The class ``django.utils.datastructures.MergeDict`` is removed.
    
  1474. 
    
  1475. * The ``zh-cn`` and ``zh-tw`` language codes are removed.
    
  1476. 
    
  1477. * The internal ``django.utils.functional.memoize()`` is removed.
    
  1478. 
    
  1479. * ``django.core.cache.get_cache`` is removed.
    
  1480. 
    
  1481. * ``django.db.models.loading`` is removed.
    
  1482. 
    
  1483. * Passing callable arguments to querysets is no longer possible.
    
  1484. 
    
  1485. * ``BaseCommand.requires_model_validation`` is removed in favor of
    
  1486.   ``requires_system_checks``. Admin validators is replaced by admin checks.
    
  1487. 
    
  1488. * The ``ModelAdmin.validator_class`` and ``default_validator_class`` attributes
    
  1489.   are removed.
    
  1490. 
    
  1491. * ``ModelAdmin.validate()`` is removed.
    
  1492. 
    
  1493. * ``django.db.backends.DatabaseValidation.validate_field`` is removed in
    
  1494.   favor of the ``check_field`` method.
    
  1495. 
    
  1496. * The ``validate`` management command is removed.
    
  1497. 
    
  1498. * ``django.utils.module_loading.import_by_path`` is removed in favor of
    
  1499.   ``django.utils.module_loading.import_string``.
    
  1500. 
    
  1501. * ``ssi`` and ``url`` template tags are removed from the ``future`` template
    
  1502.   tag library.
    
  1503. 
    
  1504. * ``django.utils.text.javascript_quote()`` is removed.
    
  1505. 
    
  1506. * Database test settings as independent entries in the database settings,
    
  1507.   prefixed by ``TEST_``, are no longer supported.
    
  1508. 
    
  1509. * The ``cache_choices`` option to :class:`~django.forms.ModelChoiceField` and
    
  1510.   :class:`~django.forms.ModelMultipleChoiceField` is removed.
    
  1511. 
    
  1512. * The default value of the
    
  1513.   :attr:`RedirectView.permanent <django.views.generic.base.RedirectView.permanent>`
    
  1514.   attribute has changed from ``True`` to ``False``.
    
  1515. 
    
  1516. * ``django.contrib.sitemaps.FlatPageSitemap`` is removed in favor of
    
  1517.   ``django.contrib.flatpages.sitemaps.FlatPageSitemap``.
    
  1518. 
    
  1519. * Private API ``django.test.utils.TestTemplateLoader`` is removed.
    
  1520. 
    
  1521. * The ``django.contrib.contenttypes.generic`` module is removed.