Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 481c2de1450e70fa8fdc1e3abf72606b > files > 1040

python-django-doc-1.11.20-1.mga7.noarch.rpm


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Django 1.9 release notes &#8212; Django 1.11.20 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Django 1.8.19 release notes" href="1.8.19.html" />
    <link rel="prev" title="Django 1.9.1 release notes" href="1.9.1.html" />



 
<script type="text/javascript" src="../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../ref/templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head><body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../index.html">Django 1.11.20 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../index.html">Home</a>  |
        <a title="Table of contents" href="../contents.html">Table of contents</a>  |
        <a title="Global index" href="../genindex.html">Index</a>  |
        <a title="Module index" href="../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="1.9.1.html" title="Django 1.9.1 release notes">previous</a>
     |
    <a href="index.html" title="Release notes" accesskey="U">up</a>
   |
    <a href="1.8.19.html" title="Django 1.8.19 release notes">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="releases-1.9">
            
  <div class="section" id="s-django-1-9-release-notes">
<span id="django-1-9-release-notes"></span><h1>Django 1.9 release notes<a class="headerlink" href="#django-1-9-release-notes" title="Permalink to this headline">¶</a></h1>
<p><em>December 1, 2015</em></p>
<p>Welcome to Django 1.9!</p>
<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
some <a class="reference internal" href="#backwards-incompatible-1-9"><span class="std std-ref">backwards incompatible changes</span></a> you’ll
want to be aware of when upgrading from Django 1.8 or older versions. We’ve
<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
their 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
features</span></a>.</p>
<p>See the <a class="reference internal" href="../howto/upgrade-version.html"><span class="doc">Upgrading Django to a newer version</span></a> guide if you’re updating an existing
project.</p>
<div class="section" id="s-python-compatibility">
<span id="python-compatibility"></span><h2>Python compatibility<a class="headerlink" href="#python-compatibility" title="Permalink to this headline">¶</a></h2>
<p>Django 1.9 requires Python 2.7, 3.4, or 3.5. We <strong>highly recommend</strong> and only
officially support the latest release of each series.</p>
<p>The Django 1.8 series is the last to support Python 3.2 and 3.3.</p>
</div>
<div class="section" id="s-what-s-new-in-django-1-9">
<span id="s-whats-new-1-9"></span><span id="what-s-new-in-django-1-9"></span><span id="whats-new-1-9"></span><h2>What’s new in Django 1.9<a class="headerlink" href="#what-s-new-in-django-1-9" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-performing-actions-after-a-transaction-commit">
<span id="performing-actions-after-a-transaction-commit"></span><h3>Performing actions after a transaction commit<a class="headerlink" href="#performing-actions-after-a-transaction-commit" title="Permalink to this headline">¶</a></h3>
<p>The new <a class="reference internal" href="../topics/db/transactions.html#django.db.transaction.on_commit" title="django.db.transaction.on_commit"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_commit()</span></code></a> hook allows performing actions
after a database transaction is successfully committed. This is useful for
tasks such as sending notification emails, creating queued tasks, or
invalidating caches.</p>
<p>This functionality from the <a class="reference external" href="https://pypi.python.org/pypi/django-transaction-hooks">django-transaction-hooks</a> package has been
integrated into Django.</p>
</div>
<div class="section" id="s-password-validation">
<span id="password-validation"></span><h3>Password validation<a class="headerlink" href="#password-validation" title="Permalink to this headline">¶</a></h3>
<p>Django now offers password validation to help prevent the usage of weak
passwords by users. The validation is integrated in the included password
change and reset forms and is simple to integrate in any other code.
Validation is performed by one or more validators, configured in the new
<a class="reference internal" href="../ref/settings.html#std:setting-AUTH_PASSWORD_VALIDATORS"><code class="xref std std-setting docutils literal notranslate"><span class="pre">AUTH_PASSWORD_VALIDATORS</span></code></a> setting.</p>
<p>Four validators are included in Django, which can enforce a minimum length,
compare the password to the user’s attributes like their name, ensure
passwords aren’t entirely numeric, or check against an included list of common
passwords. You can combine multiple validators, and some validators have
custom configuration options. For example, you can choose to provide a custom
list of common passwords. Each validator provides a help text to explain its
requirements to the user.</p>
<p>By default, no validation is performed and all passwords are accepted, so if
you don’t set <a class="reference internal" href="../ref/settings.html#std:setting-AUTH_PASSWORD_VALIDATORS"><code class="xref std std-setting docutils literal notranslate"><span class="pre">AUTH_PASSWORD_VALIDATORS</span></code></a>, you will not see any
change. In new projects created with the default <a class="reference internal" href="../ref/django-admin.html#django-admin-startproject"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">startproject</span></code></a>
template, a simple set of validators is enabled. To enable basic validation in
the included auth forms for your project, you could set, for example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">AUTH_PASSWORD_VALIDATORS</span> <span class="o">=</span> <span class="p">[</span>
    <span class="p">{</span>
        <span class="s1">&#39;NAME&#39;</span><span class="p">:</span> <span class="s1">&#39;django.contrib.auth.password_validation.UserAttributeSimilarityValidator&#39;</span><span class="p">,</span>
    <span class="p">},</span>
    <span class="p">{</span>
        <span class="s1">&#39;NAME&#39;</span><span class="p">:</span> <span class="s1">&#39;django.contrib.auth.password_validation.MinimumLengthValidator&#39;</span><span class="p">,</span>
    <span class="p">},</span>
    <span class="p">{</span>
        <span class="s1">&#39;NAME&#39;</span><span class="p">:</span> <span class="s1">&#39;django.contrib.auth.password_validation.CommonPasswordValidator&#39;</span><span class="p">,</span>
    <span class="p">},</span>
    <span class="p">{</span>
        <span class="s1">&#39;NAME&#39;</span><span class="p">:</span> <span class="s1">&#39;django.contrib.auth.password_validation.NumericPasswordValidator&#39;</span><span class="p">,</span>
    <span class="p">},</span>
