{"title":"Django 1.9 release notes","version":"dev","locale":"en","docname":"releases/1.9","url":"/en/dev/releases/1.9/","canonical":"https://djangodocs.dev/en/dev/releases/1.9/","summary":"Welcome to Django 1.9! These release notes cover the new features, as well as some backwards incompatible changes you’ll want to be aware of when upgrading…","html":"<h1>Django 1.9 release notes<a class=\"heading-anchor\" href=\"#django-1-9-release-notes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p><em>December 1, 2015</em></p>\n<p>Welcome to Django 1.9!</p>\n<p>These release notes cover the <a class=\"reference internal\" href=\"#whats-new-1-9\"><span class=\"std std-ref\">new features</span></a>, as well as\nsome <a class=\"reference internal\" href=\"#backwards-incompatible-1-9\"><span class=\"std std-ref\">backwards incompatible changes</span></a> you’ll\nwant to be aware of when upgrading from Django 1.8 or older versions. We’ve\n<a class=\"reference internal\" href=\"#removed-features-1-9\"><span class=\"std std-ref\">dropped some features</span></a> that have reached the end of\ntheir deprecation cycle, and we’ve <a class=\"reference internal\" href=\"#deprecated-features-1-9\"><span class=\"std std-ref\">begun the deprecation process for some\nfeatures</span></a>.</p>\n<p>See the <a class=\"reference internal\" href=\"/en/dev/howto/upgrade-version/\"><span class=\"doc\">How to upgrade Django to a newer version</span></a> guide if you’re updating an existing\nproject.</p>\n<section id=\"python-compatibility\">\n<h2>Python compatibility<a class=\"heading-anchor\" href=\"#python-compatibility\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django 1.9 requires Python 2.7, 3.4, or 3.5. We <strong>highly recommend</strong> and only\nofficially support the latest release of each series.</p>\n<p>The Django 1.8 series is the last to support Python 3.2 and 3.3.</p>\n</section>\n<section id=\"what-s-new-in-django-1-9\">\n<span id=\"whats-new-1-9\"></span><h2>What’s new in Django 1.9<a class=\"heading-anchor\" href=\"#what-s-new-in-django-1-9\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"performing-actions-after-a-transaction-commit\">\n<h3>Performing actions after a transaction commit<a class=\"heading-anchor\" href=\"#performing-actions-after-a-transaction-commit\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The new <a class=\"reference internal\" href=\"/en/dev/topics/db/transactions/#django.db.transaction.on_commit\" title=\"django.db.transaction.on_commit\"><code class=\"xref py py-func docutils literal notranslate\">on_commit()</code></a> hook allows performing actions\nafter a database transaction is successfully committed. This is useful for\ntasks such as sending notification emails, creating queued tasks, or\ninvalidating caches.</p>\n<p>This functionality from the <a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/django-transaction-hooks/\">django-transaction-hooks</a> package has been\nintegrated into Django.</p>\n</section>\n<section id=\"password-validation\">\n<h3>Password validation<a class=\"heading-anchor\" href=\"#password-validation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django now offers password validation to help prevent the usage of weak\npasswords by users. The validation is integrated in the included password\nchange and reset forms and is simple to integrate in any other code.\nValidation is performed by one or more validators, configured in the new\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-AUTH_PASSWORD_VALIDATORS\"><code class=\"xref std std-setting docutils literal notranslate\">AUTH_PASSWORD_VALIDATORS</code></a> setting.</p>\n<p>Four validators are included in Django, which can enforce a minimum length,\ncompare the password to the user’s attributes like their name, ensure\npasswords aren’t entirely numeric, or check against an included list of common\npasswords. You can combine multiple validators, and some validators have\ncustom configuration options. For example, you can choose to provide a custom\nlist of common passwords. Each validator provides a help text to explain its\nrequirements to the user.</p>\n<p>By default, no validation is performed and all passwords are accepted, so if\nyou don’t set <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-AUTH_PASSWORD_VALIDATORS\"><code class=\"xref std std-setting docutils literal notranslate\">AUTH_PASSWORD_VALIDATORS</code></a>, you will not see any\nchange. In new projects created with the default <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-startproject\"><code class=\"xref std std-djadmin docutils literal notranslate\">startproject</code></a>\ntemplate, a simple set of validators is enabled. To enable basic validation in\nthe included auth forms for your project, you could set, for example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>AUTH_PASSWORD_VALIDATORS <span class=\"o\">=</span> <span class=\"p\">[</span>\n    <span class=\"p\">{</span>\n        <span class=\"s2\">&quot;NAME&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;django.contrib.auth.password_validation.UserAttributeSimilarityValidator&quot;</span><span class=\"p\">,</span>\n    <span class=\"p\">},</span>\n    <span class=\"p\">{</span>\n        <span class=\"s2\">&quot;NAME&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;django.contrib.auth.password_validation.MinimumLengthValidator&quot;</span><span class=\"p\">,</span>\n    <span class=\"p\">},</span>\n    <span class=\"p\">{</span>\n        <span class=\"s2\">&quot;NAME&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;django.contrib.auth.password_validation.CommonPasswordValidator&quot;</span><span class=\"p\">,</span>\n    <span class=\"p\">},</span>\n    <span class=\"p\">{</span>\n        <span class=\"s2\">&quot;NAME&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;django.contrib.auth.password_validation.NumericPasswordValidator&quot;</span><span class=\"p\">,</span>\n    <span class=\"p\">},</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p>See <a class=\"reference internal\" href=\"/en/dev/topics/auth/passwords/#password-validation\"><span class=\"std std-ref\">Password validation</span></a> for more details.</p>\n</section>\n<section id=\"permission-mixins-for-class-based-views\">\n<h3>Permission mixins for class-based views<a class=\"heading-anchor\" href=\"#permission-mixins-for-class-based-views\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django now ships with the mixins\n<a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.mixins.AccessMixin\" title=\"django.contrib.auth.mixins.AccessMixin\"><code class=\"xref py py-class docutils literal notranslate\">AccessMixin</code></a>,\n<a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.mixins.LoginRequiredMixin\" title=\"django.contrib.auth.mixins.LoginRequiredMixin\"><code class=\"xref py py-class docutils literal notranslate\">LoginRequiredMixin</code></a>,\n<a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.mixins.PermissionRequiredMixin\" title=\"django.contrib.auth.mixins.PermissionRequiredMixin\"><code class=\"xref py py-class docutils literal notranslate\">PermissionRequiredMixin</code></a>, and\n<a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.mixins.UserPassesTestMixin\" title=\"django.contrib.auth.mixins.UserPassesTestMixin\"><code class=\"xref py py-class docutils literal notranslate\">UserPassesTestMixin</code></a> to provide the\nfunctionality of the <code class=\"docutils literal notranslate\">django.contrib.auth.decorators</code> for class-based views.\nThese mixins have been taken from, or are at least inspired by, the\n<a class=\"reference external\" href=\"https://django-braces.readthedocs.io/en/latest/index.html\">django-braces</a> project.</p>\n<p>There are a few differences between Django’s and <code class=\"docutils literal notranslate\">django-braces</code>'\nimplementation, though:</p>\n<ul class=\"simple\">\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.mixins.AccessMixin.raise_exception\" title=\"django.contrib.auth.mixins.AccessMixin.raise_exception\"><code class=\"xref py py-attr docutils literal notranslate\">raise_exception</code></a> attribute\ncan only be <code class=\"docutils literal notranslate\">True</code> or <code class=\"docutils literal notranslate\">False</code>. Custom exceptions or callables are not\nsupported.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.mixins.AccessMixin.handle_no_permission\" title=\"django.contrib.auth.mixins.AccessMixin.handle_no_permission\"><code class=\"xref py py-meth docutils literal notranslate\">handle_no_permission()</code></a>\nmethod does not take a <code class=\"docutils literal notranslate\">request</code> argument. The current request is available\nin <code class=\"docutils literal notranslate\">self.request</code>.</p></li>\n<li><p>The custom <code class=\"docutils literal notranslate\">test_func()</code> of\n<a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.mixins.UserPassesTestMixin\" title=\"django.contrib.auth.mixins.UserPassesTestMixin\"><code class=\"xref py py-class docutils literal notranslate\">UserPassesTestMixin</code></a> does not take a\n<code class=\"docutils literal notranslate\">user</code> argument. The current user is available in <code class=\"docutils literal notranslate\">self.request.user</code>.</p></li>\n<li><p>The\n<a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.mixins.PermissionRequiredMixin\" title=\"django.contrib.auth.mixins.PermissionRequiredMixin\"><code class=\"xref py py-attr docutils literal notranslate\">permission_required</code></a>\nattribute supports a string (defining one permission) or a list/tuple of\nstrings (defining multiple permissions) that need to be fulfilled to grant\naccess.</p></li>\n<li><p>The new\n<a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.mixins.AccessMixin.permission_denied_message\" title=\"django.contrib.auth.mixins.AccessMixin.permission_denied_message\"><code class=\"xref py py-attr docutils literal notranslate\">permission_denied_message</code></a>\nattribute allows passing a message to the <code class=\"docutils literal notranslate\">PermissionDenied</code> exception.</p></li>\n</ul>\n</section>\n<section id=\"new-styling-for-contrib-admin\">\n<h3>New styling for <code class=\"docutils literal notranslate\">contrib.admin</code><a class=\"heading-anchor\" href=\"#new-styling-for-contrib-admin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The admin sports a modern, flat design with new SVG icons which look perfect\non HiDPI screens. It still provides a fully-functional experience to <a class=\"reference external\" href=\"https://github.com/yui/yui3/wiki/Graded-Browser-Support\">YUI’s\nA-grade</a> browsers. Older browser may experience varying levels of graceful\ndegradation.</p>\n</section>\n<section id=\"running-tests-in-parallel\">\n<h3>Running tests in parallel<a class=\"heading-anchor\" href=\"#running-tests-in-parallel\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-test\"><code class=\"xref std std-djadmin docutils literal notranslate\">test</code></a> command now supports a <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#cmdoption-test-parallel\"><code class=\"xref std std-option docutils literal notranslate\">--parallel</code></a> option to run a project’s tests in multiple processes in parallel.</p>\n<p>Each process gets its own database. You must ensure that different test cases\ndon’t access the same resources. For instance, test cases that touch the\nfilesystem should create a temporary directory for their own use.</p>\n<p>This option is enabled by default for Django’s own test suite provided:</p>\n<ul class=\"simple\">\n<li><p>the OS supports it (all but Windows)</p></li>\n<li><p>the database backend supports it (all the built-in backends but Oracle)</p></li>\n</ul>\n</section>\n<section id=\"minor-features\">\n<h3>Minor features<a class=\"heading-anchor\" href=\"#minor-features\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"django-contrib-admin\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#module-django.contrib.admin\" title=\"django.contrib.admin: Django's admin site.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.admin</code></a><a class=\"heading-anchor\" href=\"#django-contrib-admin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>Admin views now have <code class=\"docutils literal notranslate\">model_admin</code> or <code class=\"docutils literal notranslate\">admin_site</code> attributes.</p></li>\n<li><p>The URL of the admin change view has been changed (was at\n<code class=\"docutils literal notranslate\">/admin/&lt;app&gt;/&lt;model&gt;/&lt;pk&gt;/</code> by default and is now at\n<code class=\"docutils literal notranslate\">/admin/&lt;app&gt;/&lt;model&gt;/&lt;pk&gt;/change/</code>). This should not affect your\napplication unless you have hardcoded admin URLs. In that case, replace those\nlinks by <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#admin-reverse-urls\"><span class=\"std std-ref\">reversing admin URLs</span></a> instead. Note that\nthe old URL still redirects to the new one for backwards compatibility, but\nit may be removed in a future version.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_list_select_related\" title=\"django.contrib.admin.ModelAdmin.get_list_select_related\"><code class=\"xref py py-meth docutils literal notranslate\">ModelAdmin.get_list_select_related()</code></a> was added to allow\nchanging the <code class=\"docutils literal notranslate\">select_related()</code> values used in the admin’s changelist query\nbased on the request.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">available_apps</code> context variable, which lists the available\napplications for the current user, has been added to the\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.AdminSite.each_context\" title=\"django.contrib.admin.AdminSite.each_context\"><code class=\"xref py py-meth docutils literal notranslate\">AdminSite.each_context()</code></a>\nmethod.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.AdminSite.empty_value_display\" title=\"django.contrib.admin.AdminSite.empty_value_display\"><code class=\"xref py py-attr docutils literal notranslate\">AdminSite.empty_value_display</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.empty_value_display\" title=\"django.contrib.admin.ModelAdmin.empty_value_display\"><code class=\"xref py py-attr docutils literal notranslate\">ModelAdmin.empty_value_display</code></a> were added to override\nthe display of empty values in admin change list. You can also customize the\nvalue for each field.</p></li>\n<li><p>Added jQuery events <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/javascript/#admin-javascript-inline-form-events\"><span class=\"std std-ref\">when an inline form is added or removed</span></a> on the change form page.</p></li>\n<li><p>The time picker widget includes a ‘6 p.m’ option for consistency of having\npredefined options every 6 hours.</p></li>\n<li><p>JavaScript slug generation now supports Romanian characters.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-admindocs\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/admindocs/#module-django.contrib.admindocs\" title=\"django.contrib.admindocs: Django's admin documentation generator.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.admindocs</code></a><a class=\"heading-anchor\" href=\"#django-contrib-admindocs\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The model section of the <code class=\"docutils literal notranslate\">admindocs</code> now also describes methods that take\narguments, rather than ignoring them.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-auth\">\n<h4><a class=\"reference internal\" href=\"/en/dev/topics/auth/#module-django.contrib.auth\" title=\"django.contrib.auth: Django's authentication framework.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.auth</code></a><a class=\"heading-anchor\" href=\"#django-contrib-auth\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The default iteration count for the PBKDF2 password hasher has been increased\nby 20%. This backwards compatible change will not affect users who have\nsubclassed <code class=\"docutils literal notranslate\">django.contrib.auth.hashers.PBKDF2PasswordHasher</code> to change the\ndefault value.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">BCryptSHA256PasswordHasher</code> will now update passwords if its\n<code class=\"docutils literal notranslate\">rounds</code> attribute is changed.</p></li>\n<li><p><code class=\"docutils literal notranslate\">AbstractBaseUser</code> and <code class=\"docutils literal notranslate\">BaseUserManager</code> were moved to a new\n<code class=\"docutils literal notranslate\">django.contrib.auth.base_user</code> module so that they can be imported without\nincluding <code class=\"docutils literal notranslate\">django.contrib.auth</code> in <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> (doing so\nraised a deprecation warning in older versions and is no longer supported in\nDjango 1.9).</p></li>\n<li><p>The permission argument of\n<a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.decorators.permission_required\" title=\"django.contrib.auth.decorators.permission_required\"><code class=\"xref py py-func docutils literal notranslate\">permission_required()</code></a> accepts all\nkinds of iterables, not only list and tuples.</p></li>\n<li><p>The new\n<a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.contrib.auth.middleware.PersistentRemoteUserMiddleware\" title=\"django.contrib.auth.middleware.PersistentRemoteUserMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">PersistentRemoteUserMiddleware</code></a>\nmakes it possible to use <code class=\"docutils literal notranslate\">REMOTE_USER</code> for setups where the header is only\npopulated on login pages instead of every request in the session.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">django.contrib.auth.views.password_reset()</code> view accepts an\n<code class=\"docutils literal notranslate\">extra_email_context</code> parameter.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-contenttypes\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/contenttypes/#module-django.contrib.contenttypes\" title=\"django.contrib.contenttypes: Provides generic interface to installed models.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.contenttypes</code></a><a class=\"heading-anchor\" href=\"#django-contrib-contenttypes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>It’s now possible to use\n<a class=\"reference internal\" href=\"/en/dev/ref/models/options/#django.db.models.Options.order_with_respect_to\" title=\"django.db.models.Options.order_with_respect_to\"><code class=\"xref py py-attr docutils literal notranslate\">order_with_respect_to</code></a> with a\n<code class=\"docutils literal notranslate\">GenericForeignKey</code>.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-gis\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/gis/#module-django.contrib.gis\" title=\"django.contrib.gis: Geographic Information System (GIS) extensions for Django\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.gis</code></a><a class=\"heading-anchor\" href=\"#django-contrib-gis\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>All <code class=\"docutils literal notranslate\">GeoQuerySet</code> methods have been deprecated and replaced by\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/gis/functions/\"><span class=\"doc\">equivalent database functions</span></a>. As soon\nas the legacy methods have been replaced in your code, you should even be\nable to remove the special <code class=\"docutils literal notranslate\">GeoManager</code> from your GIS-enabled classes.</p></li>\n<li><p>The GDAL interface now supports instantiating file-based and in-memory\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/gis/gdal/#raster-data-source-objects\"><span class=\"std std-ref\">GDALRaster objects</span></a> from raw data.\nSetters for raster properties such as projection or pixel values have\nbeen added.</p></li>\n<li><p>For PostGIS users, the new <a class=\"reference internal\" href=\"/en/dev/ref/contrib/gis/model-api/#django.contrib.gis.db.models.RasterField\" title=\"django.contrib.gis.db.models.RasterField\"><code class=\"xref py py-class docutils literal notranslate\">RasterField</code></a>\nallows <a class=\"reference internal\" href=\"/en/dev/ref/contrib/gis/db-api/#creating-and-saving-raster-models\"><span class=\"std std-ref\">storing GDALRaster objects</span></a>.\nIt supports automatic spatial index creation and reprojection when saving a\nmodel. It does not yet support spatial querying.</p></li>\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/contrib/gis/gdal/#django.contrib.gis.gdal.GDALRaster.warp\" title=\"django.contrib.gis.gdal.GDALRaster.warp\"><code class=\"xref py py-meth docutils literal notranslate\">GDALRaster.warp()</code></a>\nmethod allows warping a raster by specifying target raster properties such as\norigin, width, height, or pixel size (among others).</p></li>\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/contrib/gis/gdal/#django.contrib.gis.gdal.GDALRaster.transform\" title=\"django.contrib.gis.gdal.GDALRaster.transform\"><code class=\"xref py py-meth docutils literal notranslate\">GDALRaster.transform()</code></a> method allows transforming a\nraster into a different spatial reference system by specifying a target\n<code class=\"docutils literal notranslate\">srid</code>.</p></li>\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/contrib/gis/geoip2/#django.contrib.gis.geoip2.GeoIP2\" title=\"django.contrib.gis.geoip2.GeoIP2\"><code class=\"xref py py-class docutils literal notranslate\">GeoIP2</code></a> class allows using\nMaxMind’s GeoLite2 databases which includes support for IPv6 addresses.</p></li>\n<li><p>The default OpenLayers library version included in widgets has been updated\nfrom 2.13 to 2.13.1.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-postgres\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/postgres/#module-django.contrib.postgres\" title=\"django.contrib.postgres: PostgreSQL-specific fields and features\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.postgres</code></a><a class=\"heading-anchor\" href=\"#django-contrib-postgres\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>Added support for the <a class=\"reference internal\" href=\"/en/dev/ref/contrib/postgres/fields/#std-fieldlookup-rangefield.contained_by\"><code class=\"xref std std-lookup docutils literal notranslate\">rangefield.contained_by</code></a> lookup for some built\nin fields which correspond to the range fields.</p></li>\n<li><p>Added <code class=\"docutils literal notranslate\">django.contrib.postgres.fields.JSONField</code>.</p></li>\n<li><p>Added <a class=\"reference internal\" href=\"/en/dev/ref/contrib/postgres/aggregates/\"><span class=\"doc\">PostgreSQL specific aggregation functions</span></a>.</p></li>\n<li><p>Added the <a class=\"reference internal\" href=\"/en/dev/ref/contrib/postgres/functions/#django.contrib.postgres.functions.TransactionNow\" title=\"django.contrib.postgres.functions.TransactionNow\"><code class=\"xref py py-class docutils literal notranslate\">TransactionNow</code></a> database\nfunction.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-sessions\">\n<h4><a class=\"reference internal\" href=\"/en/dev/topics/http/sessions/#module-django.contrib.sessions\" title=\"django.contrib.sessions: Provides session management for Django projects.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.sessions</code></a><a class=\"heading-anchor\" href=\"#django-contrib-sessions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The session model and <code class=\"docutils literal notranslate\">SessionStore</code> classes for the <code class=\"docutils literal notranslate\">db</code> and\n<code class=\"docutils literal notranslate\">cached_db</code> backends are refactored to allow a custom database session\nbackend to build upon them. See\n<a class=\"reference internal\" href=\"/en/dev/topics/http/sessions/#extending-database-backed-session-engines\"><span class=\"std std-ref\">Extending database-backed session engines</span></a> for more details.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-sites\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/sites/#module-django.contrib.sites\" title=\"django.contrib.sites: Lets you operate multiple websites from the same database and Django project\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.sites</code></a><a class=\"heading-anchor\" href=\"#django-contrib-sites\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/sites/#django.contrib.sites.shortcuts.get_current_site\" title=\"django.contrib.sites.shortcuts.get_current_site\"><code class=\"xref py py-func docutils literal notranslate\">get_current_site()</code></a> now handles the case\nwhere <code class=\"docutils literal notranslate\">request.get_host()</code> returns <code class=\"docutils literal notranslate\">domain:port</code>, e.g.\n<code class=\"docutils literal notranslate\">example.com:80</code>. If the lookup fails because the host does not match a\nrecord in the database and the host has a port, the port is stripped and the\nlookup is retried with the domain part only.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-syndication\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/syndication/#module-django.contrib.syndication\" title=\"django.contrib.syndication: A framework for generating syndication feeds, in RSS and Atom, quite easily.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.syndication</code></a><a class=\"heading-anchor\" href=\"#django-contrib-syndication\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>Support for multiple enclosures per feed item has been added. If multiple\nenclosures are defined on a RSS feed, an exception is raised as RSS feeds,\nunlike Atom feeds, do not support multiple enclosures per feed item.</p></li>\n</ul>\n</section>\n<section id=\"cache\">\n<h4>Cache<a class=\"heading-anchor\" href=\"#cache\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">django.core.cache.backends.base.BaseCache</code> now has a <code class=\"docutils literal notranslate\">get_or_set()</code>\nmethod.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/http/decorators/#django.views.decorators.cache.never_cache\" title=\"django.views.decorators.cache.never_cache\"><code class=\"xref py py-func docutils literal notranslate\">django.views.decorators.cache.never_cache()</code></a> now sends more persuasive\nheaders (added <code class=\"docutils literal notranslate\">no-cache, no-store, must-revalidate</code> to <code class=\"docutils literal notranslate\">Cache-Control</code>)\nto better prevent caching. This was also added in Django 1.8.8.</p></li>\n</ul>\n</section>\n<section id=\"csrf\">\n<h4>CSRF<a class=\"heading-anchor\" href=\"#csrf\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The request header’s name used for CSRF authentication can be customized\nwith <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CSRF_HEADER_NAME\"><code class=\"xref std std-setting docutils literal notranslate\">CSRF_HEADER_NAME</code></a>.</p></li>\n<li><p>The CSRF referer header is now validated against the\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CSRF_COOKIE_DOMAIN\"><code class=\"xref std std-setting docutils literal notranslate\">CSRF_COOKIE_DOMAIN</code></a> setting if set. See <a class=\"reference internal\" href=\"/en/dev/ref/csrf/#how-csrf-works\"><span class=\"std std-ref\">How it works</span></a> for\ndetails.</p></li>\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CSRF_TRUSTED_ORIGINS\"><code class=\"xref std std-setting docutils literal notranslate\">CSRF_TRUSTED_ORIGINS</code></a> setting provides a way to allow\ncross-origin unsafe requests (e.g. <code class=\"docutils literal notranslate\">POST</code>) over HTTPS.</p></li>\n</ul>\n</section>\n<section id=\"database-backends\">\n<h4>Database backends<a class=\"heading-anchor\" href=\"#database-backends\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The PostgreSQL backend (<code class=\"docutils literal notranslate\">django.db.backends.postgresql_psycopg2</code>) is also\navailable as <code class=\"docutils literal notranslate\">django.db.backends.postgresql</code>. The old name will continue to\nbe available for backwards compatibility.</p></li>\n</ul>\n</section>\n<section id=\"file-storage\">\n<h4>File Storage<a class=\"heading-anchor\" href=\"#file-storage\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/files/storage/#django.core.files.storage.Storage.get_valid_name\" title=\"django.core.files.storage.Storage.get_valid_name\"><code class=\"xref py py-meth docutils literal notranslate\">Storage.get_valid_name()</code></a> is now called when\nthe <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.FileField.upload_to\" title=\"django.db.models.FileField.upload_to\"><code class=\"xref py py-attr docutils literal notranslate\">upload_to</code></a> is a callable.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/files/file/#django.core.files.File\" title=\"django.core.files.File\"><code class=\"xref py py-class docutils literal notranslate\">File</code></a> now has the <code class=\"docutils literal notranslate\">seekable()</code> method when using\nPython 3.</p></li>\n</ul>\n</section>\n<section id=\"forms\">\n<h4>Forms<a class=\"heading-anchor\" href=\"#forms\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/forms/modelforms/#django.forms.ModelForm\" title=\"django.forms.ModelForm\"><code class=\"xref py py-class docutils literal notranslate\">ModelForm</code></a> accepts the new <code class=\"docutils literal notranslate\">Meta</code> option\n<code class=\"docutils literal notranslate\">field_classes</code> to customize the type of the fields. See\n<a class=\"reference internal\" href=\"/en/dev/topics/forms/modelforms/#modelforms-overriding-default-fields\"><span class=\"std std-ref\">Overriding the default fields</span></a> for details.</p></li>\n<li><p>You can now specify the order in which form fields are rendered with the\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.field_order\" title=\"django.forms.Form.field_order\"><code class=\"xref py py-attr docutils literal notranslate\">field_order</code></a> attribute, the <code class=\"docutils literal notranslate\">field_order</code>\nconstructor argument , or the <a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.order_fields\" title=\"django.forms.Form.order_fields\"><code class=\"xref py py-meth docutils literal notranslate\">order_fields()</code></a> method.</p></li>\n<li><p>A form prefix can be specified inside a form class, not only when\ninstantiating a form. See <a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#form-prefix\"><span class=\"std std-ref\">Prefixes for forms</span></a> for details.</p></li>\n<li><p>You can now <a class=\"reference internal\" href=\"/en/dev/topics/forms/formsets/#custom-formset-form-kwargs\"><span class=\"std std-ref\">specify keyword arguments</span></a>\nthat you want to pass to the constructor of forms in a formset.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.SlugField\" title=\"django.forms.SlugField\"><code class=\"xref py py-class docutils literal notranslate\">SlugField</code></a> now accepts an\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.SlugField.allow_unicode\" title=\"django.forms.SlugField.allow_unicode\"><code class=\"xref py py-attr docutils literal notranslate\">allow_unicode</code></a> argument to allow Unicode\ncharacters in slugs.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.CharField\" title=\"django.forms.CharField\"><code class=\"xref py py-class docutils literal notranslate\">CharField</code></a> now accepts a\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.CharField.strip\" title=\"django.forms.CharField.strip\"><code class=\"xref py py-attr docutils literal notranslate\">strip</code></a> argument to strip input data of leading\nand trailing whitespace. As this defaults to <code class=\"docutils literal notranslate\">True</code> this is different\nbehavior from previous releases.</p></li>\n<li><p>Form fields now support the <a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.Field.disabled\" title=\"django.forms.Field.disabled\"><code class=\"xref py py-attr docutils literal notranslate\">disabled</code></a> argument,\nallowing the field widget to be displayed disabled by browsers.</p></li>\n<li><p>It’s now possible to customize bound fields by overriding a field’s\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.Field.get_bound_field\" title=\"django.forms.Field.get_bound_field\"><code class=\"xref py py-meth docutils literal notranslate\">get_bound_field()</code></a> method.</p></li>\n</ul>\n</section>\n<section id=\"generic-views\">\n<h4>Generic Views<a class=\"heading-anchor\" href=\"#generic-views\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>Class-based views generated using <code class=\"docutils literal notranslate\">as_view()</code> now have <code class=\"docutils literal notranslate\">view_class</code>\nand <code class=\"docutils literal notranslate\">view_initkwargs</code> attributes.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.decorators.method_decorator\" title=\"django.utils.decorators.method_decorator\"><code class=\"xref py py-func docutils literal notranslate\">method_decorator()</code></a> can now be used with a list\nor tuple of decorators. It can also be used to <a class=\"reference internal\" href=\"/en/dev/topics/class-based-views/intro/#id1\"><span class=\"std std-ref\">decorate classes instead\nof methods</span></a>.</p></li>\n</ul>\n</section>\n<section id=\"internationalization\">\n<h4>Internationalization<a class=\"heading-anchor\" href=\"#internationalization\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#django.views.i18n.set_language\" title=\"django.views.i18n.set_language\"><code class=\"xref py py-func docutils literal notranslate\">django.views.i18n.set_language()</code></a> view now properly redirects to\n<a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#url-internationalization\"><span class=\"std std-ref\">translated URLs</span></a>, when available.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">django.views.i18n.javascript_catalog()</code> view now works correctly\nif used multiple times with different configurations on the same page.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.timezone.make_aware\" title=\"django.utils.timezone.make_aware\"><code class=\"xref py py-func docutils literal notranslate\">django.utils.timezone.make_aware()</code></a> function gained an <code class=\"docutils literal notranslate\">is_dst</code>\nargument to help resolve ambiguous times during DST transitions.</p></li>\n<li><p>You can now use locale variants supported by gettext. These are usually used\nfor languages which can be written in different scripts, for example Latin\nand Cyrillic (e.g. <code class=\"docutils literal notranslate\">be&#64;latin</code>).</p></li>\n<li><p>Added the <code class=\"docutils literal notranslate\">django.views.i18n.json_catalog()</code> view to help build a custom\nclient-side i18n library upon Django translations. It returns a JSON object\ncontaining a translations catalog, formatting settings, and a plural rule.</p></li>\n<li><p>Added the <code class=\"docutils literal notranslate\">name_translated</code> attribute to the object returned by the\n<a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#std-templatetag-get_language_info\"><code class=\"xref std std-ttag docutils literal notranslate\">get_language_info</code></a> template tag. Also added a corresponding template\nfilter: <a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#std-templatefilter-language_name_translated\"><code class=\"xref std std-tfilter docutils literal notranslate\">language_name_translated</code></a>.</p></li>\n<li><p>You can now run <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-compilemessages\"><code class=\"xref std std-djadmin docutils literal notranslate\">compilemessages</code></a> from the root directory of your\nproject and it will find all the app message files that were created by\n<a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-makemessages\"><code class=\"xref std std-djadmin docutils literal notranslate\">makemessages</code></a>.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-makemessages\"><code class=\"xref std std-djadmin docutils literal notranslate\">makemessages</code></a> now calls <code class=\"docutils literal notranslate\">xgettext</code> once per locale directory\nrather than once per translatable file. This speeds up localization builds.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#std-templatetag-blocktrans\"><code class=\"xref std std-ttag docutils literal notranslate\">blocktrans</code></a> supports assigning its output to a variable using\n<code class=\"docutils literal notranslate\">asvar</code>.</p></li>\n<li><p>Two new languages are available: Colombian Spanish and Scottish Gaelic.</p></li>\n</ul>\n</section>\n<section id=\"management-commands\">\n<h4>Management Commands<a class=\"heading-anchor\" href=\"#management-commands\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-sendtestemail\"><code class=\"xref std std-djadmin docutils literal notranslate\">sendtestemail</code></a> command lets you send a test email to\neasily confirm that email sending through Django is working.</p></li>\n<li><p>To increase the readability of the SQL code generated by\n<a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-sqlmigrate\"><code class=\"xref std std-djadmin docutils literal notranslate\">sqlmigrate</code></a>, the SQL code generated for each migration operation is\npreceded by the operation’s description.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-dumpdata\"><code class=\"xref std std-djadmin docutils literal notranslate\">dumpdata</code></a> command output is now deterministically ordered.\nMoreover, when the <code class=\"docutils literal notranslate\">--output</code> option is specified, it also shows a progress\nbar in the terminal.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-createcachetable\"><code class=\"xref std std-djadmin docutils literal notranslate\">createcachetable</code></a> command now has a <code class=\"docutils literal notranslate\">--dry-run</code> flag to\nprint out the SQL rather than execute it.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-startapp\"><code class=\"xref std std-djadmin docutils literal notranslate\">startapp</code></a> command creates an <code class=\"docutils literal notranslate\">apps.py</code> file. Since it doesn’t\nuse <code class=\"docutils literal notranslate\">default_app_config</code> (<a class=\"reference internal\" href=\"/en/dev/ref/applications/#configuring-applications-ref\"><span class=\"std std-ref\">a discouraged API</span></a>), you must specify the app config’s path,\ne.g. <code class=\"docutils literal notranslate\">'polls.apps.PollsConfig'</code>, in <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> for it to be\nused (instead of just <code class=\"docutils literal notranslate\">'polls'</code>).</p></li>\n<li><p>When using the PostgreSQL backend, the <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-dbshell\"><code class=\"xref std std-djadmin docutils literal notranslate\">dbshell</code></a> command can connect\nto the database using the password from your settings file (instead of\nrequiring it to be manually entered).</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">django</code> package may be run as a script, i.e. <code class=\"docutils literal notranslate\">python -m django</code>,\nwhich will behave the same as <code class=\"docutils literal notranslate\">django-admin</code>.</p></li>\n<li><p>Management commands that have the <code class=\"docutils literal notranslate\">--noinput</code> option now also take\n<code class=\"docutils literal notranslate\">--no-input</code> as an alias for that option.</p></li>\n</ul>\n</section>\n<section id=\"migrations\">\n<h4>Migrations<a class=\"heading-anchor\" href=\"#migrations\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul>\n<li><p>Initial migrations are now marked with an <a class=\"reference internal\" href=\"/en/dev/topics/migrations/#django.db.migrations.Migration.initial\" title=\"django.db.migrations.Migration.initial\"><code class=\"xref py py-attr docutils literal notranslate\">initial = True</code></a> class attribute which allows\n<a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#cmdoption-migrate-fake-initial\"><code class=\"xref std std-option docutils literal notranslate\">migrate --fake-initial</code></a> to more easily detect initial migrations.</p></li>\n<li><p>Added support for serialization of <code class=\"docutils literal notranslate\">functools.partial</code> and <code class=\"docutils literal notranslate\">LazyObject</code>\ninstances.</p></li>\n<li><p>When supplying <code class=\"docutils literal notranslate\">None</code> as a value in <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-MIGRATION_MODULES\"><code class=\"xref std std-setting docutils literal notranslate\">MIGRATION_MODULES</code></a>, Django\nwill consider the app an app without migrations.</p></li>\n<li><p>When applying migrations, the “Rendering model states” step that’s displayed\nwhen running migrate with verbosity 2 or higher now computes only the states\nfor the migrations that have already been applied. The model states for\nmigrations being applied are generated on demand, drastically reducing the\namount of required memory.</p>\n<p>However, this improvement is not available when unapplying migrations and\ntherefore still requires the precomputation and storage of the intermediate\nmigration states.</p>\n<p>This improvement also requires that Django no longer supports mixed migration\nplans. Mixed plans consist of a list of migrations where some are being\napplied and others are being unapplied. This was never officially supported\nand never had a public API that supports this behavior.</p>\n</li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-squashmigrations\"><code class=\"xref std std-djadmin docutils literal notranslate\">squashmigrations</code></a> command now supports specifying the starting\nmigration from which migrations will be squashed.</p></li>\n</ul>\n</section>\n<section id=\"models\">\n<h4>Models<a class=\"heading-anchor\" href=\"#models\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.bulk_create\" title=\"django.db.models.query.QuerySet.bulk_create\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.bulk_create()</code></a>\nnow works on proxy models.</p></li>\n<li><p>Database configuration gained a <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-DATABASE-TIME_ZONE\"><code class=\"xref std std-setting docutils literal notranslate\">TIME_ZONE</code></a>\noption for interacting with databases that store datetimes in local time and\ndon’t support time zones when <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-USE_TZ\"><code class=\"xref std std-setting docutils literal notranslate\">USE_TZ</code></a> is <code class=\"docutils literal notranslate\">True</code>.</p></li>\n<li><p>Added the <a class=\"reference internal\" href=\"/en/dev/ref/models/relations/#django.db.models.fields.related.RelatedManager.set\" title=\"django.db.models.fields.related.RelatedManager.set\"><code class=\"xref py py-meth docutils literal notranslate\">RelatedManager.set()</code></a> method to the related\nmanagers created by <code class=\"docutils literal notranslate\">ForeignKey</code>, <code class=\"docutils literal notranslate\">GenericForeignKey</code>, and\n<code class=\"docutils literal notranslate\">ManyToManyField</code>.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/models/relations/#django.db.models.fields.related.RelatedManager.add\" title=\"django.db.models.fields.related.RelatedManager.add\"><code class=\"xref py py-meth docutils literal notranslate\">add()</code></a> method on\na reverse foreign key now has a <code class=\"docutils literal notranslate\">bulk</code> parameter to allow executing one\nquery regardless of the number of objects being added rather than one query\nper object.</p></li>\n<li><p>Added the <code class=\"docutils literal notranslate\">keep_parents</code> parameter to <a class=\"reference internal\" href=\"/en/dev/ref/models/instances/#django.db.models.Model.delete\" title=\"django.db.models.Model.delete\"><code class=\"xref py py-meth docutils literal notranslate\">Model.delete()</code></a> to allow deleting only a child’s data in a\nmodel that uses multi-table inheritance.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/models/instances/#django.db.models.Model.delete\" title=\"django.db.models.Model.delete\"><code class=\"xref py py-meth docutils literal notranslate\">Model.delete()</code></a>\nand <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.delete\" title=\"django.db.models.query.QuerySet.delete\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.delete()</code></a> return\nthe number of objects deleted.</p></li>\n<li><p>Added a system check to prevent defining both <code class=\"docutils literal notranslate\">Meta.ordering</code> and\n<code class=\"docutils literal notranslate\">order_with_respect_to</code> on the same model.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-year\"><code class=\"xref std std-lookup docutils literal notranslate\">Date and time</code></a> lookups can be chained with other lookups\n(such as <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-exact\"><code class=\"xref std std-lookup docutils literal notranslate\">exact</code></a>, <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-gt\"><code class=\"xref std std-lookup docutils literal notranslate\">gt</code></a>, <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-lt\"><code class=\"xref std std-lookup docutils literal notranslate\">lt</code></a>, etc.). For example:\n<code class=\"docutils literal notranslate\">Entry.objects.filter(pub_date__month__gt=6)</code>.</p></li>\n<li><p>Time lookups (hour, minute, second) are now supported by\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.TimeField\" title=\"django.db.models.TimeField\"><code class=\"xref py py-class docutils literal notranslate\">TimeField</code></a> for all database backends. Support for\nbackends other than SQLite was added but undocumented in Django 1.7.</p></li>\n<li><p>You can specify the <code class=\"docutils literal notranslate\">output_field</code> parameter of the\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.Avg\" title=\"django.db.models.Avg\"><code class=\"xref py py-class docutils literal notranslate\">Avg</code></a> aggregate in order to aggregate over\nnon-numeric columns, such as <code class=\"docutils literal notranslate\">DurationField</code>.</p></li>\n<li><p>Added the <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-date\"><code class=\"xref std std-lookup docutils literal notranslate\">date</code></a> lookup to <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.DateTimeField\" title=\"django.db.models.DateTimeField\"><code class=\"xref py py-class docutils literal notranslate\">DateTimeField</code></a>\nto allow querying the field by only the date portion.</p></li>\n<li><p>Added the <a class=\"reference internal\" href=\"/en/dev/ref/models/database-functions/#django.db.models.functions.Greatest\" title=\"django.db.models.functions.Greatest\"><code class=\"xref py py-class docutils literal notranslate\">Greatest</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/models/database-functions/#django.db.models.functions.Least\" title=\"django.db.models.functions.Least\"><code class=\"xref py py-class docutils literal notranslate\">Least</code></a> database functions.</p></li>\n<li><p>Added the <a class=\"reference internal\" href=\"/en/dev/ref/models/database-functions/#django.db.models.functions.Now\" title=\"django.db.models.functions.Now\"><code class=\"xref py py-class docutils literal notranslate\">Now</code></a> database function, which\nreturns the current date and time.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/models/lookups/#django.db.models.Transform\" title=\"django.db.models.Transform\"><code class=\"xref py py-class docutils literal notranslate\">Transform</code></a> is now a subclass of\n<a class=\"reference internal\" href=\"/en/dev/ref/models/expressions/#func-expressions\"><span class=\"std std-ref\">Func()</span></a> which allows <code class=\"docutils literal notranslate\">Transform</code>s to be used on\nthe right hand side of an expression, just like regular <code class=\"docutils literal notranslate\">Func</code>s. This\nallows registering some database functions like\n<a class=\"reference internal\" href=\"/en/dev/ref/models/database-functions/#django.db.models.functions.Length\" title=\"django.db.models.functions.Length\"><code class=\"xref py py-class docutils literal notranslate\">Length</code></a>,\n<a class=\"reference internal\" href=\"/en/dev/ref/models/database-functions/#django.db.models.functions.Lower\" title=\"django.db.models.functions.Lower\"><code class=\"xref py py-class docutils literal notranslate\">Lower</code></a>, and\n<a class=\"reference internal\" href=\"/en/dev/ref/models/database-functions/#django.db.models.functions.Upper\" title=\"django.db.models.functions.Upper\"><code class=\"xref py py-class docutils literal notranslate\">Upper</code></a> as transforms.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.SlugField\" title=\"django.db.models.SlugField\"><code class=\"xref py py-class docutils literal notranslate\">SlugField</code></a> now accepts an\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.SlugField.allow_unicode\" title=\"django.db.models.SlugField.allow_unicode\"><code class=\"xref py py-attr docutils literal notranslate\">allow_unicode</code></a> argument to allow Unicode\ncharacters in slugs.</p></li>\n<li><p>Added support for referencing annotations in <code class=\"docutils literal notranslate\">QuerySet.distinct()</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">connection.queries</code> shows queries with substituted parameters on SQLite.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/models/expressions/\"><span class=\"doc\">Query expressions</span></a> can now be used when\ncreating new model instances using <code class=\"docutils literal notranslate\">save()</code>, <code class=\"docutils literal notranslate\">create()</code>, and\n<code class=\"docutils literal notranslate\">bulk_create()</code>.</p></li>\n</ul>\n</section>\n<section id=\"requests-and-responses\">\n<h4>Requests and Responses<a class=\"heading-anchor\" href=\"#requests-and-responses\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>Unless <a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpResponse.reason_phrase\" title=\"django.http.HttpResponse.reason_phrase\"><code class=\"xref py py-attr docutils literal notranslate\">HttpResponse.reason_phrase</code></a> is explicitly set, it now is\ndetermined by the current value of <a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpResponse.status_code\" title=\"django.http.HttpResponse.status_code\"><code class=\"xref py py-attr docutils literal notranslate\">HttpResponse.status_code</code></a>. Modifying the value of\n<code class=\"docutils literal notranslate\">status_code</code> outside of the constructor will also modify the value of\n<code class=\"docutils literal notranslate\">reason_phrase</code>.</p></li>\n<li><p>The debug view now shows details of chained exceptions on Python 3.</p></li>\n<li><p>The default 40x error views now accept a second positional parameter, the\nexception that triggered the view.</p></li>\n<li><p>View error handlers now support\n<a class=\"reference internal\" href=\"/en/dev/ref/template-response/#django.template.response.TemplateResponse\" title=\"django.template.response.TemplateResponse\"><code class=\"xref py py-class docutils literal notranslate\">TemplateResponse</code></a>, commonly used with\nclass-based views.</p></li>\n<li><p>Exceptions raised by the <code class=\"docutils literal notranslate\">render()</code> method are now passed to the\n<code class=\"docutils literal notranslate\">process_exception()</code> method of each middleware.</p></li>\n<li><p>Request middleware can now set <a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpRequest.urlconf\" title=\"django.http.HttpRequest.urlconf\"><code class=\"xref py py-attr docutils literal notranslate\">HttpRequest.urlconf</code></a> to <code class=\"docutils literal notranslate\">None</code> to revert any changes made\nby previous middleware and return to using the <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-ROOT_URLCONF\"><code class=\"xref std std-setting docutils literal notranslate\">ROOT_URLCONF</code></a>.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-DISALLOWED_USER_AGENTS\"><code class=\"xref std std-setting docutils literal notranslate\">DISALLOWED_USER_AGENTS</code></a> check in\n<a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.middleware.common.CommonMiddleware\" title=\"django.middleware.common.CommonMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">CommonMiddleware</code></a> now raises a\n<a class=\"reference internal\" href=\"/en/dev/ref/exceptions/#django.core.exceptions.PermissionDenied\" title=\"django.core.exceptions.PermissionDenied\"><code class=\"xref py py-class docutils literal notranslate\">PermissionDenied</code></a> exception as opposed to\nreturning an <a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpResponseForbidden\" title=\"django.http.HttpResponseForbidden\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponseForbidden</code></a> so that\n<a class=\"reference internal\" href=\"/en/dev/ref/urls/#django.conf.urls.handler403\" title=\"django.conf.urls.handler403\"><code class=\"xref py py-data docutils literal notranslate\">handler403</code></a> is invoked.</p></li>\n<li><p>Added <a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpRequest.get_port\" title=\"django.http.HttpRequest.get_port\"><code class=\"xref py py-meth docutils literal notranslate\">HttpRequest.get_port()</code></a> to\nfetch the originating port of the request.</p></li>\n<li><p>Added the <code class=\"docutils literal notranslate\">json_dumps_params</code> parameter to\n<a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.JsonResponse\" title=\"django.http.JsonResponse\"><code class=\"xref py py-class docutils literal notranslate\">JsonResponse</code></a> to allow passing keyword arguments to the\n<code class=\"docutils literal notranslate\">json.dumps()</code> call used to generate the response.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.middleware.common.BrokenLinkEmailsMiddleware\" title=\"django.middleware.common.BrokenLinkEmailsMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">BrokenLinkEmailsMiddleware</code></a> now\nignores 404s when the referer is equal to the requested URL. To circumvent\nthe empty referer check already implemented, some web bots set the referer to\nthe requested URL.</p></li>\n</ul>\n</section>\n<section id=\"templates\">\n<h4>Templates<a class=\"heading-anchor\" href=\"#templates\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>Template tags created with the <a class=\"reference internal\" href=\"/en/dev/howto/custom-template-tags/#django.template.Library.simple_tag\" title=\"django.template.Library.simple_tag\"><code class=\"xref py py-meth docutils literal notranslate\">simple_tag()</code></a>\nhelper can now store results in a template variable by using the <code class=\"docutils literal notranslate\">as</code>\nargument.</p></li>\n<li><p>Added a <a class=\"reference internal\" href=\"/en/dev/ref/templates/api/#django.template.Context.setdefault\" title=\"django.template.Context.setdefault\"><code class=\"xref py py-meth docutils literal notranslate\">Context.setdefault()</code></a>\nmethod.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/logging/#django-template-logger\"><span class=\"std std-ref\">django.template</span></a> logger was added and\nincludes the following messages:</p>\n<ul>\n<li><p>A <code class=\"docutils literal notranslate\">DEBUG</code> level message for missing context variables.</p></li>\n<li><p>A <code class=\"docutils literal notranslate\">WARNING</code> level message for uncaught exceptions raised\nduring the rendering of an <code class=\"docutils literal notranslate\">{% include %}</code> when debug mode is off\n(helpful since <code class=\"docutils literal notranslate\">{% include %}</code> silences the exception and returns an\nempty string).</p></li>\n</ul>\n</li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-firstof\"><code class=\"xref std std-ttag docutils literal notranslate\">firstof</code></a> template tag supports storing the output in a variable\nusing ‘as’.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/templates/api/#django.template.Context.update\" title=\"django.template.Context.update\"><code class=\"xref py py-meth docutils literal notranslate\">Context.update()</code></a> can now be used as\na context manager.</p></li>\n<li><p>Django template loaders can now extend templates recursively.</p></li>\n<li><p>The debug page template postmortem now include output from each engine that\nis installed.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/howto/custom-template-backend/#template-debug-integration\"><span class=\"std std-ref\">Debug page integration</span></a> for custom\ntemplate engines was added.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/topics/templates/#django.template.backends.django.DjangoTemplates\" title=\"django.template.backends.django.DjangoTemplates\"><code class=\"xref py py-class docutils literal notranslate\">DjangoTemplates</code></a> backend gained\nthe ability to register libraries and builtins explicitly through the\ntemplate <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-TEMPLATES-OPTIONS\"><code class=\"xref std std-setting docutils literal notranslate\">OPTIONS</code></a>.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">timesince</code> and <code class=\"docutils literal notranslate\">timeuntil</code> filters were improved to deal with leap\nyears when given large time spans.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">include</code> tag now caches parsed templates objects during template\nrendering, speeding up reuse in places such as for loops.</p></li>\n</ul>\n</section>\n<section id=\"tests\">\n<h4>Tests<a class=\"heading-anchor\" href=\"#tests\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>Added the <a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.Response.json\" title=\"django.test.Response.json\"><code class=\"xref py py-meth docutils literal notranslate\">json()</code></a> method to test client\nresponses to give access to the response body as JSON.</p></li>\n<li><p>Added the <a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.Client.force_login\" title=\"django.test.Client.force_login\"><code class=\"xref py py-meth docutils literal notranslate\">force_login()</code></a> method to the test\nclient. Use this method to simulate the effect of a user logging into the\nsite while skipping the authentication and verification steps of\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.Client.login\" title=\"django.test.Client.login\"><code class=\"xref py py-meth docutils literal notranslate\">login()</code></a>.</p></li>\n</ul>\n</section>\n<section id=\"urls\">\n<h4>URLs<a class=\"heading-anchor\" href=\"#urls\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>Regular expression lookaround assertions are now allowed in URL patterns.</p></li>\n<li><p>The application namespace can now be set using an <code class=\"docutils literal notranslate\">app_name</code> attribute\non the included module or object. It can also be set by passing a 2-tuple\nof (&lt;list of patterns&gt;, &lt;application namespace&gt;) as the first argument to\n<code class=\"docutils literal notranslate\">include()</code>.</p></li>\n<li><p>System checks have been added for common URL pattern mistakes.</p></li>\n</ul>\n</section>\n<section id=\"validators\">\n<h4>Validators<a class=\"heading-anchor\" href=\"#validators\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>Added <a class=\"reference internal\" href=\"/en/dev/ref/validators/#django.core.validators.int_list_validator\" title=\"django.core.validators.int_list_validator\"><code class=\"xref py py-func docutils literal notranslate\">django.core.validators.int_list_validator()</code></a> to generate\nvalidators of strings containing integers separated with a custom character.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/validators/#django.core.validators.EmailValidator\" title=\"django.core.validators.EmailValidator\"><code class=\"xref py py-class docutils literal notranslate\">EmailValidator</code></a> now limits the length of\ndomain name labels to 63 characters per <span class=\"target\" id=\"index-0\"></span><a class=\"rfc reference external\" href=\"https://datatracker.ietf.org/doc/html/rfc1034.html\"><strong>RFC 1034</strong></a>.</p></li>\n<li><p>Added <a class=\"reference internal\" href=\"/en/dev/ref/validators/#django.core.validators.validate_unicode_slug\" title=\"django.core.validators.validate_unicode_slug\"><code class=\"xref py py-func docutils literal notranslate\">validate_unicode_slug()</code></a> to validate slugs\nthat may contain Unicode characters.</p></li>\n</ul>\n</section>\n</section>\n</section>\n<section id=\"backwards-incompatible-changes-in-1-9\">\n<span id=\"backwards-incompatible-1-9\"></span><h2>Backwards incompatible changes in 1.9<a class=\"heading-anchor\" href=\"#backwards-incompatible-changes-in-1-9\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Warning</p>\n<p>In addition to the changes outlined in this section, be sure to review the\n<a class=\"reference internal\" href=\"#removed-features-1-9\"><span class=\"std std-ref\">Features removed in 1.9</span></a> for the features that have reached the end of\ntheir deprecation cycle and therefore been removed. If you haven’t updated\nyour code within the deprecation timeline for a given feature, its removal\nmay appear as a backwards incompatible change.</p>\n</aside>\n<section id=\"database-backend-api\">\n<h3>Database backend API<a class=\"heading-anchor\" href=\"#database-backend-api\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<ul>\n<li><p>A couple of new tests rely on the ability of the backend to introspect column\ndefaults (returning the result as <code class=\"docutils literal notranslate\">Field.default</code>). You can set the\n<code class=\"docutils literal notranslate\">can_introspect_default</code> database feature to <code class=\"docutils literal notranslate\">False</code> if your backend\ndoesn’t implement this. You may want to review the implementation on the\nbackends that Django includes for reference (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/24245\">#24245</a>).</p></li>\n<li><p>Registering a global adapter or converter at the level of the DB-API module\nto handle time zone information of <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime</code></a> values passed\nas query parameters or returned as query results on databases that don’t\nsupport time zones is discouraged. It can conflict with other libraries.</p>\n<p>The recommended way to add a time zone to <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime</code></a> values\nfetched from the database is to register a converter for <code class=\"docutils literal notranslate\">DateTimeField</code>\nin <code class=\"docutils literal notranslate\">DatabaseOperations.get_db_converters()</code>.</p>\n<p>The <code class=\"docutils literal notranslate\">needs_datetime_string_cast</code> database feature was removed. Database\nbackends that set it must register a converter instead, as explained above.</p>\n</li>\n<li><p>The <code class=\"docutils literal notranslate\">DatabaseOperations.value_to_db_&lt;type&gt;()</code> methods were renamed to\n<code class=\"docutils literal notranslate\">adapt_&lt;type&gt;field_value()</code> to mirror the <code class=\"docutils literal notranslate\">convert_&lt;type&gt;field_value()</code>\nmethods.</p></li>\n<li><p>To use the new <code class=\"docutils literal notranslate\">date</code> lookup, third-party database backends may need to\nimplement the <code class=\"docutils literal notranslate\">DatabaseOperations.datetime_cast_date_sql()</code> method.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">DatabaseOperations.time_extract_sql()</code> method was added. It calls the\nexisting <code class=\"docutils literal notranslate\">date_extract_sql()</code> method. This method is overridden by the\nSQLite backend to add time lookups (hour, minute, second) to\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.TimeField\" title=\"django.db.models.TimeField\"><code class=\"xref py py-class docutils literal notranslate\">TimeField</code></a>, and may be needed by third-party\ndatabase backends.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">DatabaseOperations.datetime_cast_sql()</code> method (not to be confused\nwith <code class=\"docutils literal notranslate\">DatabaseOperations.datetime_cast_date_sql()</code> mentioned above)\nhas been removed. This method served to format dates on Oracle long\nbefore 1.0, but hasn’t been overridden by any core backend in years\nand hasn’t been called anywhere in Django’s code or tests.</p></li>\n<li><p>In order to support test parallelization, you must implement the\n<code class=\"docutils literal notranslate\">DatabaseCreation._clone_test_db()</code> method and set\n<code class=\"docutils literal notranslate\">DatabaseFeatures.can_clone_databases = True</code>. You may have to adjust\n<code class=\"docutils literal notranslate\">DatabaseCreation.get_test_db_clone_settings()</code>.</p></li>\n</ul>\n</section>\n<section id=\"default-settings-that-were-tuples-are-now-lists\">\n<h3>Default settings that were tuples are now lists<a class=\"heading-anchor\" href=\"#default-settings-that-were-tuples-are-now-lists\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The default settings in <code class=\"docutils literal notranslate\">django.conf.global_settings</code> were a combination of\nlists and tuples. All settings that were formerly tuples are now lists.</p>\n</section>\n<section id=\"is-usable-attribute-on-template-loaders-is-removed\">\n<h3><code class=\"docutils literal notranslate\">is_usable</code> attribute on template loaders is removed<a class=\"heading-anchor\" href=\"#is-usable-attribute-on-template-loaders-is-removed\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django template loaders previously required an <code class=\"docutils literal notranslate\">is_usable</code> attribute to be\ndefined. If a loader was configured in the template settings and this attribute\nwas <code class=\"docutils literal notranslate\">False</code>, the loader would be silently ignored. In practice, this was only\nused by the egg loader to detect if <code class=\"docutils literal notranslate\">setuptools</code> was installed. The\n<code class=\"docutils literal notranslate\">is_usable</code> attribute is now removed and the egg loader instead fails at\nruntime if <code class=\"docutils literal notranslate\">setuptools</code> is not installed.</p>\n</section>\n<section id=\"related-set-direct-assignment\">\n<h3>Related set direct assignment<a class=\"heading-anchor\" href=\"#related-set-direct-assignment\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Direct assignment of related objects in the ORM used to perform a <code class=\"docutils literal notranslate\">clear()</code>\nfollowed by a call to <code class=\"docutils literal notranslate\">add()</code>. This caused needlessly large data changes and\nprevented using the <a class=\"reference internal\" href=\"/en/dev/ref/signals/#django.db.models.signals.m2m_changed\" title=\"django.db.models.signals.m2m_changed\"><code class=\"xref py py-data docutils literal notranslate\">m2m_changed</code></a> signal to\ntrack individual changes in many-to-many relations.</p>\n<p>Direct assignment now relies on the new\n<a class=\"reference internal\" href=\"/en/dev/ref/models/relations/#django.db.models.fields.related.RelatedManager.set\" title=\"django.db.models.fields.related.RelatedManager.set\"><code class=\"xref py py-meth docutils literal notranslate\">set()</code></a> method on related\nmanagers which by default only processes changes between the existing related\nset and the one that’s newly assigned. The previous behavior can be restored by\nreplacing direct assignment by a call to <code class=\"docutils literal notranslate\">set()</code> with the keyword argument\n<code class=\"docutils literal notranslate\">clear=True</code>.</p>\n<p><code class=\"docutils literal notranslate\">ModelForm</code>, and therefore <code class=\"docutils literal notranslate\">ModelAdmin</code>, internally rely on direct\nassignment for many-to-many relations and as a consequence now use the new\nbehavior.</p>\n</section>\n<section id=\"filesystem-based-template-loaders-catch-more-specific-exceptions\">\n<h3>Filesystem-based template loaders catch more specific exceptions<a class=\"heading-anchor\" href=\"#filesystem-based-template-loaders-catch-more-specific-exceptions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>When using the\n<a class=\"reference internal\" href=\"/en/dev/ref/templates/api/#django.template.loaders.filesystem.Loader\" title=\"django.template.loaders.filesystem.Loader\"><code class=\"xref py py-class docutils literal notranslate\">filesystem.Loader</code></a> or\n<a class=\"reference internal\" href=\"/en/dev/ref/templates/api/#django.template.loaders.app_directories.Loader\" title=\"django.template.loaders.app_directories.Loader\"><code class=\"xref py py-class docutils literal notranslate\">app_directories.Loader</code></a>\ntemplate loaders, earlier versions of Django raised a\n<a class=\"reference internal\" href=\"/en/dev/topics/templates/#django.template.TemplateDoesNotExist\" title=\"django.template.TemplateDoesNotExist\"><code class=\"xref py py-exc docutils literal notranslate\">TemplateDoesNotExist</code></a> error if a template source existed\nbut was unreadable. This could happen under many circumstances, such as if\nDjango didn’t have permissions to open the file, or if the template source was\na directory. Now, Django only silences the exception if the template source\ndoes not exist. All other situations result in the original <code class=\"docutils literal notranslate\">IOError</code> being\nraised.</p>\n</section>\n<section id=\"http-redirects-no-longer-forced-to-absolute-uris\">\n<h3>HTTP redirects no longer forced to absolute URIs<a class=\"heading-anchor\" href=\"#http-redirects-no-longer-forced-to-absolute-uris\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Relative redirects are no longer converted to absolute URIs. <span class=\"target\" id=\"index-1\"></span><a class=\"rfc reference external\" href=\"https://datatracker.ietf.org/doc/html/rfc2616.html\"><strong>RFC 2616</strong></a>\nrequired the <code class=\"docutils literal notranslate\">Location</code> header in redirect responses to be an absolute URI,\nbut it has been superseded by <span class=\"target\" id=\"index-2\"></span><a class=\"rfc reference external\" href=\"https://datatracker.ietf.org/doc/html/rfc7231.html\"><strong>RFC 7231</strong></a> which allows relative URIs in\n<code class=\"docutils literal notranslate\">Location</code>, recognizing the actual practice of user agents, almost all of\nwhich support them.</p>\n<p>Consequently, the expected URLs passed to <code class=\"docutils literal notranslate\">assertRedirects</code> should generally\nno longer include the scheme and domain part of the URLs. For example,\n<code class=\"docutils literal notranslate\">self.assertRedirects(response, 'http://testserver/some-url/')</code> should be\nreplaced by <code class=\"docutils literal notranslate\">self.assertRedirects(response, '/some-url/')</code> (unless the\nredirection specifically contained an absolute URL).</p>\n<p>In the rare case that you need the old behavior (discovered with an ancient\nversion of Apache with <code class=\"docutils literal notranslate\">mod_scgi</code> that interprets a relative redirect as an\n“internal redirect”), you can restore it by writing a custom middleware:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">class</span> <span class=\"nc\">LocationHeaderFix</span><span class=\"p\">(</span><span class=\"nb\">object</span><span class=\"p\">):</span>\n    <span class=\"k\">def</span> <span class=\"nf\">process_response</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">,</span> request<span class=\"p\">,</span> response<span class=\"p\">):</span>\n        <span class=\"k\">if</span> <span class=\"s2\">&quot;Location&quot;</span> <span class=\"ow\">in</span> response<span class=\"p\">:</span>\n            response<span class=\"p\">[</span><span class=\"s2\">&quot;Location&quot;</span><span class=\"p\">]</span> <span class=\"o\">=</span> request<span class=\"o\">.</span>build_absolute_uri<span class=\"p\">(</span>response<span class=\"p\">[</span><span class=\"s2\">&quot;Location&quot;</span><span class=\"p\">])</span>\n        <span class=\"k\">return</span> response\n</code></pre></div>\n</section>\n<section id=\"dropped-support-for-postgresql-9-0\">\n<h3>Dropped support for PostgreSQL 9.0<a class=\"heading-anchor\" href=\"#dropped-support-for-postgresql-9-0\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Upstream support for PostgreSQL 9.0 ended in September 2015. As a consequence,\nDjango 1.9 sets 9.1 as the minimum PostgreSQL version it officially supports.</p>\n</section>\n<section id=\"dropped-support-for-oracle-11-1\">\n<h3>Dropped support for Oracle 11.1<a class=\"heading-anchor\" href=\"#dropped-support-for-oracle-11-1\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Upstream support for Oracle 11.1 ended in August 2015. As a consequence, Django\n1.9 sets 11.2 as the minimum Oracle version it officially supports.</p>\n</section>\n<section id=\"bulk-behavior-of-add-method-of-related-managers\">\n<h3>Bulk behavior of <code class=\"docutils literal notranslate\">add()</code> method of related managers<a class=\"heading-anchor\" href=\"#bulk-behavior-of-add-method-of-related-managers\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>To improve performance, the <code class=\"docutils literal notranslate\">add()</code> methods of the related managers created\nby <code class=\"docutils literal notranslate\">ForeignKey</code> and <code class=\"docutils literal notranslate\">GenericForeignKey</code> changed from a series of\n<code class=\"docutils literal notranslate\">Model.save()</code> calls to a single <code class=\"docutils literal notranslate\">QuerySet.update()</code> call. The change means\nthat <code class=\"docutils literal notranslate\">pre_save</code> and <code class=\"docutils literal notranslate\">post_save</code> signals aren’t sent anymore. You can use\nthe <code class=\"docutils literal notranslate\">bulk=False</code> keyword argument to revert to the previous behavior.</p>\n</section>\n<section id=\"template-loaderorigin-and-stringorigin-are-removed\">\n<h3>Template <code class=\"docutils literal notranslate\">LoaderOrigin</code> and <code class=\"docutils literal notranslate\">StringOrigin</code> are removed<a class=\"heading-anchor\" href=\"#template-loaderorigin-and-stringorigin-are-removed\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>In previous versions of Django, when a template engine was initialized with\ndebug as <code class=\"docutils literal notranslate\">True</code>, an instance of <code class=\"docutils literal notranslate\">django.template.loader.LoaderOrigin</code> or\n<code class=\"docutils literal notranslate\">django.template.base.StringOrigin</code> was set as the origin attribute on the\ntemplate object. These classes have been combined into\n<a class=\"reference internal\" href=\"/en/dev/ref/templates/api/#django.template.base.Origin\" title=\"django.template.base.Origin\"><code class=\"xref py py-class docutils literal notranslate\">Origin</code></a> and is now always set regardless of the\nengine debug setting. For a minimal level of backwards compatibility, the old\nclass names will be kept as aliases to the new <code class=\"docutils literal notranslate\">Origin</code> class until\nDjango 2.0.</p>\n</section>\n<section id=\"changes-to-the-default-logging-configuration\">\n<span id=\"default-logging-changes-19\"></span><h3>Changes to the default logging configuration<a class=\"heading-anchor\" href=\"#changes-to-the-default-logging-configuration\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>To make it easier to write custom logging configurations, Django’s default\nlogging configuration no longer defines <code class=\"docutils literal notranslate\">django.request</code> and\n<code class=\"docutils literal notranslate\">django.security</code> loggers. Instead, it defines a single <code class=\"docutils literal notranslate\">django</code> logger,\nfiltered at the <code class=\"docutils literal notranslate\">INFO</code> level, with two handlers:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">console</code>: filtered at the <code class=\"docutils literal notranslate\">INFO</code> level and only active if <code class=\"docutils literal notranslate\">DEBUG=True</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">mail_admins</code>: filtered at the <code class=\"docutils literal notranslate\">ERROR</code> level and only active if\n<code class=\"docutils literal notranslate\">DEBUG=False</code>.</p></li>\n</ul>\n<p>If you aren’t overriding Django’s default logging, you should see minimal\nchanges in behavior, but you might see some new logging to the <code class=\"docutils literal notranslate\">runserver</code>\nconsole, for example.</p>\n<p>If you are overriding Django’s default logging, you should check to see how\nyour configuration merges with the new defaults.</p>\n</section>\n<section id=\"httprequest-details-in-error-reporting\">\n<h3><code class=\"docutils literal notranslate\">HttpRequest</code> details in error reporting<a class=\"heading-anchor\" href=\"#httprequest-details-in-error-reporting\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>It was redundant to display the full details of the\n<a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpRequest\" title=\"django.http.HttpRequest\"><code class=\"xref py py-class docutils literal notranslate\">HttpRequest</code></a> each time it appeared as a stack frame\nvariable in the HTML version of the debug page and error email. Thus, the HTTP\nrequest will now display the same standard representation as other variables\n(<code class=\"docutils literal notranslate\">repr(request)</code>). As a result, the\n<code class=\"docutils literal notranslate\">ExceptionReporterFilter.get_request_repr()</code> method and the undocumented\n<code class=\"docutils literal notranslate\">django.http.build_request_repr()</code> function were removed.</p>\n<p>The contents of the text version of the email were modified to provide a\ntraceback of the same structure as in the case of AJAX requests. The traceback\ndetails are rendered by the <code class=\"docutils literal notranslate\">ExceptionReporter.get_traceback_text()</code> method.</p>\n</section>\n<section id=\"removal-of-time-zone-aware-global-adapters-and-converters-for-datetimes\">\n<h3>Removal of time zone aware global adapters and converters for datetimes<a class=\"heading-anchor\" href=\"#removal-of-time-zone-aware-global-adapters-and-converters-for-datetimes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django no longer registers global adapters and converters for managing time\nzone information on <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime</code></a> values sent to the database as\nquery parameters or read from the database in query results. This change\naffects projects that meet all the following conditions:</p>\n<ul class=\"simple\">\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-USE_TZ\"><code class=\"xref std std-setting docutils literal notranslate\">USE_TZ</code></a> setting is <code class=\"docutils literal notranslate\">True</code>.</p></li>\n<li><p>The database is SQLite, MySQL, Oracle, or a third-party database that\ndoesn’t support time zones. In doubt, you can check the value of\n<code class=\"docutils literal notranslate\">connection.features.supports_timezones</code>.</p></li>\n<li><p>The code queries the database outside of the ORM, typically with\n<code class=\"docutils literal notranslate\">cursor.execute(sql, params)</code>.</p></li>\n</ul>\n<p>If you’re passing aware <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime</code></a> parameters to such\nqueries, you should turn them into naive datetimes in UTC:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.utils</span> <span class=\"kn\">import</span> timezone\n\nparam <span class=\"o\">=</span> timezone<span class=\"o\">.</span>make_naive<span class=\"p\">(</span>param<span class=\"p\">,</span> timezone<span class=\"o\">.</span>utc<span class=\"p\">)</span>\n</code></pre></div>\n<p>If you fail to do so, the conversion will be performed as in earlier versions\n(with a deprecation warning) up until Django 1.11. Django 2.0 won’t perform any\nconversion, which may result in data corruption.</p>\n<p>If you’re reading <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime</code></a> values from the results, they\nwill be naive instead of aware. You can compensate as follows:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.utils</span> <span class=\"kn\">import</span> timezone\n\nvalue <span class=\"o\">=</span> timezone<span class=\"o\">.</span>make_aware<span class=\"p\">(</span>value<span class=\"p\">,</span> timezone<span class=\"o\">.</span>utc<span class=\"p\">)</span>\n</code></pre></div>\n<p>You don’t need any of this if you’re querying the database through the ORM,\neven if you’re using <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.raw\" title=\"django.db.models.query.QuerySet.raw\"><code class=\"xref py py-meth docutils literal notranslate\">raw()</code></a>\nqueries. The ORM takes care of managing time zone information.</p>\n</section>\n<section id=\"template-tag-modules-are-imported-when-templates-are-configured\">\n<h3>Template tag modules are imported when templates are configured<a class=\"heading-anchor\" href=\"#template-tag-modules-are-imported-when-templates-are-configured\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <a class=\"reference internal\" href=\"/en/dev/topics/templates/#django.template.backends.django.DjangoTemplates\" title=\"django.template.backends.django.DjangoTemplates\"><code class=\"xref py py-class docutils literal notranslate\">DjangoTemplates</code></a> backend now\nperforms discovery on installed template tag modules when instantiated. This\nupdate enables libraries to be provided explicitly via the <code class=\"docutils literal notranslate\">'libraries'</code>\nkey of <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-TEMPLATES-OPTIONS\"><code class=\"xref std std-setting docutils literal notranslate\">OPTIONS</code></a> when defining a\n<a class=\"reference internal\" href=\"/en/dev/topics/templates/#django.template.backends.django.DjangoTemplates\" title=\"django.template.backends.django.DjangoTemplates\"><code class=\"xref py py-class docutils literal notranslate\">DjangoTemplates</code></a> backend. Import\nor syntax errors in template tag modules now fail early at instantiation time\nrather than when a template with a <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-load\"><code class=\"xref std std-ttag docutils literal notranslate\">{% load %}</code></a> tag is first\ncompiled.</p>\n</section>\n<section id=\"django-template-base-add-to-builtins-is-removed\">\n<h3><code class=\"docutils literal notranslate\">django.template.base.add_to_builtins()</code> is removed<a class=\"heading-anchor\" href=\"#django-template-base-add-to-builtins-is-removed\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Although it was a private API, projects commonly used <code class=\"docutils literal notranslate\">add_to_builtins()</code> to\nmake template tags and filters available without using the\n<a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-load\"><code class=\"xref std std-ttag docutils literal notranslate\">{% load %}</code></a> tag. This API has been formalized. Projects should now\ndefine built-in libraries via the <code class=\"docutils literal notranslate\">'builtins'</code> key of <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-TEMPLATES-OPTIONS\"><code class=\"xref std std-setting docutils literal notranslate\">OPTIONS</code></a> when defining a\n<a class=\"reference internal\" href=\"/en/dev/topics/templates/#django.template.backends.django.DjangoTemplates\" title=\"django.template.backends.django.DjangoTemplates\"><code class=\"xref py py-class docutils literal notranslate\">DjangoTemplates</code></a> backend.</p>\n</section>\n<section id=\"simple-tag-now-wraps-tag-output-in-conditional-escape\">\n<span id=\"simple-tag-conditional-escape-fix\"></span><h3><code class=\"docutils literal notranslate\">simple_tag</code> now wraps tag output in <code class=\"docutils literal notranslate\">conditional_escape</code><a class=\"heading-anchor\" href=\"#simple-tag-now-wraps-tag-output-in-conditional-escape\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>In general, template tags do not autoescape their contents, and this behavior\nis <a class=\"reference internal\" href=\"/en/dev/howto/custom-template-tags/#tags-auto-escaping\"><span class=\"std std-ref\">documented</span></a>. For tags like\n<a class=\"reference internal\" href=\"/en/dev/howto/custom-template-tags/#django.template.Library.inclusion_tag\" title=\"django.template.Library.inclusion_tag\"><code class=\"xref py py-class docutils literal notranslate\">inclusion_tag</code></a>, this is not a problem because\nthe included template will perform autoescaping. For <code class=\"docutils literal notranslate\">assignment_tag()</code>,\nthe output will be escaped when it is used as a variable in the template.</p>\n<p>For the intended use cases of <a class=\"reference internal\" href=\"/en/dev/howto/custom-template-tags/#django.template.Library.simple_tag\" title=\"django.template.Library.simple_tag\"><code class=\"xref py py-class docutils literal notranslate\">simple_tag</code></a>,\nhowever, it is very easy to end up with incorrect HTML and possibly an XSS\nexploit. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"nd\">@register</span><span class=\"o\">.</span>simple_tag<span class=\"p\">(</span>takes_context<span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">)</span>\n<span class=\"k\">def</span> <span class=\"nf\">greeting</span><span class=\"p\">(</span>context<span class=\"p\">):</span>\n    <span class=\"k\">return</span> <span class=\"s2\">&quot;Hello </span><span class=\"si\">{0}</span><span class=\"s2\">!&quot;</span><span class=\"o\">.</span>format<span class=\"p\">(</span>context<span class=\"p\">[</span><span class=\"s2\">&quot;request&quot;</span><span class=\"p\">]</span><span class=\"o\">.</span>user<span class=\"o\">.</span>first_name<span class=\"p\">)</span>\n</code></pre></div>\n<p>In older versions of Django, this will be an XSS issue because\n<code class=\"docutils literal notranslate\">user.first_name</code> is not escaped.</p>\n<p>In Django 1.9, this is fixed: if the template context has <code class=\"docutils literal notranslate\">autoescape=True</code>\nset (the default), then <code class=\"docutils literal notranslate\">simple_tag</code> will wrap the output of the tag function\nwith <a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.html.conditional_escape\" title=\"django.utils.html.conditional_escape\"><code class=\"xref py py-func docutils literal notranslate\">conditional_escape()</code></a>.</p>\n<p>To fix your <code class=\"docutils literal notranslate\">simple_tag</code>s, it is best to apply the following practices:</p>\n<ul class=\"simple\">\n<li><p>Any code that generates HTML should use either the template system or\n<a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.html.format_html\" title=\"django.utils.html.format_html\"><code class=\"xref py py-func docutils literal notranslate\">format_html()</code></a>.</p></li>\n<li><p>If the output of a <code class=\"docutils literal notranslate\">simple_tag</code> needs escaping, use\n<a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.html.escape\" title=\"django.utils.html.escape\"><code class=\"xref py py-func docutils literal notranslate\">escape()</code></a> or\n<a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.html.conditional_escape\" title=\"django.utils.html.conditional_escape\"><code class=\"xref py py-func docutils literal notranslate\">conditional_escape()</code></a>.</p></li>\n<li><p>If you are absolutely certain that you are outputting HTML from a trusted\nsource (e.g. a CMS field that stores HTML entered by admins), you can mark it\nas such using <a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.safestring.mark_safe\" title=\"django.utils.safestring.mark_safe\"><code class=\"xref py py-func docutils literal notranslate\">mark_safe()</code></a>.</p></li>\n</ul>\n<p>Tags that follow these rules will be correct and safe whether they are run on\nDjango 1.9+ or earlier.</p>\n</section>\n<section id=\"paginator-page-range\">\n<h3><code class=\"docutils literal notranslate\">Paginator.page_range</code><a class=\"heading-anchor\" href=\"#paginator-page-range\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><a class=\"reference internal\" href=\"/en/dev/ref/paginator/#django.core.paginator.Paginator.page_range\" title=\"django.core.paginator.Paginator.page_range\"><code class=\"xref py py-attr docutils literal notranslate\">Paginator.page_range</code></a> is\nnow an iterator instead of a list.</p>\n<p>In versions of Django previous to 1.8, <code class=\"docutils literal notranslate\">Paginator.page_range</code> returned a\n<code class=\"docutils literal notranslate\">list</code> in Python 2 and a <code class=\"docutils literal notranslate\">range</code> in Python 3. Django 1.8 consistently\nreturned a list, but an iterator is more efficient.</p>\n<p>Existing code that depends on <code class=\"docutils literal notranslate\">list</code> specific features, such as indexing,\ncan be ported by converting the iterator into a <code class=\"docutils literal notranslate\">list</code> using <code class=\"docutils literal notranslate\">list()</code>.</p>\n</section>\n<section id=\"implicit-queryset-in-lookup-removed\">\n<h3>Implicit <code class=\"docutils literal notranslate\">QuerySet</code> <code class=\"docutils literal notranslate\">__in</code> lookup removed<a class=\"heading-anchor\" href=\"#implicit-queryset-in-lookup-removed\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>In earlier versions, queries such as:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>Model<span class=\"o\">.</span>objects<span class=\"o\">.</span>filter<span class=\"p\">(</span>related_id<span class=\"o\">=</span>RelatedModel<span class=\"o\">.</span>objects<span class=\"o\">.</span>all<span class=\"p\">())</span>\n</code></pre></div>\n<p>would implicitly convert to:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>Model<span class=\"o\">.</span>objects<span class=\"o\">.</span>filter<span class=\"p\">(</span>related_id__in<span class=\"o\">=</span>RelatedModel<span class=\"o\">.</span>objects<span class=\"o\">.</span>all<span class=\"p\">())</span>\n</code></pre></div>\n<p>resulting in SQL like <code class=\"docutils literal notranslate\">&quot;related_id IN (SELECT id FROM ...)&quot;</code>.</p>\n<p>This implicit <code class=\"docutils literal notranslate\">__in</code> no longer happens so the “IN” SQL is now “=”, and if the\nsubquery returns multiple results, at least some databases will throw an error.</p>\n</section>\n<section id=\"contrib-admin-browser-support\">\n<span id=\"admin-browser-support-19\"></span><h3><code class=\"docutils literal notranslate\">contrib.admin</code> browser support<a class=\"heading-anchor\" href=\"#contrib-admin-browser-support\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The admin no longer supports Internet Explorer 8 and below, as these browsers\nhave reached end-of-life.</p>\n<p>CSS and images to support Internet Explorer 6 and 7 have been removed. PNG and\nGIF icons have been replaced with SVG icons, which are not supported by\nInternet Explorer 8 and earlier.</p>\n<p>The jQuery library embedded in the admin has been upgraded from version 1.11.2\nto 2.1.4. jQuery 2.x has the same API as jQuery 1.x, but does not support\nInternet Explorer 6, 7, or 8, allowing for better performance and a smaller\nfile size. If you need to support IE8 and must also use the latest version of\nDjango, you can override the admin’s copy of jQuery with your own by creating\na Django application with this structure:</p>\n<div class=\"code-block\" data-language=\"text\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Text</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Text code\"><code>app/static/admin/js/vendor/\n    jquery.js\n    jquery.min.js\n</code></pre></div>\n</section>\n<section id=\"syntaxerror-when-installing-django-setuptools-5-5-x\">\n<span id=\"syntax-error-old-setuptools-django-19\"></span><h3><code class=\"docutils literal notranslate\">SyntaxError</code> when installing Django <code class=\"docutils literal notranslate\">setuptools</code> 5.5.x<a class=\"heading-anchor\" href=\"#syntaxerror-when-installing-django-setuptools-5-5-x\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>When installing Django 1.9 or 1.9.1 with <code class=\"docutils literal notranslate\">setuptools</code> 5.5.x, you’ll see:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>Compiling django/conf/app_template/apps.py ...\n  File <span class=\"s2\">&quot;django/conf/app_template/apps.py&quot;</span>, line <span class=\"m\">4</span>\n    class <span class=\"o\">{{</span> camel_case_app_name <span class=\"o\">}}</span>Config<span class=\"o\">(</span>AppConfig<span class=\"o\">)</span>:\n          ^\nSyntaxError: invalid syntax\n\nCompiling django/conf/app_template/models.py ...\n  File <span class=\"s2\">&quot;django/conf/app_template/models.py&quot;</span>, line <span class=\"m\">1</span>\n    <span class=\"o\">{{</span> unicode_literals <span class=\"o\">}}</span>from django.db import models\n                             ^\nSyntaxError: invalid syntax\n</code></pre></div>\n<p>It’s safe to ignore these errors (Django will still install just fine), but you\ncan avoid them by upgrading <code class=\"docutils literal notranslate\">setuptools</code> to a more recent version. If you’re\nusing pip, you can upgrade pip using <code class=\"docutils literal notranslate\">python -m pip install -U pip</code> which\nwill also upgrade <code class=\"docutils literal notranslate\">setuptools</code>. This is resolved in later versions of Django\nas described in the <a class=\"reference internal\" href=\"/en/dev/releases/1.9.2/\"><span class=\"doc\">Django 1.9.2 release notes</span></a>.</p>\n</section>\n<section id=\"miscellaneous\">\n<h3>Miscellaneous<a class=\"heading-anchor\" href=\"#miscellaneous\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<ul class=\"simple\">\n<li><p>The jQuery static files in <code class=\"docutils literal notranslate\">contrib.admin</code> have been moved into a\n<code class=\"docutils literal notranslate\">vendor/jquery</code> subdirectory.</p></li>\n<li><p>The text displayed for null columns in the admin changelist <code class=\"docutils literal notranslate\">list_display</code>\ncells has changed from <code class=\"docutils literal notranslate\">(None)</code> (or its translated equivalent) to <code class=\"docutils literal notranslate\">-</code> (a\ndash).</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.http.responses.REASON_PHRASES</code> and\n<code class=\"docutils literal notranslate\">django.core.handlers.wsgi.STATUS_CODE_TEXT</code> have been removed. Use\nPython’s Standard Library instead: <a class=\"reference external\" href=\"https://docs.python.org/3/library/http.client.html#http.client.responses\" title=\"(in Python v3.14)\"><code class=\"xref py py-data docutils literal notranslate\">http.client.responses</code></a> for Python\n3 and <a class=\"reference external\" href=\"https://docs.python.org/2/library/httplib.html#httplib.responses\">httplib.responses</a> for Python 2.</p>\n</li>\n<li><p><code class=\"docutils literal notranslate\">ValuesQuerySet</code> and <code class=\"docutils literal notranslate\">ValuesListQuerySet</code> have been removed.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">admin/base.html</code> template no longer sets\n<code class=\"docutils literal notranslate\">window.__admin_media_prefix__</code> or <code class=\"docutils literal notranslate\">window.__admin_utc_offset__</code>. Image\nreferences in JavaScript that used that value to construct absolute URLs have\nbeen moved to CSS for easier customization. The UTC offset is stored on a\ndata attribute of the <code class=\"docutils literal notranslate\">&lt;body&gt;</code> tag.</p></li>\n<li><p><code class=\"docutils literal notranslate\">CommaSeparatedIntegerField</code> validation has been refined to forbid values\nlike <code class=\"docutils literal notranslate\">','</code>, <code class=\"docutils literal notranslate\">',1'</code>, and <code class=\"docutils literal notranslate\">'1,,2'</code>.</p></li>\n<li><p>Form initialization was moved from the <a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/mixins-editing/#django.views.generic.edit.ProcessFormView.get\" title=\"django.views.generic.edit.ProcessFormView.get\"><code class=\"xref py py-meth docutils literal notranslate\">ProcessFormView.get()</code></a> method to the new\n<a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/mixins-editing/#django.views.generic.edit.FormMixin.get_context_data\" title=\"django.views.generic.edit.FormMixin.get_context_data\"><code class=\"xref py py-meth docutils literal notranslate\">FormMixin.get_context_data()</code></a> method. This may be\nbackwards incompatible if you have overridden the <code class=\"docutils literal notranslate\">get_context_data()</code>\nmethod without calling <code class=\"docutils literal notranslate\">super()</code>.</p></li>\n<li><p>Support for PostGIS 1.5 has been dropped.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">django.contrib.sites.models.Site.domain</code> field was changed to be\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.Field.unique\" title=\"django.db.models.Field.unique\"><code class=\"xref py py-attr docutils literal notranslate\">unique</code></a>.</p></li>\n<li><p>In order to enforce test isolation, database queries are not allowed\nby default in <a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.SimpleTestCase\" title=\"django.test.SimpleTestCase\"><code class=\"xref py py-class docutils literal notranslate\">SimpleTestCase</code></a> tests anymore. You\ncan disable this behavior by setting the <code class=\"docutils literal notranslate\">allow_database_queries</code> class\nattribute to <code class=\"docutils literal notranslate\">True</code> on your test class.</p></li>\n<li><p><code class=\"docutils literal notranslate\">ResolverMatch.app_name</code> was changed to contain the full namespace path in\nthe case of nested namespaces. For consistency with\n<code class=\"docutils literal notranslate\">ResolverMatch.namespace</code>, the empty value is now an empty string instead\nof <code class=\"docutils literal notranslate\">None</code>.</p></li>\n<li><p>For security hardening, session keys must be at least 8 characters.</p></li>\n<li><p>Private function <code class=\"docutils literal notranslate\">django.utils.functional.total_ordering()</code> has been\nremoved. It contained a workaround for a <code class=\"docutils literal notranslate\">functools.total_ordering()</code> bug\nin Python versions older than 2.7.3.</p></li>\n<li><p>XML serialization (either through <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-dumpdata\"><code class=\"xref std std-djadmin docutils literal notranslate\">dumpdata</code></a> or the syndication\nframework) used to output any characters it received. Now if the content to\nbe serialized contains any control characters not allowed in the XML 1.0\nstandard, the serialization will fail with a <a class=\"reference external\" href=\"https://docs.python.org/3/library/exceptions.html#ValueError\" title=\"(in Python v3.14)\"><code class=\"xref py py-exc docutils literal notranslate\">ValueError</code></a>.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.CharField\" title=\"django.forms.CharField\"><code class=\"xref py py-class docutils literal notranslate\">CharField</code></a> now strips input of leading and trailing\nwhitespace by default. This can be disabled by setting the new\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.CharField.strip\" title=\"django.forms.CharField.strip\"><code class=\"xref py py-attr docutils literal notranslate\">strip</code></a> argument to <code class=\"docutils literal notranslate\">False</code>.</p></li>\n<li><p>Template text that is translated and uses two or more consecutive percent\nsigns, e.g. <code class=\"docutils literal notranslate\">&quot;%%&quot;</code>, may have a new <code class=\"docutils literal notranslate\">msgid</code> after <code class=\"docutils literal notranslate\">makemessages</code> is run\n(most likely the translation will be marked fuzzy). The new <code class=\"docutils literal notranslate\">msgid</code> will be\nmarked <code class=\"docutils literal notranslate\">&quot;#, python-format&quot;</code>.</p></li>\n<li><p>If neither <a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpRequest.current_app\" title=\"django.http.HttpRequest.current_app\"><code class=\"xref py py-attr docutils literal notranslate\">request.current_app</code></a>\nnor <a class=\"reference internal\" href=\"/en/dev/ref/templates/api/#django.template.Context\" title=\"django.template.Context\"><code class=\"xref py py-class docutils literal notranslate\">Context.current_app</code></a> are set, the\n<a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-url\"><code class=\"xref std std-ttag docutils literal notranslate\">url</code></a> template tag will now use the namespace of the current request.\nSet <code class=\"docutils literal notranslate\">request.current_app</code> to <code class=\"docutils literal notranslate\">None</code> if you don’t want to use a namespace\nhint.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-SILENCED_SYSTEM_CHECKS\"><code class=\"xref std std-setting docutils literal notranslate\">SILENCED_SYSTEM_CHECKS</code></a> setting now silences messages of all\nlevels. Previously, messages of <code class=\"docutils literal notranslate\">ERROR</code> level or higher were printed to the\nconsole.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">FlatPage.enable_comments</code> field is removed from the <code class=\"docutils literal notranslate\">FlatPageAdmin</code>\nas it’s unused by the application. If your project or a third-party app makes\nuse of it, <a class=\"reference internal\" href=\"/en/dev/ref/contrib/flatpages/#flatpages-admin\"><span class=\"std std-ref\">create a custom ModelAdmin</span></a> to add it\nback.</p></li>\n<li><p>The return value of\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/advanced/#django.test.runner.DiscoverRunner.setup_databases\" title=\"django.test.runner.DiscoverRunner.setup_databases\"><code class=\"xref py py-meth docutils literal notranslate\">setup_databases()</code></a> and the first\nargument of <a class=\"reference internal\" href=\"/en/dev/topics/testing/advanced/#django.test.runner.DiscoverRunner.teardown_databases\" title=\"django.test.runner.DiscoverRunner.teardown_databases\"><code class=\"xref py py-meth docutils literal notranslate\">teardown_databases()</code></a>\nchanged. They used to be <code class=\"docutils literal notranslate\">(old_names, mirrors)</code> tuples. Now they’re just\nthe first item, <code class=\"docutils literal notranslate\">old_names</code>.</p></li>\n<li><p>By default <a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.LiveServerTestCase\" title=\"django.test.LiveServerTestCase\"><code class=\"xref py py-class docutils literal notranslate\">LiveServerTestCase</code></a> attempts to find an\navailable port in the 8081-8179 range instead of just trying port 8081.</p></li>\n<li><p>The system checks for <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin\" title=\"django.contrib.admin.ModelAdmin\"><code class=\"xref py py-class docutils literal notranslate\">ModelAdmin</code></a> now check\ninstances rather than classes.</p></li>\n<li><p>The private API to apply mixed migration plans has been dropped for\nperformance reasons. Mixed plans consist of a list of migrations where some\nare being applied and others are being unapplied.</p></li>\n<li><p>The related model object descriptor classes in\n<code class=\"docutils literal notranslate\">django.db.models.fields.related</code> (private API) are moved from the\n<code class=\"docutils literal notranslate\">related</code> module to <code class=\"docutils literal notranslate\">related_descriptors</code> and renamed as follows:</p>\n<ul>\n<li><p><code class=\"docutils literal notranslate\">ReverseSingleRelatedObjectDescriptor</code> is <code class=\"docutils literal notranslate\">ForwardManyToOneDescriptor</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">SingleRelatedObjectDescriptor</code> is <code class=\"docutils literal notranslate\">ReverseOneToOneDescriptor</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">ForeignRelatedObjectsDescriptor</code> is <code class=\"docutils literal notranslate\">ReverseManyToOneDescriptor</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">ManyRelatedObjectsDescriptor</code> is <code class=\"docutils literal notranslate\">ManyToManyDescriptor</code></p></li>\n</ul>\n</li>\n<li><p>If you implement a custom <a class=\"reference internal\" href=\"/en/dev/ref/urls/#django.conf.urls.handler404\" title=\"django.conf.urls.handler404\"><code class=\"xref py py-data docutils literal notranslate\">handler404</code></a> view, it must\nreturn a response with an HTTP 404 status code. Use\n<a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpResponseNotFound\" title=\"django.http.HttpResponseNotFound\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponseNotFound</code></a> or pass <code class=\"docutils literal notranslate\">status=404</code> to the\n<a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpResponse\" title=\"django.http.HttpResponse\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponse</code></a>. Otherwise, <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-APPEND_SLASH\"><code class=\"xref std std-setting docutils literal notranslate\">APPEND_SLASH</code></a> won’t\nwork correctly with <code class=\"docutils literal notranslate\">DEBUG=False</code>.</p></li>\n</ul>\n</section>\n</section>\n<section id=\"features-deprecated-in-1-9\">\n<span id=\"deprecated-features-1-9\"></span><h2>Features deprecated in 1.9<a class=\"heading-anchor\" href=\"#features-deprecated-in-1-9\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"assignment-tag\">\n<h3><code class=\"docutils literal notranslate\">assignment_tag()</code><a class=\"heading-anchor\" href=\"#assignment-tag\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.4 added the <code class=\"docutils literal notranslate\">assignment_tag</code> helper to ease the creation of\ntemplate tags that store results in a template variable. The\n<a class=\"reference internal\" href=\"/en/dev/howto/custom-template-tags/#django.template.Library.simple_tag\" title=\"django.template.Library.simple_tag\"><code class=\"xref py py-meth docutils literal notranslate\">simple_tag()</code></a> helper has gained this same\nability, making the <code class=\"docutils literal notranslate\">assignment_tag</code> obsolete. Tags that use\n<code class=\"docutils literal notranslate\">assignment_tag</code> should be updated to use <code class=\"docutils literal notranslate\">simple_tag</code>.</p>\n</section>\n<section id=\"cycle-syntax-with-comma-separated-arguments\">\n<h3><code class=\"docutils literal notranslate\">{% cycle %}</code> syntax with comma-separated arguments<a class=\"heading-anchor\" href=\"#cycle-syntax-with-comma-separated-arguments\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-cycle\"><code class=\"xref std std-ttag docutils literal notranslate\">cycle</code></a> tag supports an inferior old syntax from previous Django\nversions:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">cycle</span> <span class=\"nv\">row1</span><span class=\"o\">,</span><span class=\"nv\">row2</span><span class=\"o\">,</span><span class=\"nv\">row3</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>Its parsing caused bugs with the current syntax, so support for the old syntax\nwill be removed in Django 1.10 following an accelerated deprecation.</p>\n</section>\n<section id=\"foreignkey-and-onetoonefield-on-delete-argument\">\n<h3><code class=\"docutils literal notranslate\">ForeignKey</code> and <code class=\"docutils literal notranslate\">OneToOneField</code> <code class=\"docutils literal notranslate\">on_delete</code> argument<a class=\"heading-anchor\" href=\"#foreignkey-and-onetoonefield-on-delete-argument\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>In order to increase awareness about cascading model deletion, the\n<code class=\"docutils literal notranslate\">on_delete</code> argument of <code class=\"docutils literal notranslate\">ForeignKey</code> and <code class=\"docutils literal notranslate\">OneToOneField</code> will be required\nin Django 2.0.</p>\n<p>Update models and existing migrations to explicitly set the argument. Since the\ndefault is <code class=\"docutils literal notranslate\">models.CASCADE</code>, add <code class=\"docutils literal notranslate\">on_delete=models.CASCADE</code> to all\n<code class=\"docutils literal notranslate\">ForeignKey</code> and <code class=\"docutils literal notranslate\">OneToOneField</code>s that don’t use a different option. You\ncan also pass it as the second positional argument if you don’t care about\ncompatibility with older versions of Django.</p>\n</section>\n<section id=\"field-rel-changes\">\n<h3><code class=\"docutils literal notranslate\">Field.rel</code> changes<a class=\"heading-anchor\" href=\"#field-rel-changes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">Field.rel</code> and its methods and attributes have changed to match the related\nfields API. The <code class=\"docutils literal notranslate\">Field.rel</code> attribute is renamed to <code class=\"docutils literal notranslate\">remote_field</code> and many\nof its methods and attributes are either changed or renamed.</p>\n<p>The aim of these changes is to provide a documented API for relation fields.</p>\n</section>\n<section id=\"geomanager-and-geoqueryset-custom-methods\">\n<h3><code class=\"docutils literal notranslate\">GeoManager</code> and <code class=\"docutils literal notranslate\">GeoQuerySet</code> custom methods<a class=\"heading-anchor\" href=\"#geomanager-and-geoqueryset-custom-methods\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>All custom <code class=\"docutils literal notranslate\">GeoQuerySet</code> methods (<code class=\"docutils literal notranslate\">area()</code>, <code class=\"docutils literal notranslate\">distance()</code>, <code class=\"docutils literal notranslate\">gml()</code>, …)\nhave been replaced by equivalent geographic expressions in annotations (see in\nnew features). Hence the need to set a custom <code class=\"docutils literal notranslate\">GeoManager</code> to GIS-enabled\nmodels is now obsolete. As soon as your code doesn’t call any of the deprecated\nmethods, you can simply remove the <code class=\"docutils literal notranslate\">objects = GeoManager()</code> lines from your\nmodels.</p>\n</section>\n<section id=\"template-loader-apis-have-changed\">\n<h3>Template loader APIs have changed<a class=\"heading-anchor\" href=\"#template-loader-apis-have-changed\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django template loaders have been updated to allow recursive template\nextending. This change necessitated a new template loader API. The old\n<code class=\"docutils literal notranslate\">load_template()</code> and <code class=\"docutils literal notranslate\">load_template_sources()</code> methods are now deprecated.\nDetails about the new API can be found <a class=\"reference internal\" href=\"/en/dev/ref/templates/api/#custom-template-loaders\"><span class=\"std std-ref\">in the template loader\ndocumentation</span></a>.</p>\n</section>\n<section id=\"passing-a-3-tuple-or-an-app-name-to-include\">\n<h3>Passing a 3-tuple or an <code class=\"docutils literal notranslate\">app_name</code> to <code class=\"docutils literal notranslate\">include()</code><a class=\"heading-anchor\" href=\"#passing-a-3-tuple-or-an-app-name-to-include\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The instance namespace part of passing a tuple as an argument to <code class=\"docutils literal notranslate\">include()</code>\nhas been replaced by passing the <code class=\"docutils literal notranslate\">namespace</code> argument to <code class=\"docutils literal notranslate\">include()</code>. For\nexample:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>polls_patterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    url<span class=\"p\">(</span><span class=\"o\">...</span><span class=\"p\">),</span>\n<span class=\"p\">]</span>\n\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    url<span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^polls/&quot;</span><span class=\"p\">,</span> include<span class=\"p\">((</span>polls_patterns<span class=\"p\">,</span> <span class=\"s2\">&quot;polls&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;author-polls&quot;</span><span class=\"p\">))),</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p>becomes:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>polls_patterns <span class=\"o\">=</span> <span class=\"p\">(</span>\n    <span class=\"p\">[</span>\n        url<span class=\"p\">(</span><span class=\"o\">...</span><span class=\"p\">),</span>\n    <span class=\"p\">],</span>\n    <span class=\"s2\">&quot;polls&quot;</span><span class=\"p\">,</span>\n<span class=\"p\">)</span>  <span class=\"c1\"># &#39;polls&#39; is the app_name</span>\n\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    url<span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^polls/&quot;</span><span class=\"p\">,</span> include<span class=\"p\">(</span>polls_patterns<span class=\"p\">,</span> namespace<span class=\"o\">=</span><span class=\"s2\">&quot;author-polls&quot;</span><span class=\"p\">)),</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p>The <code class=\"docutils literal notranslate\">app_name</code> argument to <code class=\"docutils literal notranslate\">include()</code> has been replaced by passing a\n2-tuple (as above), or passing an object or module with an <code class=\"docutils literal notranslate\">app_name</code>\nattribute (as below). If the <code class=\"docutils literal notranslate\">app_name</code> is set in this new way, the\n<code class=\"docutils literal notranslate\">namespace</code> argument is no longer required. It will default to the value of\n<code class=\"docutils literal notranslate\">app_name</code>. For example, the URL patterns in the tutorial are changed from:</p>\n<figure class=\"code-block code-block-captioned\" data-language=\"python\"><figcaption class=\"code-block-caption\"><code class=\"docutils literal notranslate\">mysite/urls.py</code></figcaption>\n<div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code>urlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>url<span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^polls/&quot;</span><span class=\"p\">,</span> include<span class=\"p\">(</span><span class=\"s2\">&quot;polls.urls&quot;</span><span class=\"p\">,</span> namespace<span class=\"o\">=</span><span class=\"s2\">&quot;polls&quot;</span><span class=\"p\">)),</span> <span class=\"o\">...</span><span class=\"p\">]</span>\n</code></pre></figure>\n<p>to:</p>\n<figure class=\"code-block code-block-captioned\" data-language=\"python\"><figcaption class=\"code-block-caption\"><code class=\"docutils literal notranslate\">mysite/urls.py</code></figcaption>\n<div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code>urlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    url<span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^polls/&quot;</span><span class=\"p\">,</span> include<span class=\"p\">(</span><span class=\"s2\">&quot;polls.urls&quot;</span><span class=\"p\">)),</span>  <span class=\"c1\"># &#39;namespace=&quot;polls&quot;&#39; removed</span>\n    <span class=\"o\">...</span><span class=\"p\">,</span>\n<span class=\"p\">]</span>\n</code></pre></figure>\n<figure class=\"code-block code-block-captioned\" data-language=\"python\"><figcaption class=\"code-block-caption\"><code class=\"docutils literal notranslate\">polls/urls.py</code></figcaption>\n<div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code>app_name <span class=\"o\">=</span> <span class=\"s2\">&quot;polls&quot;</span>  <span class=\"c1\"># added</span>\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span><span class=\"o\">...</span><span class=\"p\">]</span>\n</code></pre></figure>\n<p>This change also means that the old way of including an <code class=\"docutils literal notranslate\">AdminSite</code> instance\nis deprecated. Instead, pass <code class=\"docutils literal notranslate\">admin.site.urls</code> directly to\n<code class=\"docutils literal notranslate\">django.conf.urls.url()</code>:</p>\n<figure class=\"code-block code-block-captioned\" data-language=\"python\"><figcaption class=\"code-block-caption\"><code class=\"docutils literal notranslate\">urls.py</code></figcaption>\n<div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.conf.urls</span> <span class=\"kn\">import</span> url\n<span class=\"kn\">from</span> <span class=\"nn\">django.contrib</span> <span class=\"kn\">import</span> admin\n\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    url<span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^admin/&quot;</span><span class=\"p\">,</span> admin<span class=\"o\">.</span>site<span class=\"o\">.</span>urls<span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></figure>\n</section>\n<section id=\"url-application-namespace-required-if-setting-an-instance-namespace\">\n<h3>URL application namespace required if setting an instance namespace<a class=\"heading-anchor\" href=\"#url-application-namespace-required-if-setting-an-instance-namespace\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>In the past, an instance namespace without an application namespace\nwould serve the same purpose as the application namespace, but it was\nimpossible to reverse the patterns if there was an application namespace\nwith the same name. Includes that specify an instance namespace require that\nthe included URLconf sets an application namespace.</p>\n</section>\n<section id=\"current-app-parameter-to-contrib-auth-views\">\n<h3><code class=\"docutils literal notranslate\">current_app</code> parameter to <code class=\"docutils literal notranslate\">contrib.auth</code> views<a class=\"heading-anchor\" href=\"#current-app-parameter-to-contrib-auth-views\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>All views in <code class=\"docutils literal notranslate\">django.contrib.auth.views</code> have the following structure:</p>\n<div class=\"code-block\" data-language=\"text\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Text</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Text code\"><code>def view(request, ..., current_app=None, ...):\n\n    ...\n\n    if current_app is not None:\n        request.current_app = current_app\n\n    return TemplateResponse(request, template_name, context)\n</code></pre></div>\n<p>As of Django 1.8, <code class=\"docutils literal notranslate\">current_app</code> is set on the <code class=\"docutils literal notranslate\">request</code> object. For\nconsistency, these views will require the caller to set <code class=\"docutils literal notranslate\">current_app</code> on the\n<code class=\"docutils literal notranslate\">request</code> instead of passing it in a separate argument.</p>\n</section>\n<section id=\"django-contrib-gis-geoip\">\n<h3><code class=\"docutils literal notranslate\">django.contrib.gis.geoip</code><a class=\"heading-anchor\" href=\"#django-contrib-gis-geoip\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <a class=\"reference internal\" href=\"/en/dev/ref/contrib/gis/geoip2/#module-django.contrib.gis.geoip2\" title=\"django.contrib.gis.geoip2: Python interface for MaxMind's GeoIP2 databases.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.gis.geoip2</code></a> module supersedes\n<code class=\"docutils literal notranslate\">django.contrib.gis.geoip</code>. The new module provides a similar API except that\nit doesn’t provide the legacy GeoIP-Python API compatibility methods.</p>\n</section>\n<section id=\"id1\">\n<h3>Miscellaneous<a class=\"heading-anchor\" href=\"#id1\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<ul class=\"simple\">\n<li><p>The <code class=\"docutils literal notranslate\">weak</code> argument to <code class=\"docutils literal notranslate\">django.dispatch.signals.Signal.disconnect()</code> has\nbeen deprecated as it has no effect.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">check_aggregate_support()</code> method of\n<code class=\"docutils literal notranslate\">django.db.backends.base.BaseDatabaseOperations</code> has been deprecated and\nwill be removed in Django 2.0. The more general\n<code class=\"docutils literal notranslate\">check_expression_support()</code> should be used instead.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.forms.extras</code> is deprecated. You can find\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/widgets/#django.forms.SelectDateWidget\" title=\"django.forms.SelectDateWidget\"><code class=\"xref py py-class docutils literal notranslate\">SelectDateWidget</code></a> in <code class=\"docutils literal notranslate\">django.forms.widgets</code>\n(or simply <code class=\"docutils literal notranslate\">django.forms</code>) instead.</p></li>\n<li><p>Private API <code class=\"docutils literal notranslate\">django.db.models.fields.add_lazy_relation()</code> is deprecated.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">django.contrib.auth.tests.utils.skipIfCustomUser()</code> decorator is\ndeprecated. With the test discovery changes in Django 1.6, the tests for\n<code class=\"docutils literal notranslate\">django.contrib</code> apps are no longer run as part of the user’s project.\nTherefore, the <code class=\"docutils literal notranslate\">&#64;skipIfCustomUser</code> decorator is no longer needed to\ndecorate tests in <code class=\"docutils literal notranslate\">django.contrib.auth</code>.</p></li>\n<li><p>If you customized some <a class=\"reference internal\" href=\"/en/dev/ref/views/#error-views\"><span class=\"std std-ref\">error handlers</span></a>, the view\nsignatures with only one request parameter are deprecated. The views should\nnow also accept a second <code class=\"docutils literal notranslate\">exception</code> positional parameter.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">django.utils.feedgenerator.Atom1Feed.mime_type</code> and\n<code class=\"docutils literal notranslate\">django.utils.feedgenerator.RssFeed.mime_type</code> attributes are deprecated in\nfavor of <code class=\"docutils literal notranslate\">content_type</code>.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/signing/#django.core.signing.Signer\" title=\"django.core.signing.Signer\"><code class=\"xref py py-class docutils literal notranslate\">Signer</code></a> now issues a warning if an invalid\nseparator is used. This will become an exception in Django 1.10.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.db.models.Field._get_val_from_obj()</code> is deprecated in favor of\n<code class=\"docutils literal notranslate\">Field.value_from_object()</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.template.loaders.eggs.Loader</code> is deprecated as distributing\napplications as eggs is not recommended.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">callable_obj</code> keyword argument to\n<code class=\"docutils literal notranslate\">SimpleTestCase.assertRaisesMessage()</code> is deprecated. Pass the callable as\na positional argument instead.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">allow_tags</code> attribute on methods of <code class=\"docutils literal notranslate\">ModelAdmin</code> has been\ndeprecated. Use <a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.html.format_html\" title=\"django.utils.html.format_html\"><code class=\"xref py py-func docutils literal notranslate\">format_html()</code></a>,\n<a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.html.format_html_join\" title=\"django.utils.html.format_html_join\"><code class=\"xref py py-func docutils literal notranslate\">format_html_join()</code></a>, or\n<a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.safestring.mark_safe\" title=\"django.utils.safestring.mark_safe\"><code class=\"xref py py-func docutils literal notranslate\">mark_safe()</code></a> when constructing the method’s\nreturn value instead.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">enclosure</code> keyword argument to <code class=\"docutils literal notranslate\">SyndicationFeed.add_item()</code> is\ndeprecated. Use the new <code class=\"docutils literal notranslate\">enclosures</code> argument which accepts a list of\n<code class=\"docutils literal notranslate\">Enclosure</code> objects instead of a single one.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">django.template.loader.LoaderOrigin</code> and\n<code class=\"docutils literal notranslate\">django.template.base.StringOrigin</code> aliases for\n<code class=\"docutils literal notranslate\">django.template.base.Origin</code> are deprecated.</p></li>\n</ul>\n</section>\n</section>\n<section id=\"features-removed-in-1-9\">\n<span id=\"removed-features-1-9\"></span><h2>Features removed in 1.9<a class=\"heading-anchor\" href=\"#features-removed-in-1-9\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>These features have reached the end of their deprecation cycle and are removed\nin Django 1.9. See <a class=\"reference internal\" href=\"/en/dev/releases/1.7/#deprecated-features-1-7\"><span class=\"std std-ref\">Features deprecated in 1.7</span></a> for details, including how to\nremove usage of these features.</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">django.utils.dictconfig</code> is removed.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.utils.importlib</code> is removed.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.utils.tzinfo</code> is removed.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.utils.unittest</code> is removed.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">syncdb</code> command is removed.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.db.models.signals.pre_syncdb</code> and\n<code class=\"docutils literal notranslate\">django.db.models.signals.post_syncdb</code> is removed.</p></li>\n<li><p>Support for <code class=\"docutils literal notranslate\">allow_syncdb</code> on database routers is removed.</p></li>\n<li><p>Automatic syncing of apps without migrations is removed. Migrations are\ncompulsory for all apps unless you pass the <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#cmdoption-migrate-run-syncdb\"><code class=\"xref std std-option docutils literal notranslate\">migrate --run-syncdb</code></a>\noption.</p></li>\n<li><p>The SQL management commands for apps without migrations, <code class=\"docutils literal notranslate\">sql</code>, <code class=\"docutils literal notranslate\">sqlall</code>,\n<code class=\"docutils literal notranslate\">sqlclear</code>, <code class=\"docutils literal notranslate\">sqldropindexes</code>, and <code class=\"docutils literal notranslate\">sqlindexes</code>, are removed.</p></li>\n<li><p>Support for automatic loading of <code class=\"docutils literal notranslate\">initial_data</code> fixtures and initial SQL\ndata is removed.</p></li>\n<li><p>All models need to be defined inside an installed application or declare an\nexplicit <a class=\"reference internal\" href=\"/en/dev/ref/models/options/#django.db.models.Options.app_label\" title=\"django.db.models.Options.app_label\"><code class=\"xref py py-attr docutils literal notranslate\">app_label</code></a>. Furthermore, it isn’t\npossible to import them before their application is loaded. In particular, it\nisn’t possible to import models inside the root package of an application.</p></li>\n<li><p>The model and form <code class=\"docutils literal notranslate\">IPAddressField</code> is removed. A stub field remains for\ncompatibility with historical migrations.</p></li>\n<li><p><code class=\"docutils literal notranslate\">AppCommand.handle_app()</code> is no longer supported.</p></li>\n<li><p><code class=\"docutils literal notranslate\">RequestSite</code> and <code class=\"docutils literal notranslate\">get_current_site()</code> are no longer importable from\n<code class=\"docutils literal notranslate\">django.contrib.sites.models</code>.</p></li>\n<li><p>FastCGI support via the <code class=\"docutils literal notranslate\">runfcgi</code> management command is removed.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.utils.datastructures.SortedDict</code> is removed.</p></li>\n<li><p><code class=\"docutils literal notranslate\">ModelAdmin.declared_fieldsets</code> is removed.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">util</code> modules that provided backwards compatibility are removed:</p>\n<ul>\n<li><p><code class=\"docutils literal notranslate\">django.contrib.admin.util</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">django.contrib.gis.db.backends.util</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">django.db.backends.util</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">django.forms.util</code></p></li>\n</ul>\n</li>\n<li><p><code class=\"docutils literal notranslate\">ModelAdmin.get_formsets</code> is removed.</p></li>\n<li><p>The backward compatible shims introduced to rename the\n<code class=\"docutils literal notranslate\">BaseMemcachedCache._get_memcache_timeout()</code> method to\n<code class=\"docutils literal notranslate\">get_backend_timeout()</code> is removed.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">--natural</code> and <code class=\"docutils literal notranslate\">-n</code> options for <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-dumpdata\"><code class=\"xref std std-djadmin docutils literal notranslate\">dumpdata</code></a> are removed.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">use_natural_keys</code> argument for <code class=\"docutils literal notranslate\">serializers.serialize()</code> is removed.</p></li>\n<li><p>Private API <code class=\"docutils literal notranslate\">django.forms.forms.get_declared_fields()</code> is removed.</p></li>\n<li><p>The ability to use a <code class=\"docutils literal notranslate\">SplitDateTimeWidget</code> with <code class=\"docutils literal notranslate\">DateTimeField</code> is\nremoved.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">WSGIRequest.REQUEST</code> property is removed.</p></li>\n<li><p>The class <code class=\"docutils literal notranslate\">django.utils.datastructures.MergeDict</code> is removed.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">zh-cn</code> and <code class=\"docutils literal notranslate\">zh-tw</code> language codes are removed.</p></li>\n<li><p>The internal <code class=\"docutils literal notranslate\">django.utils.functional.memoize()</code> is removed.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.core.cache.get_cache</code> is removed.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.db.models.loading</code> is removed.</p></li>\n<li><p>Passing callable arguments to querysets is no longer possible.</p></li>\n<li><p><code class=\"docutils literal notranslate\">BaseCommand.requires_model_validation</code> is removed in favor of\n<code class=\"docutils literal notranslate\">requires_system_checks</code>. Admin validators is replaced by admin checks.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">ModelAdmin.validator_class</code> and <code class=\"docutils literal notranslate\">default_validator_class</code> attributes\nare removed.</p></li>\n<li><p><code class=\"docutils literal notranslate\">ModelAdmin.validate()</code> is removed.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.db.backends.DatabaseValidation.validate_field</code> is removed in\nfavor of the <code class=\"docutils literal notranslate\">check_field</code> method.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">validate</code> management command is removed.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.utils.module_loading.import_by_path</code> is removed in favor of\n<code class=\"docutils literal notranslate\">django.utils.module_loading.import_string</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">ssi</code> and <code class=\"docutils literal notranslate\">url</code> template tags are removed from the <code class=\"docutils literal notranslate\">future</code> template\ntag library.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.utils.text.javascript_quote()</code> is removed.</p></li>\n<li><p>Database test settings as independent entries in the database settings,\nprefixed by <code class=\"docutils literal notranslate\">TEST_</code>, are no longer supported.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">cache_choices</code> option to <a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.ModelChoiceField\" title=\"django.forms.ModelChoiceField\"><code class=\"xref py py-class docutils literal notranslate\">ModelChoiceField</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.ModelMultipleChoiceField\" title=\"django.forms.ModelMultipleChoiceField\"><code class=\"xref py py-class docutils literal notranslate\">ModelMultipleChoiceField</code></a> is removed.</p></li>\n<li><p>The default value of the\n<a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/base/#django.views.generic.base.RedirectView.permanent\" title=\"django.views.generic.base.RedirectView.permanent\"><code class=\"xref py py-attr docutils literal notranslate\">RedirectView.permanent</code></a>\nattribute has changed from <code class=\"docutils literal notranslate\">True</code> to <code class=\"docutils literal notranslate\">False</code>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.contrib.sitemaps.FlatPageSitemap</code> is removed in favor of\n<code class=\"docutils literal notranslate\">django.contrib.flatpages.sitemaps.FlatPageSitemap</code>.</p></li>\n<li><p>Private API <code class=\"docutils literal notranslate\">django.test.utils.TestTemplateLoader</code> is removed.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">django.contrib.contenttypes.generic</code> module is removed.</p></li>\n</ul>\n</section>","rootId":"django-1-9-release-notes","toc":[{"title":"Python compatibility","anchor":"python-compatibility","children":[]},{"title":"What’s new in Django 1.9","anchor":"what-s-new-in-django-1-9","children":[{"title":"Performing actions after a transaction commit","anchor":"performing-actions-after-a-transaction-commit","children":[]},{"title":"Password validation","anchor":"password-validation","children":[]},{"title":"Permission mixins for class-based views","anchor":"permission-mixins-for-class-based-views","children":[]},{"title":"New styling for contrib.admin","anchor":"new-styling-for-contrib-admin","children":[]},{"title":"Running tests in parallel","anchor":"running-tests-in-parallel","children":[]},{"title":"Minor features","anchor":"minor-features","children":[{"title":"django.contrib.admin","anchor":"django-contrib-admin","children":[]},{"title":"django.contrib.admindocs","anchor":"django-contrib-admindocs","children":[]},{"title":"django.contrib.auth","anchor":"django-contrib-auth","children":[]},{"title":"django.contrib.contenttypes","anchor":"django-contrib-contenttypes","children":[]},{"title":"django.contrib.gis","anchor":"django-contrib-gis","children":[]},{"title":"django.contrib.postgres","anchor":"django-contrib-postgres","children":[]},{"title":"django.contrib.sessions","anchor":"django-contrib-sessions","children":[]},{"title":"django.contrib.sites","anchor":"django-contrib-sites","children":[]},{"title":"django.contrib.syndication","anchor":"django-contrib-syndication","children":[]},{"title":"Cache","anchor":"cache","children":[]},{"title":"CSRF","anchor":"csrf","children":[]},{"title":"Database backends","anchor":"database-backends","children":[]},{"title":"File Storage","anchor":"file-storage","children":[]},{"title":"Forms","anchor":"forms","children":[]},{"title":"Generic Views","anchor":"generic-views","children":[]},{"title":"Internationalization","anchor":"internationalization","children":[]},{"title":"Management Commands","anchor":"management-commands","children":[]},{"title":"Migrations","anchor":"migrations","children":[]},{"title":"Models","anchor":"models","children":[]},{"title":"Requests and Responses","anchor":"requests-and-responses","children":[]},{"title":"Templates","anchor":"templates","children":[]},{"title":"Tests","anchor":"tests","children":[]},{"title":"URLs","anchor":"urls","children":[]},{"title":"Validators","anchor":"validators","children":[]}]}]},{"title":"Backwards incompatible changes in 1.9","anchor":"backwards-incompatible-changes-in-1-9","children":[{"title":"Database backend API","anchor":"database-backend-api","children":[]},{"title":"Default settings that were tuples are now lists","anchor":"default-settings-that-were-tuples-are-now-lists","children":[]},{"title":"is_usable attribute on template loaders is removed","anchor":"is-usable-attribute-on-template-loaders-is-removed","children":[]},{"title":"Related set direct assignment","anchor":"related-set-direct-assignment","children":[]},{"title":"Filesystem-based template loaders catch more specific exceptions","anchor":"filesystem-based-template-loaders-catch-more-specific-exceptions","children":[]},{"title":"HTTP redirects no longer forced to absolute URIs","anchor":"http-redirects-no-longer-forced-to-absolute-uris","children":[]},{"title":"Dropped support for PostgreSQL 9.0","anchor":"dropped-support-for-postgresql-9-0","children":[]},{"title":"Dropped support for Oracle 11.1","anchor":"dropped-support-for-oracle-11-1","children":[]},{"title":"Bulk behavior of add() method of related managers","anchor":"bulk-behavior-of-add-method-of-related-managers","children":[]},{"title":"Template LoaderOrigin and StringOrigin are removed","anchor":"template-loaderorigin-and-stringorigin-are-removed","children":[]},{"title":"Changes to the default logging configuration","anchor":"changes-to-the-default-logging-configuration","children":[]},{"title":"HttpRequest details in error reporting","anchor":"httprequest-details-in-error-reporting","children":[]},{"title":"Removal of time zone aware global adapters and converters for datetimes","anchor":"removal-of-time-zone-aware-global-adapters-and-converters-for-datetimes","children":[]},{"title":"Template tag modules are imported when templates are configured","anchor":"template-tag-modules-are-imported-when-templates-are-configured","children":[]},{"title":"django.template.base.add_to_builtins() is removed","anchor":"django-template-base-add-to-builtins-is-removed","children":[]},{"title":"simple_tag now wraps tag output in conditional_escape","anchor":"simple-tag-now-wraps-tag-output-in-conditional-escape","children":[]},{"title":"Paginator.page_range","anchor":"paginator-page-range","children":[]},{"title":"Implicit QuerySet __in lookup removed","anchor":"implicit-queryset-in-lookup-removed","children":[]},{"title":"contrib.admin browser support","anchor":"contrib-admin-browser-support","children":[]},{"title":"SyntaxError when installing Django setuptools 5.5.x","anchor":"syntaxerror-when-installing-django-setuptools-5-5-x","children":[]},{"title":"Miscellaneous","anchor":"miscellaneous","children":[]}]},{"title":"Features deprecated in 1.9","anchor":"features-deprecated-in-1-9","children":[{"title":"assignment_tag()","anchor":"assignment-tag","children":[]},{"title":"{% cycle %} syntax with comma-separated arguments","anchor":"cycle-syntax-with-comma-separated-arguments","children":[]},{"title":"ForeignKey and OneToOneField on_delete argument","anchor":"foreignkey-and-onetoonefield-on-delete-argument","children":[]},{"title":"Field.rel changes","anchor":"field-rel-changes","children":[]},{"title":"GeoManager and GeoQuerySet custom methods","anchor":"geomanager-and-geoqueryset-custom-methods","children":[]},{"title":"Template loader APIs have changed","anchor":"template-loader-apis-have-changed","children":[]},{"title":"Passing a 3-tuple or an app_name to include()","anchor":"passing-a-3-tuple-or-an-app-name-to-include","children":[]},{"title":"URL application namespace required if setting an instance namespace","anchor":"url-application-namespace-required-if-setting-an-instance-namespace","children":[]},{"title":"current_app parameter to contrib.auth views","anchor":"current-app-parameter-to-contrib-auth-views","children":[]},{"title":"django.contrib.gis.geoip","anchor":"django-contrib-gis-geoip","children":[]},{"title":"Miscellaneous","anchor":"id1","children":[]}]},{"title":"Features removed in 1.9","anchor":"features-removed-in-1-9","children":[]}],"breadcrumbs":[{"docname":"releases/index","title":"Release notes","url":"/en/dev/releases/"}],"prev":{"docname":"releases/1.9.1","title":"Django 1.9.1 release notes","url":"/en/dev/releases/1.9.1/"},"next":{"docname":"releases/1.8.19","title":"Django 1.8.19 release notes","url":"/en/dev/releases/1.8.19/"},"formats":{"html":"/en/dev/releases/1.9/","markdown":"/en/dev/releases/1.9.md","json":"/en/dev/releases/1.9.json"},"source":"https://github.com/django/django/blob/main/docs/releases/1.9.txt","official":"https://docs.djangoproject.com/en/dev/releases/1.9/","inVersions":["dev","6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9"],"inLocales":["en"]}