{"title":"Django 1.7 release notes","version":"dev","locale":"en","docname":"releases/1.7","url":"/en/dev/releases/1.7/","canonical":"https://djangodocs.dev/en/dev/releases/1.7/","summary":"Welcome to Django 1.7! These release notes cover the new features, as well as some backwards incompatible changes you’ll want to be aware of when upgrading…","html":"<h1>Django 1.7 release notes<a class=\"heading-anchor\" href=\"#django-1-7-release-notes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p><em>September 2, 2014</em></p>\n<p>Welcome to Django 1.7!</p>\n<p>These release notes cover the <a class=\"reference internal\" href=\"#whats-new-1-7\"><span class=\"std std-ref\">new features</span></a>, as well as\nsome <a class=\"reference internal\" href=\"#backwards-incompatible-1-7\"><span class=\"std std-ref\">backwards incompatible changes</span></a> you’ll\nwant to be aware of when upgrading from Django 1.6 or older versions. We’ve\n<a class=\"reference internal\" href=\"#deprecated-features-1-7\"><span class=\"std std-ref\">begun the deprecation process for some features</span></a>, and some features have reached the end of their\ndeprecation process and <a class=\"reference internal\" href=\"#removed-features-1-7\"><span class=\"std std-ref\">have been removed</span></a>.</p>\n<section id=\"python-compatibility\">\n<h2>Python compatibility<a class=\"heading-anchor\" href=\"#python-compatibility\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django 1.7 requires Python 2.7, 3.2, 3.3, or 3.4. We <strong>highly recommend</strong> and\nonly officially support the latest release of each series.</p>\n<p>The Django 1.6 series is the last to support Python 2.6. Django 1.7 is the\nfirst release to support Python 3.4.</p>\n<p>This change should affect only a small number of Django users, as most\noperating-system vendors today are shipping Python 2.7 or newer as their\ndefault version. If you’re still using Python 2.6, however, you’ll need to\nstick to Django 1.6 until you can upgrade your Python version. Per <a class=\"reference internal\" href=\"/en/dev/internals/release-process/\"><span class=\"doc\">our\nsupport policy</span></a>, Django 1.6 will continue to\nreceive security support until the release of Django 1.8.</p>\n</section>\n<section id=\"what-s-new-in-django-1-7\">\n<span id=\"whats-new-1-7\"></span><h2>What’s new in Django 1.7<a class=\"heading-anchor\" href=\"#what-s-new-in-django-1-7\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"schema-migrations\">\n<h3>Schema migrations<a class=\"heading-anchor\" href=\"#schema-migrations\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django now has built-in support for schema migrations. It allows models to be\nupdated, changed, and deleted by creating migration files that represent the\nmodel changes and which can be run on any development, staging or production\ndatabase.</p>\n<p>Migrations are covered in <a class=\"reference internal\" href=\"/en/dev/topics/migrations/\"><span class=\"doc\">their own documentation</span></a>,\nbut a few of the key features are:</p>\n<ul>\n<li><p><code class=\"docutils literal notranslate\">syncdb</code> has been deprecated and replaced by <code class=\"docutils literal notranslate\">migrate</code>. Don’t worry -\ncalls to <code class=\"docutils literal notranslate\">syncdb</code> will still work as before.</p></li>\n<li><p>A new <code class=\"docutils literal notranslate\">makemigrations</code> command provides an easy way to autodetect changes\nto your models and make migrations for them.</p>\n<p><code class=\"docutils literal notranslate\">django.db.models.signals.pre_syncdb</code> and\n<code class=\"docutils literal notranslate\">django.db.models.signals.post_syncdb</code> have been deprecated,\nto be replaced by <a class=\"reference internal\" href=\"/en/dev/ref/signals/#django.db.models.signals.pre_migrate\" title=\"django.db.models.signals.pre_migrate\"><code class=\"xref py py-data docutils literal notranslate\">pre_migrate</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/signals/#django.db.models.signals.post_migrate\" title=\"django.db.models.signals.post_migrate\"><code class=\"xref py py-data docutils literal notranslate\">post_migrate</code></a> respectively. These\nnew signals have slightly different arguments. Check the\ndocumentation for details.</p>\n</li>\n<li><p>The <code class=\"docutils literal notranslate\">allow_syncdb</code> method on database routers is now called\n<code class=\"docutils literal notranslate\">allow_migrate</code>, but still performs the same function. Routers with\n<code class=\"docutils literal notranslate\">allow_syncdb</code> methods will still work, but that method name is deprecated\nand you should change it as soon as possible (nothing more than renaming is\nrequired).</p></li>\n<li><p><code class=\"docutils literal notranslate\">initial_data</code> fixtures are no longer loaded for apps with migrations; if\nyou want to load initial data for an app, we suggest you create a migration\nfor your application and define a\n<a class=\"reference internal\" href=\"/en/dev/ref/migration-operations/#django.db.migrations.operations.RunPython\" title=\"django.db.migrations.operations.RunPython\"><code class=\"xref py py-class docutils literal notranslate\">RunPython</code></a> or\n<a class=\"reference internal\" href=\"/en/dev/ref/migration-operations/#django.db.migrations.operations.RunSQL\" title=\"django.db.migrations.operations.RunSQL\"><code class=\"xref py py-class docutils literal notranslate\">RunSQL</code></a> operation in the\n<code class=\"docutils literal notranslate\">operations</code> section of the migration.</p></li>\n<li><p>Test rollback behavior is different for apps with migrations; in particular,\nDjango will no longer emulate rollbacks on non-transactional databases or\ninside <code class=\"docutils literal notranslate\">TransactionTestCase</code> <a class=\"reference internal\" href=\"/en/dev/topics/testing/overview/#test-case-serialized-rollback\"><span class=\"std std-ref\">unless specifically requested</span></a>.</p></li>\n<li><p>It is not advised to have apps without migrations depend on (have a\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.ForeignKey\" title=\"django.db.models.ForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">ForeignKey</code></a> or\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.ManyToManyField\" title=\"django.db.models.ManyToManyField\"><code class=\"xref py py-class docutils literal notranslate\">ManyToManyField</code></a> to) apps with migrations.</p></li>\n</ul>\n</section>\n<section id=\"app-loading-refactor\">\n<span id=\"app-loading-refactor-17-release-note\"></span><h3>App-loading refactor<a class=\"heading-anchor\" href=\"#app-loading-refactor\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Historically, Django applications were tightly linked to models. A singleton\nknown as the “app cache” dealt with both installed applications and models.\nThe models module was used as an identifier for applications in many APIs.</p>\n<p>As the concept of <a class=\"reference internal\" href=\"/en/dev/ref/applications/\"><span class=\"doc\">Django applications</span></a> matured, this\ncode showed some shortcomings. It has been refactored into an “app registry”\nwhere models modules no longer have a central role and where it’s possible to\nattach configuration data to applications.</p>\n<p>Improvements thus far include:</p>\n<ul class=\"simple\">\n<li><p>Applications can run code at startup, before Django does anything else, with\nthe <a class=\"reference internal\" href=\"/en/dev/ref/applications/#django.apps.AppConfig.ready\" title=\"django.apps.AppConfig.ready\"><code class=\"xref py py-meth docutils literal notranslate\">ready()</code></a> method of their configuration.</p></li>\n<li><p>Application labels are assigned correctly to models even when they’re\ndefined outside of <code class=\"docutils literal notranslate\">models.py</code>. You don’t have to set\n<a class=\"reference internal\" href=\"/en/dev/ref/models/options/#django.db.models.Options.app_label\" title=\"django.db.models.Options.app_label\"><code class=\"xref py py-attr docutils literal notranslate\">app_label</code></a> explicitly any more.</p></li>\n<li><p>It is possible to omit <code class=\"docutils literal notranslate\">models.py</code> entirely if an application doesn’t\nhave any models.</p></li>\n<li><p>Applications can be relabeled with the <a class=\"reference internal\" href=\"/en/dev/ref/applications/#django.apps.AppConfig.label\" title=\"django.apps.AppConfig.label\"><code class=\"xref py py-attr docutils literal notranslate\">label</code></a>\nattribute of application configurations, to work around label conflicts.</p></li>\n<li><p>The name of applications can be customized in the admin with the\n<a class=\"reference internal\" href=\"/en/dev/ref/applications/#django.apps.AppConfig.verbose_name\" title=\"django.apps.AppConfig.verbose_name\"><code class=\"xref py py-attr docutils literal notranslate\">verbose_name</code></a> of application configurations.</p></li>\n<li><p>The admin automatically calls <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.autodiscover\" title=\"django.contrib.admin.autodiscover\"><code class=\"xref py py-func docutils literal notranslate\">autodiscover()</code></a>\nwhen Django starts. You can consequently remove this line from your\nURLconf.</p></li>\n<li><p>Django imports all application configurations and models as soon as it\nstarts, through a deterministic and straightforward process. This should\nmake it easier to diagnose import issues such as import loops.</p></li>\n</ul>\n</section>\n<section id=\"new-method-on-field-subclasses\">\n<h3>New method on Field subclasses<a class=\"heading-anchor\" href=\"#new-method-on-field-subclasses\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>To help power both schema migrations and to enable easier addition of\ncomposite keys in future releases of Django, the\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.Field\" title=\"django.db.models.Field\"><code class=\"xref py py-class docutils literal notranslate\">Field</code></a> API now has a new required method:\n<code class=\"docutils literal notranslate\">deconstruct()</code>.</p>\n<p>This method takes no arguments, and returns a tuple of four items:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">name</code>: The field’s attribute name on its parent model, or <code class=\"docutils literal notranslate\">None</code> if it\nis not part of a model</p></li>\n<li><p><code class=\"docutils literal notranslate\">path</code>: A dotted, Python path to the class of this field, including the\nclass name.</p></li>\n<li><p><code class=\"docutils literal notranslate\">args</code>: Positional arguments, as a list</p></li>\n<li><p><code class=\"docutils literal notranslate\">kwargs</code>: Keyword arguments, as a dict</p></li>\n</ul>\n<p>These four values allow any field to be serialized into a file, as well as\nallowing the field to be copied safely, both essential parts of these new\nfeatures.</p>\n<p>This change should not affect you unless you write custom Field subclasses;\nif you do, you may need to reimplement the <code class=\"docutils literal notranslate\">deconstruct()</code> method if your\nsubclass changes the method signature of <code class=\"docutils literal notranslate\">__init__</code> in any way. If your\nfield just inherits from a built-in Django field and doesn’t override\n<code class=\"docutils literal notranslate\">__init__</code>, no changes are necessary.</p>\n<p>If you do need to override <code class=\"docutils literal notranslate\">deconstruct()</code>, a good place to start is the\nbuilt-in Django fields (<code class=\"docutils literal notranslate\">django/db/models/fields/__init__.py</code>) as several\nfields, including <code class=\"docutils literal notranslate\">DecimalField</code> and <code class=\"docutils literal notranslate\">DateField</code>, override it and show how\nto call the method on the superclass and simply add or remove extra arguments.</p>\n<p>This also means that all arguments to fields must themselves be serializable;\nto see what we consider serializable, and to find out how to make your own\nclasses serializable, read the\n<a class=\"reference internal\" href=\"/en/dev/topics/migrations/#migration-serializing\"><span class=\"std std-ref\">migration serialization documentation</span></a>.</p>\n</section>\n<section id=\"calling-custom-queryset-methods-from-the-manager\">\n<h3>Calling custom <code class=\"docutils literal notranslate\">QuerySet</code> methods from the <code class=\"docutils literal notranslate\">Manager</code><a class=\"heading-anchor\" href=\"#calling-custom-queryset-methods-from-the-manager\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Historically, the recommended way to make reusable model queries was to create\nmethods on a custom <code class=\"docutils literal notranslate\">Manager</code> class. The problem with this approach was that\nafter the first method call, you’d get back a <code class=\"docutils literal notranslate\">QuerySet</code> instance and\ncouldn’t call additional custom manager methods.</p>\n<p>Though not documented, it was common to work around this issue by creating a\ncustom <code class=\"docutils literal notranslate\">QuerySet</code> so that custom methods could be chained; but the solution\nhad a number of drawbacks:</p>\n<ul class=\"simple\">\n<li><p>The custom <code class=\"docutils literal notranslate\">QuerySet</code> and its custom methods were lost after the first\ncall to <code class=\"docutils literal notranslate\">values()</code> or <code class=\"docutils literal notranslate\">values_list()</code>.</p></li>\n<li><p>Writing a custom <code class=\"docutils literal notranslate\">Manager</code> was still necessary to return the custom\n<code class=\"docutils literal notranslate\">QuerySet</code> class and all methods that were desired on the <code class=\"docutils literal notranslate\">Manager</code>\nhad to be proxied to the <code class=\"docutils literal notranslate\">QuerySet</code>. The whole process went against\nthe DRY principle.</p></li>\n</ul>\n<p>The <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.as_manager\" title=\"django.db.models.query.QuerySet.as_manager\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.as_manager()</code></a>\nclass method can now directly <a class=\"reference internal\" href=\"/en/dev/topics/db/managers/#create-manager-with-queryset-methods\"><span class=\"std std-ref\">create Manager with QuerySet methods</span></a>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">class</span> <span class=\"nc\">FoodQuerySet</span><span class=\"p\">(</span>models<span class=\"o\">.</span>QuerySet<span class=\"p\">):</span>\n    <span class=\"k\">def</span> <span class=\"nf\">pizzas</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"k\">return</span> <span class=\"bp\">self</span><span class=\"o\">.</span>filter<span class=\"p\">(</span>kind<span class=\"o\">=</span><span class=\"s2\">&quot;pizza&quot;</span><span class=\"p\">)</span>\n\n    <span class=\"k\">def</span> <span class=\"nf\">vegetarian</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"k\">return</span> <span class=\"bp\">self</span><span class=\"o\">.</span>filter<span class=\"p\">(</span>vegetarian<span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">)</span>\n\n\n<span class=\"k\">class</span> <span class=\"nc\">Food</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    kind <span class=\"o\">=</span> models<span class=\"o\">.</span>CharField<span class=\"p\">(</span>max_length<span class=\"o\">=</span><span class=\"mi\">50</span><span class=\"p\">)</span>\n    vegetarian <span class=\"o\">=</span> models<span class=\"o\">.</span>BooleanField<span class=\"p\">(</span>default<span class=\"o\">=</span><span class=\"kc\">False</span><span class=\"p\">)</span>\n    objects <span class=\"o\">=</span> FoodQuerySet<span class=\"o\">.</span>as_manager<span class=\"p\">()</span>\n\n\nFood<span class=\"o\">.</span>objects<span class=\"o\">.</span>pizzas<span class=\"p\">()</span><span class=\"o\">.</span>vegetarian<span class=\"p\">()</span>\n</code></pre></div>\n</section>\n<section id=\"using-a-custom-manager-when-traversing-reverse-relations\">\n<h3>Using a custom manager when traversing reverse relations<a class=\"heading-anchor\" href=\"#using-a-custom-manager-when-traversing-reverse-relations\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>It is now possible to <a class=\"reference internal\" href=\"/en/dev/topics/db/queries/#using-custom-reverse-manager\"><span class=\"std std-ref\">specify a custom manager</span></a> when traversing a reverse relationship:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">class</span> <span class=\"nc\">Blog</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    <span class=\"k\">pass</span>\n\n\n<span class=\"k\">class</span> <span class=\"nc\">Entry</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    blog <span class=\"o\">=</span> models<span class=\"o\">.</span>ForeignKey<span class=\"p\">(</span>Blog<span class=\"p\">)</span>\n\n    objects <span class=\"o\">=</span> models<span class=\"o\">.</span>Manager<span class=\"p\">()</span>  <span class=\"c1\"># Default Manager</span>\n    entries <span class=\"o\">=</span> EntryManager<span class=\"p\">()</span>  <span class=\"c1\"># Custom Manager</span>\n\n\nb <span class=\"o\">=</span> Blog<span class=\"o\">.</span>objects<span class=\"o\">.</span>get<span class=\"p\">(</span><span class=\"nb\">id</span><span class=\"o\">=</span><span class=\"mi\">1</span><span class=\"p\">)</span>\nb<span class=\"o\">.</span>entry_set<span class=\"p\">(</span>manager<span class=\"o\">=</span><span class=\"s2\">&quot;entries&quot;</span><span class=\"p\">)</span><span class=\"o\">.</span>all<span class=\"p\">()</span>\n</code></pre></div>\n</section>\n<section id=\"new-system-check-framework\">\n<h3>New system check framework<a class=\"heading-anchor\" href=\"#new-system-check-framework\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>We’ve added a new <a class=\"reference internal\" href=\"/en/dev/ref/checks/\"><span class=\"doc\">System check framework</span></a> for\ndetecting common problems (like invalid models) and providing hints for\nresolving those problems. The framework is extensible so you can add your\nown checks for your own apps and libraries.</p>\n<p>To perform system checks, you use the <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-check\"><code class=\"xref std std-djadmin docutils literal notranslate\">check</code></a> management command.\nThis command replaces the older <code class=\"docutils literal notranslate\">validate</code> management command.</p>\n</section>\n<section id=\"new-prefetch-object-for-advanced-prefetch-related-operations\">\n<h3>New <code class=\"docutils literal notranslate\">Prefetch</code> object for advanced <code class=\"docutils literal notranslate\">prefetch_related</code> operations.<a class=\"heading-anchor\" href=\"#new-prefetch-object-for-advanced-prefetch-related-operations\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The new <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.Prefetch\" title=\"django.db.models.Prefetch\"><code class=\"xref py py-class docutils literal notranslate\">Prefetch</code></a> object allows customizing\nprefetch operations.</p>\n<p>You can specify the <code class=\"docutils literal notranslate\">QuerySet</code> used to traverse a given relation\nor customize the storage location of prefetch results.</p>\n<p>This enables things like filtering prefetched relations, calling\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.select_related\" title=\"django.db.models.query.QuerySet.select_related\"><code class=\"xref py py-meth docutils literal notranslate\">select_related()</code></a> from a prefetched\nrelation, or prefetching the same relation multiple times with different\nquerysets. See <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.prefetch_related\" title=\"django.db.models.query.QuerySet.prefetch_related\"><code class=\"xref py py-meth docutils literal notranslate\">prefetch_related()</code></a>\nfor more details.</p>\n</section>\n<section id=\"admin-shortcuts-support-time-zones\">\n<h3>Admin shortcuts support time zones<a class=\"heading-anchor\" href=\"#admin-shortcuts-support-time-zones\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The “today” and “now” shortcuts next to date and time input widgets in the\nadmin are now operating in the <a class=\"reference internal\" href=\"/en/dev/topics/i18n/timezones/#default-current-time-zone\"><span class=\"std std-ref\">current time zone</span></a>. Previously, they used the browser time zone,\nwhich could result in saving the wrong value when it didn’t match the current\ntime zone on the server.</p>\n<p>In addition, the widgets now display a help message when the browser and\nserver time zone are different, to clarify how the value inserted in the field\nwill be interpreted.</p>\n</section>\n<section id=\"using-database-cursors-as-context-managers\">\n<h3>Using database cursors as context managers<a class=\"heading-anchor\" href=\"#using-database-cursors-as-context-managers\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Prior to Python 2.7, database cursors could be used as a context manager. The\nspecific backend’s cursor defined the behavior of the context manager. The\nbehavior of magic method lookups was changed with Python 2.7 and cursors were\nno longer usable as context managers.</p>\n<p>Django 1.7 allows a cursor to be used as a context manager. That is,\nthe following can be used:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">with</span> connection<span class=\"o\">.</span>cursor<span class=\"p\">()</span> <span class=\"k\">as</span> c<span class=\"p\">:</span>\n    c<span class=\"o\">.</span>execute<span class=\"p\">(</span><span class=\"o\">...</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>instead of:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>c <span class=\"o\">=</span> connection<span class=\"o\">.</span>cursor<span class=\"p\">()</span>\n<span class=\"k\">try</span><span class=\"p\">:</span>\n    c<span class=\"o\">.</span>execute<span class=\"p\">(</span><span class=\"o\">...</span><span class=\"p\">)</span>\n<span class=\"k\">finally</span><span class=\"p\">:</span>\n    c<span class=\"o\">.</span>close<span class=\"p\">()</span>\n</code></pre></div>\n</section>\n<section id=\"custom-lookups\">\n<h3>Custom lookups<a class=\"heading-anchor\" href=\"#custom-lookups\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>It is now possible to write custom lookups and transforms for the ORM.\nCustom lookups work just like Django’s built-in lookups (e.g. <code class=\"docutils literal notranslate\">lte</code>,\n<code class=\"docutils literal notranslate\">icontains</code>) while transforms are a new concept.</p>\n<p>The <a class=\"reference internal\" href=\"/en/dev/ref/models/lookups/#django.db.models.Lookup\" title=\"django.db.models.Lookup\"><code class=\"xref py py-class docutils literal notranslate\">django.db.models.Lookup</code></a> class provides a way to add lookup\noperators for model fields. As an example it is possible to add <code class=\"docutils literal notranslate\">day_lte</code>\noperator for <code class=\"docutils literal notranslate\">DateFields</code>.</p>\n<p>The <a class=\"reference internal\" href=\"/en/dev/ref/models/lookups/#django.db.models.Transform\" title=\"django.db.models.Transform\"><code class=\"xref py py-class docutils literal notranslate\">django.db.models.Transform</code></a> class allows transformations of\ndatabase values prior to the final lookup. For example it is possible to\nwrite a <code class=\"docutils literal notranslate\">year</code> transform that extracts year from the field’s value.\nTransforms allow for chaining. After the <code class=\"docutils literal notranslate\">year</code> transform has been added\nto <code class=\"docutils literal notranslate\">DateField</code> it is possible to filter on the transformed value, for\nexample <code class=\"docutils literal notranslate\">qs.filter(author__birthdate__year__lte=1981)</code>.</p>\n<p>For more information about both custom lookups and transforms refer to\nthe <a class=\"reference internal\" href=\"/en/dev/howto/custom-lookups/\"><span class=\"doc\">custom lookups</span></a> documentation.</p>\n</section>\n<section id=\"improvements-to-form-error-handling\">\n<h3>Improvements to <code class=\"docutils literal notranslate\">Form</code> error handling<a class=\"heading-anchor\" href=\"#improvements-to-form-error-handling\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"form-add-error\">\n<h4><code class=\"docutils literal notranslate\">Form.add_error()</code><a class=\"heading-anchor\" href=\"#form-add-error\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Previously there were two main patterns for handling errors in forms:</p>\n<ul class=\"simple\">\n<li><p>Raising a <a class=\"reference internal\" href=\"/en/dev/ref/exceptions/#django.core.exceptions.ValidationError\" title=\"django.core.exceptions.ValidationError\"><code class=\"xref py py-exc docutils literal notranslate\">ValidationError</code></a> from within certain\nfunctions (e.g. <code class=\"docutils literal notranslate\">Field.clean()</code>, <code class=\"docutils literal notranslate\">Form.clean_&lt;fieldname&gt;()</code>, or\n<code class=\"docutils literal notranslate\">Form.clean()</code> for non-field errors.)</p></li>\n<li><p>Fiddling with <code class=\"docutils literal notranslate\">Form._errors</code> when targeting a specific field in\n<code class=\"docutils literal notranslate\">Form.clean()</code> or adding errors from outside of a “clean” method\n(e.g. directly from a view).</p></li>\n</ul>\n<p>Using the former pattern was straightforward since the form can guess from the\ncontext (i.e. which method raised the exception) where the errors belong and\nautomatically process them. This remains the canonical way of adding errors\nwhen possible. However the latter was fiddly and error-prone, since the burden\nof handling edge cases fell on the user.</p>\n<p>The new <a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.add_error\" title=\"django.forms.Form.add_error\"><code class=\"xref py py-meth docutils literal notranslate\">add_error()</code></a> method allows adding errors\nto specific form fields from anywhere without having to worry about the details\nsuch as creating instances of <code class=\"docutils literal notranslate\">django.forms.utils.ErrorList</code> or dealing with\n<code class=\"docutils literal notranslate\">Form.cleaned_data</code>. This new API replaces manipulating <code class=\"docutils literal notranslate\">Form._errors</code>\nwhich now becomes a private API.</p>\n<p>See <a class=\"reference internal\" href=\"/en/dev/ref/forms/validation/#validating-fields-with-clean\"><span class=\"std std-ref\">Cleaning and validating fields that depend on each other</span></a> for an example using\n<code class=\"docutils literal notranslate\">Form.add_error()</code>.</p>\n</section>\n<section id=\"error-metadata\">\n<h4>Error metadata<a class=\"heading-anchor\" href=\"#error-metadata\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>The <a class=\"reference internal\" href=\"/en/dev/ref/exceptions/#django.core.exceptions.ValidationError\" title=\"django.core.exceptions.ValidationError\"><code class=\"xref py py-exc docutils literal notranslate\">ValidationError</code></a> constructor accepts metadata\nsuch as error <code class=\"docutils literal notranslate\">code</code> or <code class=\"docutils literal notranslate\">params</code> which are then available for interpolating\ninto the error message (see <a class=\"reference internal\" href=\"/en/dev/ref/forms/validation/#raising-validation-error\"><span class=\"std std-ref\">Raising ValidationError</span></a> for more details);\nhowever, before Django 1.7 those metadata were discarded as soon as the errors\nwere added to <a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.errors\" title=\"django.forms.Form.errors\"><code class=\"xref py py-attr docutils literal notranslate\">Form.errors</code></a>.</p>\n<p><a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.errors\" title=\"django.forms.Form.errors\"><code class=\"xref py py-attr docutils literal notranslate\">Form.errors</code></a> and\n<code class=\"docutils literal notranslate\">django.forms.utils.ErrorList</code> now store the <code class=\"docutils literal notranslate\">ValidationError</code> instances\nso these metadata can be retrieved at any time through the new\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.errors.as_data\" title=\"django.forms.Form.errors.as_data\"><code class=\"xref py py-meth docutils literal notranslate\">Form.errors.as_data</code></a> method.</p>\n<p>The retrieved <code class=\"docutils literal notranslate\">ValidationError</code> instances can then be identified thanks to\ntheir error <code class=\"docutils literal notranslate\">code</code> which enables things like rewriting the error’s message\nor writing custom logic in a view when a given error is present. It can also\nbe used to serialize the errors in a custom format such as XML.</p>\n<p>The new <a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.errors.as_json\" title=\"django.forms.Form.errors.as_json\"><code class=\"xref py py-meth docutils literal notranslate\">Form.errors.as_json()</code></a>\nmethod is a convenience method which returns error messages along with error\ncodes serialized as JSON. <code class=\"docutils literal notranslate\">as_json()</code> uses <code class=\"docutils literal notranslate\">as_data()</code> and gives an idea\nof how the new system could be extended.</p>\n</section>\n<section id=\"error-containers-and-backward-compatibility\">\n<h4>Error containers and backward compatibility<a class=\"heading-anchor\" href=\"#error-containers-and-backward-compatibility\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Heavy changes to the various error containers were necessary in order\nto support the features above, specifically\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.errors\" title=\"django.forms.Form.errors\"><code class=\"xref py py-attr docutils literal notranslate\">Form.errors</code></a>,\n<code class=\"docutils literal notranslate\">django.forms.utils.ErrorList</code>, and the internal storages of\n<a class=\"reference internal\" href=\"/en/dev/ref/exceptions/#django.core.exceptions.ValidationError\" title=\"django.core.exceptions.ValidationError\"><code class=\"xref py py-exc docutils literal notranslate\">ValidationError</code></a>. These containers which used\nto store error strings now store <code class=\"docutils literal notranslate\">ValidationError</code> instances and public APIs\nhave been adapted to make this as transparent as possible, but if you’ve been\nusing private APIs, some of the changes are backwards incompatible; see\n<a class=\"reference internal\" href=\"#validation-error-constructor-and-internal-storage\"><span class=\"std std-ref\">ValidationError constructor and internal storage</span></a> for more details.</p>\n</section>\n</section>\n<section id=\"minor-features\">\n<h3>Minor features<a class=\"heading-anchor\" href=\"#minor-features\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"django-contrib-admin\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#module-django.contrib.admin\" title=\"django.contrib.admin: Django's admin site.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.admin</code></a><a class=\"heading-anchor\" href=\"#django-contrib-admin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>You can now implement <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.AdminSite.site_header\" title=\"django.contrib.admin.AdminSite.site_header\"><code class=\"xref py py-attr docutils literal notranslate\">site_header</code></a>,\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.AdminSite.site_title\" title=\"django.contrib.admin.AdminSite.site_title\"><code class=\"xref py py-attr docutils literal notranslate\">site_title</code></a>, and\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.AdminSite.index_title\" title=\"django.contrib.admin.AdminSite.index_title\"><code class=\"xref py py-attr docutils literal notranslate\">index_title</code></a> attributes on a custom\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.AdminSite\" title=\"django.contrib.admin.AdminSite\"><code class=\"xref py py-class docutils literal notranslate\">AdminSite</code></a> in order to easily change the admin\nsite’s page title and header text. No more needing to override templates!</p></li>\n<li><p>Buttons in <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#module-django.contrib.admin\" title=\"django.contrib.admin: Django's admin site.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.admin</code></a> now use the <code class=\"docutils literal notranslate\">border-radius</code> CSS\nproperty for rounded corners rather than GIF background images.</p></li>\n<li><p>Some admin templates now have <code class=\"docutils literal notranslate\">app-&lt;app_name&gt;</code> and <code class=\"docutils literal notranslate\">model-&lt;model_name&gt;</code>\nclasses in their <code class=\"docutils literal notranslate\">&lt;body&gt;</code> tag to allow customizing the CSS per app or per\nmodel.</p></li>\n<li><p>The admin changelist cells now have a <code class=\"docutils literal notranslate\">field-&lt;field_name&gt;</code> class in the\nHTML to enable style customizations.</p></li>\n<li><p>The admin’s search fields can now be customized per-request thanks to the new\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_search_fields\" title=\"django.contrib.admin.ModelAdmin.get_search_fields\"><code class=\"xref py py-meth docutils literal notranslate\">django.contrib.admin.ModelAdmin.get_search_fields()</code></a> method.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_fields\" title=\"django.contrib.admin.ModelAdmin.get_fields\"><code class=\"xref py py-meth docutils literal notranslate\">ModelAdmin.get_fields()</code></a> method may be overridden to\ncustomize the value of <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.fields\" title=\"django.contrib.admin.ModelAdmin.fields\"><code class=\"xref py py-attr docutils literal notranslate\">ModelAdmin.fields</code></a>.</p></li>\n<li><p>In addition to the existing <code class=\"docutils literal notranslate\">admin.site.register</code> syntax, you can use the\nnew <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.register\" title=\"django.contrib.admin.register\"><code class=\"xref py py-func docutils literal notranslate\">register()</code></a> decorator to register a\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin\" title=\"django.contrib.admin.ModelAdmin\"><code class=\"xref py py-class docutils literal notranslate\">ModelAdmin</code></a>.</p></li>\n<li><p>You may specify <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display_links\" title=\"django.contrib.admin.ModelAdmin.list_display_links\"><code class=\"xref py py-meth docutils literal notranslate\">ModelAdmin.list_display_links</code></a> <code class=\"docutils literal notranslate\">= None</code> to disable\nlinks on the change list page grid.</p></li>\n<li><p>You may now specify <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.view_on_site\" title=\"django.contrib.admin.ModelAdmin.view_on_site\"><code class=\"xref py py-attr docutils literal notranslate\">ModelAdmin.view_on_site</code></a> to control whether or not to\ndisplay the “View on site” link.</p></li>\n<li><p>You can specify a descending ordering for a <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display\" title=\"django.contrib.admin.ModelAdmin.list_display\"><code class=\"xref py py-attr docutils literal notranslate\">ModelAdmin.list_display</code></a> value by prefixing the\n<code class=\"docutils literal notranslate\">admin_order_field</code> value with a hyphen.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_changeform_initial_data\" title=\"django.contrib.admin.ModelAdmin.get_changeform_initial_data\"><code class=\"xref py py-meth docutils literal notranslate\">ModelAdmin.get_changeform_initial_data()</code></a> method may be\noverridden to define custom behavior for setting initial change form data.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-auth\">\n<h4><a class=\"reference internal\" href=\"/en/dev/topics/auth/#module-django.contrib.auth\" title=\"django.contrib.auth: Django's authentication framework.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.auth</code></a><a class=\"heading-anchor\" href=\"#django-contrib-auth\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>Any <code class=\"docutils literal notranslate\">**kwargs</code> passed to\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/auth/#django.contrib.auth.models.User.email_user\" title=\"django.contrib.auth.models.User.email_user\"><code class=\"xref py py-meth docutils literal notranslate\">email_user()</code></a> are passed to the\nunderlying <a class=\"reference internal\" href=\"/en/dev/topics/email/#django.core.mail.send_mail\" title=\"django.core.mail.send_mail\"><code class=\"xref py py-func docutils literal notranslate\">send_mail()</code></a> call.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.decorators.permission_required\" title=\"django.contrib.auth.decorators.permission_required\"><code class=\"xref py py-func docutils literal notranslate\">permission_required()</code></a> decorator can\ntake a list of permissions as well as a single permission.</p></li>\n<li><p>You can override the new <a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.forms.AuthenticationForm.confirm_login_allowed\" title=\"django.contrib.auth.forms.AuthenticationForm.confirm_login_allowed\"><code class=\"xref py py-meth docutils literal notranslate\">AuthenticationForm.confirm_login_allowed()</code></a> method\nto more easily customize the login policy.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.contrib.auth.views.password_reset()</code> takes an optional\n<code class=\"docutils literal notranslate\">html_email_template_name</code> parameter used to send a multipart HTML email\nfor password resets.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/topics/auth/customizing/#django.contrib.auth.models.AbstractBaseUser.get_session_auth_hash\" title=\"django.contrib.auth.models.AbstractBaseUser.get_session_auth_hash\"><code class=\"xref py py-meth docutils literal notranslate\">AbstractBaseUser.get_session_auth_hash()</code></a>\nmethod was added and if your <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-AUTH_USER_MODEL\"><code class=\"xref std std-setting docutils literal notranslate\">AUTH_USER_MODEL</code></a> inherits from\n<a class=\"reference internal\" href=\"/en/dev/topics/auth/customizing/#django.contrib.auth.models.AbstractBaseUser\" title=\"django.contrib.auth.models.AbstractBaseUser\"><code class=\"xref py py-class docutils literal notranslate\">AbstractBaseUser</code></a>, changing a user’s\npassword now invalidates old sessions if the\n<code class=\"docutils literal notranslate\">django.contrib.auth.middleware.SessionAuthenticationMiddleware</code> is\nenabled. See <a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#session-invalidation-on-password-change\"><span class=\"std std-ref\">Session invalidation on password change</span></a> for more details.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-formtools\">\n<h4><code class=\"docutils literal notranslate\">django.contrib.formtools</code><a class=\"heading-anchor\" href=\"#django-contrib-formtools\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>Calls to <code class=\"docutils literal notranslate\">WizardView.done()</code> now include a <code class=\"docutils literal notranslate\">form_dict</code> to allow easier\naccess to forms by their step name.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-gis\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/gis/#module-django.contrib.gis\" title=\"django.contrib.gis: Geographic Information System (GIS) extensions for Django\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.gis</code></a><a class=\"heading-anchor\" href=\"#django-contrib-gis\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The default OpenLayers library version included in widgets has been updated\nfrom 2.11 to 2.13.</p></li>\n<li><p>Prepared geometries now also support the <code class=\"docutils literal notranslate\">crosses</code>, <code class=\"docutils literal notranslate\">disjoint</code>,\n<code class=\"docutils literal notranslate\">overlaps</code>, <code class=\"docutils literal notranslate\">touches</code> and <code class=\"docutils literal notranslate\">within</code> predicates, if GEOS 3.3 or later is\ninstalled.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-messages\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/messages/#module-django.contrib.messages\" title=\"django.contrib.messages: Provides cookie- and session-based temporary message storage.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.messages</code></a><a class=\"heading-anchor\" href=\"#django-contrib-messages\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The backends for <a class=\"reference internal\" href=\"/en/dev/ref/contrib/messages/#module-django.contrib.messages\" title=\"django.contrib.messages: Provides cookie- and session-based temporary message storage.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.messages</code></a> that use cookies, will now\nfollow the <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-SESSION_COOKIE_SECURE\"><code class=\"xref std std-setting docutils literal notranslate\">SESSION_COOKIE_SECURE</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-SESSION_COOKIE_HTTPONLY\"><code class=\"xref std std-setting docutils literal notranslate\">SESSION_COOKIE_HTTPONLY</code></a> settings.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/contrib/messages/#message-displaying\"><span class=\"std std-ref\">messages context processor</span></a> now adds a\ndictionary of default levels under the name <code class=\"docutils literal notranslate\">DEFAULT_MESSAGE_LEVELS</code>.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/messages/#django.contrib.messages.Message\" title=\"django.contrib.messages.Message\"><code class=\"xref py py-class docutils literal notranslate\">Message</code></a> objects now have a <code class=\"docutils literal notranslate\">level_tag</code>\nattribute that contains the string representation of the message level.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-redirects\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/redirects/#module-django.contrib.redirects\" title=\"django.contrib.redirects: A framework for managing redirects.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.redirects</code></a><a class=\"heading-anchor\" href=\"#django-contrib-redirects\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/redirects/#django.contrib.redirects.middleware.RedirectFallbackMiddleware\" title=\"django.contrib.redirects.middleware.RedirectFallbackMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">RedirectFallbackMiddleware</code></a>\nhas two new attributes\n(<a class=\"reference internal\" href=\"/en/dev/ref/contrib/redirects/#django.contrib.redirects.middleware.RedirectFallbackMiddleware.response_gone_class\" title=\"django.contrib.redirects.middleware.RedirectFallbackMiddleware.response_gone_class\"><code class=\"xref py py-attr docutils literal notranslate\">response_gone_class</code></a>\nand\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/redirects/#django.contrib.redirects.middleware.RedirectFallbackMiddleware.response_redirect_class\" title=\"django.contrib.redirects.middleware.RedirectFallbackMiddleware.response_redirect_class\"><code class=\"xref py py-attr docutils literal notranslate\">response_redirect_class</code></a>)\nthat specify the types of <a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpResponse\" title=\"django.http.HttpResponse\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponse</code></a> instances the\nmiddleware returns.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-sessions\">\n<h4><a class=\"reference internal\" href=\"/en/dev/topics/http/sessions/#module-django.contrib.sessions\" title=\"django.contrib.sessions: Provides session management for Django projects.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.sessions</code></a><a class=\"heading-anchor\" href=\"#django-contrib-sessions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The <code class=\"docutils literal notranslate\">&quot;django.contrib.sessions.backends.cached_db&quot;</code> session backend now\nrespects <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-SESSION_CACHE_ALIAS\"><code class=\"xref std std-setting docutils literal notranslate\">SESSION_CACHE_ALIAS</code></a>. In previous versions, it always used\nthe <code class=\"docutils literal notranslate\">default</code> cache.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-sitemaps\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/sitemaps/#module-django.contrib.sitemaps\" title=\"django.contrib.sitemaps: A framework for generating Google sitemap XML files.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.sitemaps</code></a><a class=\"heading-anchor\" href=\"#django-contrib-sitemaps\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/contrib/sitemaps/#module-django.contrib.sitemaps\" title=\"django.contrib.sitemaps: A framework for generating Google sitemap XML files.\"><code class=\"xref py py-mod docutils literal notranslate\">sitemap framework</code></a> now makes use of\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/sitemaps/#django.contrib.sitemaps.Sitemap.lastmod\" title=\"django.contrib.sitemaps.Sitemap.lastmod\"><code class=\"xref py py-attr docutils literal notranslate\">lastmod</code></a> to set a <code class=\"docutils literal notranslate\">Last-Modified</code>\nheader in the response. This makes it possible for the\n<a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.middleware.http.ConditionalGetMiddleware\" title=\"django.middleware.http.ConditionalGetMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">ConditionalGetMiddleware</code></a> to handle\nconditional <code class=\"docutils literal notranslate\">GET</code> requests for sitemaps which set <code class=\"docutils literal notranslate\">lastmod</code>.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-sites\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/sites/#module-django.contrib.sites\" title=\"django.contrib.sites: Lets you operate multiple websites from the same database and Django project\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.sites</code></a><a class=\"heading-anchor\" href=\"#django-contrib-sites\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.contrib.sites.middleware.CurrentSiteMiddleware\" title=\"django.contrib.sites.middleware.CurrentSiteMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">django.contrib.sites.middleware.CurrentSiteMiddleware</code></a> allows\nsetting the current site on each request.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-staticfiles\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#module-django.contrib.staticfiles\" title=\"django.contrib.staticfiles: An app for handling static files.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.staticfiles</code></a><a class=\"heading-anchor\" href=\"#django-contrib-staticfiles\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#staticfiles-storages\"><span class=\"std std-ref\">static files storage classes</span></a> may be\nsubclassed to override the permissions that collected static files and\ndirectories receive by setting the\n<a class=\"reference internal\" href=\"/en/dev/ref/files/storage/#django.core.files.storage.FileSystemStorage.file_permissions_mode\" title=\"django.core.files.storage.FileSystemStorage.file_permissions_mode\"><code class=\"xref py py-attr docutils literal notranslate\">file_permissions_mode</code></a>\nand\n<a class=\"reference internal\" href=\"/en/dev/ref/files/storage/#django.core.files.storage.FileSystemStorage.directory_permissions_mode\" title=\"django.core.files.storage.FileSystemStorage.directory_permissions_mode\"><code class=\"xref py py-attr docutils literal notranslate\">directory_permissions_mode</code></a>\nparameters. See <a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\">collectstatic</code></a> for example usage.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">CachedStaticFilesStorage</code> backend gets a sibling class called\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.ManifestStaticFilesStorage\" title=\"django.contrib.staticfiles.storage.ManifestStaticFilesStorage\"><code class=\"xref py py-class docutils literal notranslate\">ManifestStaticFilesStorage</code></a>\nthat doesn’t use the cache system at all but instead a JSON file called\n<code class=\"docutils literal notranslate\">staticfiles.json</code> for storing the mapping between the original file name\n(e.g. <code class=\"docutils literal notranslate\">css/styles.css</code>) and the hashed file name (e.g.\n<code class=\"docutils literal notranslate\">css/styles.55e7cbb9ba48.css</code>). The <code class=\"docutils literal notranslate\">staticfiles.json</code> file is created\nwhen running the <a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\">collectstatic</code></a> management command and should\nbe a less expensive alternative for remote storages such as Amazon S3.</p>\n<p>See the\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.ManifestStaticFilesStorage\" title=\"django.contrib.staticfiles.storage.ManifestStaticFilesStorage\"><code class=\"xref py py-class docutils literal notranslate\">ManifestStaticFilesStorage</code></a> docs\nfor more information.</p>\n</li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#django-admin-findstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\">findstatic</code></a> now accepts verbosity flag level 2, meaning it will\nshow the relative paths of the directories it searched. See\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#django-admin-findstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\">findstatic</code></a> for example output.</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-syndication\">\n<h4><a class=\"reference internal\" href=\"/en/dev/ref/contrib/syndication/#module-django.contrib.syndication\" title=\"django.contrib.syndication: A framework for generating syndication feeds, in RSS and Atom, quite easily.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.syndication</code></a><a class=\"heading-anchor\" href=\"#django-contrib-syndication\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.feedgenerator.Atom1Feed\" title=\"django.utils.feedgenerator.Atom1Feed\"><code class=\"xref py py-class docutils literal notranslate\">Atom1Feed</code></a> syndication feed’s\n<code class=\"docutils literal notranslate\">updated</code> element now utilizes <code class=\"docutils literal notranslate\">updateddate</code> instead of <code class=\"docutils literal notranslate\">pubdate</code>,\nallowing the <code class=\"docutils literal notranslate\">published</code> element to be included in the feed (which\nrelies on <code class=\"docutils literal notranslate\">pubdate</code>).</p></li>\n</ul>\n</section>\n<section id=\"cache\">\n<h4>Cache<a class=\"heading-anchor\" href=\"#cache\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>Access to caches configured in <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CACHES\"><code class=\"xref std std-setting docutils literal notranslate\">CACHES</code></a> is now available via\n<a class=\"reference internal\" href=\"/en/dev/topics/cache/#django.core.cache.caches\" title=\"django.core.cache.caches\"><code class=\"xref py py-data docutils literal notranslate\">django.core.cache.caches</code></a>. This dict-like object provides a different\ninstance per thread. It supersedes <code class=\"docutils literal notranslate\">django.core.cache.get_cache()</code> which\nis now deprecated.</p></li>\n<li><p>If you instantiate cache backends directly, be aware that they aren’t\nthread-safe any more, as <a class=\"reference internal\" href=\"/en/dev/topics/cache/#django.core.cache.caches\" title=\"django.core.cache.caches\"><code class=\"xref py py-data docutils literal notranslate\">django.core.cache.caches</code></a> now yields\ndifferent instances per thread.</p></li>\n<li><p>Defining the <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CACHES-TIMEOUT\"><code class=\"xref std std-setting docutils literal notranslate\">TIMEOUT</code></a> argument of the\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CACHES\"><code class=\"xref std std-setting docutils literal notranslate\">CACHES</code></a> setting as <code class=\"docutils literal notranslate\">None</code> will set the cache keys as\n“non-expiring” by default. Previously, it was only possible to pass\n<code class=\"docutils literal notranslate\">timeout=None</code> to the cache backend’s <code class=\"docutils literal notranslate\">set()</code> method.</p></li>\n</ul>\n</section>\n<section id=\"cross-site-request-forgery\">\n<h4>Cross Site Request Forgery<a class=\"heading-anchor\" href=\"#cross-site-request-forgery\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CSRF_COOKIE_AGE\"><code class=\"xref std std-setting docutils literal notranslate\">CSRF_COOKIE_AGE</code></a> setting facilitates the use of session-based\nCSRF cookies.</p></li>\n</ul>\n</section>\n<section id=\"email\">\n<h4>Email<a class=\"heading-anchor\" href=\"#email\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/email/#django.core.mail.send_mail\" title=\"django.core.mail.send_mail\"><code class=\"xref py py-func docutils literal notranslate\">send_mail()</code></a> now accepts an <code class=\"docutils literal notranslate\">html_message</code>\nparameter for sending a multipart <em class=\"mimetype\">text/plain</em> and\n<em class=\"mimetype\">text/html</em> email.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/topics/email/#topic-email-smtp-backend\"><span class=\"std std-ref\">SMTP EmailBackend</span></a> now accepts a\n<code class=\"docutils literal notranslate\">timeout</code> parameter.</p></li>\n</ul>\n</section>\n<section id=\"file-storage\">\n<h4>File Storage<a class=\"heading-anchor\" href=\"#file-storage\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>File locking on Windows previously depended on the PyWin32 package; if it\nwasn’t installed, file locking failed silently. That dependency has been\nremoved, and file locking is now implemented natively on both Windows\nand Unix.</p></li>\n</ul>\n</section>\n<section id=\"file-uploads\">\n<h4>File Uploads<a class=\"heading-anchor\" href=\"#file-uploads\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/files/uploads/#django.core.files.uploadedfile.UploadedFile.content_type_extra\" title=\"django.core.files.uploadedfile.UploadedFile.content_type_extra\"><code class=\"xref py py-attr docutils literal notranslate\">UploadedFile.content_type_extra</code></a> attribute\ncontains extra parameters passed to the <code class=\"docutils literal notranslate\">content-type</code> header on a file\nupload.</p></li>\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-FILE_UPLOAD_DIRECTORY_PERMISSIONS\"><code class=\"xref std std-setting docutils literal notranslate\">FILE_UPLOAD_DIRECTORY_PERMISSIONS</code></a> setting controls\nthe file system permissions of directories created during file upload, like\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-FILE_UPLOAD_PERMISSIONS\"><code class=\"xref std std-setting docutils literal notranslate\">FILE_UPLOAD_PERMISSIONS</code></a> does for the files themselves.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.FileField.upload_to\" title=\"django.db.models.FileField.upload_to\"><code class=\"xref py py-attr docutils literal notranslate\">FileField.upload_to</code></a>\nattribute is now optional. If it is omitted or given <code class=\"docutils literal notranslate\">None</code> or an empty\nstring, a subdirectory won’t be used for storing the uploaded files.</p></li>\n<li><p>Uploaded files are now explicitly closed before the response is delivered to\nthe client. Partially uploaded files are also closed as long as they are\nnamed <code class=\"docutils literal notranslate\">file</code> in the upload handler.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/files/storage/#django.core.files.storage.Storage.get_available_name\" title=\"django.core.files.storage.Storage.get_available_name\"><code class=\"xref py py-meth docutils literal notranslate\">Storage.get_available_name()</code></a> now appends an\nunderscore plus a random 7 character alphanumeric string (e.g.\n<code class=\"docutils literal notranslate\">&quot;_x3a1gho&quot;</code>), rather than iterating through an underscore followed by a\nnumber (e.g. <code class=\"docutils literal notranslate\">&quot;_1&quot;</code>, <code class=\"docutils literal notranslate\">&quot;_2&quot;</code>, etc.) to prevent a denial-of-service attack.\nThis change was also made in the 1.6.6, 1.5.9, and 1.4.14 security releases.</p></li>\n</ul>\n</section>\n<section id=\"forms\">\n<h4>Forms<a class=\"heading-anchor\" href=\"#forms\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The <code class=\"docutils literal notranslate\">&lt;label&gt;</code> and <code class=\"docutils literal notranslate\">&lt;input&gt;</code> tags rendered by\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/widgets/#django.forms.RadioSelect\" title=\"django.forms.RadioSelect\"><code class=\"xref py py-class docutils literal notranslate\">RadioSelect</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/widgets/#django.forms.CheckboxSelectMultiple\" title=\"django.forms.CheckboxSelectMultiple\"><code class=\"xref py py-class docutils literal notranslate\">CheckboxSelectMultiple</code></a> when looping over the radio\nbuttons or checkboxes now include <code class=\"docutils literal notranslate\">for</code> and <code class=\"docutils literal notranslate\">id</code> attributes,\nrespectively. Each radio button or checkbox includes an <code class=\"docutils literal notranslate\">id_for_label</code>\nattribute to output the element’s ID.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">&lt;textarea&gt;</code> tags rendered by <a class=\"reference internal\" href=\"/en/dev/ref/forms/widgets/#django.forms.Textarea\" title=\"django.forms.Textarea\"><code class=\"xref py py-class docutils literal notranslate\">Textarea</code></a> now\ninclude a <code class=\"docutils literal notranslate\">maxlength</code> attribute if the <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.TextField\" title=\"django.db.models.TextField\"><code class=\"xref py py-class docutils literal notranslate\">TextField</code></a>\nmodel field has a <code class=\"docutils literal notranslate\">max_length</code>.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.Field.choices\" title=\"django.db.models.Field.choices\"><code class=\"xref py py-attr docutils literal notranslate\">Field.choices</code></a> now allows you to\ncustomize the “empty choice” label by including a tuple with an empty string\nor <code class=\"docutils literal notranslate\">None</code> for the key and the custom label as the value. The default blank\noption <code class=\"docutils literal notranslate\">&quot;----------&quot;</code> will be omitted in this case.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.MultiValueField\" title=\"django.forms.MultiValueField\"><code class=\"xref py py-class docutils literal notranslate\">MultiValueField</code></a> allows optional subfields by setting\nthe <code class=\"docutils literal notranslate\">require_all_fields</code> argument to <code class=\"docutils literal notranslate\">False</code>. The <code class=\"docutils literal notranslate\">required</code> attribute\nfor each individual field will be respected, and a new <code class=\"docutils literal notranslate\">incomplete</code>\nvalidation error will be raised when any required fields are empty.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.clean\" title=\"django.forms.Form.clean\"><code class=\"xref py py-meth docutils literal notranslate\">clean()</code></a> method on a form no longer needs to\nreturn <code class=\"docutils literal notranslate\">self.cleaned_data</code>. If it does return a changed dictionary then\nthat will still be used.</p></li>\n<li><p>After a temporary regression in Django 1.6, it’s now possible again to make\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.TypedChoiceField\" title=\"django.forms.TypedChoiceField\"><code class=\"xref py py-class docutils literal notranslate\">TypedChoiceField</code></a> <code class=\"docutils literal notranslate\">coerce</code> method return an arbitrary\nvalue.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/forms/widgets/#django.forms.SelectDateWidget.months\" title=\"django.forms.SelectDateWidget.months\"><code class=\"xref py py-attr docutils literal notranslate\">SelectDateWidget.months</code></a> can be used to\ncustomize the wording of the months displayed in the select widget.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">min_num</code> and <code class=\"docutils literal notranslate\">validate_min</code> parameters were added to\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/formsets/#django.forms.formsets.formset_factory\" title=\"django.forms.formsets.formset_factory\"><code class=\"xref py py-func docutils literal notranslate\">formset_factory()</code></a> to allow validating\na minimum number of submitted forms.</p></li>\n<li><p>The metaclasses used by <code class=\"docutils literal notranslate\">Form</code> and <code class=\"docutils literal notranslate\">ModelForm</code> have been reworked to\nsupport more inheritance scenarios. The previous limitation that prevented\ninheriting from both <code class=\"docutils literal notranslate\">Form</code> and <code class=\"docutils literal notranslate\">ModelForm</code> simultaneously have been\nremoved as long as <code class=\"docutils literal notranslate\">ModelForm</code> appears first in the MRO.</p></li>\n<li><p>It’s now possible to remove a field from a <code class=\"docutils literal notranslate\">Form</code> when subclassing by\nsetting the name to <code class=\"docutils literal notranslate\">None</code>.</p></li>\n<li><p>It’s now possible to customize the error messages for <code class=\"docutils literal notranslate\">ModelForm</code>’s\n<code class=\"docutils literal notranslate\">unique</code>, <code class=\"docutils literal notranslate\">unique_for_date</code>, and <code class=\"docutils literal notranslate\">unique_together</code> constraints.\nIn order to support <code class=\"docutils literal notranslate\">unique_together</code> or any other <code class=\"docutils literal notranslate\">NON_FIELD_ERROR</code>,\n<code class=\"docutils literal notranslate\">ModelForm</code> now looks for the <code class=\"docutils literal notranslate\">NON_FIELD_ERROR</code> key in the\n<code class=\"docutils literal notranslate\">error_messages</code> dictionary of the <code class=\"docutils literal notranslate\">ModelForm</code>’s inner <code class=\"docutils literal notranslate\">Meta</code> class.\nSee <a class=\"reference internal\" href=\"/en/dev/topics/forms/modelforms/#considerations-regarding-model-errormessages\"><span class=\"std std-ref\">considerations regarding model’s error_messages</span></a> for more details.</p></li>\n</ul>\n</section>\n<section id=\"internationalization\">\n<h4>Internationalization<a class=\"heading-anchor\" href=\"#internationalization\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.middleware.locale.LocaleMiddleware.response_redirect_class\" title=\"django.middleware.locale.LocaleMiddleware.response_redirect_class\"><code class=\"xref py py-attr docutils literal notranslate\">django.middleware.locale.LocaleMiddleware.response_redirect_class</code></a>\nattribute allows you to customize the redirects issued by the middleware.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.middleware.locale.LocaleMiddleware\" title=\"django.middleware.locale.LocaleMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">LocaleMiddleware</code></a> now stores the user’s\nselected language with the session key <code class=\"docutils literal notranslate\">_language</code>. This should only be\naccessed using the <code class=\"docutils literal notranslate\">LANGUAGE_SESSION_KEY</code> constant. Previously it was\nstored with the key <code class=\"docutils literal notranslate\">django_language</code> and the <code class=\"docutils literal notranslate\">LANGUAGE_SESSION_KEY</code>\nconstant did not exist, but keys reserved for Django should start with an\nunderscore. For backwards compatibility <code class=\"docutils literal notranslate\">django_language</code> is still read\nfrom in 1.7. Sessions will be migrated to the new key as they are written.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#std-templatetag-blocktrans\"><code class=\"xref std std-ttag docutils literal notranslate\">blocktrans</code></a> tag now supports a <code class=\"docutils literal notranslate\">trimmed</code> option. This\noption will remove newline characters from the beginning and the end of the\ncontent of the <code class=\"docutils literal notranslate\">{% blocktrans %}</code> tag, replace any whitespace at the\nbeginning and end of a line and merge all lines into one using a space\ncharacter to separate them. This is quite useful for indenting the content of\na <code class=\"docutils literal notranslate\">{% blocktrans %}</code> tag without having the indentation characters end up\nin the corresponding entry in the <code class=\"docutils literal notranslate\">.po</code> file, which makes the translation\nprocess easier.</p></li>\n<li><p>When you run <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-makemessages\"><code class=\"xref std std-djadmin docutils literal notranslate\">makemessages</code></a> from the root directory of your project,\nany extracted strings will now be automatically distributed to the proper\napp or project message file. See <a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#how-to-create-language-files\"><span class=\"std std-ref\">Localization: how to create language files</span></a> for\ndetails.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-makemessages\"><code class=\"xref std std-djadmin docutils literal notranslate\">makemessages</code></a> command now always adds the <code class=\"docutils literal notranslate\">--previous</code>\ncommand line flag to the <code class=\"docutils literal notranslate\">msgmerge</code> command, keeping previously translated\nstrings in <code class=\"docutils literal notranslate\">.po</code> files for fuzzy strings.</p></li>\n<li><p>The following settings to adjust the language cookie options were introduced:\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-LANGUAGE_COOKIE_AGE\"><code class=\"xref std std-setting docutils literal notranslate\">LANGUAGE_COOKIE_AGE</code></a>, <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-LANGUAGE_COOKIE_DOMAIN\"><code class=\"xref std std-setting docutils literal notranslate\">LANGUAGE_COOKIE_DOMAIN</code></a>\nand <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-LANGUAGE_COOKIE_PATH\"><code class=\"xref std std-setting docutils literal notranslate\">LANGUAGE_COOKIE_PATH</code></a>.</p></li>\n<li><p>Added <a class=\"reference internal\" href=\"/en/dev/topics/i18n/formatting/\"><span class=\"doc\">Format localization</span></a> for Esperanto.</p></li>\n</ul>\n</section>\n<section id=\"management-commands\">\n<h4>Management Commands<a class=\"heading-anchor\" href=\"#management-commands\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul>\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#cmdoption-no-color\"><code class=\"xref std std-option docutils literal notranslate\">--no-color</code></a> option for <code class=\"docutils literal notranslate\">django-admin</code> disables the\ncolorization of management command output.</p></li>\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#cmdoption-dumpdata-natural-foreign\"><code class=\"xref std std-option docutils literal notranslate\">dumpdata --natural-foreign</code></a> and <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#cmdoption-dumpdata-natural-primary\"><code class=\"xref std std-option docutils literal notranslate\">dumpdata\n--natural-primary</code></a> options, and the new <code class=\"docutils literal notranslate\">use_natural_foreign_keys</code> and\n<code class=\"docutils literal notranslate\">use_natural_primary_keys</code> arguments for <code class=\"docutils literal notranslate\">serializers.serialize()</code>, allow\nthe use of natural primary keys when serializing.</p></li>\n<li><p>It is no longer necessary to provide the cache table name or the\n<code class=\"docutils literal notranslate\">--database</code> option for the <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-createcachetable\"><code class=\"xref std std-djadmin docutils literal notranslate\">createcachetable</code></a> command.\nDjango takes this information from your settings file. If you have configured\nmultiple caches or multiple databases, all cache tables are created.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\">runserver</code></a> command received several improvements:</p>\n<ul class=\"simple\">\n<li><p>On Linux systems, if <a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/pyinotify/\">pyinotify</a> is installed, the development server\nwill reload immediately when a file is changed. Previously, it polled the\nfilesystem for changes every second. That caused a small delay before\nreloads and reduced battery life on laptops.</p></li>\n<li><p>In addition, the development server automatically reloads when a\ntranslation file is updated, i.e. after running\n<a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-compilemessages\"><code class=\"xref std std-djadmin docutils literal notranslate\">compilemessages</code></a>.</p></li>\n<li><p>All HTTP requests are logged to the console, including requests for static\nfiles or <code class=\"docutils literal notranslate\">favicon.ico</code> that used to be filtered out.</p></li>\n</ul>\n</li>\n<li><p>Management commands can now produce syntax colored output under Windows if\nthe ANSICON third-party tool is installed and active.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\">collectstatic</code></a> command with symlink option is now supported on\nWindows NT 6 (Windows Vista and newer).</p></li>\n<li><p>Initial SQL data now works better if the <a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/sqlparse/\">sqlparse</a> Python library is\ninstalled.</p>\n<p>Note that it’s deprecated in favor of the\n<a class=\"reference internal\" href=\"/en/dev/ref/migration-operations/#django.db.migrations.operations.RunSQL\" title=\"django.db.migrations.operations.RunSQL\"><code class=\"xref py py-class docutils literal notranslate\">RunSQL</code></a> operation of migrations,\nwhich benefits from the improved behavior.</p>\n</li>\n</ul>\n</section>\n<section id=\"models\">\n<h4>Models<a class=\"heading-anchor\" href=\"#models\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.update_or_create\" title=\"django.db.models.query.QuerySet.update_or_create\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.update_or_create()</code></a> method was added.</p></li>\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/models/options/#django.db.models.Options.default_permissions\" title=\"django.db.models.Options.default_permissions\"><code class=\"xref py py-attr docutils literal notranslate\">default_permissions</code></a> model\n<code class=\"docutils literal notranslate\">Meta</code> option allows you to customize (or disable) creation of the default\nadd, change, and delete permissions.</p></li>\n<li><p>Explicit <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.OneToOneField\" title=\"django.db.models.OneToOneField\"><code class=\"xref py py-class docutils literal notranslate\">OneToOneField</code></a> for\n<a class=\"reference internal\" href=\"/en/dev/topics/db/models/#multi-table-inheritance\"><span class=\"std std-ref\">Multi-table inheritance</span></a> are now discovered in abstract classes.</p></li>\n<li><p>It is now possible to avoid creating a backward relation for\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.OneToOneField\" title=\"django.db.models.OneToOneField\"><code class=\"xref py py-class docutils literal notranslate\">OneToOneField</code></a> by setting its\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.ForeignKey.related_name\" title=\"django.db.models.ForeignKey.related_name\"><code class=\"xref py py-attr docutils literal notranslate\">related_name</code></a> to\n<code class=\"docutils literal notranslate\">'+'</code> or ending it with <code class=\"docutils literal notranslate\">'+'</code>.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/models/expressions/#django.db.models.F\" title=\"django.db.models.F\"><code class=\"xref py py-class docutils literal notranslate\">F expressions</code></a> support the power operator\n(<code class=\"docutils literal notranslate\">**</code>).</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">remove()</code> and <code class=\"docutils literal notranslate\">clear()</code> methods of the related managers created by\n<code class=\"docutils literal notranslate\">ForeignKey</code> and <code class=\"docutils literal notranslate\">GenericForeignKey</code> now accept the <code class=\"docutils literal notranslate\">bulk</code> keyword\nargument to control whether or not to perform operations in bulk\n(i.e. using <code class=\"docutils literal notranslate\">QuerySet.update()</code>). Defaults to <code class=\"docutils literal notranslate\">True</code>.</p></li>\n<li><p>It is now possible to use <code class=\"docutils literal notranslate\">None</code> as a query value for the <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-iexact\"><code class=\"xref std std-lookup docutils literal notranslate\">iexact</code></a>\nlookup.</p></li>\n<li><p>It is now possible to pass a callable as value for the attribute\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.ForeignKey.limit_choices_to\" title=\"django.db.models.ForeignKey.limit_choices_to\"><code class=\"xref py py-attr docutils literal notranslate\">limit_choices_to</code></a> when defining a\n<code class=\"docutils literal notranslate\">ForeignKey</code> or <code class=\"docutils literal notranslate\">ManyToManyField</code>.</p></li>\n<li><p>Calling <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.only\" title=\"django.db.models.query.QuerySet.only\"><code class=\"xref py py-meth docutils literal notranslate\">only()</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.defer\" title=\"django.db.models.query.QuerySet.defer\"><code class=\"xref py py-meth docutils literal notranslate\">defer()</code></a> on the result of\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.values\" title=\"django.db.models.query.QuerySet.values\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.values()</code></a> now raises\nan error (before that, it would either result in a database error or\nincorrect data).</p></li>\n<li><p>You can use a single list for <code class=\"docutils literal notranslate\">index_together</code> (rather than a list of\nlists) when specifying a single set of fields.</p></li>\n<li><p>Custom intermediate models having more than one foreign key to any of the\nmodels participating in a many-to-many relationship are now permitted,\nprovided you explicitly specify which foreign keys should be used by setting\nthe new <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.ManyToManyField.through_fields\" title=\"django.db.models.ManyToManyField.through_fields\"><code class=\"xref py py-attr docutils literal notranslate\">ManyToManyField.through_fields</code></a> argument.</p></li>\n<li><p>Assigning a model instance to a non-relation field will now throw an error.\nPreviously this used to work if the field accepted integers as input as it\ntook the primary key.</p></li>\n<li><p>Integer fields are now validated against database backend specific min and\nmax values based on their <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.Field.get_internal_type\" title=\"django.db.models.Field.get_internal_type\"><code class=\"xref py py-meth docutils literal notranslate\">internal_type</code></a>. Previously model field\nvalidation didn’t prevent values out of their associated column data type\nrange from being saved resulting in an integrity error.</p></li>\n<li><p>It is now possible to explicitly\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.order_by\" title=\"django.db.models.query.QuerySet.order_by\"><code class=\"xref py py-meth docutils literal notranslate\">order_by()</code></a> a relation <code class=\"docutils literal notranslate\">_id</code> field by\nusing its attribute name.</p></li>\n</ul>\n</section>\n<section id=\"signals\">\n<h4>Signals<a class=\"heading-anchor\" href=\"#signals\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The <code class=\"docutils literal notranslate\">enter</code> argument was added to the\n<a class=\"reference internal\" href=\"/en/dev/ref/signals/#django.test.signals.setting_changed\" title=\"django.test.signals.setting_changed\"><code class=\"xref py py-data docutils literal notranslate\">setting_changed</code></a> signal.</p></li>\n<li><p>The model signals can be now be connected to using a <code class=\"docutils literal notranslate\">str</code> of the\n<code class=\"docutils literal notranslate\">'app_label.ModelName'</code> form – just like related fields – to lazily\nreference their senders.</p></li>\n</ul>\n</section>\n<section id=\"templates\">\n<h4>Templates<a class=\"heading-anchor\" href=\"#templates\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/templates/api/#django.template.Context.push\" title=\"django.template.Context.push\"><code class=\"xref py py-meth docutils literal notranslate\">Context.push()</code></a> method now returns\na context manager which automatically calls <a class=\"reference internal\" href=\"/en/dev/ref/templates/api/#django.template.Context.pop\" title=\"django.template.Context.pop\"><code class=\"xref py py-meth docutils literal notranslate\">pop()</code></a> upon exiting the <code class=\"docutils literal notranslate\">with</code> statement.\nAdditionally, <a class=\"reference internal\" href=\"/en/dev/ref/templates/api/#django.template.Context.push\" title=\"django.template.Context.push\"><code class=\"xref py py-meth docutils literal notranslate\">push()</code></a> now accepts\nparameters that are passed to the <code class=\"docutils literal notranslate\">dict</code> constructor used to build the new\ncontext level.</p></li>\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/templates/api/#django.template.Context.flatten\" title=\"django.template.Context.flatten\"><code class=\"xref py py-meth docutils literal notranslate\">Context.flatten()</code></a> method\nreturns a <code class=\"docutils literal notranslate\">Context</code>’s stack as one flat dictionary.</p></li>\n<li><p><code class=\"docutils literal notranslate\">Context</code> objects can now be compared for equality (internally, this\nuses <a class=\"reference internal\" href=\"/en/dev/ref/templates/api/#django.template.Context.flatten\" title=\"django.template.Context.flatten\"><code class=\"xref py py-meth docutils literal notranslate\">Context.flatten()</code></a> so the\ninternal structure of each <code class=\"docutils literal notranslate\">Context</code>’s stack doesn’t matter as long as\ntheir flattened version is identical).</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-widthratio\"><code class=\"xref std std-ttag docutils literal notranslate\">widthratio</code></a> template tag now accepts an <code class=\"docutils literal notranslate\">&quot;as&quot;</code> parameter to\ncapture the result in a variable.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-include\"><code class=\"xref std std-ttag docutils literal notranslate\">include</code></a> template tag will now also accept anything with a\n<code class=\"docutils literal notranslate\">render()</code> method (such as a <code class=\"docutils literal notranslate\">Template</code>) as an argument. String\narguments will be looked up using\n<a class=\"reference internal\" href=\"/en/dev/topics/templates/#django.template.loader.get_template\" title=\"django.template.loader.get_template\"><code class=\"xref py py-func docutils literal notranslate\">get_template()</code></a> as always.</p></li>\n<li><p>It is now possible to <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-include\"><code class=\"xref std std-ttag docutils literal notranslate\">include</code></a> templates recursively.</p></li>\n<li><p>Template objects now have an origin attribute set when\n<code class=\"docutils literal notranslate\">TEMPLATE_DEBUG</code> is <code class=\"docutils literal notranslate\">True</code>. This allows template origins to be\ninspected and logged outside of the <code class=\"docutils literal notranslate\">django.template</code> infrastructure.</p></li>\n<li><p><code class=\"docutils literal notranslate\">TypeError</code> exceptions are no longer silenced when raised during the\nrendering of a template.</p></li>\n<li><p>The following functions now accept a <code class=\"docutils literal notranslate\">dirs</code> parameter which is a list or\ntuple to override <code class=\"docutils literal notranslate\">TEMPLATE_DIRS</code>:</p>\n<ul>\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/templates/#django.template.loader.get_template\" title=\"django.template.loader.get_template\"><code class=\"xref py py-func docutils literal notranslate\">django.template.loader.get_template()</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/templates/#django.template.loader.select_template\" title=\"django.template.loader.select_template\"><code class=\"xref py py-func docutils literal notranslate\">django.template.loader.select_template()</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/http/shortcuts/#django.shortcuts.render\" title=\"django.shortcuts.render\"><code class=\"xref py py-func docutils literal notranslate\">django.shortcuts.render()</code></a></p></li>\n<li><p><code class=\"docutils literal notranslate\">django.shortcuts.render_to_response()</code></p></li>\n</ul>\n</li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatefilter-time\"><code class=\"xref std std-tfilter docutils literal notranslate\">time</code></a> filter now accepts timezone-related <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#date-and-time-formatting-specifiers\"><span class=\"std std-ref\">format\nspecifiers</span></a> <code class=\"docutils literal notranslate\">'e'</code>, <code class=\"docutils literal notranslate\">'O'</code> , <code class=\"docutils literal notranslate\">'T'</code>\nand <code class=\"docutils literal notranslate\">'Z'</code> and is able to digest <a class=\"reference internal\" href=\"/en/dev/topics/i18n/timezones/#naive-vs-aware-datetimes\"><span class=\"std std-ref\">time-zone-aware</span></a> <code class=\"docutils literal notranslate\">datetime</code> instances performing the expected\nrendering.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/topics/cache/#std-templatetag-cache\"><code class=\"xref std std-ttag docutils literal notranslate\">cache</code></a> tag will now try to use the cache called\n“template_fragments” if it exists and fall back to using the default cache\notherwise. It also now accepts an optional <code class=\"docutils literal notranslate\">using</code> keyword argument to\ncontrol which cache it uses.</p></li>\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatefilter-truncatechars_html\"><code class=\"xref std std-tfilter docutils literal notranslate\">truncatechars_html</code></a> filter truncates a string to be no\nlonger than the specified number of characters, taking HTML into account.</p></li>\n</ul>\n</section>\n<section id=\"requests-and-responses\">\n<h4>Requests and Responses<a class=\"heading-anchor\" href=\"#requests-and-responses\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpRequest.scheme\" title=\"django.http.HttpRequest.scheme\"><code class=\"xref py py-attr docutils literal notranslate\">HttpRequest.scheme</code></a> attribute\nspecifies the scheme of the request (<code class=\"docutils literal notranslate\">http</code> or <code class=\"docutils literal notranslate\">https</code> normally).</p></li>\n<li><p>The shortcut <a class=\"reference internal\" href=\"/en/dev/topics/http/shortcuts/#django.shortcuts.redirect\" title=\"django.shortcuts.redirect\"><code class=\"xref py py-func docutils literal notranslate\">redirect()</code></a> now supports\nrelative URLs.</p></li>\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.JsonResponse\" title=\"django.http.JsonResponse\"><code class=\"xref py py-class docutils literal notranslate\">JsonResponse</code></a> subclass of\n<a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpResponse\" title=\"django.http.HttpResponse\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponse</code></a> helps easily create JSON-encoded\nresponses.</p></li>\n</ul>\n</section>\n<section id=\"tests\">\n<h4>Tests<a class=\"heading-anchor\" href=\"#tests\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/testing/advanced/#django.test.runner.DiscoverRunner\" title=\"django.test.runner.DiscoverRunner\"><code class=\"xref py py-class docutils literal notranslate\">DiscoverRunner</code></a> has two new attributes,\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/advanced/#django.test.runner.DiscoverRunner.test_suite\" title=\"django.test.runner.DiscoverRunner.test_suite\"><code class=\"xref py py-attr docutils literal notranslate\">test_suite</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/advanced/#django.test.runner.DiscoverRunner.test_runner\" title=\"django.test.runner.DiscoverRunner.test_runner\"><code class=\"xref py py-attr docutils literal notranslate\">test_runner</code></a>, which facilitate\noverriding the way tests are collected and run.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">fetch_redirect_response</code> argument was added to\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertRedirects\" title=\"django.test.SimpleTestCase.assertRedirects\"><code class=\"xref py py-meth docutils literal notranslate\">assertRedirects()</code></a>. Since the test\nclient can’t fetch externals URLs, this allows you to use <code class=\"docutils literal notranslate\">assertRedirects</code>\nwith redirects that aren’t part of your Django app.</p></li>\n<li><p>Correct handling of scheme when making comparisons in\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertRedirects\" title=\"django.test.SimpleTestCase.assertRedirects\"><code class=\"xref py py-meth docutils literal notranslate\">assertRedirects()</code></a>.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">secure</code> argument was added to all the request methods of\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.Client\" title=\"django.test.Client\"><code class=\"xref py py-class docutils literal notranslate\">Client</code></a>. If <code class=\"docutils literal notranslate\">True</code>, the request will be made\nthrough HTTPS.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.TransactionTestCase.assertNumQueries\" title=\"django.test.TransactionTestCase.assertNumQueries\"><code class=\"xref py py-meth docutils literal notranslate\">assertNumQueries()</code></a> now prints\nout the list of executed queries if the assertion fails.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">WSGIRequest</code> instance generated by the test handler is now attached to\nthe <a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.Response.wsgi_request\" title=\"django.test.Response.wsgi_request\"><code class=\"xref py py-attr docutils literal notranslate\">django.test.Response.wsgi_request</code></a> attribute.</p></li>\n<li><p>The database settings for testing have been collected into a dictionary\nnamed <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-DATABASE-TEST\"><code class=\"xref std std-setting docutils literal notranslate\">TEST</code></a>.</p></li>\n</ul>\n</section>\n<section id=\"utilities\">\n<h4>Utilities<a class=\"heading-anchor\" href=\"#utilities\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p>Improved <a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.html.strip_tags\" title=\"django.utils.html.strip_tags\"><code class=\"xref py py-func docutils literal notranslate\">strip_tags()</code></a> accuracy (but it still cannot\nguarantee an HTML-safe result, as stated in the documentation).</p></li>\n</ul>\n</section>\n<section id=\"validators\">\n<h4>Validators<a class=\"heading-anchor\" href=\"#validators\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/validators/#django.core.validators.RegexValidator\" title=\"django.core.validators.RegexValidator\"><code class=\"xref py py-class docutils literal notranslate\">RegexValidator</code></a> now accepts the optional\n<a class=\"reference internal\" href=\"/en/dev/ref/validators/#django.core.validators.RegexValidator.flags\" title=\"django.core.validators.RegexValidator.flags\"><code class=\"xref py py-attr docutils literal notranslate\">flags</code></a> and\nBoolean <a class=\"reference internal\" href=\"/en/dev/ref/validators/#django.core.validators.RegexValidator.inverse_match\" title=\"django.core.validators.RegexValidator.inverse_match\"><code class=\"xref py py-attr docutils literal notranslate\">inverse_match</code></a>\narguments. The <a class=\"reference internal\" href=\"/en/dev/ref/validators/#django.core.validators.RegexValidator.inverse_match\" title=\"django.core.validators.RegexValidator.inverse_match\"><code class=\"xref py py-attr docutils literal notranslate\">inverse_match</code></a>\nattribute determines if the <a class=\"reference internal\" href=\"/en/dev/ref/exceptions/#django.core.exceptions.ValidationError\" title=\"django.core.exceptions.ValidationError\"><code class=\"xref py py-exc docutils literal notranslate\">ValidationError</code></a>\nshould be raised when the regular expression pattern matches (<code class=\"docutils literal notranslate\">True</code>) or\ndoes not match (<code class=\"docutils literal notranslate\">False</code>, by default) the provided <code class=\"docutils literal notranslate\">value</code>. The\n<a class=\"reference internal\" href=\"/en/dev/ref/validators/#django.core.validators.RegexValidator.flags\" title=\"django.core.validators.RegexValidator.flags\"><code class=\"xref py py-attr docutils literal notranslate\">flags</code></a> attribute sets the flags\nused when compiling a regular expression string.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/validators/#django.core.validators.URLValidator\" title=\"django.core.validators.URLValidator\"><code class=\"xref py py-class docutils literal notranslate\">URLValidator</code></a> now accepts an optional\n<code class=\"docutils literal notranslate\">schemes</code> argument which allows customization of the accepted URI schemes\n(instead of the defaults <code class=\"docutils literal notranslate\">http(s)</code> and <code class=\"docutils literal notranslate\">ftp(s)</code>).</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/validators/#django.core.validators.validate_email\" title=\"django.core.validators.validate_email\"><code class=\"xref py py-func docutils literal notranslate\">validate_email()</code></a> now accepts addresses with\nIPv6 literals, like <code class=\"docutils literal notranslate\">example&#64;[2001:db8::1]</code>, as specified in RFC 5321.</p></li>\n</ul>\n</section>\n</section>\n</section>\n<section id=\"backwards-incompatible-changes-in-1-7\">\n<span id=\"backwards-incompatible-1-7\"></span><h2>Backwards incompatible changes in 1.7<a class=\"heading-anchor\" href=\"#backwards-incompatible-changes-in-1-7\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Warning</p>\n<p>In addition to the changes outlined in this section, be sure to review the\n<a class=\"reference internal\" href=\"/en/dev/internals/deprecation/#deprecation-removed-in-1-7\"><span class=\"std std-ref\">deprecation plan</span></a> for any features that\nhave been removed. If you haven’t updated your code within the\ndeprecation timeline for a given feature, its removal may appear as a\nbackwards incompatible change.</p>\n</aside>\n<section id=\"allow-syncdb-allow-migrate\">\n<h3><code class=\"docutils literal notranslate\">allow_syncdb</code> / <code class=\"docutils literal notranslate\">allow_migrate</code><a class=\"heading-anchor\" href=\"#allow-syncdb-allow-migrate\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>While Django will still look at <code class=\"docutils literal notranslate\">allow_syncdb</code> methods even though they\nshould be renamed to <code class=\"docutils literal notranslate\">allow_migrate</code>, there is a subtle difference in which\nmodels get passed to these methods.</p>\n<p>For apps with migrations, <code class=\"docutils literal notranslate\">allow_migrate</code> will now get passed\n<a class=\"reference internal\" href=\"/en/dev/topics/migrations/#historical-models\"><span class=\"std std-ref\">historical models</span></a>, which are special versioned\nmodels without custom attributes, methods or managers. Make sure your\n<code class=\"docutils literal notranslate\">allow_migrate</code> methods are only referring to fields or other items in\n<code class=\"docutils literal notranslate\">model._meta</code>.</p>\n</section>\n<section id=\"initial-data\">\n<h3>initial_data<a class=\"heading-anchor\" href=\"#initial-data\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Apps with migrations will not load <code class=\"docutils literal notranslate\">initial_data</code> fixtures when they have\nfinished migrating. Apps without migrations will continue to load these\nfixtures during the phase of <code class=\"docutils literal notranslate\">migrate</code> which emulates the old <code class=\"docutils literal notranslate\">syncdb</code>\nbehavior, but any new apps will not have this support.</p>\n<p>Instead, you are encouraged to load initial data in migrations if you need it\n(using the <code class=\"docutils literal notranslate\">RunPython</code> operation and your model classes);\nthis has the added advantage that your initial data will not need updating\nevery time you change the schema.</p>\n<p>Additionally, like the rest of Django’s old <code class=\"docutils literal notranslate\">syncdb</code> code, <code class=\"docutils literal notranslate\">initial_data</code>\nhas been started down the deprecation path and will be removed in Django 1.9.</p>\n</section>\n<section id=\"deconstruct-and-serializability\">\n<h3><code class=\"docutils literal notranslate\">deconstruct()</code> and serializability<a class=\"heading-anchor\" href=\"#deconstruct-and-serializability\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django now requires all Field classes and all of their constructor arguments\nto be serializable. If you modify the constructor signature in your custom\nField in any way, you’ll need to implement a <code class=\"docutils literal notranslate\">deconstruct()</code> method;\nwe’ve expanded the custom field documentation with <a class=\"reference internal\" href=\"/en/dev/howto/custom-model-fields/#custom-field-deconstruct-method\"><span class=\"std std-ref\">instructions\non implementing this method</span></a>.</p>\n<p>The requirement for all field arguments to be\n<a class=\"reference internal\" href=\"/en/dev/topics/migrations/#migration-serializing\"><span class=\"std std-ref\">serializable</span></a> means that any custom class\ninstances being passed into Field constructors - things like custom Storage\nsubclasses, for instance - need to have a <a class=\"reference internal\" href=\"/en/dev/topics/migrations/#custom-deconstruct-method\"><span class=\"std std-ref\">deconstruct method defined on\nthem as well</span></a>, though Django provides a handy\nclass decorator that will work for most applications.</p>\n</section>\n<section id=\"app-loading-changes\">\n<h3>App-loading changes<a class=\"heading-anchor\" href=\"#app-loading-changes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"start-up-sequence\">\n<h4>Start-up sequence<a class=\"heading-anchor\" href=\"#start-up-sequence\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Django 1.7 loads application configurations and models as soon as it starts.\nWhile this behavior is more straightforward and is believed to be more robust,\nregressions cannot be ruled out. See <a class=\"reference internal\" href=\"/en/dev/ref/applications/#applications-troubleshooting\"><span class=\"std std-ref\">Troubleshooting</span></a> for\nsolutions to some problems you may encounter.</p>\n</section>\n<section id=\"standalone-scripts\">\n<h4>Standalone scripts<a class=\"heading-anchor\" href=\"#standalone-scripts\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>If you’re using Django in a plain Python script — rather than a management\ncommand — and you rely on the <span class=\"target\" id=\"index-0\"></span><a class=\"reference internal\" href=\"/en/dev/topics/settings/#envvar-DJANGO_SETTINGS_MODULE\"><code class=\"xref std std-envvar docutils literal notranslate\">DJANGO_SETTINGS_MODULE</code></a> environment\nvariable, you must now explicitly initialize Django at the beginning of your\nscript with:</p>\n<div class=\"code-block\" data-language=\"pycon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python console</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python console code\"><code><span class=\"gp\">&gt;&gt;&gt; </span><span class=\"kn\">import</span> <span class=\"nn\">django</span>\n<span class=\"gp\">&gt;&gt;&gt; </span>django<span class=\"o\">.</span>setup<span class=\"p\">()</span>\n</code></pre></div>\n<p>Otherwise, you will hit an <code class=\"docutils literal notranslate\">AppRegistryNotReady</code> exception.</p>\n</section>\n<section id=\"wsgi-scripts\">\n<h4>WSGI scripts<a class=\"heading-anchor\" href=\"#wsgi-scripts\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Until Django 1.3, the recommended way to create a WSGI application was:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">import</span> <span class=\"nn\">django.core.handlers.wsgi</span>\n\napplication <span class=\"o\">=</span> django<span class=\"o\">.</span>core<span class=\"o\">.</span>handlers<span class=\"o\">.</span>wsgi<span class=\"o\">.</span>WSGIHandler<span class=\"p\">()</span>\n</code></pre></div>\n<p>In Django 1.4, support for WSGI was improved and the API changed to:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.core.wsgi</span> <span class=\"kn\">import</span> get_wsgi_application\n\napplication <span class=\"o\">=</span> get_wsgi_application<span class=\"p\">()</span>\n</code></pre></div>\n<p>If you’re still using the former style in your WSGI script, you need to\nupgrade to the latter, or you will hit an <code class=\"docutils literal notranslate\">AppRegistryNotReady</code> exception.</p>\n</section>\n<section id=\"app-registry-consistency\">\n<h4>App registry consistency<a class=\"heading-anchor\" href=\"#app-registry-consistency\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>It is no longer possible to have multiple installed applications with the same\nlabel. In previous versions of Django, this didn’t always work correctly, but\ndidn’t crash outright either.</p>\n<p>If you have two apps with the same label, you should create an\n<a class=\"reference internal\" href=\"/en/dev/ref/applications/#django.apps.AppConfig\" title=\"django.apps.AppConfig\"><code class=\"xref py py-class docutils literal notranslate\">AppConfig</code></a> for one of them and override its\n<a class=\"reference internal\" href=\"/en/dev/ref/applications/#django.apps.AppConfig.label\" title=\"django.apps.AppConfig.label\"><code class=\"xref py py-class docutils literal notranslate\">label</code></a> there. You should then adjust your code\nwherever it references this application or its models with the old label.</p>\n<p>It isn’t possible to import the same model twice through different paths any\nmore. As of Django 1.6, this may happen only if you’re manually putting a\ndirectory and a subdirectory on <span class=\"target\" id=\"index-1\"></span><a class=\"reference external\" href=\"https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH\" title=\"(in Python v3.14)\"><code class=\"xref std std-envvar docutils literal notranslate\">PYTHONPATH</code></a>. Refer to the section on\nthe new project layout in the <a class=\"reference internal\" href=\"/en/dev/releases/1.4/\"><span class=\"doc\">1.4 release notes</span></a> for\nmigration instructions.</p>\n<p>You should make sure that:</p>\n<ul class=\"simple\">\n<li><p>All models are defined in applications that are listed in\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> or have an explicit\n<a class=\"reference internal\" href=\"/en/dev/ref/models/options/#django.db.models.Options.app_label\" title=\"django.db.models.Options.app_label\"><code class=\"xref py py-attr docutils literal notranslate\">app_label</code></a>.</p></li>\n<li><p>Models aren’t imported as a side-effect of loading their application.\nSpecifically, you shouldn’t import models in the root module of an\napplication nor in the module that define its configuration class.</p></li>\n</ul>\n<p>Django will enforce these requirements as of version 1.9, after a deprecation\nperiod.</p>\n</section>\n<section id=\"subclassing-appcommand\">\n<h4>Subclassing AppCommand<a class=\"heading-anchor\" href=\"#subclassing-appcommand\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Subclasses of <a class=\"reference internal\" href=\"/en/dev/howto/custom-management-commands/#django.core.management.AppCommand\" title=\"django.core.management.AppCommand\"><code class=\"xref py py-class docutils literal notranslate\">AppCommand</code></a> must now implement a\n<a class=\"reference internal\" href=\"/en/dev/howto/custom-management-commands/#django.core.management.AppCommand.handle_app_config\" title=\"django.core.management.AppCommand.handle_app_config\"><code class=\"xref py py-meth docutils literal notranslate\">handle_app_config()</code></a> method instead of\n<code class=\"docutils literal notranslate\">handle_app()</code>. This method receives an <a class=\"reference internal\" href=\"/en/dev/ref/applications/#django.apps.AppConfig\" title=\"django.apps.AppConfig\"><code class=\"xref py py-class docutils literal notranslate\">AppConfig</code></a>\ninstance instead of a models module.</p>\n</section>\n<section id=\"introspecting-applications\">\n<h4>Introspecting applications<a class=\"heading-anchor\" href=\"#introspecting-applications\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Since <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> now supports application configuration classes\nin addition to application modules, you should review code that accesses this\nsetting directly and use the app registry (<a class=\"reference internal\" href=\"/en/dev/ref/applications/#django.apps.apps\" title=\"django.apps.apps\"><code class=\"xref py py-attr docutils literal notranslate\">django.apps.apps</code></a>) instead.</p>\n<p>The app registry has preserved some features of the old app cache. Even though\nthe app cache was a private API, obsolete methods and arguments will be\nremoved through a standard deprecation path, with the exception of the\nfollowing changes that take effect immediately:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">get_model</code> raises <a class=\"reference external\" href=\"https://docs.python.org/3/library/exceptions.html#LookupError\" title=\"(in Python v3.14)\"><code class=\"xref py py-exc docutils literal notranslate\">LookupError</code></a> instead of returning <code class=\"docutils literal notranslate\">None</code> when no\nmodel is found.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">only_installed</code> argument of <code class=\"docutils literal notranslate\">get_model</code> and <code class=\"docutils literal notranslate\">get_models</code> no\nlonger exists, nor does the <code class=\"docutils literal notranslate\">seed_cache</code> argument of <code class=\"docutils literal notranslate\">get_model</code>.</p></li>\n</ul>\n</section>\n</section>\n<section id=\"management-commands-and-order-of-installed-apps\">\n<h3>Management commands and order of <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a><a class=\"heading-anchor\" href=\"#management-commands-and-order-of-installed-apps\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>When several applications provide management commands with the same name,\nDjango loads the command from the application that comes first in\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a>. Previous versions loaded the command from the\napplication that came last.</p>\n<p>This brings discovery of management commands in line with other parts of\nDjango that rely on the order of <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a>, such as static\nfiles, templates, and translations.</p>\n</section>\n<section id=\"validationerror-constructor-and-internal-storage\">\n<span id=\"validation-error-constructor-and-internal-storage\"></span><h3><code class=\"docutils literal notranslate\">ValidationError</code> constructor and internal storage<a class=\"heading-anchor\" href=\"#validationerror-constructor-and-internal-storage\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The behavior of the <code class=\"docutils literal notranslate\">ValidationError</code> constructor has changed when it\nreceives a container of errors as an argument (e.g. a <code class=\"docutils literal notranslate\">list</code> or an\n<code class=\"docutils literal notranslate\">ErrorList</code>):</p>\n<ul class=\"simple\">\n<li><p>It converts any strings it finds to instances of <code class=\"docutils literal notranslate\">ValidationError</code>\nbefore adding them to its internal storage.</p></li>\n<li><p>It doesn’t store the given container but rather copies its content to its\nown internal storage; previously the container itself was added to the\n<code class=\"docutils literal notranslate\">ValidationError</code> instance and used as internal storage.</p></li>\n</ul>\n<p>This means that if you access the <code class=\"docutils literal notranslate\">ValidationError</code> internal storages, such\nas <code class=\"docutils literal notranslate\">error_list</code>; <code class=\"docutils literal notranslate\">error_dict</code>; or the return value of\n<code class=\"docutils literal notranslate\">update_error_dict()</code> you may find instances of <code class=\"docutils literal notranslate\">ValidationError</code> where you\nwould have previously found strings.</p>\n<p>Also if you directly assigned the return value of <code class=\"docutils literal notranslate\">update_error_dict()</code>\nto <code class=\"docutils literal notranslate\">Form._errors</code> you may inadvertently add <code class=\"docutils literal notranslate\">list</code> instances where\n<code class=\"docutils literal notranslate\">ErrorList</code> instances are expected. This is a problem because unlike a\nsimple <code class=\"docutils literal notranslate\">list</code>, an <code class=\"docutils literal notranslate\">ErrorList</code> knows how to handle instances of\n<code class=\"docutils literal notranslate\">ValidationError</code>.</p>\n<p>Most use-cases that warranted using these private APIs are now covered by\nthe newly introduced <a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.add_error\" title=\"django.forms.Form.add_error\"><code class=\"xref py py-meth docutils literal notranslate\">Form.add_error()</code></a>\nmethod:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"c1\"># Old pattern:</span>\n<span class=\"k\">try</span><span class=\"p\">:</span>\n    <span class=\"o\">...</span>\n<span class=\"k\">except</span> ValidationError <span class=\"k\">as</span> e<span class=\"p\">:</span>\n    <span class=\"bp\">self</span><span class=\"o\">.</span>_errors <span class=\"o\">=</span> e<span class=\"o\">.</span>update_error_dict<span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"o\">.</span>_errors<span class=\"p\">)</span>\n\n<span class=\"c1\"># New pattern:</span>\n<span class=\"k\">try</span><span class=\"p\">:</span>\n    <span class=\"o\">...</span>\n<span class=\"k\">except</span> ValidationError <span class=\"k\">as</span> e<span class=\"p\">:</span>\n    <span class=\"bp\">self</span><span class=\"o\">.</span>add_error<span class=\"p\">(</span><span class=\"kc\">None</span><span class=\"p\">,</span> e<span class=\"p\">)</span>\n</code></pre></div>\n<p>If you need both Django &lt;= 1.6 and 1.7 compatibility you can’t use\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.add_error\" title=\"django.forms.Form.add_error\"><code class=\"xref py py-meth docutils literal notranslate\">Form.add_error()</code></a> since it\nwasn’t available before Django 1.7, but you can use the following\nworkaround to convert any <code class=\"docutils literal notranslate\">list</code> into <code class=\"docutils literal notranslate\">ErrorList</code>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">try</span><span class=\"p\">:</span>\n    <span class=\"o\">...</span>\n<span class=\"k\">except</span> ValidationError <span class=\"k\">as</span> e<span class=\"p\">:</span>\n    <span class=\"bp\">self</span><span class=\"o\">.</span>_errors <span class=\"o\">=</span> e<span class=\"o\">.</span>update_error_dict<span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"o\">.</span>_errors<span class=\"p\">)</span>\n\n<span class=\"c1\"># Additional code to ensure ``ErrorDict`` is exclusively</span>\n<span class=\"c1\"># composed of ``ErrorList`` instances.</span>\n<span class=\"k\">for</span> field<span class=\"p\">,</span> error_list <span class=\"ow\">in</span> <span class=\"bp\">self</span><span class=\"o\">.</span>_errors<span class=\"o\">.</span>items<span class=\"p\">():</span>\n    <span class=\"k\">if</span> <span class=\"ow\">not</span> <span class=\"nb\">isinstance</span><span class=\"p\">(</span>error_list<span class=\"p\">,</span> <span class=\"bp\">self</span><span class=\"o\">.</span>error_class<span class=\"p\">):</span>\n        <span class=\"bp\">self</span><span class=\"o\">.</span>_errors<span class=\"p\">[</span>field<span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"bp\">self</span><span class=\"o\">.</span>error_class<span class=\"p\">(</span>error_list<span class=\"p\">)</span>\n</code></pre></div>\n</section>\n<section id=\"behavior-of-locmemcache-regarding-pickle-errors\">\n<h3>Behavior of <code class=\"docutils literal notranslate\">LocMemCache</code> regarding pickle errors<a class=\"heading-anchor\" href=\"#behavior-of-locmemcache-regarding-pickle-errors\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>An inconsistency existed in previous versions of Django regarding how pickle\nerrors are handled by different cache backends.\n<code class=\"docutils literal notranslate\">django.core.cache.backends.locmem.LocMemCache</code> used to fail silently when\nsuch an error occurs, which is inconsistent with other backends and leads to\ncache-specific errors. This has been fixed in Django 1.7, see\n<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/21200\">#21200</a> for more details.</p>\n</section>\n<section id=\"cache-keys-are-now-generated-from-the-request-s-absolute-url\">\n<h3>Cache keys are now generated from the request’s absolute URL<a class=\"heading-anchor\" href=\"#cache-keys-are-now-generated-from-the-request-s-absolute-url\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Previous versions of Django generated cache keys using a request’s path and\nquery string but not the scheme or host. If a Django application was serving\nmultiple subdomains or domains, cache keys could collide. In Django 1.7, cache\nkeys vary by the absolute URL of the request including scheme, host, path, and\nquery string. For example, the URL portion of a cache key is now generated from\n<code class=\"docutils literal notranslate\">https://www.example.com/path/to/?key=val</code> rather than <code class=\"docutils literal notranslate\">/path/to/?key=val</code>.\nThe cache keys generated by Django 1.7 will be different from the keys\ngenerated by older versions of Django. After upgrading to Django 1.7, the first\nrequest to any previously cached URL will be a cache miss.</p>\n</section>\n<section id=\"passing-none-to-manager-db-manager\">\n<h3>Passing <code class=\"docutils literal notranslate\">None</code> to <code class=\"docutils literal notranslate\">Manager.db_manager()</code><a class=\"heading-anchor\" href=\"#passing-none-to-manager-db-manager\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>In previous versions of Django, it was possible to use\n<code class=\"docutils literal notranslate\">db_manager(using=None)</code> on a model manager instance to obtain a manager\ninstance using default routing behavior, overriding any manually specified\ndatabase routing. In Django 1.7, a value of <code class=\"docutils literal notranslate\">None</code> passed to db_manager will\nproduce a router that <em>retains</em> any manually assigned database routing – the\nmanager will <em>not</em> be reset. This was necessary to resolve an inconsistency in\nthe way routing information cascaded over joins. See <a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/13724\">#13724</a> for more\ndetails.</p>\n</section>\n<section id=\"pytz-may-be-required\">\n<h3><code class=\"docutils literal notranslate\">pytz</code> may be required<a class=\"heading-anchor\" href=\"#pytz-may-be-required\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>If your project handles datetimes before 1970 or after 2037 and Django raises\na <a class=\"reference external\" href=\"https://docs.python.org/3/library/exceptions.html#ValueError\" title=\"(in Python v3.14)\"><code class=\"xref py py-exc docutils literal notranslate\">ValueError</code></a> when encountering them, you will have to install\n<a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/pytz/\">pytz</a>. You may be affected by this problem if you use Django’s time\nzone-related date formats or <a class=\"reference internal\" href=\"/en/dev/ref/contrib/syndication/#module-django.contrib.syndication\" title=\"django.contrib.syndication: A framework for generating syndication feeds, in RSS and Atom, quite easily.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.syndication</code></a>.</p>\n</section>\n<section id=\"remove-and-clear-methods-of-related-managers\">\n<h3><code class=\"docutils literal notranslate\">remove()</code> and <code class=\"docutils literal notranslate\">clear()</code> methods of related managers<a class=\"heading-anchor\" href=\"#remove-and-clear-methods-of-related-managers\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">remove()</code> and <code class=\"docutils literal notranslate\">clear()</code> methods of the related managers created by\n<code class=\"docutils literal notranslate\">ForeignKey</code>, <code class=\"docutils literal notranslate\">GenericForeignKey</code>, and <code class=\"docutils literal notranslate\">ManyToManyField</code> suffered from a\nnumber of issues. Some operations ran multiple data modifying queries without\nwrapping them in a transaction, and some operations didn’t respect default\nfiltering when it was present (i.e. when the default manager on the related\nmodel implemented a custom <code class=\"docutils literal notranslate\">get_queryset()</code>).</p>\n<p>Fixing the issues introduced some backward incompatible changes:</p>\n<ul class=\"simple\">\n<li><p>The default implementation of <code class=\"docutils literal notranslate\">remove()</code> for <code class=\"docutils literal notranslate\">ForeignKey</code> related\nmanagers changed from a series of <code class=\"docutils literal notranslate\">Model.save()</code> calls to a single\n<code class=\"docutils literal notranslate\">QuerySet.update()</code> call. The change means that <code class=\"docutils literal notranslate\">pre_save</code> and\n<code class=\"docutils literal notranslate\">post_save</code> signals aren’t sent anymore. You can use the <code class=\"docutils literal notranslate\">bulk=False</code>\nkeyword argument to revert to the previous behavior.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">remove()</code> and <code class=\"docutils literal notranslate\">clear()</code> methods for <code class=\"docutils literal notranslate\">GenericForeignKey</code> related\nmanagers now perform bulk delete. The <code class=\"docutils literal notranslate\">Model.delete()</code> method isn’t called\non each instance anymore. You can use the <code class=\"docutils literal notranslate\">bulk=False</code> keyword argument to\nrevert to the previous behavior.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">remove()</code> and <code class=\"docutils literal notranslate\">clear()</code> methods for <code class=\"docutils literal notranslate\">ManyToManyField</code> related\nmanagers perform nested queries when filtering is involved, which may or\nmay not be an issue depending on your database and your data itself.\nSee <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#nested-queries-performance\"><span class=\"std std-ref\">this note</span></a> for more details.</p></li>\n</ul>\n</section>\n<section id=\"admin-login-redirection-strategy\">\n<h3>Admin login redirection strategy<a class=\"heading-anchor\" href=\"#admin-login-redirection-strategy\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Historically, the Django admin site passed the request from an unauthorized or\nunauthenticated user directly to the login view, without HTTP redirection. In\nDjango 1.7, this behavior changed to conform to a more traditional workflow\nwhere any unauthorized request to an admin page will be redirected (by HTTP\nstatus code 302) to the login page, with the <code class=\"docutils literal notranslate\">next</code> parameter set to the\nreferring path. The user will be redirected there after a successful login.</p>\n<p>Note also that the admin login form has been updated to not contain the\n<code class=\"docutils literal notranslate\">this_is_the_login_form</code> field (now unused) and the <code class=\"docutils literal notranslate\">ValidationError</code> code\nhas been set to the more regular <code class=\"docutils literal notranslate\">invalid_login</code> key.</p>\n</section>\n<section id=\"select-for-update-requires-a-transaction\">\n<h3><code class=\"docutils literal notranslate\">select_for_update()</code> requires a transaction<a class=\"heading-anchor\" href=\"#select-for-update-requires-a-transaction\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Historically, queries that use\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.select_for_update\" title=\"django.db.models.query.QuerySet.select_for_update\"><code class=\"xref py py-meth docutils literal notranslate\">select_for_update()</code></a> could be\nexecuted in autocommit mode, outside of a transaction. Before Django\n1.6, Django’s automatic transactions mode allowed this to be used to\nlock records until the next write operation. Django 1.6 introduced\ndatabase-level autocommit; since then, execution in such a context\nvoids the effect of <code class=\"docutils literal notranslate\">select_for_update()</code>. It is, therefore, assumed\nnow to be an error and raises an exception.</p>\n<p>This change was made because such errors can be caused by including an\napp which expects global transactions (e.g. <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-DATABASE-ATOMIC_REQUESTS\"><code class=\"xref std std-setting docutils literal notranslate\">ATOMIC_REQUESTS</code></a> set to <code class=\"docutils literal notranslate\">True</code>), or Django’s old autocommit\nbehavior, in a project which runs without them; and further, such\nerrors may manifest as data-corruption bugs. It was also made in\nDjango 1.6.3.</p>\n<p>This change may cause test failures if you use <code class=\"docutils literal notranslate\">select_for_update()</code>\nin a test class which is a subclass of\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.TransactionTestCase\" title=\"django.test.TransactionTestCase\"><code class=\"xref py py-class docutils literal notranslate\">TransactionTestCase</code></a> rather than\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.TestCase\" title=\"django.test.TestCase\"><code class=\"xref py py-class docutils literal notranslate\">TestCase</code></a>.</p>\n</section>\n<section id=\"contrib-middleware-removed-from-default-middleware-classes\">\n<h3>Contrib middleware removed from default <code class=\"docutils literal notranslate\">MIDDLEWARE_CLASSES</code><a class=\"heading-anchor\" href=\"#contrib-middleware-removed-from-default-middleware-classes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <a class=\"reference internal\" href=\"#app-loading-refactor-17-release-note\"><span class=\"std std-ref\">app-loading refactor</span></a>\ndeprecated using models from apps which are not part of the\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> setting. This exposed an incompatibility between\nthe default <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> and <code class=\"docutils literal notranslate\">MIDDLEWARE_CLASSES</code> in the\nglobal defaults (<code class=\"docutils literal notranslate\">django.conf.global_settings</code>). To bring these settings in\nsync and prevent deprecation warnings when doing things like testing reusable\napps with minimal settings,\n<a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.contrib.sessions.middleware.SessionMiddleware\" title=\"django.contrib.sessions.middleware.SessionMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">SessionMiddleware</code></a>,\n<a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.contrib.auth.middleware.AuthenticationMiddleware\" title=\"django.contrib.auth.middleware.AuthenticationMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">AuthenticationMiddleware</code></a>, and\n<a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.contrib.messages.middleware.MessageMiddleware\" title=\"django.contrib.messages.middleware.MessageMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">MessageMiddleware</code></a> were removed\nfrom the defaults. These classes will still be included in the default settings\ngenerated by <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-startproject\"><code class=\"xref std std-djadmin docutils literal notranslate\">startproject</code></a>. Most projects will not be affected by\nthis change but if you were not previously declaring the\n<code class=\"docutils literal notranslate\">MIDDLEWARE_CLASSES</code> in your project settings and relying on the\nglobal default you should ensure that the new defaults are in line with your\nproject’s needs. You should also check for any code that accesses\n<code class=\"docutils literal notranslate\">django.conf.global_settings.MIDDLEWARE_CLASSES</code> directly.</p>\n</section>\n<section id=\"miscellaneous\">\n<h3>Miscellaneous<a class=\"heading-anchor\" href=\"#miscellaneous\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<ul>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/files/uploads/#django.core.files.uploadhandler.FileUploadHandler.new_file\" title=\"django.core.files.uploadhandler.FileUploadHandler.new_file\"><code class=\"xref py py-meth docutils literal notranslate\">django.core.files.uploadhandler.FileUploadHandler.new_file()</code></a>\nmethod is now passed an additional <code class=\"docutils literal notranslate\">content_type_extra</code> parameter. If you\nhave a custom <a class=\"reference internal\" href=\"/en/dev/ref/files/uploads/#django.core.files.uploadhandler.FileUploadHandler\" title=\"django.core.files.uploadhandler.FileUploadHandler\"><code class=\"xref py py-class docutils literal notranslate\">FileUploadHandler</code></a>\nthat implements <code class=\"docutils literal notranslate\">new_file()</code>, be sure it accepts this new parameter.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/forms/modelforms/#django.forms.models.BaseModelFormSet\" title=\"django.forms.models.BaseModelFormSet\"><code class=\"xref py py-class docutils literal notranslate\">ModelFormSet</code></a>s no longer\ndelete instances when <code class=\"docutils literal notranslate\">save(commit=False)</code> is called. See\n<a class=\"reference internal\" href=\"/en/dev/topics/forms/formsets/#django.forms.formsets.BaseFormSet.can_delete\" title=\"django.forms.formsets.BaseFormSet.can_delete\"><code class=\"xref py py-attr docutils literal notranslate\">can_delete</code></a> for instructions on how\nto manually delete objects from deleted forms.</p></li>\n<li><p>Loading empty fixtures emits a <code class=\"docutils literal notranslate\">RuntimeWarning</code> rather than raising\n<a class=\"reference internal\" href=\"/en/dev/howto/custom-management-commands/#django.core.management.CommandError\" title=\"django.core.management.CommandError\"><code class=\"xref py py-exc docutils literal notranslate\">CommandError</code></a>.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#django.contrib.staticfiles.views.serve\" title=\"django.contrib.staticfiles.views.serve\"><code class=\"xref py py-func docutils literal notranslate\">django.contrib.staticfiles.views.serve()</code></a> will now raise an\n<a class=\"reference internal\" href=\"/en/dev/topics/http/views/#django.http.Http404\" title=\"django.http.Http404\"><code class=\"xref py py-exc docutils literal notranslate\">Http404</code></a> exception instead of\n<a class=\"reference internal\" href=\"/en/dev/ref/exceptions/#django.core.exceptions.ImproperlyConfigured\" title=\"django.core.exceptions.ImproperlyConfigured\"><code class=\"xref py py-exc docutils literal notranslate\">ImproperlyConfigured</code></a> when <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a>\nis <code class=\"docutils literal notranslate\">False</code>. This change removes the need to conditionally add the view to\nyour root URLconf, which in turn makes it safe to reverse by name. It also\nremoves the ability for visitors to generate spurious HTTP 500 errors by\nrequesting static files that don’t exist or haven’t been collected yet.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/models/instances/#django.db.models.Model.__eq__\" title=\"django.db.models.Model.__eq__\"><code class=\"xref py py-meth docutils literal notranslate\">django.db.models.Model.__eq__()</code></a> method is now defined in a\nway where instances of a proxy model and its base model are considered\nequal when primary keys match. Previously only instances of exact same\nclass were considered equal on primary key match.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/models/instances/#django.db.models.Model.__eq__\" title=\"django.db.models.Model.__eq__\"><code class=\"xref py py-meth docutils literal notranslate\">django.db.models.Model.__eq__()</code></a> method has changed such that\ntwo <code class=\"docutils literal notranslate\">Model</code> instances without primary key values won’t be considered\nequal (unless they are the same instance).</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/models/instances/#django.db.models.Model.__hash__\" title=\"django.db.models.Model.__hash__\"><code class=\"xref py py-meth docutils literal notranslate\">django.db.models.Model.__hash__()</code></a> method will now raise\n<code class=\"docutils literal notranslate\">TypeError</code> when called on an instance without a primary key value. This is\ndone to avoid mutable <code class=\"docutils literal notranslate\">__hash__</code> values in containers.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.AutoField\" title=\"django.db.models.AutoField\"><code class=\"xref py py-class docutils literal notranslate\">AutoField</code></a> columns in SQLite databases will now be\ncreated using the <code class=\"docutils literal notranslate\">AUTOINCREMENT</code> option, which guarantees monotonic\nincrements. This will cause primary key numbering behavior to change on\nSQLite, becoming consistent with most other SQL databases. This will only\napply to newly created tables. If you have a database created with an older\nversion of Django, you will need to migrate it to take advantage of this\nfeature. For example, you could do the following:</p>\n<ol class=\"arabic simple\">\n<li><p>Use <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-dumpdata\"><code class=\"xref std std-djadmin docutils literal notranslate\">dumpdata</code></a> to save your data.</p></li>\n<li><p>Rename the existing database file (keep it as a backup).</p></li>\n<li><p>Run <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-migrate\"><code class=\"xref std std-djadmin docutils literal notranslate\">migrate</code></a> to create the updated schema.</p></li>\n<li><p>Use <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-loaddata\"><code class=\"xref std std-djadmin docutils literal notranslate\">loaddata</code></a> to import the fixtures you exported in (1).</p></li>\n</ol>\n</li>\n<li><p><code class=\"docutils literal notranslate\">django.contrib.auth.models.AbstractUser</code> no longer defines a\n<a class=\"reference internal\" href=\"/en/dev/ref/models/instances/#django.db.models.Model.get_absolute_url\" title=\"django.db.models.Model.get_absolute_url\"><code class=\"xref py py-meth docutils literal notranslate\">get_absolute_url()</code></a> method. The old definition\nreturned  <code class=\"docutils literal notranslate\">&quot;/users/%s/&quot; % urlquote(self.username)</code> which was arbitrary\nsince applications may or may not define such a url in <code class=\"docutils literal notranslate\">urlpatterns</code>.\nDefine a <code class=\"docutils literal notranslate\">get_absolute_url()</code> method on your own custom user object or use\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-ABSOLUTE_URL_OVERRIDES\"><code class=\"xref std std-setting docutils literal notranslate\">ABSOLUTE_URL_OVERRIDES</code></a> if you want a URL for your user.</p></li>\n<li><p>The static asset-serving functionality of the\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.LiveServerTestCase\" title=\"django.test.LiveServerTestCase\"><code class=\"xref py py-class docutils literal notranslate\">django.test.LiveServerTestCase</code></a> class has been simplified: Now it’s\nonly able to serve content already present in <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-STATIC_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_ROOT</code></a> when\ntests are run. The ability to transparently serve all the static assets\n(similarly to what one gets with <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG = True</code></a> at\ndevelopment-time) has been moved to a new class that lives in the\n<code class=\"docutils literal notranslate\">staticfiles</code> application (the one actually in charge of such feature):\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#django.contrib.staticfiles.testing.StaticLiveServerTestCase\" title=\"django.contrib.staticfiles.testing.StaticLiveServerTestCase\"><code class=\"xref py py-class docutils literal notranslate\">django.contrib.staticfiles.testing.StaticLiveServerTestCase</code></a>. In\nother words, <code class=\"docutils literal notranslate\">LiveServerTestCase</code> itself is less powerful but at the same\ntime has less magic.</p>\n<p>Rationale behind this is removal of dependency of non-contrib code on\ncontrib applications.</p>\n</li>\n<li><p>The old cache URI syntax (e.g. <code class=\"docutils literal notranslate\">&quot;locmem://&quot;</code>) is no longer supported. It\nstill worked, even though it was not documented or officially supported. If\nyou’re still using it, please update to the current <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CACHES\"><code class=\"xref std std-setting docutils literal notranslate\">CACHES</code></a> syntax.</p></li>\n<li><p>The default ordering of <code class=\"docutils literal notranslate\">Form</code> fields in case of inheritance has changed to\nfollow normal Python MRO. Fields are now discovered by iterating through the\nMRO in reverse with the topmost class coming last. This only affects you if\nyou relied on the default field ordering while having fields defined on both\nthe current class <em>and</em> on a parent <code class=\"docutils literal notranslate\">Form</code>.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">required</code> argument of\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/widgets/#django.forms.SelectDateWidget\" title=\"django.forms.SelectDateWidget\"><code class=\"xref py py-class docutils literal notranslate\">SelectDateWidget</code></a> has been removed.\nThis widget now respects the form field’s <code class=\"docutils literal notranslate\">is_required</code> attribute like\nother widgets.</p></li>\n<li><p><code class=\"docutils literal notranslate\">Widget.is_hidden</code> is now a read-only property, getting its value by\nintrospecting the presence of <code class=\"docutils literal notranslate\">input_type == 'hidden'</code>.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.select_related\" title=\"django.db.models.query.QuerySet.select_related\"><code class=\"xref py py-meth docutils literal notranslate\">select_related()</code></a> now chains in the\nsame way as other similar calls like <code class=\"docutils literal notranslate\">prefetch_related</code>. That is,\n<code class=\"docutils literal notranslate\">select_related('foo', 'bar')</code> is equivalent to\n<code class=\"docutils literal notranslate\">select_related('foo').select_related('bar')</code>. Previously the latter would\nhave been equivalent to <code class=\"docutils literal notranslate\">select_related('bar')</code>.</p></li>\n<li><p>GeoDjango dropped support for GEOS &lt; 3.1.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">init_connection_state</code> method of database backends now executes in\nautocommit mode (unless you set <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-DATABASE-AUTOCOMMIT\"><code class=\"xref std std-setting docutils literal notranslate\">AUTOCOMMIT</code></a>\nto <code class=\"docutils literal notranslate\">False</code>). If you maintain a custom database backend, you should check\nthat method.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">django.db.backends.BaseDatabaseFeatures.allows_primary_key_0</code>\nattribute has been renamed to <code class=\"docutils literal notranslate\">allows_auto_pk_0</code> to better describe it.\nIt’s <code class=\"docutils literal notranslate\">True</code> for all database backends included with Django except MySQL\nwhich does allow primary keys with value 0. It only forbids <em>autoincrement</em>\nprimary keys with value 0.</p></li>\n<li><p>Shadowing model fields defined in a parent model has been forbidden as this\ncreates ambiguity in the expected model behavior. In addition, clashing\nfields in the model inheritance hierarchy result in a system check error.\nFor example, if you use multi-inheritance, you need to define custom primary\nkey fields on parent models, otherwise the default <code class=\"docutils literal notranslate\">id</code> fields will clash.\nSee <a class=\"reference internal\" href=\"/en/dev/topics/db/models/#model-multiple-inheritance-topic\"><span class=\"std std-ref\">Multiple inheritance</span></a> for details.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.utils.translation.parse_accept_lang_header()</code> now returns\nlowercase locales, instead of the case as it was provided. As locales should\nbe treated case-insensitive this allows us to speed up locale detection.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.utils.translation.get_language_from_path()</code> and\n<code class=\"docutils literal notranslate\">django.utils.translation.trans_real.get_supported_language_variant()</code>\nnow no longer have a <code class=\"docutils literal notranslate\">supported</code> argument.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">shortcut</code> view in <code class=\"docutils literal notranslate\">django.contrib.contenttypes.views</code> now supports\nprotocol-relative URLs (e.g. <code class=\"docutils literal notranslate\">//example.com</code>).</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/contenttypes/#django.contrib.contenttypes.fields.GenericRelation\" title=\"django.contrib.contenttypes.fields.GenericRelation\"><code class=\"xref py py-class docutils literal notranslate\">GenericRelation</code></a> now supports an\noptional <code class=\"docutils literal notranslate\">related_query_name</code> argument. Setting <code class=\"docutils literal notranslate\">related_query_name</code> adds\na relation from the related object back to the content type for filtering,\nordering and other query operations.</p></li>\n<li><p>When running tests on PostgreSQL, the <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-USER\"><code class=\"xref std std-setting docutils literal notranslate\">USER</code></a> will need read access\nto the built-in <code class=\"docutils literal notranslate\">postgres</code> database. This is in lieu of the previous\nbehavior of connecting to the actual non-test database.</p></li>\n<li><p>As part of the <a class=\"reference internal\" href=\"/en/dev/ref/checks/\"><span class=\"doc\">System check framework</span></a>, <a class=\"reference internal\" href=\"/en/dev/topics/checks/#field-checking\"><span class=\"std std-ref\">fields,\nmodels, and model managers</span></a> all implement a <code class=\"docutils literal notranslate\">check()</code>\nmethod that is registered with the check framework. If you have an existing\nmethod called <code class=\"docutils literal notranslate\">check()</code> on one of these objects, you will need to rename\nit.</p></li>\n<li><p>As noted above in the “Cache” section of “Minor Features”, defining the\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CACHES-TIMEOUT\"><code class=\"xref std std-setting docutils literal notranslate\">TIMEOUT</code></a> argument of the\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CACHES\"><code class=\"xref std std-setting docutils literal notranslate\">CACHES</code></a> setting as <code class=\"docutils literal notranslate\">None</code> will set the cache keys as\n“non-expiring”. Previously, with the memcache backend, a\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CACHES-TIMEOUT\"><code class=\"xref std std-setting docutils literal notranslate\">TIMEOUT</code></a> of <code class=\"docutils literal notranslate\">0</code> would set non-expiring keys,\nbut this was inconsistent with the set-and-expire (i.e. no caching) behavior\nof <code class=\"docutils literal notranslate\">set(&quot;key&quot;, &quot;value&quot;, timeout=0)</code>. If you want non-expiring keys,\nplease update your settings to use <code class=\"docutils literal notranslate\">None</code> instead of <code class=\"docutils literal notranslate\">0</code> as the latter\nnow designates set-and-expire in the settings as well.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">sql*</code> management commands now respect the <code class=\"docutils literal notranslate\">allow_migrate()</code> method\nof <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-DATABASE_ROUTERS\"><code class=\"xref std std-setting docutils literal notranslate\">DATABASE_ROUTERS</code></a>. If you have models synced to non-default\ndatabases, use the <code class=\"docutils literal notranslate\">--database</code> flag to get SQL for those models\n(previously they would always be included in the output).</p></li>\n<li><p>Decoding the query string from URLs now falls back to the ISO-8859-1 encoding\nwhen the input is not valid UTF-8.</p></li>\n<li><p>With the addition of the\n<code class=\"docutils literal notranslate\">django.contrib.auth.middleware.SessionAuthenticationMiddleware</code> to\nthe default project template (pre-1.7.2 only), a database must be created\nbefore accessing a page using <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\">runserver</code></a>.</p></li>\n<li><p>The addition of the <code class=\"docutils literal notranslate\">schemes</code> argument to <code class=\"docutils literal notranslate\">URLValidator</code> will appear\nas a backwards-incompatible change if you were previously using a custom\nregular expression to validate schemes. Any scheme not listed in <code class=\"docutils literal notranslate\">schemes</code>\nwill fail validation, even if the regular expression matches the given URL.</p></li>\n</ul>\n</section>\n</section>\n<section id=\"features-deprecated-in-1-7\">\n<span id=\"deprecated-features-1-7\"></span><h2>Features deprecated in 1.7<a class=\"heading-anchor\" href=\"#features-deprecated-in-1-7\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"django-core-cache-get-cache\">\n<h3><code class=\"docutils literal notranslate\">django.core.cache.get_cache</code><a class=\"heading-anchor\" href=\"#django-core-cache-get-cache\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">django.core.cache.get_cache</code> has been supplanted by\n<a class=\"reference internal\" href=\"/en/dev/topics/cache/#django.core.cache.caches\" title=\"django.core.cache.caches\"><code class=\"xref py py-data docutils literal notranslate\">django.core.cache.caches</code></a>.</p>\n</section>\n<section id=\"django-utils-dictconfig-django-utils-importlib\">\n<h3><code class=\"docutils literal notranslate\">django.utils.dictconfig</code>/<code class=\"docutils literal notranslate\">django.utils.importlib</code><a class=\"heading-anchor\" href=\"#django-utils-dictconfig-django-utils-importlib\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">django.utils.dictconfig</code> and <code class=\"docutils literal notranslate\">django.utils.importlib</code> were copies of\nrespectively <a class=\"reference external\" href=\"https://docs.python.org/3/library/logging.config.html#module-logging.config\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">logging.config</code></a> and <a class=\"reference external\" href=\"https://docs.python.org/3/library/importlib.html#module-importlib\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">importlib</code></a> provided for Python\nversions prior to 2.7. They have been deprecated.</p>\n</section>\n<section id=\"django-utils-module-loading-import-by-path\">\n<h3><code class=\"docutils literal notranslate\">django.utils.module_loading.import_by_path</code><a class=\"heading-anchor\" href=\"#django-utils-module-loading-import-by-path\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The current <code class=\"docutils literal notranslate\">django.utils.module_loading.import_by_path</code> function\ncatches <code class=\"docutils literal notranslate\">AttributeError</code>, <code class=\"docutils literal notranslate\">ImportError</code>, and <code class=\"docutils literal notranslate\">ValueError</code> exceptions,\nand re-raises <a class=\"reference internal\" href=\"/en/dev/ref/exceptions/#django.core.exceptions.ImproperlyConfigured\" title=\"django.core.exceptions.ImproperlyConfigured\"><code class=\"xref py py-exc docutils literal notranslate\">ImproperlyConfigured</code></a>. Such\nexception masking makes it needlessly hard to diagnose circular import\nproblems, because it makes it look like the problem comes from inside Django.\nIt has been deprecated in favor of\n<a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.module_loading.import_string\" title=\"django.utils.module_loading.import_string\"><code class=\"xref py py-meth docutils literal notranslate\">import_string()</code></a>.</p>\n</section>\n<section id=\"django-utils-tzinfo\">\n<h3><code class=\"docutils literal notranslate\">django.utils.tzinfo</code><a class=\"heading-anchor\" href=\"#django-utils-tzinfo\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">django.utils.tzinfo</code> provided two <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.tzinfo\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">tzinfo</code></a> subclasses,\n<code class=\"docutils literal notranslate\">LocalTimezone</code> and <code class=\"docutils literal notranslate\">FixedOffset</code>. They’ve been deprecated in favor of\nmore correct alternatives provided by <a class=\"reference internal\" href=\"/en/dev/ref/utils/#module-django.utils.timezone\" title=\"django.utils.timezone: Timezone support.\"><code class=\"xref py py-mod docutils literal notranslate\">django.utils.timezone</code></a>,\n<a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.timezone.get_default_timezone\" title=\"django.utils.timezone.get_default_timezone\"><code class=\"xref py py-func docutils literal notranslate\">django.utils.timezone.get_default_timezone()</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.timezone.get_fixed_timezone\" title=\"django.utils.timezone.get_fixed_timezone\"><code class=\"xref py py-func docutils literal notranslate\">django.utils.timezone.get_fixed_timezone()</code></a>.</p>\n</section>\n<section id=\"django-utils-unittest\">\n<h3><code class=\"docutils literal notranslate\">django.utils.unittest</code><a class=\"heading-anchor\" href=\"#django-utils-unittest\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">django.utils.unittest</code> provided uniform access to the <code class=\"docutils literal notranslate\">unittest2</code> library\non all Python versions. Since <code class=\"docutils literal notranslate\">unittest2</code> became the standard library’s\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/unittest.html#module-unittest\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">unittest</code></a> module in Python 2.7, and Django 1.7 drops support for older\nPython versions, this module isn’t useful anymore. It has been deprecated. Use\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/unittest.html#module-unittest\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">unittest</code></a> instead.</p>\n</section>\n<section id=\"django-utils-datastructures-sorteddict\">\n<h3><code class=\"docutils literal notranslate\">django.utils.datastructures.SortedDict</code><a class=\"heading-anchor\" href=\"#django-utils-datastructures-sorteddict\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>As <a class=\"reference external\" href=\"https://docs.python.org/3/library/collections.html#collections.OrderedDict\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">OrderedDict</code></a> was added to the standard library in\nPython 2.7, <code class=\"docutils literal notranslate\">SortedDict</code> is no longer needed and has been deprecated.</p>\n<p>The two additional, deprecated methods provided by <code class=\"docutils literal notranslate\">SortedDict</code> (<code class=\"docutils literal notranslate\">insert()</code>\nand <code class=\"docutils literal notranslate\">value_for_index()</code>) have been removed. If you relied on these methods to\nalter structures like form fields, you should now treat these <code class=\"docutils literal notranslate\">OrderedDict</code>s\nas immutable objects and override them to change their content.</p>\n<p>For example, you might want to override <code class=\"docutils literal notranslate\">MyFormClass.base_fields</code> (although\nthis attribute isn’t considered a public API) to change the ordering of fields\nfor all <code class=\"docutils literal notranslate\">MyFormClass</code> instances; or similarly, you could override\n<code class=\"docutils literal notranslate\">self.fields</code> from inside <code class=\"docutils literal notranslate\">MyFormClass.__init__()</code>, to change the fields\nfor a particular form instance. For example (from Django itself):</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>PasswordChangeForm<span class=\"o\">.</span>base_fields <span class=\"o\">=</span> OrderedDict<span class=\"p\">(</span>\n    <span class=\"p\">(</span>k<span class=\"p\">,</span> PasswordChangeForm<span class=\"o\">.</span>base_fields<span class=\"p\">[</span>k<span class=\"p\">])</span>\n    <span class=\"k\">for</span> k <span class=\"ow\">in</span> <span class=\"p\">[</span><span class=\"s2\">&quot;old_password&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;new_password1&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;new_password2&quot;</span><span class=\"p\">]</span>\n<span class=\"p\">)</span>\n</code></pre></div>\n</section>\n<section id=\"custom-sql-location-for-models-package\">\n<h3>Custom SQL location for models package<a class=\"heading-anchor\" href=\"#custom-sql-location-for-models-package\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Previously, if models were organized in a package (<code class=\"docutils literal notranslate\">myapp/models/</code>) rather\nthan simply <code class=\"docutils literal notranslate\">myapp/models.py</code>, Django would look for initial SQL data in\n<code class=\"docutils literal notranslate\">myapp/models/sql/</code>. This bug has been fixed so that Django will search\n<code class=\"docutils literal notranslate\">myapp/sql/</code> as documented. After this issue was fixed, migrations were added\nwhich deprecates initial SQL data. Thus, while this change still exists, the\ndeprecation is irrelevant as the entire feature will be removed in Django 1.9.</p>\n</section>\n<section id=\"reorganization-of-django-contrib-sites\">\n<h3>Reorganization of <code class=\"docutils literal notranslate\">django.contrib.sites</code><a class=\"heading-anchor\" href=\"#reorganization-of-django-contrib-sites\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">django.contrib.sites</code> provides reduced functionality when it isn’t in\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a>. The app-loading refactor adds some constraints in\nthat situation. As a consequence, two objects were moved, and the old\nlocations are deprecated:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/sites/#django.contrib.sites.requests.RequestSite\" title=\"django.contrib.sites.requests.RequestSite\"><code class=\"xref py py-class docutils literal notranslate\">RequestSite</code></a> now lives in\n<code class=\"docutils literal notranslate\">django.contrib.sites.requests</code>.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/sites/#django.contrib.sites.shortcuts.get_current_site\" title=\"django.contrib.sites.shortcuts.get_current_site\"><code class=\"xref py py-func docutils literal notranslate\">get_current_site()</code></a> now lives in\n<code class=\"docutils literal notranslate\">django.contrib.sites.shortcuts</code>.</p></li>\n</ul>\n</section>\n<section id=\"declared-fieldsets-attribute-on-modeladmin\">\n<h3><code class=\"docutils literal notranslate\">declared_fieldsets</code> attribute on <code class=\"docutils literal notranslate\">ModelAdmin</code><a class=\"heading-anchor\" href=\"#declared-fieldsets-attribute-on-modeladmin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">ModelAdmin.declared_fieldsets</code> has been deprecated. Despite being a private\nAPI, it will go through a regular deprecation path. This attribute was mostly\nused by methods that bypassed <code class=\"docutils literal notranslate\">ModelAdmin.get_fieldsets()</code> but this was\nconsidered a bug and has been addressed.</p>\n</section>\n<section id=\"reorganization-of-django-contrib-contenttypes\">\n<h3>Reorganization of <code class=\"docutils literal notranslate\">django.contrib.contenttypes</code><a class=\"heading-anchor\" href=\"#reorganization-of-django-contrib-contenttypes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Since <code class=\"docutils literal notranslate\">django.contrib.contenttypes.generic</code> defined both admin and model\nrelated objects, an import of this module could trigger unexpected side\neffects. As a consequence, its contents were split into\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/contenttypes/#module-django.contrib.contenttypes\" title=\"django.contrib.contenttypes: Provides generic interface to installed models.\"><code class=\"xref py py-mod docutils literal notranslate\">contenttypes</code></a> submodules and the\n<code class=\"docutils literal notranslate\">django.contrib.contenttypes.generic</code> module is deprecated:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/contenttypes/#django.contrib.contenttypes.fields.GenericForeignKey\" title=\"django.contrib.contenttypes.fields.GenericForeignKey\"><code class=\"xref py py-class docutils literal notranslate\">GenericForeignKey</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/contenttypes/#django.contrib.contenttypes.fields.GenericRelation\" title=\"django.contrib.contenttypes.fields.GenericRelation\"><code class=\"xref py py-class docutils literal notranslate\">GenericRelation</code></a> now live in\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/contenttypes/#module-django.contrib.contenttypes.fields\" title=\"django.contrib.contenttypes.fields\"><code class=\"xref py py-mod docutils literal notranslate\">fields</code></a>.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/contenttypes/#django.contrib.contenttypes.forms.BaseGenericInlineFormSet\" title=\"django.contrib.contenttypes.forms.BaseGenericInlineFormSet\"><code class=\"xref py py-class docutils literal notranslate\">BaseGenericInlineFormSet</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/contenttypes/#django.contrib.contenttypes.forms.generic_inlineformset_factory\" title=\"django.contrib.contenttypes.forms.generic_inlineformset_factory\"><code class=\"xref py py-func docutils literal notranslate\">generic_inlineformset_factory()</code></a> now\nlive in <a class=\"reference internal\" href=\"/en/dev/ref/contrib/contenttypes/#module-django.contrib.contenttypes.forms\" title=\"django.contrib.contenttypes.forms\"><code class=\"xref py py-mod docutils literal notranslate\">forms</code></a>.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/contenttypes/#django.contrib.contenttypes.admin.GenericInlineModelAdmin\" title=\"django.contrib.contenttypes.admin.GenericInlineModelAdmin\"><code class=\"xref py py-class docutils literal notranslate\">GenericInlineModelAdmin</code></a>,\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/contenttypes/#django.contrib.contenttypes.admin.GenericStackedInline\" title=\"django.contrib.contenttypes.admin.GenericStackedInline\"><code class=\"xref py py-class docutils literal notranslate\">GenericStackedInline</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/contenttypes/#django.contrib.contenttypes.admin.GenericTabularInline\" title=\"django.contrib.contenttypes.admin.GenericTabularInline\"><code class=\"xref py py-class docutils literal notranslate\">GenericTabularInline</code></a> now live in\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/contenttypes/#module-django.contrib.contenttypes.admin\" title=\"django.contrib.contenttypes.admin\"><code class=\"xref py py-mod docutils literal notranslate\">admin</code></a>.</p></li>\n</ul>\n</section>\n<section id=\"syncdb\">\n<h3><code class=\"docutils literal notranslate\">syncdb</code><a class=\"heading-anchor\" href=\"#syncdb\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">syncdb</code> command has been deprecated in favor of the new\n<a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-migrate\"><code class=\"xref std std-djadmin docutils literal notranslate\">migrate</code></a> command. <code class=\"docutils literal notranslate\">migrate</code> takes the same arguments as <code class=\"docutils literal notranslate\">syncdb</code>\nused to plus a few more, so it’s safe to just change the name you’re calling\nand nothing else.</p>\n</section>\n<section id=\"util-modules-renamed-to-utils\">\n<h3><code class=\"docutils literal notranslate\">util</code> modules renamed to <code class=\"docutils literal notranslate\">utils</code><a class=\"heading-anchor\" href=\"#util-modules-renamed-to-utils\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The following instances of <code class=\"docutils literal notranslate\">util.py</code> in the Django codebase have been renamed\nto <code class=\"docutils literal notranslate\">utils.py</code> in an effort to unify all util and utils references:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">django.contrib.admin.util</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">django.contrib.gis.db.backends.util</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">django.db.backends.util</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">django.forms.util</code></p></li>\n</ul>\n</section>\n<section id=\"get-formsets-method-on-modeladmin\">\n<h3><code class=\"docutils literal notranslate\">get_formsets</code> method on <code class=\"docutils literal notranslate\">ModelAdmin</code><a class=\"heading-anchor\" href=\"#get-formsets-method-on-modeladmin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">ModelAdmin.get_formsets</code> has been deprecated in favor of the new\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_formsets_with_inlines\" title=\"django.contrib.admin.ModelAdmin.get_formsets_with_inlines\"><code class=\"xref py py-meth docutils literal notranslate\">get_formsets_with_inlines()</code></a>, in order to\nbetter handle the case of selectively showing inlines on a <code class=\"docutils literal notranslate\">ModelAdmin</code>.</p>\n</section>\n<section id=\"ipaddressfield\">\n<h3><code class=\"docutils literal notranslate\">IPAddressField</code><a class=\"heading-anchor\" href=\"#ipaddressfield\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">django.db.models.IPAddressField</code> and <code class=\"docutils literal notranslate\">django.forms.IPAddressField</code>\nfields have been deprecated in favor of\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.GenericIPAddressField\" title=\"django.db.models.GenericIPAddressField\"><code class=\"xref py py-class docutils literal notranslate\">django.db.models.GenericIPAddressField</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.GenericIPAddressField\" title=\"django.forms.GenericIPAddressField\"><code class=\"xref py py-class docutils literal notranslate\">django.forms.GenericIPAddressField</code></a>.</p>\n</section>\n<section id=\"basememcachedcache-get-memcache-timeout-method\">\n<h3><code class=\"docutils literal notranslate\">BaseMemcachedCache._get_memcache_timeout</code> method<a class=\"heading-anchor\" href=\"#basememcachedcache-get-memcache-timeout-method\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">BaseMemcachedCache._get_memcache_timeout()</code> method has been renamed to\n<code class=\"docutils literal notranslate\">get_backend_timeout()</code>. Despite being a private API, it will go through the\nnormal deprecation.</p>\n</section>\n<section id=\"natural-key-serialization-options\">\n<h3>Natural key serialization options<a class=\"heading-anchor\" href=\"#natural-key-serialization-options\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">--natural</code> and <code class=\"docutils literal notranslate\">-n</code> options for <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-dumpdata\"><code class=\"xref std std-djadmin docutils literal notranslate\">dumpdata</code></a> have been\ndeprecated. Use <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#cmdoption-dumpdata-natural-foreign\"><code class=\"xref std std-option docutils literal notranslate\">dumpdata --natural-foreign</code></a> instead.</p>\n<p>Similarly, the <code class=\"docutils literal notranslate\">use_natural_keys</code> argument for <code class=\"docutils literal notranslate\">serializers.serialize()</code>\nhas been deprecated. Use <code class=\"docutils literal notranslate\">use_natural_foreign_keys</code> instead.</p>\n</section>\n<section id=\"merging-of-post-and-get-arguments-into-wsgirequest-request\">\n<h3>Merging of <code class=\"docutils literal notranslate\">POST</code> and <code class=\"docutils literal notranslate\">GET</code> arguments into <code class=\"docutils literal notranslate\">WSGIRequest.REQUEST</code><a class=\"heading-anchor\" href=\"#merging-of-post-and-get-arguments-into-wsgirequest-request\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>It was already strongly suggested that you use <code class=\"docutils literal notranslate\">GET</code> and <code class=\"docutils literal notranslate\">POST</code> instead of\n<code class=\"docutils literal notranslate\">REQUEST</code>, because the former are more explicit. The property <code class=\"docutils literal notranslate\">REQUEST</code> is\ndeprecated and will be removed in Django 1.9.</p>\n</section>\n<section id=\"django-utils-datastructures-mergedict-class\">\n<h3><code class=\"docutils literal notranslate\">django.utils.datastructures.MergeDict</code> class<a class=\"heading-anchor\" href=\"#django-utils-datastructures-mergedict-class\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">MergeDict</code> exists primarily to support merging <code class=\"docutils literal notranslate\">POST</code> and <code class=\"docutils literal notranslate\">GET</code>\narguments into a <code class=\"docutils literal notranslate\">REQUEST</code> property on <code class=\"docutils literal notranslate\">WSGIRequest</code>. To merge\ndictionaries, use <code class=\"docutils literal notranslate\">dict.update()</code> instead. The class <code class=\"docutils literal notranslate\">MergeDict</code> is\ndeprecated and will be removed in Django 1.9.</p>\n</section>\n<section id=\"language-codes-zh-cn-zh-tw-and-fy-nl\">\n<h3>Language codes <code class=\"docutils literal notranslate\">zh-cn</code>, <code class=\"docutils literal notranslate\">zh-tw</code> and <code class=\"docutils literal notranslate\">fy-nl</code><a class=\"heading-anchor\" href=\"#language-codes-zh-cn-zh-tw-and-fy-nl\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The currently used language codes for Simplified Chinese <code class=\"docutils literal notranslate\">zh-cn</code>,\nTraditional Chinese <code class=\"docutils literal notranslate\">zh-tw</code> and (Western) Frysian <code class=\"docutils literal notranslate\">fy-nl</code> are deprecated\nand should be replaced by the language codes <code class=\"docutils literal notranslate\">zh-hans</code>, <code class=\"docutils literal notranslate\">zh-hant</code> and\n<code class=\"docutils literal notranslate\">fy</code> respectively. If you use these language codes, you should rename the\nlocale directories and update your settings to reflect these changes. The\ndeprecated language codes will be removed in Django 1.9.</p>\n</section>\n<section id=\"django-utils-functional-memoize-function\">\n<h3><code class=\"docutils literal notranslate\">django.utils.functional.memoize</code> function<a class=\"heading-anchor\" href=\"#django-utils-functional-memoize-function\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The function <code class=\"docutils literal notranslate\">memoize</code> is deprecated and should be replaced by the\n<code class=\"docutils literal notranslate\">functools.lru_cache</code> decorator (available from Python 3.2 onward).</p>\n<p>Django ships a backport of this decorator for older Python versions and it’s\navailable at <code class=\"docutils literal notranslate\">django.utils.lru_cache.lru_cache</code>. The deprecated function will\nbe removed in Django 1.9.</p>\n</section>\n<section id=\"geo-sitemaps\">\n<h3>Geo Sitemaps<a class=\"heading-anchor\" href=\"#geo-sitemaps\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Google has retired support for the Geo Sitemaps format. Hence Django support\nfor Geo Sitemaps is deprecated and will be removed in Django 1.8.</p>\n</section>\n<section id=\"passing-callable-arguments-to-queryset-methods\">\n<h3>Passing callable arguments to queryset methods<a class=\"heading-anchor\" href=\"#passing-callable-arguments-to-queryset-methods\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Callable arguments for querysets were an undocumented feature that was\nunreliable. It’s been deprecated and will be removed in Django 1.9.</p>\n<p>Callable arguments were evaluated when a queryset was constructed rather than\nwhen it was evaluated, thus this feature didn’t offer any benefit compared to\nevaluating arguments before passing them to queryset and created confusion that\nthe arguments may have been evaluated at query time.</p>\n</section>\n<section id=\"admin-for-setting\">\n<h3><code class=\"docutils literal notranslate\">ADMIN_FOR</code> setting<a class=\"heading-anchor\" href=\"#admin-for-setting\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">ADMIN_FOR</code> feature, part of the admindocs, has been removed. You can\nremove the setting from your configuration at your convenience.</p>\n</section>\n<section id=\"splitdatetimewidget-with-datetimefield\">\n<h3><code class=\"docutils literal notranslate\">SplitDateTimeWidget</code> with <code class=\"docutils literal notranslate\">DateTimeField</code><a class=\"heading-anchor\" href=\"#splitdatetimewidget-with-datetimefield\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">SplitDateTimeWidget</code> support in <a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.DateTimeField\" title=\"django.forms.DateTimeField\"><code class=\"xref py py-class docutils literal notranslate\">DateTimeField</code></a> is\ndeprecated, use <code class=\"docutils literal notranslate\">SplitDateTimeWidget</code> with\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.SplitDateTimeField\" title=\"django.forms.SplitDateTimeField\"><code class=\"xref py py-class docutils literal notranslate\">SplitDateTimeField</code></a> instead.</p>\n</section>\n<section id=\"validate\">\n<h3><code class=\"docutils literal notranslate\">validate</code><a class=\"heading-anchor\" href=\"#validate\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">validate</code> management command is deprecated in favor of the\n<a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-check\"><code class=\"xref std std-djadmin docutils literal notranslate\">check</code></a> command.</p>\n</section>\n<section id=\"django-core-management-basecommand\">\n<h3><code class=\"docutils literal notranslate\">django.core.management.BaseCommand</code><a class=\"heading-anchor\" href=\"#django-core-management-basecommand\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">requires_model_validation</code> is deprecated in favor of a new\n<code class=\"docutils literal notranslate\">requires_system_checks</code> flag. If the latter flag is missing, then the\nvalue of the former flag is used. Defining both <code class=\"docutils literal notranslate\">requires_system_checks</code> and\n<code class=\"docutils literal notranslate\">requires_model_validation</code> results in an error.</p>\n<p>The <code class=\"docutils literal notranslate\">check()</code> method has replaced the old <code class=\"docutils literal notranslate\">validate()</code> method.</p>\n</section>\n<section id=\"modeladmin-validators\">\n<h3><code class=\"docutils literal notranslate\">ModelAdmin</code> validators<a class=\"heading-anchor\" href=\"#modeladmin-validators\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">ModelAdmin.validator_class</code> and <code class=\"docutils literal notranslate\">default_validator_class</code> attributes\nare deprecated in favor of the new <code class=\"docutils literal notranslate\">checks_class</code> attribute.</p>\n<p>The <code class=\"docutils literal notranslate\">ModelAdmin.validate()</code> method is deprecated in favor of\n<code class=\"docutils literal notranslate\">ModelAdmin.check()</code>.</p>\n<p>The <code class=\"docutils literal notranslate\">django.contrib.admin.validation</code> module is deprecated.</p>\n</section>\n<section id=\"django-db-backends-databasevalidation-validate-field\">\n<h3><code class=\"docutils literal notranslate\">django.db.backends.DatabaseValidation.validate_field</code><a class=\"heading-anchor\" href=\"#django-db-backends-databasevalidation-validate-field\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This method is deprecated in favor of a new <code class=\"docutils literal notranslate\">check_field</code> method. The\nfunctionality required by <code class=\"docutils literal notranslate\">check_field()</code> is the same as that provided by\n<code class=\"docutils literal notranslate\">validate_field()</code>, but the output format is different. Third-party database\nbackends needing this functionality should provide an implementation of\n<code class=\"docutils literal notranslate\">check_field()</code>.</p>\n</section>\n<section id=\"loading-ssi-and-url-template-tags-from-future-library\">\n<h3>Loading <code class=\"docutils literal notranslate\">ssi</code> and <code class=\"docutils literal notranslate\">url</code> template tags from <code class=\"docutils literal notranslate\">future</code> library<a class=\"heading-anchor\" href=\"#loading-ssi-and-url-template-tags-from-future-library\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.3 introduced <code class=\"docutils literal notranslate\">{% load ssi from future %}</code> and\n<code class=\"docutils literal notranslate\">{% load url from future %}</code> syntax for forward compatibility of the\n<code class=\"docutils literal notranslate\">ssi</code> and <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-url\"><code class=\"xref std std-ttag docutils literal notranslate\">url</code></a> template tags. This syntax is now deprecated and\nwill be removed in Django 1.9. You can simply remove the\n<code class=\"docutils literal notranslate\">{% load ... from future %}</code> tags.</p>\n</section>\n<section id=\"django-utils-text-javascript-quote\">\n<h3><code class=\"docutils literal notranslate\">django.utils.text.javascript_quote</code><a class=\"heading-anchor\" href=\"#django-utils-text-javascript-quote\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">javascript_quote()</code> was an undocumented function present in\n<code class=\"docutils literal notranslate\">django.utils.text</code>. It was used internally in the <code class=\"docutils literal notranslate\">javascript_catalog()</code>\nview whose implementation was changed to make use of <code class=\"docutils literal notranslate\">json.dumps()</code> instead.\nIf you were relying on this function to provide safe output from untrusted\nstrings, you should use <code class=\"docutils literal notranslate\">django.utils.html.escapejs</code> or the\n<a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatefilter-escapejs\"><code class=\"xref std std-tfilter docutils literal notranslate\">escapejs</code></a> template filter.\nIf all you need is to generate valid JavaScript strings, you can simply use\n<code class=\"docutils literal notranslate\">json.dumps()</code>.</p>\n</section>\n<section id=\"fix-ampersands-utils-method-and-template-filter\">\n<h3><code class=\"docutils literal notranslate\">fix_ampersands</code> utils method and template filter<a class=\"heading-anchor\" href=\"#fix-ampersands-utils-method-and-template-filter\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">django.utils.html.fix_ampersands</code> method and the <code class=\"docutils literal notranslate\">fix_ampersands</code>\ntemplate filter are deprecated, as the escaping of ampersands is already taken\ncare of by Django’s standard HTML escaping features. Combining this with\n<code class=\"docutils literal notranslate\">fix_ampersands</code> would either result in double escaping, or, if the output is\nassumed to be safe, a risk of introducing XSS vulnerabilities. Along with\n<code class=\"docutils literal notranslate\">fix_ampersands</code>, <code class=\"docutils literal notranslate\">django.utils.html.clean_html</code> is deprecated, an\nundocumented function that calls <code class=\"docutils literal notranslate\">fix_ampersands</code>. As this is an accelerated\ndeprecation, <code class=\"docutils literal notranslate\">fix_ampersands</code> and <code class=\"docutils literal notranslate\">clean_html</code> will be removed in Django\n1.8.</p>\n</section>\n<section id=\"reorganization-of-database-test-settings\">\n<h3>Reorganization of database test settings<a class=\"heading-anchor\" href=\"#reorganization-of-database-test-settings\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>All database settings with a <code class=\"docutils literal notranslate\">TEST_</code> prefix have been deprecated in favor of\nentries in a <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-DATABASE-TEST\"><code class=\"xref std std-setting docutils literal notranslate\">TEST</code></a> dictionary in the database\nsettings. The old settings will be supported until Django 1.9. For backwards\ncompatibility with older versions of Django, you can define both versions of\nthe settings as long as they match.</p>\n</section>\n<section id=\"fastcgi-support\">\n<h3>FastCGI support<a class=\"heading-anchor\" href=\"#fastcgi-support\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>FastCGI support via the <code class=\"docutils literal notranslate\">runfcgi</code> management command will be removed in\nDjango 1.9. Please deploy your project using WSGI.</p>\n</section>\n<section id=\"moved-objects-in-contrib-sites\">\n<h3>Moved objects in <code class=\"docutils literal notranslate\">contrib.sites</code><a class=\"heading-anchor\" href=\"#moved-objects-in-contrib-sites\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Following the app-loading refactor, two objects in\n<code class=\"docutils literal notranslate\">django.contrib.sites.models</code> needed to be moved because they must be\navailable without importing <code class=\"docutils literal notranslate\">django.contrib.sites.models</code> when\n<code class=\"docutils literal notranslate\">django.contrib.sites</code> isn’t installed. Import <code class=\"docutils literal notranslate\">RequestSite</code> from\n<code class=\"docutils literal notranslate\">django.contrib.sites.requests</code> and <code class=\"docutils literal notranslate\">get_current_site()</code> from\n<code class=\"docutils literal notranslate\">django.contrib.sites.shortcuts</code>. The old import locations will work until\nDjango 1.9.</p>\n</section>\n<section id=\"django-forms-forms-get-declared-fields\">\n<h3><code class=\"docutils literal notranslate\">django.forms.forms.get_declared_fields()</code><a class=\"heading-anchor\" href=\"#django-forms-forms-get-declared-fields\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django no longer uses this functional internally. Even though it’s a private\nAPI, it’ll go through the normal deprecation cycle.</p>\n</section>\n<section id=\"private-query-lookup-apis\">\n<h3>Private Query Lookup APIs<a class=\"heading-anchor\" href=\"#private-query-lookup-apis\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Private APIs <code class=\"docutils literal notranslate\">django.db.models.sql.where.WhereNode.make_atom()</code> and\n<code class=\"docutils literal notranslate\">django.db.models.sql.where.Constraint</code> are deprecated in favor of the new\n<a class=\"reference internal\" href=\"/en/dev/ref/models/lookups/\"><span class=\"doc\">custom lookups API</span></a>.</p>\n</section>\n</section>\n<section id=\"features-removed-in-1-7\">\n<span id=\"removed-features-1-7\"></span><h2>Features removed in 1.7<a class=\"heading-anchor\" href=\"#features-removed-in-1-7\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>These features have reached the end of their deprecation cycle and are removed\nin Django 1.7. See <a class=\"reference internal\" href=\"/en/dev/releases/1.5/#deprecated-features-1-5\"><span class=\"std std-ref\">Features deprecated in 1.5</span></a> for details, including how to\nremove usage of these features.</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">django.utils.simplejson</code> is removed.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.utils.itercompat.product</code> is removed.</p></li>\n<li><p>INSTALLED_APPS and TEMPLATE_DIRS are no longer corrected from a plain\nstring into a tuple.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpResponse\" title=\"django.http.HttpResponse\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponse</code></a>,\n<a class=\"reference internal\" href=\"/en/dev/ref/template-response/#django.template.response.SimpleTemplateResponse\" title=\"django.template.response.SimpleTemplateResponse\"><code class=\"xref py py-class docutils literal notranslate\">SimpleTemplateResponse</code></a>,\n<a class=\"reference internal\" href=\"/en/dev/ref/template-response/#django.template.response.TemplateResponse\" title=\"django.template.response.TemplateResponse\"><code class=\"xref py py-class docutils literal notranslate\">TemplateResponse</code></a>,\n<code class=\"docutils literal notranslate\">render_to_response()</code>, <a class=\"reference internal\" href=\"/en/dev/ref/contrib/sitemaps/#django.contrib.sitemaps.views.index\" title=\"django.contrib.sitemaps.views.index\"><code class=\"xref py py-func docutils literal notranslate\">index()</code></a>, and\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/sitemaps/#django.contrib.sitemaps.views.sitemap\" title=\"django.contrib.sitemaps.views.sitemap\"><code class=\"xref py py-func docutils literal notranslate\">sitemap()</code></a> no longer take a <code class=\"docutils literal notranslate\">mimetype</code>\nargument</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpResponse\" title=\"django.http.HttpResponse\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponse</code></a> immediately consumes its content if it’s\nan iterator.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">AUTH_PROFILE_MODULE</code> setting, and the <code class=\"docutils literal notranslate\">get_profile()</code> method on\nthe User model are removed.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">cleanup</code> management command is removed.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">daily_cleanup.py</code> script is removed.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.select_related\" title=\"django.db.models.query.QuerySet.select_related\"><code class=\"xref py py-meth docutils literal notranslate\">select_related()</code></a> no longer has a\n<code class=\"docutils literal notranslate\">depth</code> keyword argument.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">get_warnings_state()</code>/<code class=\"docutils literal notranslate\">restore_warnings_state()</code>\nfunctions from <a class=\"reference internal\" href=\"/en/dev/topics/testing/advanced/#module-django.test.utils\" title=\"django.test.utils: Helpers to write custom test runners.\"><code class=\"xref py py-mod docutils literal notranslate\">django.test.utils</code></a> and the <code class=\"docutils literal notranslate\">save_warnings_state()</code>/\n<code class=\"docutils literal notranslate\">restore_warnings_state()</code>\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django-testcase-subclasses\"><span class=\"std std-ref\">django.test.*TestCase</span></a> are removed.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">check_for_test_cookie</code> method in\n<a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.forms.AuthenticationForm\" title=\"django.contrib.auth.forms.AuthenticationForm\"><code class=\"xref py py-class docutils literal notranslate\">AuthenticationForm</code></a> is removed.</p></li>\n<li><p>The version of <code class=\"docutils literal notranslate\">django.contrib.auth.views.password_reset_confirm()</code> that\nsupports base36 encoded user IDs\n(<code class=\"docutils literal notranslate\">django.contrib.auth.views.password_reset_confirm_uidb36</code>) is removed.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">django.utils.encoding.StrAndUnicode</code> mix-in is removed.</p></li>\n</ul>\n</section>","rootId":"django-1-7-release-notes","toc":[{"title":"Python compatibility","anchor":"python-compatibility","children":[]},{"title":"What’s new in Django 1.7","anchor":"what-s-new-in-django-1-7","children":[{"title":"Schema migrations","anchor":"schema-migrations","children":[]},{"title":"App-loading refactor","anchor":"app-loading-refactor","children":[]},{"title":"New method on Field subclasses","anchor":"new-method-on-field-subclasses","children":[]},{"title":"Calling custom QuerySet methods from the Manager","anchor":"calling-custom-queryset-methods-from-the-manager","children":[]},{"title":"Using a custom manager when traversing reverse relations","anchor":"using-a-custom-manager-when-traversing-reverse-relations","children":[]},{"title":"New system check framework","anchor":"new-system-check-framework","children":[]},{"title":"New Prefetch object for advanced prefetch_related operations.","anchor":"new-prefetch-object-for-advanced-prefetch-related-operations","children":[]},{"title":"Admin shortcuts support time zones","anchor":"admin-shortcuts-support-time-zones","children":[]},{"title":"Using database cursors as context managers","anchor":"using-database-cursors-as-context-managers","children":[]},{"title":"Custom lookups","anchor":"custom-lookups","children":[]},{"title":"Improvements to Form error handling","anchor":"improvements-to-form-error-handling","children":[{"title":"Form.add_error()","anchor":"form-add-error","children":[]},{"title":"Error metadata","anchor":"error-metadata","children":[]},{"title":"Error containers and backward compatibility","anchor":"error-containers-and-backward-compatibility","children":[]}]},{"title":"Minor features","anchor":"minor-features","children":[{"title":"django.contrib.admin","anchor":"django-contrib-admin","children":[]},{"title":"django.contrib.auth","anchor":"django-contrib-auth","children":[]},{"title":"django.contrib.formtools","anchor":"django-contrib-formtools","children":[]},{"title":"django.contrib.gis","anchor":"django-contrib-gis","children":[]},{"title":"django.contrib.messages","anchor":"django-contrib-messages","children":[]},{"title":"django.contrib.redirects","anchor":"django-contrib-redirects","children":[]},{"title":"django.contrib.sessions","anchor":"django-contrib-sessions","children":[]},{"title":"django.contrib.sitemaps","anchor":"django-contrib-sitemaps","children":[]},{"title":"django.contrib.sites","anchor":"django-contrib-sites","children":[]},{"title":"django.contrib.staticfiles","anchor":"django-contrib-staticfiles","children":[]},{"title":"django.contrib.syndication","anchor":"django-contrib-syndication","children":[]},{"title":"Cache","anchor":"cache","children":[]},{"title":"Cross Site Request Forgery","anchor":"cross-site-request-forgery","children":[]},{"title":"Email","anchor":"email","children":[]},{"title":"File Storage","anchor":"file-storage","children":[]},{"title":"File Uploads","anchor":"file-uploads","children":[]},{"title":"Forms","anchor":"forms","children":[]},{"title":"Internationalization","anchor":"internationalization","children":[]},{"title":"Management Commands","anchor":"management-commands","children":[]},{"title":"Models","anchor":"models","children":[]},{"title":"Signals","anchor":"signals","children":[]},{"title":"Templates","anchor":"templates","children":[]},{"title":"Requests and Responses","anchor":"requests-and-responses","children":[]},{"title":"Tests","anchor":"tests","children":[]},{"title":"Utilities","anchor":"utilities","children":[]},{"title":"Validators","anchor":"validators","children":[]}]}]},{"title":"Backwards incompatible changes in 1.7","anchor":"backwards-incompatible-changes-in-1-7","children":[{"title":"allow_syncdb / allow_migrate","anchor":"allow-syncdb-allow-migrate","children":[]},{"title":"initial_data","anchor":"initial-data","children":[]},{"title":"deconstruct() and serializability","anchor":"deconstruct-and-serializability","children":[]},{"title":"App-loading changes","anchor":"app-loading-changes","children":[{"title":"Start-up sequence","anchor":"start-up-sequence","children":[]},{"title":"Standalone scripts","anchor":"standalone-scripts","children":[]},{"title":"WSGI scripts","anchor":"wsgi-scripts","children":[]},{"title":"App registry consistency","anchor":"app-registry-consistency","children":[]},{"title":"Subclassing AppCommand","anchor":"subclassing-appcommand","children":[]},{"title":"Introspecting applications","anchor":"introspecting-applications","children":[]}]},{"title":"Management commands and order of INSTALLED_APPS","anchor":"management-commands-and-order-of-installed-apps","children":[]},{"title":"ValidationError constructor and internal storage","anchor":"validationerror-constructor-and-internal-storage","children":[]},{"title":"Behavior of LocMemCache regarding pickle errors","anchor":"behavior-of-locmemcache-regarding-pickle-errors","children":[]},{"title":"Cache keys are now generated from the request’s absolute URL","anchor":"cache-keys-are-now-generated-from-the-request-s-absolute-url","children":[]},{"title":"Passing None to Manager.db_manager()","anchor":"passing-none-to-manager-db-manager","children":[]},{"title":"pytz may be required","anchor":"pytz-may-be-required","children":[]},{"title":"remove() and clear() methods of related managers","anchor":"remove-and-clear-methods-of-related-managers","children":[]},{"title":"Admin login redirection strategy","anchor":"admin-login-redirection-strategy","children":[]},{"title":"select_for_update() requires a transaction","anchor":"select-for-update-requires-a-transaction","children":[]},{"title":"Contrib middleware removed from default MIDDLEWARE_CLASSES","anchor":"contrib-middleware-removed-from-default-middleware-classes","children":[]},{"title":"Miscellaneous","anchor":"miscellaneous","children":[]}]},{"title":"Features deprecated in 1.7","anchor":"features-deprecated-in-1-7","children":[{"title":"django.core.cache.get_cache","anchor":"django-core-cache-get-cache","children":[]},{"title":"django.utils.dictconfig/django.utils.importlib","anchor":"django-utils-dictconfig-django-utils-importlib","children":[]},{"title":"django.utils.module_loading.import_by_path","anchor":"django-utils-module-loading-import-by-path","children":[]},{"title":"django.utils.tzinfo","anchor":"django-utils-tzinfo","children":[]},{"title":"django.utils.unittest","anchor":"django-utils-unittest","children":[]},{"title":"django.utils.datastructures.SortedDict","anchor":"django-utils-datastructures-sorteddict","children":[]},{"title":"Custom SQL location for models package","anchor":"custom-sql-location-for-models-package","children":[]},{"title":"Reorganization of django.contrib.sites","anchor":"reorganization-of-django-contrib-sites","children":[]},{"title":"declared_fieldsets attribute on ModelAdmin","anchor":"declared-fieldsets-attribute-on-modeladmin","children":[]},{"title":"Reorganization of django.contrib.contenttypes","anchor":"reorganization-of-django-contrib-contenttypes","children":[]},{"title":"syncdb","anchor":"syncdb","children":[]},{"title":"util modules renamed to utils","anchor":"util-modules-renamed-to-utils","children":[]},{"title":"get_formsets method on ModelAdmin","anchor":"get-formsets-method-on-modeladmin","children":[]},{"title":"IPAddressField","anchor":"ipaddressfield","children":[]},{"title":"BaseMemcachedCache._get_memcache_timeout method","anchor":"basememcachedcache-get-memcache-timeout-method","children":[]},{"title":"Natural key serialization options","anchor":"natural-key-serialization-options","children":[]},{"title":"Merging of POST and GET arguments into WSGIRequest.REQUEST","anchor":"merging-of-post-and-get-arguments-into-wsgirequest-request","children":[]},{"title":"django.utils.datastructures.MergeDict class","anchor":"django-utils-datastructures-mergedict-class","children":[]},{"title":"Language codes zh-cn, zh-tw and fy-nl","anchor":"language-codes-zh-cn-zh-tw-and-fy-nl","children":[]},{"title":"django.utils.functional.memoize function","anchor":"django-utils-functional-memoize-function","children":[]},{"title":"Geo Sitemaps","anchor":"geo-sitemaps","children":[]},{"title":"Passing callable arguments to queryset methods","anchor":"passing-callable-arguments-to-queryset-methods","children":[]},{"title":"ADMIN_FOR setting","anchor":"admin-for-setting","children":[]},{"title":"SplitDateTimeWidget with DateTimeField","anchor":"splitdatetimewidget-with-datetimefield","children":[]},{"title":"validate","anchor":"validate","children":[]},{"title":"django.core.management.BaseCommand","anchor":"django-core-management-basecommand","children":[]},{"title":"ModelAdmin validators","anchor":"modeladmin-validators","children":[]},{"title":"django.db.backends.DatabaseValidation.validate_field","anchor":"django-db-backends-databasevalidation-validate-field","children":[]},{"title":"Loading ssi and url template tags from future library","anchor":"loading-ssi-and-url-template-tags-from-future-library","children":[]},{"title":"django.utils.text.javascript_quote","anchor":"django-utils-text-javascript-quote","children":[]},{"title":"fix_ampersands utils method and template filter","anchor":"fix-ampersands-utils-method-and-template-filter","children":[]},{"title":"Reorganization of database test settings","anchor":"reorganization-of-database-test-settings","children":[]},{"title":"FastCGI support","anchor":"fastcgi-support","children":[]},{"title":"Moved objects in contrib.sites","anchor":"moved-objects-in-contrib-sites","children":[]},{"title":"django.forms.forms.get_declared_fields()","anchor":"django-forms-forms-get-declared-fields","children":[]},{"title":"Private Query Lookup APIs","anchor":"private-query-lookup-apis","children":[]}]},{"title":"Features removed in 1.7","anchor":"features-removed-in-1-7","children":[]}],"breadcrumbs":[{"docname":"releases/index","title":"Release notes","url":"/en/dev/releases/"}],"prev":{"docname":"releases/1.7.1","title":"Django 1.7.1 release notes","url":"/en/dev/releases/1.7.1/"},"next":{"docname":"releases/1.6.11","title":"Django 1.6.11 release notes","url":"/en/dev/releases/1.6.11/"},"formats":{"html":"/en/dev/releases/1.7/","markdown":"/en/dev/releases/1.7.md","json":"/en/dev/releases/1.7.json"},"source":"https://github.com/django/django/blob/main/docs/releases/1.7.txt","official":"https://docs.djangoproject.com/en/dev/releases/1.7/","inVersions":["dev","6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9","1.8"],"inLocales":["en"]}