<span class="p">]</span>
</pre></div>
</div>
<p>See <a class="reference internal" href="../topics/auth/passwords.html#password-validation"><span class="std std-ref">Password validation</span></a> for more details.</p>
</div>
<div class="section" id="s-permission-mixins-for-class-based-views">
<span id="permission-mixins-for-class-based-views"></span><h3>Permission mixins for class-based views<a class="headerlink" href="#permission-mixins-for-class-based-views" title="Permalink to this headline">¶</a></h3>
<p>Django now ships with the mixins
<a class="reference internal" href="../topics/auth/default.html#django.contrib.auth.mixins.AccessMixin" title="django.contrib.auth.mixins.AccessMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">AccessMixin</span></code></a>,
<a class="reference internal" href="../topics/auth/default.html#django.contrib.auth.mixins.LoginRequiredMixin" title="django.contrib.auth.mixins.LoginRequiredMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">LoginRequiredMixin</span></code></a>,
<a class="reference internal" href="../topics/auth/default.html#django.contrib.auth.mixins.PermissionRequiredMixin" title="django.contrib.auth.mixins.PermissionRequiredMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">PermissionRequiredMixin</span></code></a>, and
<a class="reference internal" href="../topics/auth/default.html#django.contrib.auth.mixins.UserPassesTestMixin" title="django.contrib.auth.mixins.UserPassesTestMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">UserPassesTestMixin</span></code></a> to provide the
functionality of the <code class="docutils literal notranslate"><span class="pre">django.contrib.auth.decorators</span></code> for class-based views.
These mixins have been taken from, or are at least inspired by, the
<a class="reference external" href="https://django-braces.readthedocs.io/en/latest/index.html">django-braces</a> project.</p>
<p>There are a few differences between Django’s and <code class="docutils literal notranslate"><span class="pre">django-braces</span></code>’
implementation, though:</p>
<ul class="simple">
<li>The <a class="reference internal" href="../topics/auth/default.html#django.contrib.auth.mixins.AccessMixin.raise_exception" title="django.contrib.auth.mixins.AccessMixin.raise_exception"><code class="xref py py-attr docutils literal notranslate"><span class="pre">raise_exception</span></code></a> attribute
can only be <code class="docutils literal notranslate"><span class="pre">True</span></code> or <code class="docutils literal notranslate"><span class="pre">False</span></code>. Custom exceptions or callables are not
supported.</li>
<li>The <a class="reference internal" href="../topics/auth/default.html#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"><span class="pre">handle_no_permission()</span></code></a>
method does not take a <code class="docutils literal notranslate"><span class="pre">request</span></code> argument. The current request is available
in <code class="docutils literal notranslate"><span class="pre">self.request</span></code>.</li>
<li>The custom <code class="docutils literal notranslate"><span class="pre">test_func()</span></code> of <a class="reference internal" href="../topics/auth/default.html#django.contrib.auth.mixins.UserPassesTestMixin" title="django.contrib.auth.mixins.UserPassesTestMixin"><code class="xref py py-class docutils literal notranslate"><span class="pre">UserPassesTestMixin</span></code></a>
does not take a <code class="docutils literal notranslate"><span class="pre">user</span></code> argument. The current user is available in
<code class="docutils literal notranslate"><span class="pre">self.request.user</span></code>.</li>
<li>The <a class="reference internal" href="../topics/auth/default.html#django.contrib.auth.mixins.PermissionRequiredMixin" title="django.contrib.auth.mixins.PermissionRequiredMixin"><code class="xref py py-attr docutils literal notranslate"><span class="pre">permission_required</span></code></a>
attribute supports a string (defining one permission) or a list/tuple of
strings (defining multiple permissions) that need to be fulfilled to grant
access.</li>
<li>The new <a class="reference internal" href="../topics/auth/default.html#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"><span class="pre">permission_denied_message</span></code></a>
attribute allows passing a message to the <code class="docutils literal notranslate"><span class="pre">PermissionDenied</span></code> exception.</li>
</ul>
</div>
<div class="section" id="s-new-styling-for-contrib-admin">
<span id="new-styling-for-contrib-admin"></span><h3>New styling for <code class="docutils literal notranslate"><span class="pre">contrib.admin</span></code><a class="headerlink" href="#new-styling-for-contrib-admin" title="Permalink to this headline">¶</a></h3>
<p>The admin sports a modern, flat design with new SVG icons which look perfect
on 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
A-grade</a> browsers. Older browser may experience varying levels of graceful
degradation.</p>
</div>
<div class="section" id="s-running-tests-in-parallel">
<span id="running-tests-in-parallel"></span><h3>Running tests in parallel<a class="headerlink" href="#running-tests-in-parallel" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../ref/django-admin.html#django-admin-test"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">test</span></code></a> command now supports a <a class="reference internal" href="../ref/django-admin.html#cmdoption-test-parallel"><code class="xref std std-option docutils literal notranslate"><span class="pre">--parallel</span></code></a> option to run a project’s tests in multiple processes in parallel.</p>
<p>Each process gets its own database. You must ensure that different test cases
don’t access the same resources. For instance, test cases that touch the
filesystem should create a temporary directory for their own use.</p>
<p>This option is enabled by default for Django’s own test suite provided:</p>
<ul class="simple">
<li>the OS supports it (all but Windows)</li>
<li>the database backend supports it (all the built-in backends but Oracle)</li>
</ul>
</div>
<div class="section" id="s-minor-features">
<span id="minor-features"></span><h3>Minor features<a class="headerlink" href="#minor-features" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s-django-contrib-admin">
<span id="django-contrib-admin"></span><h4><a class="reference internal" href="../ref/contrib/admin/index.html#module-django.contrib.admin" title="django.contrib.admin: Django's admin site."><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.contrib.admin</span></code></a><a class="headerlink" href="#django-contrib-admin" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Admin views now have <code class="docutils literal notranslate"><span class="pre">model_admin</span></code> or <code class="docutils literal notranslate"><span class="pre">admin_site</span></code> attributes.</li>
<li>The URL of the admin change view has been changed (was at
<code class="docutils literal notranslate"><span class="pre">/admin/&lt;app&gt;/&lt;model&gt;/&lt;pk&gt;/</span></code> by default and is now at
<code class="docutils literal notranslate"><span class="pre">/admin/&lt;app&gt;/&lt;model&gt;/&lt;pk&gt;/change/</span></code>). This should not affect your
application unless you have hardcoded admin URLs. In that case, replace those
links by <a class="reference internal" href="../ref/contrib/admin/index.html#admin-reverse-urls"><span class="std std-ref">reversing admin URLs</span></a> instead. Note that
the old URL still redirects to the new one for backwards compatibility, but
it may be removed in a future version.</li>
<li><a class="reference internal" href="../ref/contrib/admin/index.html#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"><span class="pre">ModelAdmin.get_list_select_related()</span></code></a> was added to allow
changing the <code class="docutils literal notranslate"><span class="pre">select_related()</span></code> values used in the admin’s changelist query
based on the request.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">available_apps</span></code> context variable, which lists the available
applications for the current user, has been added to the
<a class="reference internal" href="../ref/contrib/admin/index.html#django.contrib.admin.AdminSite.each_context" title="django.contrib.admin.AdminSite.each_context"><code class="xref py py-meth docutils literal notranslate"><span class="pre">AdminSite.each_context()</span></code></a>
method.</li>
<li><a class="reference internal" href="../ref/contrib/admin/index.html#django.contrib.admin.AdminSite.empty_value_display" title="django.contrib.admin.AdminSite.empty_value_display"><code class="xref py py-attr docutils literal notranslate"><span class="pre">AdminSite.empty_value_display</span></code></a> and
<a class="reference internal" href="../ref/contrib/admin/index.html#django.contrib.admin.ModelAdmin.empty_value_display" title="django.contrib.admin.ModelAdmin.empty_value_display"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ModelAdmin.empty_value_display</span></code></a> were added to override
the display of empty values in admin change list. You can also customize the
value for each field.</li>
<li>Added jQuery events <a class="reference internal" href="../ref/contrib/admin/javascript.html#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.</li>
<li>The time picker widget includes a ‘6 p.m’ option for consistency of having
predefined options every 6 hours.</li>
<li>JavaScript slug generation now supports Romanian characters.</li>
</ul>
</div>
<div class="section" id="s-django-contrib-admindocs">
<span id="django-contrib-admindocs"></span><h4><a class="reference internal" href="../ref/contrib/admin/admindocs.html#module-django.contrib.admindocs" title="django.contrib.admindocs: Django's admin documentation generator."><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.contrib.admindocs</span></code></a><a class="headerlink" href="#django-contrib-admindocs" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The model section of the <code class="docutils literal notranslate"><span class="pre">admindocs</span></code> now also describes methods that take
arguments, rather than ignoring them.</li>
</ul>
</div>
<div class="section" id="s-django-contrib-auth">
<span id="django-contrib-auth"></span><h4><a class="reference internal" href="../topics/auth/index.html#module-django.contrib.auth" title="django.contrib.auth: Django's authentication framework."><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.contrib.auth</span></code></a><a class="headerlink" href="#django-contrib-auth" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The default iteration count for the PBKDF2 password hasher has been increased
by 20%. This backwards compatible change will not affect users who have
subclassed <code class="docutils literal notranslate"><span class="pre">django.contrib.auth.hashers.PBKDF2PasswordHasher</span></code> to change the
default value.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">BCryptSHA256PasswordHasher</span></code> will now update passwords if its
<code class="docutils literal notranslate"><span class="pre">rounds</span></code> attribute is changed.</li>
<li><code class="docutils literal notranslate"><span class="pre">AbstractBaseUser</span></code> and <code class="docutils literal notranslate"><span class="pre">BaseUserManager</span></code> were moved to a new
<code class="docutils literal notranslate"><span class="pre">django.contrib.auth.base_user</span></code> module so that they can be imported without
including <code class="docutils literal notranslate"><span class="pre">django.contrib.auth</span></code> in <a class="reference internal" href="../ref/settings.html#std:setting-INSTALLED_APPS"><code class="xref std std-setting docutils literal notranslate"><span class="pre">INSTALLED_APPS</span></code></a> (doing so
raised a deprecation warning in older versions and is no longer supported in
Django 1.9).</li>
<li>The permission argument of
<a class="reference internal" href="../topics/auth/default.html#django.contrib.auth.decorators.permission_required" title="django.contrib.auth.decorators.permission_required"><code class="xref py py-func docutils literal notranslate"><span class="pre">permission_required()</span></code></a> accepts all
kinds of iterables, not only list and tuples.</li>
<li>The new <a class="reference internal" href="../ref/middleware.html#django.contrib.auth.middleware.PersistentRemoteUserMiddleware" title="django.contrib.auth.middleware.PersistentRemoteUserMiddleware"><code class="xref py py-class docutils literal notranslate"><span class="pre">PersistentRemoteUserMiddleware</span></code></a>
makes it possible to use <code class="docutils literal notranslate"><span class="pre">REMOTE_USER</span></code> for setups where the header is only
populated on login pages instead of every request in the session.</li>
<li>The <a class="reference internal" href="../topics/auth/default.html#django.contrib.auth.views.password_reset" title="django.contrib.auth.views.password_reset"><code class="xref py py-func docutils literal notranslate"><span class="pre">password_reset()</span></code></a> view accepts an
<code class="docutils literal notranslate"><span class="pre">extra_email_context</span></code> parameter.</li>
</ul>
</div>
<div class="section" id="s-django-contrib-contenttypes">
<span id="django-contrib-contenttypes"></span><h4><a class="reference internal" href="../ref/contrib/contenttypes.html#module-django.contrib.contenttypes" title="django.contrib.contenttypes: Provides generic interface to installed models."><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.contrib.contenttypes</span></code></a><a class="headerlink" href="#django-contrib-contenttypes" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>It’s now possible to use
<a class="reference internal" href="../ref/models/options.html#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"><span class="pre">order_with_respect_to</span></code></a> with a
<code class="docutils literal notranslate"><span class="pre">GenericForeignKey</span></code>.</li>
</ul>
</div>
<div class="section" id="s-django-contrib-gis">
<span id="django-contrib-gis"></span><h4><a class="reference internal" href="../ref/contrib/gis/index.html#module-django.contrib.gis" title="django.contrib.gis: Geographic Information System (GIS) extensions for Django"><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.contrib.gis</span></code></a><a class="headerlink" href="#django-contrib-gis" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>All <code class="docutils literal notranslate"><span class="pre">GeoQuerySet</span></code> methods have been deprecated and replaced by
<a class="reference internal" href="../ref/contrib/gis/functions.html"><span class="doc">equivalent database functions</span></a>. As soon
as the legacy methods have been replaced in your code, you should even be
able to remove the special <code class="docutils literal notranslate"><span class="pre">GeoManager</span></code> from your GIS-enabled classes.</li>
<li>The GDAL interface now supports instantiating file-based and in-memory
<a class="reference internal" href="../ref/contrib/gis/gdal.html#raster-data-source-objects"><span class="std std-ref">GDALRaster objects</span></a> from raw data.
Setters for raster properties such as projection or pixel values have
been added.</li>
<li>For PostGIS users, the new <a class="reference internal" href="../ref/contrib/gis/model-api.html#django.contrib.gis.db.models.RasterField" title="django.contrib.gis.db.models.RasterField"><code class="xref py py-class docutils literal notranslate"><span class="pre">RasterField</span></code></a>
allows <a class="reference internal" href="../ref/contrib/gis/db-api.html#creating-and-saving-raster-models"><span class="std std-ref">storing GDALRaster objects</span></a>.
It supports automatic spatial index creation and reprojection when saving a
model. It does not yet support spatial querying.</li>
<li>The new <a class="reference internal" href="../ref/contrib/gis/gdal.html#django.contrib.gis.gdal.GDALRaster.warp" title="django.contrib.gis.gdal.GDALRaster.warp"><code class="xref py py-meth docutils literal notranslate"><span class="pre">GDALRaster.warp()</span></code></a>
method allows warping a raster by specifying target raster properties such as
origin, width, height, or pixel size (amongst others).</li>
<li>The new <a class="reference internal" href="../ref/contrib/gis/gdal.html#django.contrib.gis.gdal.GDALRaster.transform" title="django.contrib.gis.gdal.GDALRaster.transform"><code class="xref py py-meth docutils literal notranslate"><span class="pre">GDALRaster.transform()</span></code></a> method allows transforming a
raster into a different spatial reference system by specifying a target
<code class="docutils literal notranslate"><span class="pre">srid</span></code>.</li>
<li>The new <a class="reference internal" href="../ref/contrib/gis/geoip2.html#django.contrib.gis.geoip2.GeoIP2" title="django.contrib.gis.geoip2.GeoIP2"><code class="xref py py-class docutils literal notranslate"><span class="pre">GeoIP2</span></code></a> class allows using
MaxMind’s GeoLite2 databases which includes support for IPv6 addresses.</li>
<li>The default OpenLayers library version included in widgets has been updated
from 2.13 to 2.13.1.</li>
</ul>
</div>
<div class="section" id="s-django-contrib-postgres">
<span id="django-contrib-postgres"></span><h4><a class="reference internal" href="../ref/contrib/postgres/index.html#module-django.contrib.postgres" title="django.contrib.postgres: PostgreSQL-specific fields and features"><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.contrib.postgres</span></code></a><a class="headerlink" href="#django-contrib-postgres" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Added support for the <a class="reference internal" href="../ref/contrib/postgres/fields.html#std:fieldlookup-rangefield.contained_by"><code class="xref std std-lookup docutils literal notranslate"><span class="pre">rangefield.contained_by</span></code></a> lookup for some built
in fields which correspond to the range fields.</li>
<li>Added <a class="reference internal" href="../ref/contrib/postgres/fields.html#django.contrib.postgres.fields.JSONField" title="django.contrib.postgres.fields.JSONField"><code class="xref py py-class docutils literal notranslate"><span class="pre">JSONField</span></code></a>.</li>
<li>Added <a class="reference internal" href="../ref/contrib/postgres/aggregates.html"><span class="doc">PostgreSQL specific aggregation functions</span></a>.</li>
<li>Added the <a class="reference internal" href="../ref/contrib/postgres/functions.html#django.contrib.postgres.functions.TransactionNow" title="django.contrib.postgres.functions.TransactionNow"><code class="xref py py-class docutils literal notranslate"><span class="pre">TransactionNow</span></code></a> database
function.</li>
</ul>
</div>
<div class="section" id="s-django-contrib-sessions">
<span id="django-contrib-sessions"></span><h4><a class="reference internal" href="../topics/http/sessions.html#module-django.contrib.sessions" title="django.contrib.sessions: Provides session management for Django projects."><code class="xref py py-mod docutils literal notranslate"><span class="pre">django.contrib.sessions</span></code></a><a class="headerlink" href="#django-contrib-sessions" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The session model and <code class="docutils literal notranslate"><span class="pre">SessionStore</span></code> classes for the <code class="docutils literal notranslate"><span class="pre">db</span></code> and
<code class="docutils literal notranslate"><span class="pre">cached_db</span></code> backends are refactored to allow a custom database session
backend to build upon them. See
<a class="reference internal" href="../topics/http/sessions.html#extending-database-backed-session-engines"><span class="std std-ref">Extending database-backed session engines</span></a> for more details.</li>
</ul>
</div>
<div class="section" id="s-django-contrib-sites">
<span id="django-contrib-sites"></span><h4><a class="reference internal" href="../ref/contrib/sites.html#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"><span class="pre">django.contrib.sites</span></code></a><a class="headerlink" href="#django-contrib-sites" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference internal" href="../ref/contrib/sites.html#django.contrib.sites.shortcuts.get_current_site" title="django.contrib.sites.shortcuts.get_current_site"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_current_site()</span></code></a> now handles the case
where <code class="docutils literal notranslate"><span class="pre">request.get_host()</span></code> returns <code class="docutils literal notranslate"><span class="pre">domain:port</span></code>, e.g.
<code class="docutils literal notranslate"><span class="pre">example.com:80</span></code>. If the lookup fails because the host does not match a
record in the database and the host has a port, the port is stripped and the
lookup is retried with the domain part only.</li>
</ul>
</div>
<div class="section" id="s-django-contrib-syndication">
<span id="django-contrib-syndication"></span><h4><a class="reference internal" href="../ref/contrib/syndication.html#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"><span class="pre">django.contrib.syndication</span></code></a><a class="headerlink" href="#django-contrib-syndication" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Support for multiple enclosures per feed item has been added. If multiple
enclosures are defined on a RSS feed, an exception is raised as RSS feeds,
unlike Atom feeds, do not support multiple enclosures per feed item.</li>
</ul>
</div>
<div class="section" id="s-cache">
<span id="cache"></span><h4>Cache<a class="headerlink" href="#cache" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">django.core.cache.backends.base.BaseCache</span></code> now has a <code class="docutils literal notranslate"><span class="pre">get_or_set()</span></code>
method.</li>
<li><a class="reference internal" href="../topics/http/decorators.html#django.views.decorators.cache.never_cache" title="django.views.decorators.cache.never_cache"><code class="xref py py-func docutils literal notranslate"><span class="pre">django.views.decorators.cache.never_cache()</span></code></a> now sends more persuasive
headers (added <code class="docutils literal notranslate"><span class="pre">no-cache,</span> <span class="pre">no-store,</span> <span class="pre">must-revalidate</span></code> to <code class="docutils literal notranslate"><span class="pre">Cache-Control</span></code>)
to better prevent caching. This was also added in Django 1.8.8.</li>
</ul>
</div>
<div class="section" id="s-csrf">
<span id="csrf"></span><h4>CSRF<a class="headerlink" href="#csrf" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The request header’s name used for CSRF authentication can be customized
with <a class="reference internal" href="../ref/settings.html#std:setting-CSRF_HEADER_NAME"><code class="xref std std-setting docutils literal notranslate"><span class="pre">CSRF_HEADER_NAME</span></code></a>.</li>
<li>The CSRF referer header is now validated against the
<a class="reference internal" href="../ref/settings.html#std:setting-CSRF_COOKIE_DOMAIN"><code class="xref std std-setting docutils literal notranslate"><span class="pre">CSRF_COOKIE_DOMAIN</span></code></a> setting if set. See <a class="reference internal" href="../ref/csrf.html#how-csrf-works"><span class="std std-ref">How it works</span></a> for
details.</li>
<li>The new <a class="reference internal" href="../ref/settings.html#std:setting-CSRF_TRUSTED_ORIGINS"><code class="xref std std-setting docutils literal notranslate"><span class="pre">CSRF_TRUSTED_ORIGINS</span></code></a> setting provides a way to allow
cross-origin unsafe requests (e.g. <code class="docutils literal notranslate"><span class="pre">POST</span></code>) over HTTPS.</li>
</ul>
</div>
<div class="section" id="s-database-backends">
<span id="database-backends"></span><h4>Database backends<a class="headerlink" href="#database-backends" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The PostgreSQL backend (<code class="docutils literal notranslate"><span class="pre">django.db.backends.postgresql_psycopg2</span></code>) is also
available as <code class="docutils literal notranslate"><span class="pre">django.db.backends.postgresql</span></code>. The old name will continue to
be available for backwards compatibility.</li>
</ul>
</div>
<div class="section" id="s-file-storage">
<span id="file-storage"></span><h4>File Storage<a class="headerlink" href="#file-storage" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference internal" href="../ref/files/storage.html#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"><span class="pre">Storage.get_valid_name()</span></code></a> is now called when
the <a class="reference internal" href="../ref/models/fields.html#django.db.models.FileField.upload_to" title="django.db.models.FileField.upload_to"><code class="xref py py-attr docutils literal notranslate"><span class="pre">upload_to</span></code></a> is a callable.</li>
<li><a class="reference internal" href="../ref/files/file.html#django.core.files.File" title="django.core.files.File"><code class="xref py py-class docutils literal notranslate"><span class="pre">File</span></code></a> now has the <code class="docutils literal notranslate"><span class="pre">seekable()</span></code> method when using
Python 3.</li>
</ul>
</div>
<div class="section" id="s-forms">
<span id="forms"></span><h4>Forms<a class="headerlink" href="#forms" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference internal" href="../topics/forms/modelforms.html#django.forms.ModelForm" title="django.forms.ModelForm"><code class="xref py py-class docutils literal notranslate"><span class="pre">ModelForm</span></code></a> accepts the new <code class="docutils literal notranslate"><span class="pre">Meta</span></code> option
<code class="docutils literal notranslate"><span class="pre">field_classes</span></code> to customize the type of the fields. See
<a class="reference internal" href="../topics/forms/modelforms.html#modelforms-overriding-default-fields"><span class="std std-ref">Overriding the default fields</span></a> for details.</li>
<li>You can now specify the order in which form fields are rendered with the
<a class="reference internal" href="../ref/forms/api.html#django.forms.Form.field_order" title="django.forms.Form.field_order"><code class="xref py py-attr docutils literal notranslate"><span class="pre">field_order</span></code></a> attribute, the <code class="docutils literal notranslate"><span class="pre">field_order</span></code>
constructor argument , or the <a class="reference internal" href="../ref/forms/api.html#django.forms.Form.order_fields" title="django.forms.Form.order_fields"><code class="xref py py-meth docutils literal notranslate"><span class="pre">order_fields()</span></code></a> method.</li>
<li>A form prefix can be specified inside a form class, not only when
instantiating a form. See <a class="reference internal" href="../ref/forms/api.html#form-prefix"><span class="std std-ref">Prefixes for forms</span></a> for details.</li>
<li>You can now <a class="reference internal" href="../topics/forms/formsets.html#custom-formset-form-kwargs"><span class="std std-ref">specify keyword arguments</span></a>
that you want to pass to the constructor of forms in a formset.</li>
<li><a class="reference internal" href="../ref/forms/fields.html#django.forms.SlugField" title="django.forms.SlugField"><code class="xref py py-class docutils literal notranslate"><span class="pre">SlugField</span></code></a> now accepts an
<a class="reference internal" href="../ref/forms/fields.html#django.forms.SlugField.allow_unicode" title="django.forms.SlugField.allow_unicode"><code class="xref py py-attr docutils literal notranslate"><span class="pre">allow_unicode</span></code></a> argument to allow Unicode
characters in slugs.</li>
<li><a class="reference internal" href="../ref/forms/fields.html#django.forms.CharField" title="django.forms.CharField"><code class="xref py py-class docutils literal notranslate"><span class="pre">CharField</span></code></a> now accepts a
<a class="reference internal" href="../ref/forms/fields.html#django.forms.CharField.strip" title="django.forms.CharField.strip"><code class="xref py py-attr docutils literal notranslate"><span class="pre">strip</span></code></a> argument to strip input data of leading
and trailing whitespace.  As this defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code> this is different
behavior from previous releases.</li>
<li>Form fields now support the <a class="reference internal" href="../ref/forms/fields.html#django.forms.Field.disabled" title="django.forms.Field.disabled"><code class="xref py py-attr docutils literal notranslate"><span class="pre">disabled</span></code></a> argument,
allowing the field widget to be displayed disabled by browsers.</li>
<li>It’s now possible to customize bound fields by overriding a field’s
<a class="reference internal" href="../ref/forms/api.html#django.forms.Field.get_bound_field" title="django.forms.Field.get_bound_field"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_bound_field()</span></code></a> method.</li>
</ul>
</div>
<div class="section" id="s-generic-views">
<span id="generic-views"></span><h4>Generic Views<a class="headerlink" href="#generic-views" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Class-based views generated using <code class="docutils literal notranslate"><span class="pre">as_view()</span></code> now have <code class="docutils literal notranslate"><span class="pre">view_class</span></code>
and <code class="docutils literal notranslate"><span class="pre">view_initkwargs</span></code> attributes.</li>
<li><a class="reference internal" href="../ref/utils.html#django.utils.decorators.method_decorator" title="django.utils.decorators.method_decorator"><code class="xref py py-func docutils literal notranslate"><span class="pre">method_decorator()</span></code></a> can now be used with a list
or tuple of decorators. It can also be used to <a class="reference internal" href="../topics/class-based-views/intro.html#id1"><span class="std std-ref">decorate classes instead
of methods</span></a>.</li>
</ul>
</div>
<div class="section" id="s-internationalization">
<span id="internationalization"></span><h4>Internationalization<a class="headerlink" href="#internationalization" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The <a class="reference internal" href="../topics/i18n/translation.html#django.views.i18n.set_language" title="django.views.i18n.set_language"><code class="xref py py-func docutils literal notranslate"><span class="pre">django.views.i18n.set_language()</span></code></a> view now properly redirects to
<a class="reference internal" href="../topics/i18n/translation.html#url-internationalization"><span class="std std-ref">translated URLs</span></a>, when available.</li>
<li>The <a class="reference internal" href="../topics/i18n/translation.html#django.views.i18n.javascript_catalog" title="django.views.i18n.javascript_catalog"><code class="xref py py-func docutils literal notranslate"><span class="pre">django.views.i18n.javascript_catalog()</span></code></a> view now works correctly
if used multiple times with different configurations on the same page.</li>
<li>The <a class="reference internal" href="../ref/utils.html#django.utils.timezone.make_aware" title="django.utils.timezone.make_aware"><code class="xref py py-func docutils literal notranslate"><span class="pre">django.utils.timezone.make_aware()</span></code></a> function gained an <code class="docutils literal notranslate"><span class="pre">is_dst</span></code>
argument to help resolve ambiguous times during DST transitions.</li>
<li>You can now use locale variants supported by gettext. These are usually used
for languages which can be written in different scripts, for example Latin
and Cyrillic (e.g. <code class="docutils literal notranslate"><span class="pre">be&#64;latin</span></code>).</li>
<li>Added the <a class="reference internal" href="../topics/i18n/translation.html#django.views.i18n.json_catalog" title="django.views.i18n.json_catalog"><code class="xref py py-func docutils literal notranslate"><span class="pre">django.views.i18n.json_catalog()</span></code></a> view to help build a custom
client-side i18n library upon Django translations. It returns a JSON object
containing a translations catalog, formatting settings, and a plural rule.</li>
<li>Added the <code class="docutils literal notranslate"><span class="pre">name_translated</span></code> attribute to the object returned by the
<a class="reference internal" href="../topics/i18n/translation.html#std:templatetag-get_language_info"><code class="xref std std-ttag docutils literal notranslate"><span class="pre">get_language_info</span></code></a> template tag. Also added a corresponding template
filter: <a class="reference internal" href="../topics/i18n/translation.html#std:templatefilter-language_name_translated"><code class="xref std std-tfilter docutils literal notranslate"><span class="pre">language_name_translated</span></code></a>.</li>
<li>You can now run <a class="reference internal" href="../ref/django-admin.html#django-admin-compilemessages"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">compilemessages</span></code></a> from the root directory of your
project and it will find all the app message files that were created by
<a class="reference internal" href="../ref/django-admin.html#django-admin-makemessages"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">makemessages</span></code></a>.</li>
<li><a class="reference internal" href="../ref/django-admin.html#django-admin-makemessages"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">makemessages</span></code></a> now calls xgettext once per locale directory rather
than once per translatable file. This speeds up localization builds.</li>
<li><a class="reference internal" href="../topics/i18n/translation.html#std:templatetag-blocktrans"><code class="xref std std-ttag docutils literal notranslate"><span class="pre">blocktrans</span></code></a> supports assigning its output to a variable using
<code class="docutils literal notranslate"><span class="pre">asvar</span></code>.</li>
<li>Two new languages are available: Colombian Spanish and Scottish Gaelic.</li>
</ul>
</div>
<div class="section" id="s-management-commands">
<span id="management-commands"></span><h4>Management Commands<a class="headerlink" href="#management-commands" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>The new <a class="reference internal" href="../ref/django-admin.html#django-admin-sendtestemail"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">sendtestemail</span></code></a> command lets you send a test email to
easily confirm that email sending through Django is working.</li>
<li>To increase the readability of the SQL code generated by
<a class="reference internal" href="../ref/django-admin.html#django-admin-sqlmigrate"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">sqlmigrate</span></code></a>, the SQL code generated for each migration operation is
preceded by the operation’s description.</li>
<li>The <a class="reference internal" href="../ref/django-admin.html#django-admin-dumpdata"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">dumpdata</span></code></a> command output is now deterministically ordered.
Moreover, when the <code class="docutils literal notranslate"><span class="pre">--output</span></code> option is specified, it also shows a progress
bar in the terminal.</li>
<li>The <a class="reference internal" href="../ref/django-admin.html#django-admin-createcachetable"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">createcachetable</span></code></a> command now has a <code class="docutils literal notranslate"><span class="pre">--dry-run</span></code> flag to
print out the SQL rather than execute it.</li>
<li>The <a class="reference internal" href="../ref/django-admin.html#django-admin-startapp"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">startapp</span></code></a> command creates an <code class="docutils literal notranslate"><span class="pre">apps.py</span></code> file. Since it doesn’t
use <code class="docutils literal notranslate"><span class="pre">default_app_config</span></code> (<a class="reference internal" href="../ref/applications.html#configuring-applications-ref"><span class="std std-ref">a discouraged API</span></a>), you must specify the app config’s path,
e.g. <code class="docutils literal notranslate"><span class="pre">'polls.apps.PollsConfig'</span></code>, in <a class="reference internal" href="../ref/settings.html#std:setting-INSTALLED_APPS"><code class="xref std std-setting docutils literal notranslate"><span class="pre">INSTALLED_APPS</span></code></a> for it to be
used (instead of just <code class="docutils literal notranslate"><span class="pre">'polls'</span></code>).</li>
<li>When using the PostgreSQL backend, the <a class="reference internal" href="../ref/django-admin.html#django-admin-dbshell"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">dbshell</span></code></a> command can connect
to the database using the password from your settings file (instead of
requiring it to be manually entered).</li>
<li>The <code class="docutils literal notranslate"><span class="pre">django</span></code> package may be run as a script, i.e. <code class="docutils literal notranslate"><span class="pre">python</span> <span class="pre">-m</span> <span class="pre">django</span></code>,
which will behave the same as <code class="docutils literal notranslate"><span class="pre">django-admin</span></code>.</li>
<li>Management commands that have the <code class="docutils literal notranslate"><span class="pre">--noinput</span></code> option now also take
<code class="docutils literal notranslate"><span class="pre">--no-input</span></code> as an alias for that option.</li>
</ul>
</div>
<div class="section" id="s-migrations">
<span id="migrations"></span><h4>Migrations<a class="headerlink" href="#migrations" title="Permalink to this headline">¶</a></h4>
<ul>
<li><p class="first">Initial migrations are now marked with an <a class="reference internal" href="../topics/migrations.html#django.db.migrations.Migration.initial" title="django.db.migrations.Migration.initial"><code class="xref py py-attr docutils literal notranslate"><span class="pre">initial</span> <span class="pre">=</span> <span class="pre">True</span></code></a> class attribute which allows
<a class="reference internal" href="../ref/django-admin.html#cmdoption-migrate-fake-initial"><code class="xref std std-option docutils literal notranslate"><span class="pre">migrate</span> <span class="pre">--fake-initial</span></code></a> to more easily detect initial migrations.</p>
</li>
<li><p class="first">Added support for serialization of <code class="docutils literal notranslate"><span class="pre">functools.partial</span></code> and <code class="docutils literal notranslate"><span class="pre">LazyObject</span></code>
instances.</p>
</li>
<li><p class="first">When supplying <code class="docutils literal notranslate"><span class="pre">None</span></code> as a value in <a class="reference internal" href="../ref/settings.html#std:setting-MIGRATION_MODULES"><code class="xref std std-setting docutils literal notranslate"><span class="pre">MIGRATION_MODULES</span></code></a>, Django
will consider the app an app without migrations.</p>
</li>
<li><p class="first">When applying migrations, the “Rendering model states” step that’s displayed
when running migrate with verbosity 2 or higher now computes only the states
for the migrations that have already been applied. The model states for
migrations being applied are generated on demand, drastically reducing the
amount of required memory.</p>
<p>However, this improvement is not available when unapplying migrations and
therefore still requires the precomputation and storage of the intermediate
migration states.</p>
<p>This improvement also requires that Django no longer supports mixed migration
plans. Mixed plans consist of a list of migrations where some are being
applied and others are being unapplied. This was never officially supported
and never had a public API that supports this behavior.</p>
</li>
<li><p class="first">The <a class="reference internal" href="../ref/django-admin.html#django-admin-squashmigrations"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">squashmigrations</span></code></a> command now supports specifying the starting
migration from which migrations will be squashed.</p>
</li>
</ul>
</div>
<div class="section" id="s-models">
<span id="models"></span><h4>Models<a class="headerlink" href="#models" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li><a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.bulk_create" title="django.db.models.query.QuerySet.bulk_create"><code class="xref py py-meth docutils literal notranslate"><span class="pre">QuerySet.bulk_create()</span></code></a>
now works on proxy models.</li>
<li>Database configuration gained a <a class="reference internal" href="../ref/settings.html#std:setting-DATABASE-TIME_ZONE"><code class="xref std std-setting docutils literal notranslate"><span class="pre">TIME_ZONE</span></code></a>
option for interacting with databases that store datetimes in local time and
don’t support time zones when <a class="reference internal" href="../ref/settings.html#std:setting-USE_TZ"><code class="xref std std-setting docutils literal notranslate"><span class="pre">USE_TZ</span></code></a> is <code class="docutils literal notranslate"><span class="pre">True</span></code>.</li>
<li>Added the <a class="reference internal" href="../ref/models/relations.html#django.db.models.fields.related.RelatedManager.set" title="django.db.models.fields.related.RelatedManager.set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">RelatedManager.set()</span></code></a> method to the related
managers created by <code class="docutils literal notranslate"><span class="pre">ForeignKey</span></code>, <code class="docutils literal notranslate"><span class="pre">GenericForeignKey</span></code>, and
<code class="docutils literal notranslate"><span class="pre">ManyToManyField</span></code>.</li>
<li>The <a class="reference internal" href="../ref/models/relations.html#django.db.models.fields.related.RelatedManager.add" title="django.db.models.fields.related.RelatedManager.add"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add()</span></code></a> method on
a reverse foreign key now has a <code class="docutils literal notranslate"><span class="pre">bulk</span></code> parameter to allow executing one
query regardless of the number of objects being added rather than one query
per object.</li>
<li>Added the <code class="docutils literal notranslate"><span class="pre">keep_parents</span></code> parameter to <a class="reference internal" href="../ref/models/instances.html#django.db.models.Model.delete" title="django.db.models.Model.delete"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Model.delete()</span></code></a> to allow deleting only a child’s data in a
model that uses multi-table inheritance.</li>
<li><a class="reference internal" href="../ref/models/instances.html#django.db.models.Model.delete" title="django.db.models.Model.delete"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Model.delete()</span></code></a>
and <a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.delete" title="django.db.models.query.QuerySet.delete"><code class="xref py py-meth docutils literal notranslate"><span class="pre">QuerySet.delete()</span></code></a> return
the number of objects deleted.</li>
<li>Added a system check to prevent defining both <code class="docutils literal notranslate"><span class="pre">Meta.ordering</span></code> and
<code class="docutils literal notranslate"><span class="pre">order_with_respect_to</span></code> on the same model.</li>
<li><a class="reference internal" href="../ref/models/querysets.html#std:fieldlookup-year"><code class="xref std std-lookup docutils literal notranslate"><span class="pre">Date</span> <span class="pre">and</span> <span class="pre">time</span></code></a> lookups can be chained with other lookups
(such as <a class="reference internal" href="../ref/models/querysets.html#std:fieldlookup-exact"><code class="xref std std-lookup docutils literal notranslate"><span class="pre">exact</span></code></a>, <a class="reference internal" href="../ref/models/querysets.html#std:fieldlookup-gt"><code class="xref std std-lookup docutils literal notranslate"><span class="pre">gt</span></code></a>, <a class="reference internal" href="../ref/models/querysets.html#std:fieldlookup-lt"><code class="xref std std-lookup docutils literal notranslate"><span class="pre">lt</span></code></a>, etc.). For example:
<code class="docutils literal notranslate"><span class="pre">Entry.objects.filter(pub_date__month__gt=6)</span></code>.</li>
<li>Time lookups (hour, minute, second) are now supported by
<a class="reference internal" href="../ref/models/fields.html#django.db.models.TimeField" title="django.db.models.TimeField"><code class="xref py py-class docutils literal notranslate"><span class="pre">TimeField</span></code></a> for all database backends. Support for
backends other than SQLite was added but undocumented in Django 1.7.</li>
<li>You can specify the <code class="docutils literal notranslate"><span class="pre">output_field</span></code> parameter of the
<a class="reference internal" href="../ref/models/querysets.html#django.db.models.Avg" title="django.db.models.Avg"><code class="xref py py-class docutils literal notranslate"><span class="pre">Avg</span></code></a> aggregate in order to aggregate over
non-numeric columns, such as <code class="docutils literal notranslate"><span class="pre">DurationField</span></code>.</li>
<li>Added the <a class="reference internal" href="../ref/models/querysets.html#std:fieldlookup-date"><code class="xref std std-lookup docutils literal notranslate"><span class="pre">date</span></code></a> lookup to <a class="reference internal" href="../ref/models/fields.html#django.db.models.DateTimeField" title="django.db.models.DateTimeField"><code class="xref py py-class docutils literal notranslate"><span class="pre">DateTimeField</span></code></a>
to allow querying the field by only the date portion.</li>
<li>Added the <a class="reference internal" href="../ref/models/database-functions.html#django.db.models.functions.Greatest" title="django.db.models.functions.Greatest"><code class="xref py py-class docutils literal notranslate"><span class="pre">Greatest</span></code></a> and
<a class="reference internal" href="../ref/models/database-functions.html#django.db.models.functions.Least" title="django.db.models.functions.Least"><code class="xref py py-class docutils literal notranslate"><span class="pre">Least</span></code></a> database functions.</li>
<li>Added the <a class="reference internal" href="../ref/models/database-functions.html#django.db.models.functions.Now" title="django.db.models.functions.Now"><code class="xref py py-class docutils literal notranslate"><span class="pre">Now</span></code></a> database function, which
returns the current date and time.</li>
<li><a class="reference internal" href="../ref/models/lookups.html#django.db.models.Transform" title="django.db.models.Transform"><code class="xref py py-class docutils literal notranslate"><span class="pre">Transform</span></code></a> is now a subclass of
<a class="reference internal" href="../ref/models/expressions.html#func-expressions"><span class="std std-ref">Func()</span></a> which allows <code class="docutils literal notranslate"><span class="pre">Transform</span></code>s to be used on
the right hand side of an expression, just like regular <code class="docutils literal notranslate"><span class="pre">Func</span></code>s. This
allows registering some database functions like
<a class="reference internal" href="../ref/models/database-functions.html#django.db.models.functions.Length" title="django.db.models.functions.Length"><code class="xref py py-class docutils literal notranslate"><span class="pre">Length</span></code></a>,
<a class="reference internal" href="../ref/models/database-functions.html#django.db.models.functions.Lower" title="django.db.models.functions.Lower"><code class="xref py py-class docutils literal notranslate"><span class="pre">Lower</span></code></a>, and
<a class="reference internal" href="../ref/models/database-functions.html#django.db.models.functions.Upper" title="django.db.models.functions.Upper"><code class="xref py py-class docutils literal notranslate"><span class="pre">Upper</span></code></a> as transforms.</li>
<li><a class="reference internal" href="../ref/models/fields.html#django.db.models.SlugField" title="django.db.models.SlugField"><code class="xref py py-class docutils literal notranslate"><span class="pre">SlugField</span></code></a> now accepts an
<a class="reference internal" href="../ref/models/fields.html#django.db.models.SlugField.allow_unicode" title="django.db.models.SlugField.allow_unicode"><code class="xref py py-attr docutils literal notranslate"><span class="pre">allow_unicode</span></code></a> argument to allow Unicode
characters in slugs.</li>
<li>Added support for referencing annotations in <code class="docutils literal notranslate"><span class="pre">QuerySet.distinct()</span></code>.</li>
<li><code class="docutils literal notranslate"><span class="pre">connection.queries</span></code> shows queries with substituted parameters on SQLite.</li>
<li><a class="reference internal" href="../ref/models/expressions.html"><span class="doc">Query expressions</span></a> can now be used when
creating new model instances using <code class="docutils literal notranslate"><span class="pre">save()</span></code>, <code class="docutils literal notranslate"><span class="pre">create()</span></code>, and
<code class="docutils literal notranslate"><span class="pre">bulk_create()</span></code>.</li>
</ul>
</div>
<div class="section" id="s-requests-and-responses">
<span id="requests-and-responses"></span><h4>Requests and Responses<a class="headerlink" href="#requests-and-responses" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Unless <a class="reference internal" href="../ref/request-response.html#django.http.HttpResponse.reason_phrase" title="django.http.HttpResponse.reason_phrase"><code class="xref py py-attr docutils literal notranslate"><span class="pre">HttpResponse.reason_phrase</span></code></a> is explicitly set, it now is
determined by the current value of <a class="reference internal" href="../ref/request-response.html#django.http.HttpResponse.status_code" title="django.http.HttpResponse.status_code"><code class="xref py py-attr docutils literal notranslate"><span class="pre">HttpResponse.status_code</span></code></a>. Modifying the value of
<code class="docutils literal notranslate"><span class="pre">status_code</span></code> outside of the constructor will also modify the value of
<code class="docutils literal notranslate"><span class="pre">reason_phrase</span></code>.</li>
<li>The debug view now shows details of chained exceptions on Python 3.</li>
<li>The default 40x error views now accept a second positional parameter, the
exception that triggered the view.</li>
<li>View error handlers now support
<a class="reference internal" href="../ref/template-response.html#django.template.response.TemplateResponse" title="django.template.response.TemplateResponse"><code class="xref py py-class docutils literal notranslate"><span class="pre">TemplateResponse</span></code></a>, commonly used with
class-based views.</li>
<li>Exceptions raised by the <code class="docutils literal notranslate"><span class="pre">render()</span></code> method are now passed to the
<code class="docutils literal notranslate"><span class="pre">process_exception()</span></code> method of each middleware.</li>
<li>Request middleware can now set <a class="reference internal" href="../ref/request-response.html#django.http.HttpRequest.urlconf" title="django.http.HttpRequest.urlconf"><code class="xref py py-attr docutils literal notranslate"><span class="pre">HttpRequest.urlconf</span></code></a> to <code class="docutils literal notranslate"><span class="pre">None</span></code> to revert any changes made
by previous middleware and return to using the <a class="reference internal" href="../ref/settings.html#std:setting-ROOT_URLCONF"><code class="xref std std-setting docutils literal notranslate"><span class="pre">ROOT_URLCONF</span></code></a>.</li>
<li>The <a class="reference internal" href="../ref/settings.html#std:setting-DISALLOWED_USER_AGENTS"><code class="xref std std-setting docutils literal notranslate"><span class="pre">DISALLOWED_USER_AGENTS</span></code></a> check in
<a class="reference internal" href="../ref/middleware.html#django.middleware.common.CommonMiddleware" title="django.middleware.common.CommonMiddleware"><code class="xref py py-class docutils literal notranslate"><span class="pre">CommonMiddleware</span></code></a> now raises a
<a class="reference internal" href="../ref/exceptions.html#django.core.exceptions.PermissionDenied" title="django.core.exceptions.PermissionDenied"><code class="xref py py-class docutils literal notranslate"><span class="pre">PermissionDenied</span></code></a> exception as opposed to
returning an <a class="reference internal" href="../ref/request-response.html#django.http.HttpResponseForbidden" title="django.http.HttpResponseForbidden"><code class="xref py py-class docutils literal notranslate"><span class="pre">HttpResponseForbidden</span></code></a> so that
<a class="reference internal" href="../ref/urls.html#django.conf.urls.handler403" title="django.conf.urls.handler403"><code class="xref py py-data docutils literal notranslate"><span class="pre">handler403</span></code></a> is invoked.</li>
<li>Added <a class="reference internal" href="../ref/request-response.html#django.http.HttpRequest.get_port" title="django.http.HttpRequest.get_port"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HttpRequest.get_port()</span></code></a> to
fetch the originating port of the request.</li>
<li>Added the <code class="docutils literal notranslate"><span class="pre">json_dumps_params</span></code> parameter to
<a class="reference internal" href="../ref/request-response.html#django.http.JsonResponse" title="django.http.JsonResponse"><code class="xref py py-class docutils literal notranslate"><span class="pre">JsonResponse</span></code></a> to allow passing keyword arguments to the
<code class="docutils literal notranslate"><span class="pre">json.dumps()</span></code> call used to generate the response.</li>
<li>The <a class="reference internal" href="../ref/middleware.html#django.middleware.common.BrokenLinkEmailsMiddleware" title="django.middleware.common.BrokenLinkEmailsMiddleware"><code class="xref py py-class docutils literal notranslate"><span class="pre">BrokenLinkEmailsMiddleware</span></code></a> now
ignores 404s when the referer is equal to the requested URL. To circumvent
the empty referer check already implemented, some Web bots set the referer to
the requested URL.</li>
</ul>
</div>
<div class="section" id="s-templates">
<span id="templates"></span><h4>Templates<a class="headerlink" href="#templates" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Template tags created with the <a class="reference internal" href="../howto/custom-template-tags.html#django.template.Library.simple_tag" title="django.template.Library.simple_tag"><code class="xref py py-meth docutils literal notranslate"><span class="pre">simple_tag()</span></code></a>
helper can now store results in a template variable by using the <code class="docutils literal notranslate"><span class="pre">as</span></code>
argument.</li>
<li>Added a <a class="reference internal" href="../ref/templates/api.html#django.template.Context.setdefault" title="django.template.Context.setdefault"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Context.setdefault()</span></code></a>
method.</li>
<li>The <a class="reference internal" href="../topics/logging.html#django-template-logger"><span class="std std-ref">django.template</span></a> logger was added and
includes the following messages:<ul>
<li>A <code class="docutils literal notranslate"><span class="pre">DEBUG</span></code> level message for missing context variables.</li>
<li>A <code class="docutils literal notranslate"><span class="pre">WARNING</span></code> level message for uncaught exceptions raised
during the rendering of an <code class="docutils literal notranslate"><span class="pre">{%</span> <span class="pre">include</span> <span class="pre">%}</span></code> when debug mode is off
(helpful since <code class="docutils literal notranslate"><span class="pre">{%</span> <span class="pre">include</span> <span class="pre">%}</span></code> silences the exception and returns an
empty string).</li>
</ul>
</li>
<li>The <a class="reference internal" href="../ref/templates/builtins.html#std:templatetag-firstof"><code class="xref std std-ttag docutils literal notranslate"><span class="pre">firstof</span></code></a> template tag supports storing the output in a variable
using ‘as’.</li>
<li><a class="reference internal" href="../ref/templates/api.html#django.template.Context.update" title="django.template.Context.update"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Context.update()</span></code></a> can now be used as
a context manager.</li>
<li>Django template loaders can now extend templates recursively.</li>
<li>The debug page template postmortem now include output from each engine that
is installed.</li>
<li><a class="reference internal" href="../topics/templates.html#template-debug-integration"><span class="std std-ref">Debug page integration</span></a> for custom
template engines was added.</li>
<li>The <a class="reference internal" href="../topics/templates.html#django.template.backends.django.DjangoTemplates" title="django.template.backends.django.DjangoTemplates"><code class="xref py py-class docutils literal notranslate"><span class="pre">DjangoTemplates</span></code></a> backend gained
the ability to register libraries and builtins explicitly through the
template <a class="reference internal" href="../ref/settings.html#std:setting-TEMPLATES-OPTIONS"><code class="xref std std-setting docutils literal notranslate"><span class="pre">OPTIONS</span></code></a>.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">timesince</span></code> and <code class="docutils literal notranslate"><span class="pre">timeuntil</span></code> filters were improved to deal with leap
years when given large time spans.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">include</span></code> tag now caches parsed templates objects during template
rendering, speeding up reuse in places such as for loops.</li>
</ul>
</div>
<div class="section" id="s-tests">
<span id="tests"></span><h4>Tests<a class="headerlink" href="#tests" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Added the <a class="reference internal" href="../topics/testing/tools.html#django.test.Response.json" title="django.test.Response.json"><code class="xref py py-meth docutils literal notranslate"><span class="pre">json()</span></code></a> method to test client
responses to give access to the response body as JSON.</li>
<li>Added the <a class="reference internal" href="../topics/testing/tools.html#django.test.Client.force_login" title="django.test.Client.force_login"><code class="xref py py-meth docutils literal notranslate"><span class="pre">force_login()</span></code></a> method to the test
client. Use this method to simulate the effect of a user logging into the
site while skipping the authentication and verification steps of
<a class="reference internal" href="../topics/testing/tools.html#django.test.Client.login" title="django.test.Client.login"><code class="xref py py-meth docutils literal notranslate"><span class="pre">login()</span></code></a>.</li>
</ul>
</div>
<div class="section" id="s-urls">
<span id="urls"></span><h4>URLs<a class="headerlink" href="#urls" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Regular expression lookaround assertions are now allowed in URL patterns.</li>
<li>The application namespace can now be set using an <code class="docutils literal notranslate"><span class="pre">app_name</span></code> attribute
on the included module or object. It can also be set by passing a 2-tuple
of (&lt;list of patterns&gt;, &lt;application namespace&gt;) as the first argument to
<a class="reference internal" href="../ref/urls.html#django.conf.urls.include" title="django.conf.urls.include"><code class="xref py py-func docutils literal notranslate"><span class="pre">include()</span></code></a>.</li>
<li>System checks have been added for common URL pattern mistakes.</li>
</ul>
</div>
<div class="section" id="s-validators">
<span id="validators"></span><h4>Validators<a class="headerlink" href="#validators" title="Permalink to this headline">¶</a></h4>
<ul class="simple">
<li>Added <a class="reference internal" href="../ref/validators.html#django.core.validators.int_list_validator" title="django.core.validators.int_list_validator"><code class="xref py py-func docutils literal notranslate"><span class="pre">django.core.validators.int_list_validator()</span></code></a> to generate
validators of strings containing integers separated with a custom character.</li>
<li><a class="reference internal" href="../ref/validators.html#django.core.validators.EmailValidator" title="django.core.validators.EmailValidator"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailValidator</span></code></a> now limits the length of
domain name labels to 63 characters per <span class="target" id="index-0"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc1034.html"><strong>RFC 1034</strong></a>.</li>
<li>Added <a class="reference internal" href="../ref/validators.html#django.core.validators.validate_unicode_slug" title="django.core.validators.validate_unicode_slug"><code class="xref py py-func docutils literal notranslate"><span class="pre">validate_unicode_slug()</span></code></a> to validate slugs
that may contain Unicode characters.</li>
</ul>
</div>
</div>
</div>
<div class="section" id="s-backwards-incompatible-changes-in-1-9">
<span id="s-backwards-incompatible-1-9"></span><span id="backwards-incompatible-changes-in-1-9"></span><span id="backwards-incompatible-1-9"></span><h2>Backwards incompatible changes in 1.9<a class="headerlink" href="#backwards-incompatible-changes-in-1-9" title="Permalink to this headline">¶</a></h2>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">In addition to the changes outlined in this section, be sure to review the
<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
their deprecation cycle and therefore been removed. If you haven’t updated
your code within the deprecation timeline for a given feature, its removal
may appear as a backwards incompatible change.</p>
</div>
<div class="section" id="s-database-backend-api">
<span id="database-backend-api"></span><h3>Database backend API<a class="headerlink" href="#database-backend-api" title="Permalink to this headline">¶</a></h3>
<ul>
<li><p class="first">A couple of new tests rely on the ability of the backend to introspect column
defaults (returning the result as <code class="docutils literal notranslate"><span class="pre">Field.default</span></code>). You can set the
<code class="docutils literal notranslate"><span class="pre">can_introspect_default</span></code> database feature to <code class="docutils literal notranslate"><span class="pre">False</span></code> if your backend
doesn’t implement this. You may want to review the implementation on the
backends that Django includes for reference (<a class="reference external" href="https://code.djangoproject.com/ticket/24245">#24245</a>).</p>
</li>
<li><p class="first">Registering a global adapter or converter at the level of the DB-API module
to handle time zone information of <code class="xref py py-class docutils literal notranslate"><span class="pre">datetime</span></code> values passed
as query parameters or returned as query results on databases that don’t
support time zones is discouraged. It can conflict with other libraries.</p>
<p>The recommended way to add a time zone to <code class="xref py py-class docutils literal notranslate"><span class="pre">datetime</span></code> values
fetched from the database is to register a converter for <code class="docutils literal notranslate"><span class="pre">DateTimeField</span></code>
in <code class="docutils literal notranslate"><span class="pre">DatabaseOperations.get_db_converters()</span></code>.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">needs_datetime_string_cast</span></code> database feature was removed. Database
backends that set it must register a converter instead, as explained above.</p>
</li>
<li><p class="first">The <code class="docutils literal notranslate"><span class="pre">DatabaseOperations.value_to_db_&lt;type&gt;()</span></code> methods were renamed to
<code class="docutils literal notranslate"><span class="pre">adapt_&lt;type&gt;field_value()</span></code> to mirror the <code class="docutils literal notranslate"><span class="pre">convert_&lt;type&gt;field_value()</span></code>
methods.</p>
</li>
<li><p class="first">To use the new <code class="docutils literal notranslate"><span class="pre">date</span></code> lookup, third-party database backends may need to
implement the <code class="docutils literal notranslate"><span class="pre">DatabaseOperations.datetime_cast_date_sql()</span></code> method.</p>
</li>
<li><p class="first">The <code class="docutils literal notranslate"><span class="pre">DatabaseOperations.time_extract_sql()</span></code> method was added. It calls the
existing <code class="docutils literal notranslate"><span class="pre">date_extract_sql()</span></code> method. This method is overridden by the
SQLite backend to add time lookups (hour, minute, second) to
<a class="reference internal" href="../ref/models/fields.html#django.db.models.TimeField" title="django.db.models.TimeField"><code class="xref py py-class docutils literal notranslate"><span class="pre">TimeField</span></code></a>, and may be needed by third-party
database backends.</p>
</li>
<li><p class="first">The <code class="docutils literal notranslate"><span class="pre">DatabaseOperations.datetime_cast_sql()</span></code> method (not to be confused
with <code class="docutils literal notranslate"><span class="pre">DatabaseOperations.datetime_cast_date_sql()</span></code> mentioned above)
has been removed. This method served to format dates on Oracle long
before 1.0, but hasn’t been overridden by any core backend in years
and hasn’t been called anywhere in Django’s code or tests.</p>
</li>
<li><p class="first">In order to support test parallelization, you must implement the
<code class="docutils literal notranslate"><span class="pre">DatabaseCreation._clone_test_db()</span></code> method and set
<code class="docutils literal notranslate"><span class="pre">DatabaseFeatures.can_clone_databases</span> <span class="pre">=</span> <span class="pre">True</span></code>. You may have to adjust
<code class="docutils literal notranslate"><span class="pre">DatabaseCreation.get_test_db_clone_settings()</span></code>.</p>
</li>
</ul>
</div>
<div class="section" id="s-default-settings-that-were-tuples-are-now-lists">
<span id="default-settings-that-were-tuples-are-now-lists"></span><h3>Default settings that were tuples are now lists<a class="headerlink" href="#default-settings-that-were-tuples-are-now-lists" title="Permalink to this headline">¶</a></h3>
<p>The default settings in <code class="docutils literal notranslate"><span class="pre">django.conf.global_settings</span></code> were a combination of
lists and tuples. All settings that were formerly tuples are now lists.</p>
</div>
<div class="section" id="s-is-usable-attribute-on-template-loaders-is-removed">
<span id="is-usable-attribute-on-template-loaders-is-removed"></span><h3><code class="docutils literal notranslate"><span class="pre">is_usable</span></code> attribute on template loaders is removed<a class="headerlink" href="#is-usable-attribute-on-template-loaders-is-removed" title="Permalink to this headline">¶</a></h3>
<p>Django template loaders previously required an <code class="docutils literal notranslate"><span class="pre">is_usable</span></code> attribute to be
defined. If a loader was configured in the template settings and this attribute
was <code class="docutils literal notranslate"><span class="pre">False</span></code>, the loader would be silently ignored. In practice, this was only
used by the egg loader to detect if setuptools was installed. The <code class="docutils literal notranslate"><span class="pre">is_usable</span></code>
attribute is now removed and the egg loader instead fails at runtime if
setuptools is not installed.</p>
</div>
<div class="section" id="s-related-set-direct-assignment">
<span id="related-set-direct-assignment"></span><h3>Related set direct assignment<a class="headerlink" href="#related-set-direct-assignment" title="Permalink to this headline">¶</a></h3>
<p>Direct assignment of related objects in the ORM used to perform a <code class="docutils literal notranslate"><span class="pre">clear()</span></code>
followed by a call to <code class="docutils literal notranslate"><span class="pre">add()</span></code>. This caused needlessly large data changes and
prevented using the <a class="reference internal" href="../ref/signals.html#django.db.models.signals.m2m_changed" title="django.db.models.signals.m2m_changed"><code class="xref py py-data docutils literal notranslate"><span class="pre">m2m_changed</span></code></a> signal to
track individual changes in many-to-many relations.</p>
<p>Direct assignment now relies on the the new
<a class="reference internal" href="../ref/models/relations.html#django.db.models.fields.related.RelatedManager.set" title="django.db.models.fields.related.RelatedManager.set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code></a> method on related
managers which by default only processes changes between the existing related
set and the one that’s newly assigned. The previous behavior can be restored by
replacing direct assignment by a call to <code class="docutils literal notranslate"><span class="pre">set()</span></code> with the keyword argument
<code class="docutils literal notranslate"><span class="pre">clear=True</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">ModelForm</span></code>, and therefore <code class="docutils literal notranslate"><span class="pre">ModelAdmin</span></code>, internally rely on direct
assignment for many-to-many relations and as a consequence now use the new
behavior.</p>
</div>
<div class="section" id="s-filesystem-based-template-loaders-catch-more-specific-exceptions">
<span id="filesystem-based-template-loaders-catch-more-specific-exceptions"></span><h3>Filesystem-based template loaders catch more specific exceptions<a class="headerlink" href="#filesystem-based-template-loaders-catch-more-specific-exceptions" title="Permalink to this headline">¶</a></h3>
<p>When using the <a class="reference internal" href="../ref/templates/api.html#django.template.loaders.filesystem.Loader" title="django.template.loaders.filesystem.Loader"><code class="xref py py-class docutils literal notranslate"><span class="pre">filesystem.Loader</span></code></a>
or <a class="reference internal" href="../ref/templates/api.html#django.template.loaders.app_directories.Loader" title="django.template.loaders.app_directories.Loader"><code class="xref py py-class docutils literal notranslate"><span class="pre">app_directories.Loader</span></code></a>
template loaders, earlier versions of Django raised a
<a class="reference internal" href="../topics/templates.html#django.template.TemplateDoesNotExist" title="django.template.TemplateDoesNotExist"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TemplateDoesNotExist</span></code></a> error if a template source existed
but was unreadable. This could happen under many circumstances, such as if
Django didn’t have permissions to open the file, or if the template source was
a directory. Now, Django only silences the exception if the template source
does not exist. All other situations result in the original <code class="docutils literal notranslate"><span class="pre">IOError</span></code> being
raised.</p>
</div>
<div class="section" id="s-http-redirects-no-longer-forced-to-absolute-uris">
<span id="http-redirects-no-longer-forced-to-absolute-uris"></span><h3>HTTP redirects no longer forced to absolute URIs<a class="headerlink" href="#http-redirects-no-longer-forced-to-absolute-uris" title="Permalink to this headline">¶</a></h3>
<p>Relative redirects are no longer converted to absolute URIs. <span class="target" id="index-1"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc2616.html"><strong>RFC 2616</strong></a>
required the <code class="docutils literal notranslate"><span class="pre">Location</span></code> header in redirect responses to be an absolute URI,
but it has been superseded by <span class="target" id="index-2"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc7231.html"><strong>RFC 7231</strong></a> which allows relative URIs in
<code class="docutils literal notranslate"><span class="pre">Location</span></code>, recognizing the actual practice of user agents, almost all of
which support them.</p>
<p>Consequently, the expected URLs passed to <code class="docutils literal notranslate"><span class="pre">assertRedirects</span></code> should generally
no longer include the scheme and domain part of the URLs. For example,
<code class="docutils literal notranslate"><span class="pre">self.assertRedirects(response,</span> <span class="pre">'http://testserver/some-url/')</span></code> should be
replaced by <code class="docutils literal notranslate"><span class="pre">self.assertRedirects(response,</span> <span class="pre">'/some-url/')</span></code> (unless the
redirection specifically contained an absolute URL, of course).</p>
<p>In the rare case that you need the old behavior (discovered with an ancient
version of Apache with <code class="docutils literal notranslate"><span class="pre">mod_scgi</span></code> that interprets a relative redirect as an
“internal redirect”), you can restore it by writing a custom middleware:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">LocationHeaderFix</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">process_response</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request</span><span class="p">,</span> <span class="n">response</span><span class="p">):</span>
        <span class="k">if</span> <span class="s1">&#39;Location&#39;</span> <span class="ow">in</span> <span class="n">response</span><span class="p">:</span>
            <span class="n">response</span><span class="p">[</span><span class="s1">&#39;Location&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">build_absolute_uri</span><span class="p">(</span><span class="n">response</span><span class="p">[</span><span class="s1">&#39;Location&#39;</span><span class="p">])</span>
        <span class="k">return</span> <span class="n">response</span>
</pre></div>
</div>
</div>
<div class="section" id="s-dropped-support-for-postgresql-9-0">
<span id="dropped-support-for-postgresql-9-0"></span><h3>Dropped support for PostgreSQL 9.0<a class="headerlink" href="#dropped-support-for-postgresql-9-0" title="Permalink to this headline">¶</a></h3>
<p>Upstream support for PostgreSQL 9.0 ended in September 2015. As a consequence,
Django 1.9 sets 9.1 as the minimum PostgreSQL version it officially supports.</p>
</div>
<div class="section" id="s-dropped-support-for-oracle-11-1">
<span id="dropped-support-for-oracle-11-1"></span><h3>Dropped support for Oracle 11.1<a class="headerlink" href="#dropped-support-for-oracle-11-1" title="Permalink to this headline">¶</a></h3>
<p>Upstream support for Oracle 11.1 ended in August 2015. As a consequence, Django
1.9 sets 11.2 as the minimum Oracle version it officially supports.</p>
</div>
<div class="section" id="s-bulk-behavior-of-add-method-of-related-managers">
<span id="bulk-behavior-of-add-method-of-related-managers"></span><h3>Bulk behavior of <code class="docutils literal notranslate"><span class="pre">add()</span></code> method of related managers<a class="headerlink" href="#bulk-behavior-of-add-method-of-related-managers" title="Permalink to this headline">¶</a></h3>
<p>To improve performance, the <code class="docutils literal notranslate"><span class="pre">add()</span></code> methods of the related managers created
by <code class="docutils literal notranslate"><span class="pre">ForeignKey</span></code> and <code class="docutils literal notranslate"><span class="pre">GenericForeignKey</span></code> changed from a series of
<code class="docutils literal notranslate"><span class="pre">Model.save()</span></code> calls to a single <code class="docutils literal notranslate"><span class="pre">QuerySet.update()</span></code> call. The change means
that <code class="docutils literal notranslate"><span class="pre">pre_save</span></code> and <code class="docutils literal notranslate"><span class="pre">post_save</span></code> signals aren’t sent anymore. You can use
the <code class="docutils literal notranslate"><span class="pre">bulk=False</span></code> keyword argument to revert to the previous behavior.</p>
</div>
<div class="section" id="s-template-loaderorigin-and-stringorigin-are-removed">
<span id="template-loaderorigin-and-stringorigin-are-removed"></span><h3>Template <code class="docutils literal notranslate"><span class="pre">LoaderOrigin</span></code> and <code class="docutils literal notranslate"><span class="pre">StringOrigin</span></code> are removed<a class="headerlink" href="#template-loaderorigin-and-stringorigin-are-removed" title="Permalink to this headline">¶</a></h3>
<p>In previous versions of Django, when a template engine was initialized with
debug as <code class="docutils literal notranslate"><span class="pre">True</span></code>, an instance of <code class="docutils literal notranslate"><span class="pre">django.template.loader.LoaderOrigin</span></code> or
<code class="docutils literal notranslate"><span class="pre">django.template.base.StringOrigin</span></code> was set as the origin attribute on the
template object. These classes have been combined into
<a class="reference internal" href="../ref/templates/api.html#django.template.base.Origin" title="django.template.base.Origin"><code class="xref py py-class docutils literal notranslate"><span class="pre">Origin</span></code></a> and is now always set regardless of the
engine debug setting. For a minimal level of backwards compatibility, the old
class names will be kept as aliases to the new <code class="docutils literal notranslate"><span class="pre">Origin</span></code> class until
Django 2.0.</p>
</div>
<div class="section" id="s-changes-to-the-default-logging-configuration">
<span id="s-default-logging-changes-19"></span><span id="changes-to-the-default-logging-configuration"></span><span id="default-logging-changes-19"></span><h3>Changes to the default logging configuration<a class="headerlink" href="#changes-to-the-default-logging-configuration" title="Permalink to this headline">¶</a></h3>
<p>To make it easier to write custom logging configurations, Django’s default
logging configuration no longer defines <code class="docutils literal notranslate"><span class="pre">django.request</span></code> and
<code class="docutils literal notranslate"><span class="pre">django.security</span></code> loggers. Instead, it defines a single <code class="docutils literal notranslate"><span class="pre">django</span></code> logger,
filtered at the <code class="docutils literal notranslate"><span class="pre">INFO</span></code> level, with two handlers:</p>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">console</span></code>: filtered at the <code class="docutils literal notranslate"><span class="pre">INFO</span></code> level and only active if <code class="docutils literal notranslate"><span class="pre">DEBUG=True</span></code>.</li>
<li><code class="docutils literal notranslate"><span class="pre">mail_admins</span></code>: filtered at the <code class="docutils literal notranslate"><span class="pre">ERROR</span></code> level and only active if
<code class="docutils literal notranslate"><span class="pre">DEBUG=False</span></code>.</li>
</ul>
<p>If you aren’t overriding Django’s default logging, you should see minimal
changes in behavior, but you might see some new logging to the <code class="docutils literal notranslate"><span class="pre">runserver</span></code>
console, for example.</p>
<p>If you are overriding Django’s default logging, you should check to see how
your configuration merges with the new defaults.</p>
</div>
<div class="section" id="s-httprequest-details-in-error-reporting">
<span id="httprequest-details-in-error-reporting"></span><h3><code class="docutils literal notranslate"><span class="pre">HttpRequest</span></code> details in error reporting<a class="headerlink" href="#httprequest-details-in-error-reporting" title="Permalink to this headline">¶</a></h3>
<p>It was redundant to display the full details of the
<a class="reference internal" href="../ref/request-response.html#django.http.HttpRequest" title="django.http.HttpRequest"><code class="xref py py-class docutils literal notranslate"><span class="pre">HttpRequest</span></code></a> each time it appeared as a stack frame
variable in the HTML version of the debug page and error email. Thus, the HTTP
request will now display the same standard representation as other variables
(<code class="docutils literal notranslate"><span class="pre">repr(request)</span></code>). As a result, the
<code class="docutils literal notranslate"><span class="pre">ExceptionReporterFilter.get_request_repr()</span></code> method and the undocumented
<code class="docutils literal notranslate"><span class="pre">django.http.build_request_repr()</span></code> function were removed.</p>
<p>The contents of the text version of the email were modified to provide a
traceback of the same structure as in the case of AJAX requests. The traceback
details are rendered by the <code class="docutils literal notranslate"><span class="pre">ExceptionReporter.get_traceback_text()</span></code> method.</p>
</div>
<div class="section" id="s-removal-of-time-zone-aware-global-adapters-and-converters-for-datetimes">
<span id="removal-of-time-zone-aware-global-adapters-and-converters-for-datetimes"></span><h3>Removal of time zone aware global adapters and converters for datetimes<a class="headerlink" href="#removal-of-time-zone-aware-global-adapters-and-converters-for-datetimes" title="Permalink to this headline">¶</a></h3>
<p>Django no longer registers global adapters and converters for managing time
zone information on <code class="xref py py-class docutils literal notranslate"><span class="pre">datetime</span></code> values sent to the database as
query parameters or read from the database in query results. This change
affects projects that meet all the following conditions:</p>
<ul class="simple">
<li>The <a class="reference internal" href="../ref/settings.html#std:setting-USE_TZ"><code class="xref std std-setting docutils literal notranslate"><span class="pre">USE_TZ</span></code></a> setting is <code class="docutils literal notranslate"><span class="pre">True</span></code>.</li>
<li>The database is SQLite, MySQL, Oracle, or a third-party database that
doesn’t support time zones. In doubt, you can check the value of
<code class="docutils literal notranslate"><span class="pre">connection.features.supports_timezones</span></code>.</li>
<li>The code queries the database outside of the ORM, typically with
<code class="docutils literal notranslate"><span class="pre">cursor.execute(sql,</span> <span class="pre">params)</span></code>.</li>
</ul>
<p>If you’re passing aware <code class="xref py py-class docutils literal notranslate"><span class="pre">datetime</span></code> parameters to such
queries, you should turn them into naive datetimes in UTC:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.utils</span> <span class="k">import</span> <span class="n">timezone</span>
<span class="n">param</span> <span class="o">=</span> <span class="n">timezone</span><span class="o">.</span><span class="n">make_naive</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">timezone</span><span class="o">.</span><span class="n">utc</span><span class="p">)</span>
</pre></div>
</div>
<p>If you fail to do so, the conversion will be performed as in earlier versions
(with a deprecation warning) up until Django 1.11. Django 2.0 won’t perform any
conversion, which may result in data corruption.</p>
<p>If you’re reading <code class="xref py py-class docutils literal notranslate"><span class="pre">datetime</span></code> values from the results, they
will be naive instead of aware. You can compensate as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.utils</span> <span class="k">import</span> <span class="n">timezone</span>
<span class="n">value</span> <span class="o">=</span> <span class="n">timezone</span><span class="o">.</span><span class="n">make_aware</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">timezone</span><span class="o">.</span><span class="n">utc</span><span class="p">)</span>
</pre></div>
</div>
<p>You don’t need any of this if you’re querying the database through the ORM,
even if you’re using <a class="reference internal" href="../ref/models/querysets.html#django.db.models.query.QuerySet.raw" title="django.db.models.query.QuerySet.raw"><code class="xref py py-meth docutils literal notranslate"><span class="pre">raw()</span></code></a>
queries. The ORM takes care of managing time zone information.</p>
</div>
<div class="section" id="s-template-tag-modules-are-imported-when-templates-are-configured">
<span id="template-tag-modules-are-imported-when-templates-are-configured"></span><h3>Template tag modules are imported when templates are configured<a class="headerlink" href="#template-tag-modules-are-imported-when-templates-are-configured" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../topics/templates.html#django.template.backends.django.DjangoTemplates" title="django.template.backends.django.DjangoTemplates"><code class="xref py py-class docutils literal notranslate"><span class="pre">DjangoTemplates</span></code></a> backend now
performs discovery on installed template tag modules when instantiated. This
update enables libraries to be provided explicitly via the <code class="docutils literal notranslate"><span class="pre">'libraries'</span></code>
key of <a class="reference internal" href="../ref/settings.html#std:setting-TEMPLATES-OPTIONS"><code class="xref std std-setting docutils literal notranslate"><span class="pre">OPTIONS</span></code></a> when defining a
<a class="reference internal" href="../topics/templates.html#django.template.backends.django.DjangoTemplates" title="django.template.backends.django.DjangoTemplates"><code class="xref py py-class docutils literal notranslate"><span class="pre">DjangoTemplates</span></code></a> backend. Import
or syntax errors in template tag modules now fail early at instantiation time
rather than when a template with a <a class="reference internal" href="../ref/templates/builtins.html#std:templatetag-load"><code class="xref std std-ttag docutils literal notranslate"><span class="pre">{%</span> <span class="pre">load</span> <span class="pre">%}</span></code></a> tag is first
compiled.</p>
</div>
<div class="section" id="s-django-template-base-add-to-builtins-is-removed">
<span id="django-template-base-add-to-builtins-is-removed"></span><h3><code class="docutils literal notranslate"><span class="pre">django.template.base.add_to_builtins()</span></code> is removed<a class="headerlink" href="#django-template-base-add-to-builtins-is-removed" title="Permalink to this headline">¶</a></h3>
<p>Although it was a private API, projects commonly used <code class="docutils literal notranslate"><span class="pre">add_to_builtins()</span></code> to
make template tags and filters available without using the
<a class="reference internal" href="../ref/templates/builtins.html#std:templatetag-load"><code class="xref std std-ttag docutils literal notranslate"><span class="pre">{%</span> <span class="pre">load</span> <span class="pre">%}</span></code></a> tag. This API has been formalized. Projects should now
define built-in libraries via the <code class="docutils literal notranslate"><span class="pre">'builtins'</span></code> key of <a class="reference internal" href="../ref/settings.html#std:setting-TEMPLATES-OPTIONS"><code class="xref std std-setting docutils literal notranslate"><span class="pre">OPTIONS</span></code></a> when defining a
<a class="reference internal" href="../topics/templates.html#django.template.backends.django.DjangoTemplates" title="django.template.backends.django.DjangoTemplates"><code class="xref py py-class docutils literal notranslate"><span class="pre">DjangoTemplates</span></code></a> backend.</p>
</div>
<div class="section" id="s-simple-tag-now-wraps-tag-output-in-conditional-escape">
<span id="s-simple-tag-conditional-escape-fix"></span><span id="simple-tag-now-wraps-tag-output-in-conditional-escape"></span><span id="simple-tag-conditional-escape-fix"></span><h3><code class="docutils literal notranslate"><span class="pre">simple_tag</span></code> now wraps tag output in <code class="docutils literal notranslate"><span class="pre">conditional_escape</span></code><a class="headerlink" href="#simple-tag-now-wraps-tag-output-in-conditional-escape" title="Permalink to this headline">¶</a></h3>
<p>In general, template tags do not autoescape their contents, and this behavior is
<a class="reference internal" href="../howto/custom-template-tags.html#tags-auto-escaping"><span class="std std-ref">documented</span></a>. For tags like
<a class="reference internal" href="../howto/custom-template-tags.html#django.template.Library.inclusion_tag" title="django.template.Library.inclusion_tag"><code class="xref py py-class docutils literal notranslate"><span class="pre">inclusion_tag</span></code></a>, this is not a problem because
the included template will perform autoescaping. For
<a class="reference internal" href="../howto/custom-template-tags.html#django.template.Library.assignment_tag" title="django.template.Library.assignment_tag"><code class="xref py py-class docutils literal notranslate"><span class="pre">assignment_tag</span></code></a>, the output will be escaped
when it is used as a variable in the template.</p>
<p>For the intended use cases of <a class="reference internal" href="../howto/custom-template-tags.html#django.template.Library.simple_tag" title="django.template.Library.simple_tag"><code class="xref py py-class docutils literal notranslate"><span class="pre">simple_tag</span></code></a>,
however, it is very easy to end up with incorrect HTML and possibly an XSS
exploit. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@register</span><span class="o">.</span><span class="n">simple_tag</span><span class="p">(</span><span class="n">takes_context</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">greeting</span><span class="p">(</span><span class="n">context</span><span class="p">):</span>
    <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><span class="n">format</span><span class="p">(</span><span class="n">context</span><span class="p">[</span><span class="s1">&#39;request&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">user</span><span class="o">.</span><span class="n">first_name</span><span class="p">)</span>
</pre></div>
</div>
<p>In older versions of Django, this will be an XSS issue because
<code class="docutils literal notranslate"><span class="pre">user.first_name</span></code> is not escaped.</p>
<p>In Django 1.9, this is fixed: if the template context has <code class="docutils literal notranslate"><span class="pre">autoescape=True</span></code>
set (the default), then <code class="docutils literal notranslate"><span class="pre">simple_tag</span></code> will wrap the output of the tag function
with <a class="reference internal" href="../ref/utils.html#django.utils.html.conditional_escape" title="django.utils.html.conditional_escape"><code class="xref py py-func docutils literal notranslate"><span class="pre">conditional_escape()</span></code></a>.</p>
<p>To fix your <code class="docutils literal notranslate"><span class="pre">simple_tag</span></code>s, it is best to apply the following practices:</p>
<ul class="simple">
<li>Any code that generates HTML should use either the template system or
<a class="reference internal" href="../ref/utils.html#django.utils.html.format_html" title="django.utils.html.format_html"><code class="xref py py-func docutils literal notranslate"><span class="pre">format_html()</span></code></a>.</li>
<li>If the output of a <code class="docutils literal notranslate"><span class="pre">simple_tag</span></code> needs escaping, use
<a class="reference internal" href="../ref/utils.html#django.utils.html.escape" title="django.utils.html.escape"><code class="xref py py-func docutils literal notranslate"><span class="pre">escape()</span></code></a> or
<a class="reference internal" href="../ref/utils.html#django.utils.html.conditional_escape" title="django.utils.html.conditional_escape"><code class="xref py py-func docutils literal notranslate"><span class="pre">conditional_escape()</span></code></a>.</li>
<li>If you are absolutely certain that you are outputting HTML from a trusted
source (e.g. a CMS field that stores HTML entered by admins), you can mark it
as such using <a class="reference internal" href="../ref/utils.html#django.utils.safestring.mark_safe" title="django.utils.safestring.mark_safe"><code class="xref py py-func docutils literal notranslate"><span class="pre">mark_safe()</span></code></a>.</li>
</ul>
<p>Tags that follow these rules will be correct and safe whether they are run on
Django 1.9+ or earlier.</p>
</div>
<div class="section" id="s-paginator-page-range">
<span id="paginator-page-range"></span><h3><code class="docutils literal notranslate"><span class="pre">Paginator.page_range</span></code><a class="headerlink" href="#paginator-page-range" title="Permalink to this headline">¶</a></h3>
<p><a class="reference internal" href="../topics/pagination.html#django.core.paginator.Paginator.page_range" title="django.core.paginator.Paginator.page_range"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Paginator.page_range</span></code></a> is
now an iterator instead of a list.</p>
<p>In versions of Django previous to 1.8, <code class="docutils literal notranslate"><span class="pre">Paginator.page_range</span></code> returned a
<code class="docutils literal notranslate"><span class="pre">list</span></code> in Python 2 and a <code class="docutils literal notranslate"><span class="pre">range</span></code> in Python 3. Django 1.8 consistently
returned a list, but an iterator is more efficient.</p>
<p>Existing code that depends on <code class="docutils literal notranslate"><span class="pre">list</span></code> specific features, such as indexing,
can be ported by converting the iterator into a <code class="docutils literal notranslate"><span class="pre">list</span></code> using <code class="docutils literal notranslate"><span class="pre">list()</span></code>.</p>
</div>
<div class="section" id="s-implicit-queryset-in-lookup-removed">
<span id="implicit-queryset-in-lookup-removed"></span><h3>Implicit <code class="docutils literal notranslate"><span class="pre">QuerySet</span></code> <code class="docutils literal notranslate"><span class="pre">__in</span></code> lookup removed<a class="headerlink" href="#implicit-queryset-in-lookup-removed" title="Permalink to this headline">¶</a></h3>
<p>In earlier versions, queries such as:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Model</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">related_id</span><span class="o">=</span><span class="n">RelatedModel</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">())</span>
</pre></div>
</div>
<p>would implicitly convert to:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">Model</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">related_id__in</span><span class="o">=</span><span class="n">RelatedModel</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">())</span>
</pre></div>
</div>
<p>resulting in SQL like <code class="docutils literal notranslate"><span class="pre">&quot;related_id</span> <span class="pre">IN</span> <span class="pre">(SELECT</span> <span class="pre">id</span> <span class="pre">FROM</span> <span class="pre">...)&quot;</span></code>.</p>
<p>This implicit <code class="docutils literal notranslate"><span class="pre">__in</span></code> no longer happens so the “IN” SQL is now “=”, and if the
subquery returns multiple results, at least some databases will throw an error.</p>
</div>
<div class="section" id="s-contrib-admin-browser-support">
<span id="s-admin-browser-support-19"></span><span id="contrib-admin-browser-support"></span><span id="admin-browser-support-19"></span><h3><code class="docutils literal notranslate"><span class="pre">contrib.admin</span></code> browser support<a class="headerlink" href="#contrib-admin-browser-support" title="Permalink to this headline">¶</a></h3>
<p>The admin no longer supports Internet Explorer 8 and below, as these browsers
have reached end-of-life.</p>
<p>CSS and images to support Internet Explorer 6 and 7 have been removed. PNG and
GIF icons have been replaced with SVG icons, which are not supported by
Internet Explorer 8 and earlier.</p>
<p>The jQuery library embedded in the admin has been upgraded from version 1.11.2
to 2.1.4. jQuery 2.x has the same API as jQuery 1.x, but does not support
Internet Explorer 6, 7, or 8, allowing for better performance and a smaller
file size. If you need to support IE8 and must also use the latest version of
Django, you can override the admin’s copy of jQuery with your own by creating
a Django application with this structure:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">app</span><span class="o">/</span><span class="n">static</span><span class="o">/</span><span class="n">admin</span><span class="o">/</span><span class="n">js</span><span class="o">/</span><span class="n">vendor</span><span class="o">/</span>
    <span class="n">jquery</span><span class="o">.</span><span class="n">js</span>
    <span class="n">jquery</span><span class="o">.</span><span class="n">min</span><span class="o">.</span><span class="n">js</span>
</pre></div>
</div>
</div>
<div class="section" id="s-syntaxerror-when-installing-django-setuptools-5-5-x">
<span id="s-syntax-error-old-setuptools-django-19"></span><span id="syntaxerror-when-installing-django-setuptools-5-5-x"></span><span id="syntax-error-old-setuptools-django-19"></span><h3><code class="docutils literal notranslate"><span class="pre">SyntaxError</span></code> when installing Django setuptools 5.5.x<a class="headerlink" href="#syntaxerror-when-installing-django-setuptools-5-5-x" title="Permalink to this headline">¶</a></h3>
<p>When installing Django 1.9 or 1.9.1 with setuptools 5.5.x, you’ll see:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>Compiling django/conf/app_template/apps.py ...
  File &quot;django/conf/app_template/apps.py&quot;, line 4
    class {{ camel_case_app_name }}Config(AppConfig):
          ^
SyntaxError: invalid syntax

Compiling django/conf/app_template/models.py ...
  File &quot;django/conf/app_template/models.py&quot;, line 1
    {{ unicode_literals }}from django.db import models
                             ^
SyntaxError: invalid syntax
</pre></div>
</div>
<p>It’s safe to ignore these errors (Django will still install just fine), but you
can avoid them by upgrading setuptools to a more recent version. If you’re
using pip, you can upgrade pip using <code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">-U</span> <span class="pre">pip</span></code> which will also
upgrade setuptools. This is resolved in later versions of Django as described
in the <a class="reference internal" href="1.9.2.html"><span class="doc">Django 1.9.2 release notes</span></a>.</p>
</div>
<div class="section" id="s-miscellaneous">
<span id="miscellaneous"></span><h3>Miscellaneous<a class="headerlink" href="#miscellaneous" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>The jQuery static files in <code class="docutils literal notranslate"><span class="pre">contrib.admin</span></code> have been moved into a
<code class="docutils literal notranslate"><span class="pre">vendor/jquery</span></code> subdirectory.</li>
<li>The text displayed for null columns in the admin changelist <code class="docutils literal notranslate"><span class="pre">list_display</span></code>
cells has changed from <code class="docutils literal notranslate"><span class="pre">(None)</span></code> (or its translated equivalent) to <code class="docutils literal notranslate"><span class="pre">-</span></code> (a
dash).</li>
<li><code class="docutils literal notranslate"><span class="pre">django.http.responses.REASON_PHRASES</span></code> and
<code class="docutils literal notranslate"><span class="pre">django.core.handlers.wsgi.STATUS_CODE_TEXT</span></code> have been removed. Use
Python’s stdlib instead: <code class="xref py py-data docutils literal notranslate"><span class="pre">http.client.responses</span></code> for Python 3 and
<a class="reference external" href="https://docs.python.org/2/library/httplib.html#httplib.responses">httplib.responses</a> for Python 2.</li>
<li><code class="docutils literal notranslate"><span class="pre">ValuesQuerySet</span></code> and <code class="docutils literal notranslate"><span class="pre">ValuesListQuerySet</span></code> have been removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">admin/base.html</span></code> template no longer sets
<code class="docutils literal notranslate"><span class="pre">window.__admin_media_prefix__</span></code> or <code class="docutils literal notranslate"><span class="pre">window.__admin_utc_offset__</span></code>. Image
references in JavaScript that used that value to construct absolute URLs have
been moved to CSS for easier customization. The UTC offset is stored on a
data attribute of the <code class="docutils literal notranslate"><span class="pre">&lt;body&gt;</span></code> tag.</li>
<li><code class="docutils literal notranslate"><span class="pre">CommaSeparatedIntegerField</span></code> validation has been refined to forbid values
like <code class="docutils literal notranslate"><span class="pre">','</span></code>, <code class="docutils literal notranslate"><span class="pre">',1'</span></code>, and <code class="docutils literal notranslate"><span class="pre">'1,,2'</span></code>.</li>
<li>Form initialization was moved from the <a class="reference internal" href="../ref/class-based-views/mixins-editing.html#django.views.generic.edit.ProcessFormView.get" title="django.views.generic.edit.ProcessFormView.get"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ProcessFormView.get()</span></code></a> method to the new
<a class="reference internal" href="../ref/class-based-views/mixins-editing.html#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"><span class="pre">FormMixin.get_context_data()</span></code></a> method. This may be
backwards incompatible if you have overridden the <code class="docutils literal notranslate"><span class="pre">get_context_data()</span></code>
method without calling <code class="docutils literal notranslate"><span class="pre">super()</span></code>.</li>
<li>Support for PostGIS 1.5 has been dropped.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">django.contrib.sites.models.Site.domain</span></code> field was changed to be
<a class="reference internal" href="../ref/models/fields.html#django.db.models.Field.unique" title="django.db.models.Field.unique"><code class="xref py py-attr docutils literal notranslate"><span class="pre">unique</span></code></a>.</li>
<li>In order to enforce test isolation, database queries are not allowed
by default in <a class="reference internal" href="../topics/testing/tools.html#django.test.SimpleTestCase" title="django.test.SimpleTestCase"><code class="xref py py-class docutils literal notranslate"><span class="pre">SimpleTestCase</span></code></a> tests anymore. You
can disable this behavior by setting the
<a class="reference internal" href="../topics/testing/tools.html#django.test.SimpleTestCase.allow_database_queries" title="django.test.SimpleTestCase.allow_database_queries"><code class="xref py py-attr docutils literal notranslate"><span class="pre">allow_database_queries</span></code></a> class attribute
to <code class="docutils literal notranslate"><span class="pre">True</span></code> on your test class.</li>
<li><code class="docutils literal notranslate"><span class="pre">ResolverMatch.app_name</span></code> was changed to contain the full namespace path in
the case of nested namespaces. For consistency with
<code class="docutils literal notranslate"><span class="pre">ResolverMatch.namespace</span></code>, the empty value is now an empty string instead
of <code class="docutils literal notranslate"><span class="pre">None</span></code>.</li>
<li>For security hardening, session keys must be at least 8 characters.</li>
<li>Private function <code class="docutils literal notranslate"><span class="pre">django.utils.functional.total_ordering()</span></code> has been
removed. It contained a workaround for a <code class="docutils literal notranslate"><span class="pre">functools.total_ordering()</span></code> bug
in Python versions older than 2.7.3.</li>
<li>XML serialization (either through <a class="reference internal" href="../ref/django-admin.html#django-admin-dumpdata"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">dumpdata</span></code></a> or the syndication
framework) used to output any characters it received. Now if the content to
be serialized contains any control characters not allowed in the XML 1.0
standard, the serialization will fail with a <code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code>.</li>
<li><a class="reference internal" href="../ref/forms/fields.html#django.forms.CharField" title="django.forms.CharField"><code class="xref py py-class docutils literal notranslate"><span class="pre">CharField</span></code></a> now strips input of leading and trailing
whitespace by default. This can be disabled by setting the new
<a class="reference internal" href="../ref/forms/fields.html#django.forms.CharField.strip" title="django.forms.CharField.strip"><code class="xref py py-attr docutils literal notranslate"><span class="pre">strip</span></code></a> argument to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</li>
<li>Template text that is translated and uses two or more consecutive percent
signs, e.g. <code class="docutils literal notranslate"><span class="pre">&quot;%%&quot;</span></code>, may have a new <cite>msgid</cite> after <code class="docutils literal notranslate"><span class="pre">makemessages</span></code> is run
(most likely the translation will be marked fuzzy). The new <code class="docutils literal notranslate"><span class="pre">msgid</span></code> will be
marked <code class="docutils literal notranslate"><span class="pre">&quot;#,</span> <span class="pre">python-format&quot;</span></code>.</li>
<li>If neither <a class="reference internal" href="../ref/request-response.html#django.http.HttpRequest.current_app" title="django.http.HttpRequest.current_app"><code class="xref py py-attr docutils literal notranslate"><span class="pre">request.current_app</span></code></a>
nor <a class="reference internal" href="../ref/templates/api.html#django.template.Context" title="django.template.Context"><code class="xref py py-class docutils literal notranslate"><span class="pre">Context.current_app</span></code></a> are set, the
<a class="reference internal" href="../ref/templates/builtins.html#std:templatetag-url"><code class="xref std std-ttag docutils literal notranslate"><span class="pre">url</span></code></a> template tag will now use the namespace of the current request.
Set <code class="docutils literal notranslate"><span class="pre">request.current_app</span></code> to <code class="docutils literal notranslate"><span class="pre">None</span></code> if you don’t want to use a namespace
hint.</li>
<li>The <a class="reference internal" href="../ref/settings.html#std:setting-SILENCED_SYSTEM_CHECKS"><code class="xref std std-setting docutils literal notranslate"><span class="pre">SILENCED_SYSTEM_CHECKS</span></code></a> setting now silences messages of all
levels. Previously, messages of <code class="docutils literal notranslate"><span class="pre">ERROR</span></code> level or higher were printed to the
console.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">FlatPage.enable_comments</span></code> field is removed from the <code class="docutils literal notranslate"><span class="pre">FlatPageAdmin</span></code>
as it’s unused by the application. If your project or a third-party app makes
use of it, <a class="reference internal" href="../ref/contrib/flatpages.html#flatpages-admin"><span class="std std-ref">create a custom ModelAdmin</span></a> to add it back.</li>
<li>The return value of
<a class="reference internal" href="../topics/testing/advanced.html#django.test.runner.DiscoverRunner.setup_databases" title="django.test.runner.DiscoverRunner.setup_databases"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setup_databases()</span></code></a> and the first
argument of <a class="reference internal" href="../topics/testing/advanced.html#django.test.runner.DiscoverRunner.teardown_databases" title="django.test.runner.DiscoverRunner.teardown_databases"><code class="xref py py-meth docutils literal notranslate"><span class="pre">teardown_databases()</span></code></a>
changed. They used to be <code class="docutils literal notranslate"><span class="pre">(old_names,</span> <span class="pre">mirrors)</span></code> tuples. Now they’re just
the first item, <code class="docutils literal notranslate"><span class="pre">old_names</span></code>.</li>
<li>By default <a class="reference internal" href="../topics/testing/tools.html#django.test.LiveServerTestCase" title="django.test.LiveServerTestCase"><code class="xref py py-class docutils literal notranslate"><span class="pre">LiveServerTestCase</span></code></a> attempts to find an
available port in the 8081-8179 range instead of just trying port 8081.</li>
<li>The system checks for <a class="reference internal" href="../ref/contrib/admin/index.html#django.contrib.admin.ModelAdmin" title="django.contrib.admin.ModelAdmin"><code class="xref py py-class docutils literal notranslate"><span class="pre">ModelAdmin</span></code></a> now check
instances rather than classes.</li>
<li>The private API to apply mixed migration plans has been dropped for
performance reasons. Mixed plans consist of a list of migrations where some
are being applied and others are being unapplied.</li>
<li>The related model object descriptor classes in
<code class="docutils literal notranslate"><span class="pre">django.db.models.fields.related</span></code> (private API) are moved from the
<code class="docutils literal notranslate"><span class="pre">related</span></code> module to <code class="docutils literal notranslate"><span class="pre">related_descriptors</span></code> and renamed as follows:<ul>
<li><code class="docutils literal notranslate"><span class="pre">ReverseSingleRelatedObjectDescriptor</span></code> is <code class="docutils literal notranslate"><span class="pre">ForwardManyToOneDescriptor</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">SingleRelatedObjectDescriptor</span></code> is <code class="docutils literal notranslate"><span class="pre">ReverseOneToOneDescriptor</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">ForeignRelatedObjectsDescriptor</span></code> is <code class="docutils literal notranslate"><span class="pre">ReverseManyToOneDescriptor</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">ManyRelatedObjectsDescriptor</span></code> is <code class="docutils literal notranslate"><span class="pre">ManyToManyDescriptor</span></code></li>
</ul>
</li>
<li>If you implement a custom <a class="reference internal" href="../ref/urls.html#django.conf.urls.handler404" title="django.conf.urls.handler404"><code class="xref py py-data docutils literal notranslate"><span class="pre">handler404</span></code></a> view, it must
return a response with an HTTP 404 status code. Use
<a class="reference internal" href="../ref/request-response.html#django.http.HttpResponseNotFound" title="django.http.HttpResponseNotFound"><code class="xref py py-class docutils literal notranslate"><span class="pre">HttpResponseNotFound</span></code></a> or pass <code class="docutils literal notranslate"><span class="pre">status=404</span></code> to the
<a class="reference internal" href="../ref/request-response.html#django.http.HttpResponse" title="django.http.HttpResponse"><code class="xref py py-class docutils literal notranslate"><span class="pre">HttpResponse</span></code></a>. Otherwise, <a class="reference internal" href="../ref/settings.html#std:setting-APPEND_SLASH"><code class="xref std std-setting docutils literal notranslate"><span class="pre">APPEND_SLASH</span></code></a> won’t
work correctly with <code class="docutils literal notranslate"><span class="pre">DEBUG=False</span></code>.</li>
</ul>
</div>
</div>
<div class="section" id="s-features-deprecated-in-1-9">
<span id="s-deprecated-features-1-9"></span><span id="features-deprecated-in-1-9"></span><span id="deprecated-features-1-9"></span><h2>Features deprecated in 1.9<a class="headerlink" href="#features-deprecated-in-1-9" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-assignment-tag">
<span id="assignment-tag"></span><h3><code class="docutils literal notranslate"><span class="pre">assignment_tag()</span></code><a class="headerlink" href="#assignment-tag" title="Permalink to this headline">¶</a></h3>
<p>Django 1.4 added the <code class="docutils literal notranslate"><span class="pre">assignment_tag</span></code> helper to ease the creation of
template tags that store results in a template variable. The
<a class="reference internal" href="../howto/custom-template-tags.html#django.template.Library.simple_tag" title="django.template.Library.simple_tag"><code class="xref py py-meth docutils literal notranslate"><span class="pre">simple_tag()</span></code></a> helper has gained this same
ability, making the <code class="docutils literal notranslate"><span class="pre">assignment_tag</span></code> obsolete. Tags that use
<code class="docutils literal notranslate"><span class="pre">assignment_tag</span></code> should be updated to use <code class="docutils literal notranslate"><span class="pre">simple_tag</span></code>.</p>
</div>
<div class="section" id="s-cycle-syntax-with-comma-separated-arguments">
<span id="cycle-syntax-with-comma-separated-arguments"></span><h3><code class="docutils literal notranslate"><span class="pre">{%</span> <span class="pre">cycle</span> <span class="pre">%}</span></code> syntax with comma-separated arguments<a class="headerlink" href="#cycle-syntax-with-comma-separated-arguments" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../ref/templates/builtins.html#std:templatetag-cycle"><code class="xref std std-ttag docutils literal notranslate"><span class="pre">cycle</span></code></a> tag supports an inferior old syntax from previous Django
versions:</p>
<div class="highlight-html+django notranslate"><div class="highlight"><pre><span></span><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>
</pre></div>
</div>
<p>Its parsing caused bugs with the current syntax, so support for the old syntax
will be removed in Django 1.10 following an accelerated deprecation.</p>
</div>
<div class="section" id="s-foreignkey-and-onetoonefield-on-delete-argument">
<span id="foreignkey-and-onetoonefield-on-delete-argument"></span><h3><code class="docutils literal notranslate"><span class="pre">ForeignKey</span></code> and <code class="docutils literal notranslate"><span class="pre">OneToOneField</span></code> <code class="docutils literal notranslate"><span class="pre">on_delete</span></code> argument<a class="headerlink" href="#foreignkey-and-onetoonefield-on-delete-argument" title="Permalink to this headline">¶</a></h3>
<p>In order to increase awareness about cascading model deletion, the
<code class="docutils literal notranslate"><span class="pre">on_delete</span></code> argument of <code class="docutils literal notranslate"><span class="pre">ForeignKey</span></code> and <code class="docutils literal notranslate"><span class="pre">OneToOneField</span></code> will be required
in Django 2.0.</p>
<p>Update models and existing migrations to explicitly set the argument. Since the
default is <code class="docutils literal notranslate"><span class="pre">models.CASCADE</span></code>, add <code class="docutils literal notranslate"><span class="pre">on_delete=models.CASCADE</span></code> to all
<code class="docutils literal notranslate"><span class="pre">ForeignKey</span></code> and <code class="docutils literal notranslate"><span class="pre">OneToOneField</span></code>s that don’t use a different option. You
can also pass it as the second positional argument if you don’t care about
compatibility with older versions of Django.</p>
</div>
<div class="section" id="s-field-rel-changes">
<span id="field-rel-changes"></span><h3><code class="docutils literal notranslate"><span class="pre">Field.rel</span></code> changes<a class="headerlink" href="#field-rel-changes" title="Permalink to this headline">¶</a></h3>
<p><code class="docutils literal notranslate"><span class="pre">Field.rel</span></code> and its methods and attributes have changed to match the related
fields API. The <code class="docutils literal notranslate"><span class="pre">Field.rel</span></code> attribute is renamed to <code class="docutils literal notranslate"><span class="pre">remote_field</span></code> and many
of its methods and attributes are either changed or renamed.</p>
<p>The aim of these changes is to provide a documented API for relation fields.</p>
</div>
<div class="section" id="s-geomanager-and-geoqueryset-custom-methods">
<span id="geomanager-and-geoqueryset-custom-methods"></span><h3><code class="docutils literal notranslate"><span class="pre">GeoManager</span></code> and <code class="docutils literal notranslate"><span class="pre">GeoQuerySet</span></code> custom methods<a class="headerlink" href="#geomanager-and-geoqueryset-custom-methods" title="Permalink to this headline">¶</a></h3>
<p>All custom <code class="docutils literal notranslate"><span class="pre">GeoQuerySet</span></code> methods (<code class="docutils literal notranslate"><span class="pre">area()</span></code>, <code class="docutils literal notranslate"><span class="pre">distance()</span></code>, <code class="docutils literal notranslate"><span class="pre">gml()</span></code>, …)
have been replaced by equivalent geographic expressions in annotations (see in
new features). Hence the need to set a custom <code class="docutils literal notranslate"><span class="pre">GeoManager</span></code> to GIS-enabled
models is now obsolete. As soon as your code doesn’t call any of the deprecated
methods, you can simply remove the <code class="docutils literal notranslate"><span class="pre">objects</span> <span class="pre">=</span> <span class="pre">GeoManager()</span></code> lines from your
models.</p>
</div>
<div class="section" id="s-template-loader-apis-have-changed">
<span id="template-loader-apis-have-changed"></span><h3>Template loader APIs have changed<a class="headerlink" href="#template-loader-apis-have-changed" title="Permalink to this headline">¶</a></h3>
<p>Django template loaders have been updated to allow recursive template
extending. This change necessitated a new template loader API. The old
<code class="docutils literal notranslate"><span class="pre">load_template()</span></code> and <code class="docutils literal notranslate"><span class="pre">load_template_sources()</span></code> methods are now deprecated.
Details about the new API can be found <a class="reference internal" href="../ref/templates/api.html#custom-template-loaders"><span class="std std-ref">in the template loader
documentation</span></a>.</p>
</div>
<div class="section" id="s-passing-a-3-tuple-or-an-app-name-to-include">
<span id="passing-a-3-tuple-or-an-app-name-to-include"></span><h3>Passing a 3-tuple or an <code class="docutils literal notranslate"><span class="pre">app_name</span></code> to <a class="reference internal" href="../ref/urls.html#django.conf.urls.include" title="django.conf.urls.include"><code class="xref py py-func docutils literal notranslate"><span class="pre">include()</span></code></a><a class="headerlink" href="#passing-a-3-tuple-or-an-app-name-to-include" title="Permalink to this headline">¶</a></h3>
<p>The instance namespace part of passing a tuple as an argument to <code class="docutils literal notranslate"><span class="pre">include()</span></code>
has been replaced by passing the <code class="docutils literal notranslate"><span class="pre">namespace</span></code> argument to <code class="docutils literal notranslate"><span class="pre">include()</span></code>. For
example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">polls_patterns</span> <span class="o">=</span> <span class="p">[</span>
     <span class="n">url</span><span class="p">(</span><span class="o">...</span><span class="p">),</span>
<span class="p">]</span>

<span class="n">urlpatterns</span> <span class="o">=</span> <span class="p">[</span>
    <span class="n">url</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;^polls/&#39;</span><span class="p">,</span> <span class="n">include</span><span class="p">((</span><span class="n">polls_patterns</span><span class="p">,</span> <span class="s1">&#39;polls&#39;</span><span class="p">,</span> <span class="s1">&#39;author-polls&#39;</span><span class="p">))),</span>
<span class="p">]</span>
</pre></div>
</div>
<p>becomes:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">polls_patterns</span> <span class="o">=</span> <span class="p">([</span>
     <span class="n">url</span><span class="p">(</span><span class="o">...</span><span class="p">),</span>
<span class="p">],</span> <span class="s1">&#39;polls&#39;</span><span class="p">)</span>  <span class="c1"># &#39;polls&#39; is the app_name</span>

<span class="n">urlpatterns</span> <span class="o">=</span> <span class="p">[</span>
    <span class="n">url</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;^polls/&#39;</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="n">polls_patterns</span><span class="p">,</span> <span class="n">namespace</span><span class="o">=</span><span class="s1">&#39;author-polls&#39;</span><span class="p">)),</span>
<span class="p">]</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">app_name</span></code> argument to <code class="docutils literal notranslate"><span class="pre">include()</span></code> has been replaced by passing a
2-tuple (as above), or passing an object or module with an <code class="docutils literal notranslate"><span class="pre">app_name</span></code>
attribute (as below). If the <code class="docutils literal notranslate"><span class="pre">app_name</span></code> is set in this new way, the
<code class="docutils literal notranslate"><span class="pre">namespace</span></code> argument is no longer required. It will default to the value of
<code class="docutils literal notranslate"><span class="pre">app_name</span></code>. For example, the URL patterns in the tutorial are changed from:</p>
<div class="highlight-default snippet"><div class="snippet-filename">mysite/urls.py</div>
<div class="highlight"><pre><span></span><span class="n">urlpatterns</span> <span class="o">=</span> <span class="p">[</span>
    <span class="n">url</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;^polls/&#39;</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="s1">&#39;polls.urls&#39;</span><span class="p">,</span> <span class="n">namespace</span><span class="o">=</span><span class="s2">&quot;polls&quot;</span><span class="p">)),</span>
    <span class="o">...</span>
<span class="p">]</span>
</pre></div>
</div>
<p>to:</p>
<div class="highlight-default snippet"><div class="snippet-filename">mysite/urls.py</div>
<div class="highlight"><pre><span></span><span class="n">urlpatterns</span> <span class="o">=</span> <span class="p">[</span>
    <span class="n">url</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;^polls/&#39;</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="s1">&#39;polls.urls&#39;</span><span class="p">)),</span>  <span class="c1"># &#39;namespace=&quot;polls&quot;&#39; removed</span>
    <span class="o">...</span>
<span class="p">]</span>
</pre></div>
</div>
<div class="highlight-default snippet"><div class="snippet-filename">polls/urls.py</div>
<div class="highlight"><pre><span></span><span class="n">app_name</span> <span class="o">=</span> <span class="s1">&#39;polls&#39;</span>  <span class="c1"># added</span>
<span class="n">urlpatterns</span> <span class="o">=</span> <span class="p">[</span><span class="o">...</span><span class="p">]</span>
</pre></div>
</div>
<p>This change also means that the old way of including an <code class="docutils literal notranslate"><span class="pre">AdminSite</span></code> instance
is deprecated. Instead, pass <code class="docutils literal notranslate"><span class="pre">admin.site.urls</span></code> directly to
<a class="reference internal" href="../ref/urls.html#django.conf.urls.url" title="django.conf.urls.url"><code class="xref py py-func docutils literal notranslate"><span class="pre">url()</span></code></a>:</p>
<div class="highlight-default snippet"><div class="snippet-filename">urls.py</div>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.conf.urls</span> <span class="k">import</span> <span class="n">url</span>
<span class="kn">from</span> <span class="nn">django.contrib</span> <span class="k">import</span> <span class="n">admin</span>

<span class="n">urlpatterns</span> <span class="o">=</span> <span class="p">[</span>
    <span class="n">url</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;^admin/&#39;</span><span class="p">,</span> <span class="n">admin</span><span class="o">.</span><span class="n">site</span><span class="o">.</span><span class="n">urls</span><span class="p">),</span>
<span class="p">]</span>
</pre></div>
</div>
</div>
<div class="section" id="s-url-application-namespace-required-if-setting-an-instance-namespace">
<span id="url-application-namespace-required-if-setting-an-instance-namespace"></span><h3>URL application namespace required if setting an instance namespace<a class="headerlink" href="#url-application-namespace-required-if-setting-an-instance-namespace" title="Permalink to this headline">¶</a></h3>
<p>In the past, an instance namespace without an application namespace
would serve the same purpose as the application namespace, but it was
impossible to reverse the patterns if there was an application namespace
with the same name. Includes that specify an instance namespace require that
the included URLconf sets an application namespace.</p>
</div>
<div class="section" id="s-current-app-parameter-to-contrib-auth-views">
<span id="current-app-parameter-to-contrib-auth-views"></span><h3><code class="docutils literal notranslate"><span class="pre">current_app</span></code> parameter to <code class="docutils literal notranslate"><span class="pre">contrib.auth</span></code> views<a class="headerlink" href="#current-app-parameter-to-contrib-auth-views" title="Permalink to this headline">¶</a></h3>
<p>All views in <code class="docutils literal notranslate"><span class="pre">django.contrib.auth.views</span></code> have the following structure:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">view</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="o">...</span><span class="p">,</span> <span class="n">current_app</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">...</span><span class="p">):</span>

    <span class="o">...</span>

    <span class="k">if</span> <span class="n">current_app</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
        <span class="n">request</span><span class="o">.</span><span class="n">current_app</span> <span class="o">=</span> <span class="n">current_app</span>

    <span class="k">return</span> <span class="n">TemplateResponse</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">template_name</span><span class="p">,</span> <span class="n">context</span><span class="p">)</span>
</pre></div>
</div>
<p>As of Django 1.8, <code class="docutils literal notranslate"><span class="pre">current_app</span></code> is set on the <code class="docutils literal notranslate"><span class="pre">request</span></code> object. For
consistency, these views will require the caller to set <code class="docutils literal notranslate"><span class="pre">current_app</span></code> on the
<code class="docutils literal notranslate"><span class="pre">request</span></code> instead of passing it in a separate argument.</p>
</div>
<div class="section" id="s-django-contrib-gis-geoip">
<span id="django-contrib-gis-geoip"></span><h3><code class="docutils literal notranslate"><span class="pre">django.contrib.gis.geoip</span></code><a class="headerlink" href="#django-contrib-gis-geoip" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference internal" href="../ref/contrib/gis/geoip2.html#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"><span class="pre">django.contrib.gis.geoip2</span></code></a> module supersedes
<code class="docutils literal notranslate"><span class="pre">django.contrib.gis.geoip</span></code>. The new module provides a similar API except that
it doesn’t provide the legacy GeoIP-Python API compatibility methods.</p>
</div>
<div class="section" id="s-id1">
<span id="id1"></span><h3>Miscellaneous<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
<ul class="simple">
<li>The <code class="docutils literal notranslate"><span class="pre">weak</span></code> argument to <code class="docutils literal notranslate"><span class="pre">django.dispatch.signals.Signal.disconnect()</span></code> has
been deprecated as it has no effect.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">check_aggregate_support()</span></code> method of
<code class="docutils literal notranslate"><span class="pre">django.db.backends.base.BaseDatabaseOperations</span></code> has been deprecated and
will be removed in Django 2.0. The more general <code class="docutils literal notranslate"><span class="pre">check_expression_support()</span></code>
should be used instead.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.forms.extras</span></code> is deprecated. You can find
<a class="reference internal" href="../ref/forms/widgets.html#django.forms.SelectDateWidget" title="django.forms.SelectDateWidget"><code class="xref py py-class docutils literal notranslate"><span class="pre">SelectDateWidget</span></code></a> in <code class="docutils literal notranslate"><span class="pre">django.forms.widgets</span></code>
(or simply <code class="docutils literal notranslate"><span class="pre">django.forms</span></code>) instead.</li>
<li>Private API <code class="docutils literal notranslate"><span class="pre">django.db.models.fields.add_lazy_relation()</span></code> is deprecated.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">django.contrib.auth.tests.utils.skipIfCustomUser()</span></code> decorator is
deprecated. With the test discovery changes in Django 1.6, the tests for
<code class="docutils literal notranslate"><span class="pre">django.contrib</span></code> apps are no longer run as part of the user’s project.
Therefore, the <code class="docutils literal notranslate"><span class="pre">&#64;skipIfCustomUser</span></code> decorator is no longer needed to
decorate tests in <code class="docutils literal notranslate"><span class="pre">django.contrib.auth</span></code>.</li>
<li>If you customized some <a class="reference internal" href="../ref/views.html#error-views"><span class="std std-ref">error handlers</span></a>, the view
signatures with only one request parameter are deprecated. The views should
now also accept a second <code class="docutils literal notranslate"><span class="pre">exception</span></code> positional parameter.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">django.utils.feedgenerator.Atom1Feed.mime_type</span></code> and
<code class="docutils literal notranslate"><span class="pre">django.utils.feedgenerator.RssFeed.mime_type</span></code> attributes are deprecated in
favor of <code class="docutils literal notranslate"><span class="pre">content_type</span></code>.</li>
<li><a class="reference internal" href="../topics/signing.html#django.core.signing.Signer" title="django.core.signing.Signer"><code class="xref py py-class docutils literal notranslate"><span class="pre">Signer</span></code></a> now issues a warning if an invalid
separator is used. This will become an exception in Django 1.10.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.db.models.Field._get_val_from_obj()</span></code> is deprecated in favor of
<code class="docutils literal notranslate"><span class="pre">Field.value_from_object()</span></code>.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.template.loaders.eggs.Loader</span></code> is deprecated as distributing
applications as eggs is not recommended.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">callable_obj</span></code> keyword argument to
<code class="docutils literal notranslate"><span class="pre">SimpleTestCase.assertRaisesMessage()</span></code> is deprecated. Pass the callable as
a positional argument instead.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">allow_tags</span></code> attribute on methods of <code class="docutils literal notranslate"><span class="pre">ModelAdmin</span></code> has been
deprecated. Use <a class="reference internal" href="../ref/utils.html#django.utils.html.format_html" title="django.utils.html.format_html"><code class="xref py py-func docutils literal notranslate"><span class="pre">format_html()</span></code></a>,
<a class="reference internal" href="../ref/utils.html#django.utils.html.format_html_join" title="django.utils.html.format_html_join"><code class="xref py py-func docutils literal notranslate"><span class="pre">format_html_join()</span></code></a>, or
<a class="reference internal" href="../ref/utils.html#django.utils.safestring.mark_safe" title="django.utils.safestring.mark_safe"><code class="xref py py-func docutils literal notranslate"><span class="pre">mark_safe()</span></code></a> when constructing the method’s
return value instead.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">enclosure</span></code> keyword argument to <code class="docutils literal notranslate"><span class="pre">SyndicationFeed.add_item()</span></code> is
deprecated. Use the new <code class="docutils literal notranslate"><span class="pre">enclosures</span></code> argument which accepts a list of
<code class="docutils literal notranslate"><span class="pre">Enclosure</span></code> objects instead of a single one.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">django.template.loader.LoaderOrigin</span></code> and
<code class="docutils literal notranslate"><span class="pre">django.template.base.StringOrigin</span></code> aliases for
<code class="docutils literal notranslate"><span class="pre">django.template.base.Origin</span></code> are deprecated.</li>
</ul>
</div>
</div>
<div class="section" id="s-features-removed-in-1-9">
<span id="s-removed-features-1-9"></span><span id="features-removed-in-1-9"></span><span id="removed-features-1-9"></span><h2>Features removed in 1.9<a class="headerlink" href="#features-removed-in-1-9" title="Permalink to this headline">¶</a></h2>
<p>These features have reached the end of their deprecation cycle and are removed
in Django 1.9. See <a class="reference internal" href="1.7.html#deprecated-features-1-7"><span class="std std-ref">Features deprecated in 1.7</span></a> for details, including how to
remove usage of these features.</p>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">django.utils.dictconfig</span></code> is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.utils.importlib</span></code> is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.utils.tzinfo</span></code> is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.utils.unittest</span></code> is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">syncdb</span></code> command is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.db.models.signals.pre_syncdb</span></code> and
<code class="docutils literal notranslate"><span class="pre">django.db.models.signals.post_syncdb</span></code> is removed.</li>
<li>Support for <code class="docutils literal notranslate"><span class="pre">allow_syncdb</span></code> on database routers is removed.</li>
<li>Automatic syncing of apps without migrations is removed. Migrations are
compulsory for all apps unless you pass the <a class="reference internal" href="../ref/django-admin.html#cmdoption-migrate-run-syncdb"><code class="xref std std-option docutils literal notranslate"><span class="pre">migrate</span> <span class="pre">--run-syncdb</span></code></a>
option.</li>
<li>The SQL management commands for apps without migrations, <code class="docutils literal notranslate"><span class="pre">sql</span></code>, <code class="docutils literal notranslate"><span class="pre">sqlall</span></code>,
<code class="docutils literal notranslate"><span class="pre">sqlclear</span></code>, <code class="docutils literal notranslate"><span class="pre">sqldropindexes</span></code>, and <code class="docutils literal notranslate"><span class="pre">sqlindexes</span></code>, are removed.</li>
<li>Support for automatic loading of <code class="docutils literal notranslate"><span class="pre">initial_data</span></code> fixtures and initial SQL
data is removed.</li>
<li>All models need to be defined inside an installed application or declare an
explicit <a class="reference internal" href="../ref/models/options.html#django.db.models.Options.app_label" title="django.db.models.Options.app_label"><code class="xref py py-attr docutils literal notranslate"><span class="pre">app_label</span></code></a>. Furthermore, it isn’t
possible to import them before their application is loaded. In particular, it
isn’t possible to import models inside the root package of an application.</li>
<li>The model and form <code class="docutils literal notranslate"><span class="pre">IPAddressField</span></code> is removed. A stub field remains for
compatibility with historical migrations.</li>
<li><code class="docutils literal notranslate"><span class="pre">AppCommand.handle_app()</span></code> is no longer supported.</li>
<li><code class="docutils literal notranslate"><span class="pre">RequestSite</span></code> and <code class="docutils literal notranslate"><span class="pre">get_current_site()</span></code> are no longer importable from
<code class="docutils literal notranslate"><span class="pre">django.contrib.sites.models</span></code>.</li>
<li>FastCGI support via the <code class="docutils literal notranslate"><span class="pre">runfcgi</span></code> management command is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.utils.datastructures.SortedDict</span></code> is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">ModelAdmin.declared_fieldsets</span></code> is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">util</span></code> modules that provided backwards compatibility are removed:<ul>
<li><code class="docutils literal notranslate"><span class="pre">django.contrib.admin.util</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">django.contrib.gis.db.backends.util</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">django.db.backends.util</span></code></li>
<li><code class="docutils literal notranslate"><span class="pre">django.forms.util</span></code></li>
</ul>
</li>
<li><code class="docutils literal notranslate"><span class="pre">ModelAdmin.get_formsets</span></code> is removed.</li>
<li>The backward compatible shims introduced to rename the
<code class="docutils literal notranslate"><span class="pre">BaseMemcachedCache._get_memcache_timeout()</span></code> method to
<code class="docutils literal notranslate"><span class="pre">get_backend_timeout()</span></code> is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">--natural</span></code> and <code class="docutils literal notranslate"><span class="pre">-n</span></code> options for <a class="reference internal" href="../ref/django-admin.html#django-admin-dumpdata"><code class="xref std std-djadmin docutils literal notranslate"><span class="pre">dumpdata</span></code></a> are removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">use_natural_keys</span></code> argument for <code class="docutils literal notranslate"><span class="pre">serializers.serialize()</span></code> is removed.</li>
<li>Private API <code class="docutils literal notranslate"><span class="pre">django.forms.forms.get_declared_fields()</span></code> is removed.</li>
<li>The ability to use a <code class="docutils literal notranslate"><span class="pre">SplitDateTimeWidget</span></code> with <code class="docutils literal notranslate"><span class="pre">DateTimeField</span></code> is
removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">WSGIRequest.REQUEST</span></code> property is removed.</li>
<li>The class <code class="docutils literal notranslate"><span class="pre">django.utils.datastructures.MergeDict</span></code> is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">zh-cn</span></code> and <code class="docutils literal notranslate"><span class="pre">zh-tw</span></code> language codes are removed.</li>
<li>The internal <code class="docutils literal notranslate"><span class="pre">django.utils.functional.memoize()</span></code> is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.core.cache.get_cache</span></code> is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.db.models.loading</span></code> is removed.</li>
<li>Passing callable arguments to querysets is no longer possible.</li>
<li><code class="docutils literal notranslate"><span class="pre">BaseCommand.requires_model_validation</span></code> is removed in favor of
<code class="docutils literal notranslate"><span class="pre">requires_system_checks</span></code>. Admin validators is replaced by admin checks.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">ModelAdmin.validator_class</span></code> and <code class="docutils literal notranslate"><span class="pre">default_validator_class</span></code> attributes
are removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">ModelAdmin.validate()</span></code> is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.db.backends.DatabaseValidation.validate_field</span></code> is removed in
favor of the <code class="docutils literal notranslate"><span class="pre">check_field</span></code> method.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">validate</span></code> management command is removed.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.utils.module_loading.import_by_path</span></code> is removed in favor of
<code class="docutils literal notranslate"><span class="pre">django.utils.module_loading.import_string</span></code>.</li>
<li><code class="docutils literal notranslate"><span class="pre">ssi</span></code> and <code class="docutils literal notranslate"><span class="pre">url</span></code> template tags are removed from the <code class="docutils literal notranslate"><span class="pre">future</span></code> template
tag library.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.utils.text.javascript_quote()</span></code> is removed.</li>
<li>Database test settings as independent entries in the database settings,
prefixed by <code class="docutils literal notranslate"><span class="pre">TEST_</span></code>, are no longer supported.</li>
<li>The <cite>cache_choices</cite> option to <a class="reference internal" href="../ref/forms/fields.html#django.forms.ModelChoiceField" title="django.forms.ModelChoiceField"><code class="xref py py-class docutils literal notranslate"><span class="pre">ModelChoiceField</span></code></a> and
<a class="reference internal" href="../ref/forms/fields.html#django.forms.ModelMultipleChoiceField" title="django.forms.ModelMultipleChoiceField"><code class="xref py py-class docutils literal notranslate"><span class="pre">ModelMultipleChoiceField</span></code></a> is removed.</li>
<li>The default value of the
<a class="reference internal" href="../ref/class-based-views/base.html#django.views.generic.base.RedirectView.permanent" title="django.views.generic.base.RedirectView.permanent"><code class="xref py py-attr docutils literal notranslate"><span class="pre">RedirectView.permanent</span></code></a>
attribute has changed from <code class="docutils literal notranslate"><span class="pre">True</span></code> to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</li>
<li><code class="docutils literal notranslate"><span class="pre">django.contrib.sitemaps.FlatPageSitemap</span></code> is removed in favor of
<code class="docutils literal notranslate"><span class="pre">django.contrib.flatpages.sitemaps.FlatPageSitemap</span></code>.</li>
<li>Private API <code class="docutils literal notranslate"><span class="pre">django.test.utils.TestTemplateLoader</span></code> is removed.</li>
<li>The <code class="docutils literal notranslate"><span class="pre">django.contrib.contenttypes.generic</span></code> module is removed.</li>
</ul>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Django 1.9 release notes</a><ul>
<li><a class="reference internal" href="#python-compatibility">Python compatibility</a></li>
<li><a class="reference internal" href="#what-s-new-in-django-1-9">What’s new in Django 1.9</a><ul>
<li><a class="reference internal" href="#performing-actions-after-a-transaction-commit">Performing actions after a transaction commit</a></li>
<li><a class="reference internal" href="#password-validation">Password validation</a></li>
<li><a class="reference internal" href="#permission-mixins-for-class-based-views">Permission mixins for class-based views</a></li>
<li><a class="reference internal" href="#new-styling-for-contrib-admin">New styling for <code class="docutils literal notranslate"><span class="pre">contrib.admin</span></code></a></li>
<li><a class="reference internal" href="#running-tests-in-parallel">Running tests in parallel</a></li>
<li><a class="reference internal" href="#minor-features">Minor features</a><ul>
<li><a class="reference internal" href="#django-contrib-admin"><code class="docutils literal notranslate"><span class="pre">django.contrib.admin</span></code></a></li>
<li><a class="reference internal" href="#django-contrib-admindocs"><code class="docutils literal notranslate"><span class="pre">django.contrib.admindocs</span></code></a></li>
<li><a class="reference internal" href="#django-contrib-auth"><code class="docutils literal notranslate"><span class="pre">django.contrib.auth</span></code></a></li>
<li><a class="reference internal" href="#django-contrib-contenttypes"><code class="docutils literal notranslate"><span class="pre">django.contrib.contenttypes</span></code></a></li>
<li><a class="reference internal" href="#django-contrib-gis"><code class="docutils literal notranslate"><span class="pre">django.contrib.gis</span></code></a></li>
<li><a class="reference internal" href="#django-contrib-postgres"><code class="docutils literal notranslate"><span class="pre">django.contrib.postgres</span></code></a></li>
<li><a class="reference internal" href="#django-contrib-sessions"><code class="docutils literal notranslate"><span class="pre">django.contrib.sessions</span></code></a></li>
<li><a class="reference internal" href="#django-contrib-sites"><code class="docutils literal notranslate"><span class="pre">django.contrib.sites</span></code></a></li>
<li><a class="reference internal" href="#django-contrib-syndication"><code class="docutils literal notranslate"><span class="pre">django.contrib.syndication</span></code></a></li>
<li><a class="reference internal" href="#cache">Cache</a></li>
<li><a class="reference internal" href="#csrf">CSRF</a></li>
<li><a class="reference internal" href="#database-backends">Database backends</a></li>
<li><a class="reference internal" href="#file-storage">File Storage</a></li>
<li><a class="reference internal" href="#forms">Forms</a></li>
<li><a class="reference internal" href="#generic-views">Generic Views</a></li>
<li><a class="reference internal" href="#internationalization">Internationalization</a></li>
<li><a class="reference internal" href="#management-commands">Management Commands</a></li>
<li><a class="reference internal" href="#migrations">Migrations</a></li>
<li><a class="reference internal" href="#models">Models</a></li>
<li><a class="reference internal" href="#requests-and-responses">Requests and Responses</a></li>
<li><a class="reference internal" href="#templates">Templates</a></li>
<li><a class="reference internal" href="#tests">Tests</a></li>
<li><a class="reference internal" href="#urls">URLs</a></li>
<li><a class="reference internal" href="#validators">Validators</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#backwards-incompatible-changes-in-1-9">Backwards incompatible changes in 1.9</a><ul>
<li><a class="reference internal" href="#database-backend-api">Database backend API</a></li>
<li><a class="reference internal" href="#default-settings-that-were-tuples-are-now-lists">Default settings that were tuples are now lists</a></li>
<li><a class="reference internal" href="#is-usable-attribute-on-template-loaders-is-removed"><code class="docutils literal notranslate"><span class="pre">is_usable</span></code> attribute on template loaders is removed</a></li>
<li><a class="reference internal" href="#related-set-direct-assignment">Related set direct assignment</a></li>
<li><a class="reference internal" href="#filesystem-based-template-loaders-catch-more-specific-exceptions">Filesystem-based template loaders catch more specific exceptions</a></li>
<li><a class="reference internal" href="#http-redirects-no-longer-forced-to-absolute-uris">HTTP redirects no longer forced to absolute URIs</a></li>
<li><a class="reference internal" href="#dropped-support-for-postgresql-9-0">Dropped support for PostgreSQL 9.0</a></li>
<li><a class="reference internal" href="#dropped-support-for-oracle-11-1">Dropped support for Oracle 11.1</a></li>
<li><a class="reference internal" href="#bulk-behavior-of-add-method-of-related-managers">Bulk behavior of <code class="docutils literal notranslate"><span class="pre">add()</span></code> method of related managers</a></li>
<li><a class="reference internal" href="#template-loaderorigin-and-stringorigin-are-removed">Template <code class="docutils literal notranslate"><span class="pre">LoaderOrigin</span></code> and <code class="docutils literal notranslate"><span class="pre">StringOrigin</span></code> are removed</a></li>
<li><a class="reference internal" href="#changes-to-the-default-logging-configuration">Changes to the default logging configuration</a></li>
<li><a class="reference internal" href="#httprequest-details-in-error-reporting"><code class="docutils literal notranslate"><span class="pre">HttpRequest</span></code> details in error reporting</a></li>
<li><a class="reference internal" href="#removal-of-time-zone-aware-global-adapters-and-converters-for-datetimes">Removal of time zone aware global adapters and converters for datetimes</a></li>
<li><a class="reference internal" href="#template-tag-modules-are-imported-when-templates-are-configured">Template tag modules are imported when templates are configured</a></li>
<li><a class="reference internal" href="#django-template-base-add-to-builtins-is-removed"><code class="docutils literal notranslate"><span class="pre">django.template.base.add_to_builtins()</span></code> is removed</a></li>
<li><a class="reference internal" href="#simple-tag-now-wraps-tag-output-in-conditional-escape"><code class="docutils literal notranslate"><span class="pre">simple_tag</span></code> now wraps tag output in <code class="docutils literal notranslate"><span class="pre">conditional_escape</span></code></a></li>
<li><a class="reference internal" href="#paginator-page-range"><code class="docutils literal notranslate"><span class="pre">Paginator.page_range</span></code></a></li>
<li><a class="reference internal" href="#implicit-queryset-in-lookup-removed">Implicit <code class="docutils literal notranslate"><span class="pre">QuerySet</span></code> <code class="docutils literal notranslate"><span class="pre">__in</span></code> lookup removed</a></li>
<li><a class="reference internal" href="#contrib-admin-browser-support"><code class="docutils literal notranslate"><span class="pre">contrib.admin</span></code> browser support</a></li>
<li><a class="reference internal" href="#syntaxerror-when-installing-django-setuptools-5-5-x"><code class="docutils literal notranslate"><span class="pre">SyntaxError</span></code> when installing Django setuptools 5.5.x</a></li>
<li><a class="reference internal" href="#miscellaneous">Miscellaneous</a></li>
</ul>
</li>
<li><a class="reference internal" href="#features-deprecated-in-1-9">Features deprecated in 1.9</a><ul>
<li><a class="reference internal" href="#assignment-tag"><code class="docutils literal notranslate"><span class="pre">assignment_tag()</span></code></a></li>
<li><a class="reference internal" href="#cycle-syntax-with-comma-separated-arguments"><code class="docutils literal notranslate"><span class="pre">{%</span> <span class="pre">cycle</span> <span class="pre">%}</span></code> syntax with comma-separated arguments</a></li>
<li><a class="reference internal" href="#foreignkey-and-onetoonefield-on-delete-argument"><code class="docutils literal notranslate"><span class="pre">ForeignKey</span></code> and <code class="docutils literal notranslate"><span class="pre">OneToOneField</span></code> <code class="docutils literal notranslate"><span class="pre">on_delete</span></code> argument</a></li>
<li><a class="reference internal" href="#field-rel-changes"><code class="docutils literal notranslate"><span class="pre">Field.rel</span></code> changes</a></li>
<li><a class="reference internal" href="#geomanager-and-geoqueryset-custom-methods"><code class="docutils literal notranslate"><span class="pre">GeoManager</span></code> and <code class="docutils literal notranslate"><span class="pre">GeoQuerySet</span></code> custom methods</a></li>
<li><a class="reference internal" href="#template-loader-apis-have-changed">Template loader APIs have changed</a></li>
<li><a class="reference internal" href="#passing-a-3-tuple-or-an-app-name-to-include">Passing a 3-tuple or an <code class="docutils literal notranslate"><span class="pre">app_name</span></code> to <code class="docutils literal notranslate"><span class="pre">include()</span></code></a></li>
<li><a class="reference internal" href="#url-application-namespace-required-if-setting-an-instance-namespace">URL application namespace required if setting an instance namespace</a></li>
<li><a class="reference internal" href="#current-app-parameter-to-contrib-auth-views"><code class="docutils literal notranslate"><span class="pre">current_app</span></code> parameter to <code class="docutils literal notranslate"><span class="pre">contrib.auth</span></code> views</a></li>
<li><a class="reference internal" href="#django-contrib-gis-geoip"><code class="docutils literal notranslate"><span class="pre">django.contrib.gis.geoip</span></code></a></li>
<li><a class="reference internal" href="#id1">Miscellaneous</a></li>
</ul>
</li>
<li><a class="reference internal" href="#features-removed-in-1-9">Features removed in 1.9</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="1.9.1.html"
                        title="previous chapter">Django 1.9.1 release notes</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="1.8.19.html"
                        title="next chapter">Django 1.8.19 release notes</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/releases/1.9.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Feb 11, 2019</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="1.9.1.html" title="Django 1.9.1 release notes">previous</a>
     |
    <a href="index.html" title="Release notes" accesskey="U">up</a>
   |
    <a href="1.8.19.html" title="Django 1.8.19 release notes">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>