{"title":"Django 1.6 release notes","version":"dev","locale":"en","docname":"releases/1.6","url":"/en/dev/releases/1.6/","canonical":"https://djangodocs.dev/en/dev/releases/1.6/","summary":"Welcome to Django 1.6! 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.6 release notes<a class=\"heading-anchor\" href=\"#django-1-6-release-notes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Note</p>\n<p>Dedicated to Malcolm Tredinnick</p>\n<p>On March 17, 2013, the Django project and the free software community lost\na very dear friend and developer.</p>\n<p>Malcolm was a long-time contributor to Django, a model community member, a\nbrilliant mind, and a friend. His contributions to Django — and to many\nother open source projects — are nearly impossible to enumerate. Many on\nthe core Django team had their first patches reviewed by him; his\nmentorship enriched us. His consideration, patience, and dedication will\nalways be an inspiration to us.</p>\n<p>This release of Django is for Malcolm.</p>\n<p>– The Django Developers</p>\n</aside>\n<p><em>November 6, 2013</em></p>\n<p>Welcome to Django 1.6!</p>\n<p>These release notes cover the <a class=\"reference internal\" href=\"#whats-new-1-6\"><span class=\"std std-ref\">new features</span></a>, as well as\nsome <a class=\"reference internal\" href=\"#backwards-incompatible-1-6\"><span class=\"std std-ref\">backwards incompatible changes</span></a> you’ll\nwant to be aware of when upgrading from Django 1.5 or older versions. We’ve\nalso dropped some features, which are detailed in <a class=\"reference internal\" href=\"/en/dev/internals/deprecation/#deprecation-removed-in-1-6\"><span class=\"std std-ref\">our deprecation plan</span></a>, and we’ve <a class=\"reference internal\" href=\"#deprecated-features-1-6\"><span class=\"std std-ref\">begun the deprecation process\nfor some features</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.6, like Django 1.5, requires Python 2.6.5 or above. Python 3 is also\nofficially supported. We <strong>highly recommend</strong> the latest minor release for each\nsupported Python series (2.6.X, 2.7.X, 3.2.X, and 3.3.X).</p>\n<p>Django 1.6 will be the final release series to support Python 2.6; beginning\nwith Django 1.7, the minimum supported Python version will be 2.7.</p>\n<p>Python 3.4 is not supported, but support will be added in Django 1.7.</p>\n</section>\n<section id=\"what-s-new-in-django-1-6\">\n<span id=\"whats-new-1-6\"></span><h2>What’s new in Django 1.6<a class=\"heading-anchor\" href=\"#what-s-new-in-django-1-6\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"simplified-default-project-and-app-templates\">\n<h3>Simplified default project and app templates<a class=\"heading-anchor\" href=\"#simplified-default-project-and-app-templates\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The default templates used 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> and <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-startapp\"><code class=\"xref std std-djadmin docutils literal notranslate\">startapp</code></a>\nhave been simplified and modernized. The <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/\"><span class=\"doc\">admin</span></a> is now enabled by default in new projects; the\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/sites/\"><span class=\"doc\">sites</span></a> framework no longer is. <a class=\"reference internal\" href=\"/en/dev/ref/clickjacking/#clickjacking-prevention\"><span class=\"std std-ref\">clickjacking\nprevention</span></a> is now on and the database defaults to\nSQLite.</p>\n<p>If the default templates don’t suit your tastes, you can use <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#custom-app-and-project-templates\"><span class=\"std std-ref\">custom\nproject and app templates</span></a>.</p>\n</section>\n<section id=\"improved-transaction-management\">\n<h3>Improved transaction management<a class=\"heading-anchor\" href=\"#improved-transaction-management\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django’s transaction management was overhauled. Database-level autocommit is\nnow turned on by default. This makes transaction handling more explicit and\nshould improve performance. The existing APIs were deprecated, and new APIs\nwere introduced, as described in the <a class=\"reference internal\" href=\"/en/dev/topics/db/transactions/\"><span class=\"doc\">transaction management docs</span></a>.</p>\n</section>\n<section id=\"persistent-database-connections\">\n<h3>Persistent database connections<a class=\"heading-anchor\" href=\"#persistent-database-connections\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django now supports reusing the same database connection for several requests.\nThis avoids the overhead of reestablishing a connection at the beginning of\neach request. For backwards compatibility, this feature is disabled by\ndefault. See <a class=\"reference internal\" href=\"/en/dev/ref/databases/#persistent-database-connections\"><span class=\"std std-ref\">Persistent connections</span></a> for details.</p>\n</section>\n<section id=\"discovery-of-tests-in-any-test-module\">\n<h3>Discovery of tests in any test module<a class=\"heading-anchor\" href=\"#discovery-of-tests-in-any-test-module\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.6 ships with a new test runner that allows more flexibility in the\nlocation of tests. The previous runner\n(<code class=\"docutils literal notranslate\">django.test.simple.DjangoTestSuiteRunner</code>) found tests only in the\n<code class=\"docutils literal notranslate\">models.py</code> and <code class=\"docutils literal notranslate\">tests.py</code> modules of a Python package 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>.</p>\n<p>The new runner (<code class=\"docutils literal notranslate\">django.test.runner.DiscoverRunner</code>) uses the test discovery\nfeatures built into <code class=\"docutils literal notranslate\">unittest2</code> (the version of <code class=\"docutils literal notranslate\">unittest</code> in the\nPython 2.7+ standard library, and bundled with Django). With test discovery,\ntests can be located in any module whose name matches the pattern <code class=\"docutils literal notranslate\">test*.py</code>.</p>\n<p>In addition, the test labels provided to <code class=\"docutils literal notranslate\">./manage.py test</code> to nominate\nspecific tests to run must now be full Python dotted paths (or directory\npaths), rather than <code class=\"docutils literal notranslate\">applabel.TestCase.test_method_name</code> pseudo-paths. This\nallows running tests located anywhere in your codebase, rather than only 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>. For more details, see <a class=\"reference internal\" href=\"/en/dev/topics/testing/\"><span class=\"doc\">Testing in Django</span></a>.</p>\n<p>This change is backwards-incompatible; see the <a class=\"reference internal\" href=\"#new-test-runner\"><span class=\"std std-ref\">backwards-incompatibility\nnotes</span></a>.</p>\n</section>\n<section id=\"time-zone-aware-aggregation\">\n<h3>Time zone aware aggregation<a class=\"heading-anchor\" href=\"#time-zone-aware-aggregation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The support for <a class=\"reference internal\" href=\"/en/dev/topics/i18n/timezones/\"><span class=\"doc\">time zones</span></a> introduced in\nDjango 1.4 didn’t work well with <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.dates\" title=\"django.db.models.query.QuerySet.dates\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.dates()</code></a>: aggregation was always performed in\nUTC. This limitation was lifted in Django 1.6. Use <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.datetimes\" title=\"django.db.models.query.QuerySet.datetimes\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.datetimes()</code></a> to perform time zone aware\naggregation on a <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.DateTimeField\" title=\"django.db.models.DateTimeField\"><code class=\"xref py py-class docutils literal notranslate\">DateTimeField</code></a>.</p>\n</section>\n<section id=\"support-for-savepoints-in-sqlite\">\n<h3>Support for savepoints in SQLite<a class=\"heading-anchor\" href=\"#support-for-savepoints-in-sqlite\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.6 adds support for savepoints in SQLite, with some <a class=\"reference internal\" href=\"/en/dev/topics/db/transactions/#savepoints-in-sqlite\"><span class=\"std std-ref\">limitations</span></a>.</p>\n</section>\n<section id=\"binaryfield-model-field\">\n<h3><code class=\"docutils literal notranslate\">BinaryField</code> model field<a class=\"heading-anchor\" href=\"#binaryfield-model-field\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>A new <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.BinaryField\" title=\"django.db.models.BinaryField\"><code class=\"xref py py-class docutils literal notranslate\">django.db.models.BinaryField</code></a> model field allows storage of raw\nbinary data in the database.</p>\n</section>\n<section id=\"geodjango-form-widgets\">\n<h3>GeoDjango form widgets<a class=\"heading-anchor\" href=\"#geodjango-form-widgets\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>GeoDjango now provides <a class=\"reference internal\" href=\"/en/dev/ref/contrib/gis/forms-api/\"><span class=\"doc\">form fields and widgets</span></a> for its geo-specialized fields. They are\nOpenLayers-based by default, but they can be customized to use any other JS\nframework.</p>\n</section>\n<section id=\"check-management-command-added-for-verifying-compatibility\">\n<h3><code class=\"docutils literal notranslate\">check</code> management command added for verifying compatibility<a class=\"heading-anchor\" href=\"#check-management-command-added-for-verifying-compatibility\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>A <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 was added, enabling you to verify if your\ncurrent configuration (currently oriented at settings) is compatible with the\ncurrent version of Django.</p>\n</section>\n<section id=\"model-save-algorithm-changed\">\n<h3><a class=\"reference internal\" href=\"/en/dev/ref/models/instances/#django.db.models.Model.save\" title=\"django.db.models.Model.save\"><code class=\"xref py py-meth docutils literal notranslate\">Model.save()</code></a> algorithm changed<a class=\"heading-anchor\" href=\"#model-save-algorithm-changed\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <a class=\"reference internal\" href=\"/en/dev/ref/models/instances/#django.db.models.Model.save\" title=\"django.db.models.Model.save\"><code class=\"xref py py-meth docutils literal notranslate\">Model.save()</code></a> method now\ntries to directly <code class=\"docutils literal notranslate\">UPDATE</code> the database if the instance has a primary\nkey value. Previously <code class=\"docutils literal notranslate\">SELECT</code> was performed to determine if <code class=\"docutils literal notranslate\">UPDATE</code>\nor <code class=\"docutils literal notranslate\">INSERT</code> were needed. The new algorithm needs only one query for\nupdating an existing row while the old algorithm needed two. See\n<a class=\"reference internal\" href=\"/en/dev/ref/models/instances/#django.db.models.Model.save\" title=\"django.db.models.Model.save\"><code class=\"xref py py-meth docutils literal notranslate\">Model.save()</code></a> for more details.</p>\n<p>In some rare cases the database doesn’t report that a matching row was\nfound when doing an <code class=\"docutils literal notranslate\">UPDATE</code>. An example is the PostgreSQL <code class=\"docutils literal notranslate\">ON UPDATE</code>\ntrigger which returns <code class=\"docutils literal notranslate\">NULL</code>. In such cases it is possible to set\n<a class=\"reference internal\" href=\"/en/dev/ref/models/options/#django.db.models.Options.select_on_save\" title=\"django.db.models.Options.select_on_save\"><code class=\"xref py py-attr docutils literal notranslate\">django.db.models.Options.select_on_save</code></a> flag to force saving to\nuse the old algorithm.</p>\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<ul class=\"simple\">\n<li><p>Authentication backends can raise <code class=\"docutils literal notranslate\">PermissionDenied</code> to immediately fail\nthe authentication chain.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">HttpOnly</code> flag can be set on the CSRF cookie with\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CSRF_COOKIE_HTTPONLY\"><code class=\"xref std std-setting docutils literal notranslate\">CSRF_COOKIE_HTTPONLY</code></a>.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">assertQuerysetEqual()</code> now checks\nfor undefined order and raises <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> if undefined\norder is spotted. The order is seen as undefined if the given <code class=\"docutils literal notranslate\">QuerySet</code>\nisn’t ordered and there is more than one ordered value to compare against.</p></li>\n<li><p>Added <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.earliest\" title=\"django.db.models.query.QuerySet.earliest\"><code class=\"xref py py-meth docutils literal notranslate\">earliest()</code></a> for symmetry with\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.latest\" title=\"django.db.models.query.QuerySet.latest\"><code class=\"xref py py-meth docutils literal notranslate\">latest()</code></a>.</p></li>\n<li><p>In addition to <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-year\"><code class=\"xref std std-lookup docutils literal notranslate\">year</code></a>, <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-month\"><code class=\"xref std std-lookup docutils literal notranslate\">month</code></a> and <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-day\"><code class=\"xref std std-lookup docutils literal notranslate\">day</code></a>, the ORM\nnow supports <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-hour\"><code class=\"xref std std-lookup docutils literal notranslate\">hour</code></a>, <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-minute\"><code class=\"xref std std-lookup docutils literal notranslate\">minute</code></a> and <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-second\"><code class=\"xref std std-lookup docutils literal notranslate\">second</code></a> lookups.</p></li>\n<li><p>Django now wraps all <span class=\"target\" id=\"index-0\"></span><a class=\"pep reference external\" href=\"https://peps.python.org/pep-0249/\"><strong>PEP 249</strong></a> exceptions.</p></li>\n<li><p>The default widgets for <a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.EmailField\" title=\"django.forms.EmailField\"><code class=\"xref py py-class docutils literal notranslate\">EmailField</code></a>,\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.URLField\" title=\"django.forms.URLField\"><code class=\"xref py py-class docutils literal notranslate\">URLField</code></a>, <a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.IntegerField\" title=\"django.forms.IntegerField\"><code class=\"xref py py-class docutils literal notranslate\">IntegerField</code></a>,\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.FloatField\" title=\"django.forms.FloatField\"><code class=\"xref py py-class docutils literal notranslate\">FloatField</code></a> and <a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.DecimalField\" title=\"django.forms.DecimalField\"><code class=\"xref py py-class docutils literal notranslate\">DecimalField</code></a> use\nthe new type attributes available in HTML5 (<code class=\"docutils literal notranslate\">type='email'</code>, <code class=\"docutils literal notranslate\">type='url'</code>,\n<code class=\"docutils literal notranslate\">type='number'</code>). Note that due to erratic support of the <code class=\"docutils literal notranslate\">number</code>\ninput type with localized numbers in current browsers, Django only uses it\nwhen numeric fields are not localized.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">number</code> argument for <a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#lazy-plural-translations\"><span class=\"std std-ref\">lazy plural translations</span></a> can be provided at translation time rather than\nat definition time.</p></li>\n<li><p>For custom management commands: Verification of the presence of valid\nsettings in commands that ask for it by using the\n<code class=\"docutils literal notranslate\">BaseCommand.can_import_settings</code> internal\noption is now performed independently from handling of the locale that\nshould be active during the execution of the command. The latter can now be\ninfluenced by the new\n<code class=\"docutils literal notranslate\">BaseCommand.leave_locale_alone</code> internal\noption. See <a class=\"reference internal\" href=\"/en/dev/howto/custom-management-commands/#management-commands-and-locales\"><span class=\"std std-ref\">Management commands and locales</span></a> for more details.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/mixins-editing/#django.views.generic.edit.DeletionMixin.success_url\" title=\"django.views.generic.edit.DeletionMixin.success_url\"><code class=\"xref py py-attr docutils literal notranslate\">success_url</code></a> of\n<a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/mixins-editing/#django.views.generic.edit.DeletionMixin\" title=\"django.views.generic.edit.DeletionMixin\"><code class=\"xref py py-class docutils literal notranslate\">DeletionMixin</code></a> is now interpolated with\nits <code class=\"docutils literal notranslate\">object</code>’s <code class=\"docutils literal notranslate\">__dict__</code>.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpResponseRedirect\" title=\"django.http.HttpResponseRedirect\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponseRedirect</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpResponsePermanentRedirect\" title=\"django.http.HttpResponsePermanentRedirect\"><code class=\"xref py py-class docutils literal notranslate\">HttpResponsePermanentRedirect</code></a> now provide an <code class=\"docutils literal notranslate\">url</code>\nattribute (equivalent to the URL the response will redirect to).</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">MemcachedCache</code> cache backend now uses the latest <a class=\"reference external\" href=\"https://docs.python.org/3/library/pickle.html#module-pickle\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">pickle</code></a>\nprotocol available.</p></li>\n<li><p>Added <a class=\"reference internal\" href=\"/en/dev/ref/contrib/messages/#django.contrib.messages.views.SuccessMessageMixin\" title=\"django.contrib.messages.views.SuccessMessageMixin\"><code class=\"xref py py-class docutils literal notranslate\">SuccessMessageMixin</code></a> which\nprovides a <code class=\"docutils literal notranslate\">success_message</code> attribute for\n<a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/generic-editing/#django.views.generic.edit.FormView\" title=\"django.views.generic.edit.FormView\"><code class=\"xref py py-class docutils literal notranslate\">FormView</code></a> based classes.</p></li>\n<li><p>Added the <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.ForeignKey.db_constraint\" title=\"django.db.models.ForeignKey.db_constraint\"><code class=\"xref py py-attr docutils literal notranslate\">django.db.models.ForeignKey.db_constraint</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.ManyToManyField.db_constraint\" title=\"django.db.models.ManyToManyField.db_constraint\"><code class=\"xref py py-attr docutils literal notranslate\">django.db.models.ManyToManyField.db_constraint</code></a> options.</p></li>\n<li><p>The jQuery library embedded in the admin has been upgraded to version 1.9.1.</p></li>\n<li><p>Syndication feeds (<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>) can now pass extra\ncontext through to feed templates using a new\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/syndication/#django.contrib.syndication.Feed.get_context_data\" title=\"django.contrib.syndication.Feed.get_context_data\"><code class=\"xref py py-meth docutils literal notranslate\">Feed.get_context_data()</code></a> callback.</p></li>\n<li><p>The admin list columns have a <code class=\"docutils literal notranslate\">column-&lt;field_name&gt;</code> class in the HTML\nso the columns header can be styled with CSS, e.g. to set a column width.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/databases/#database-isolation-level\"><span class=\"std std-ref\">isolation level</span></a> can be customized under\nPostgreSQL.</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> template tag now respects\n<code class=\"docutils literal notranslate\">TEMPLATE_STRING_IF_INVALID</code> for variables not present in the\ncontext, just like other template constructs.</p></li>\n<li><p><code class=\"docutils literal notranslate\">SimpleLazyObject</code>s will now present more helpful representations in shell\ndebugging situations.</p></li>\n<li><p>Generic <a class=\"reference internal\" href=\"/en/dev/ref/contrib/gis/model-api/#django.contrib.gis.db.models.GeometryField\" title=\"django.contrib.gis.db.models.GeometryField\"><code class=\"xref py py-class docutils literal notranslate\">GeometryField</code></a> is now editable\nwith the OpenLayers widget in the admin.</p></li>\n<li><p>The documentation contains a <a class=\"reference internal\" href=\"/en/dev/howto/deployment/checklist/\"><span class=\"doc\">deployment checklist</span></a>.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-diffsettings\"><code class=\"xref std std-djadmin docutils literal notranslate\">diffsettings</code></a> command gained a <code class=\"docutils literal notranslate\">--all</code> option.</p></li>\n<li><p><code class=\"docutils literal notranslate\">django.forms.fields.Field.__init__</code> now calls <code class=\"docutils literal notranslate\">super()</code>, allowing\nfield mixins to implement <code class=\"docutils literal notranslate\">__init__()</code> methods that will reliably be\ncalled.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">validate_max</code> parameter was added to <code class=\"docutils literal notranslate\">BaseFormSet</code> and\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>, and <code class=\"docutils literal notranslate\">ModelForm</code> and inline\nversions of the same. The behavior of validation for formsets with\n<code class=\"docutils literal notranslate\">max_num</code> was clarified. The previously undocumented behavior that\nhardened formsets against memory exhaustion attacks was documented,\nand the undocumented limit of the higher of 1000 or <code class=\"docutils literal notranslate\">max_num</code> forms\nwas changed so it is always 1000 more than <code class=\"docutils literal notranslate\">max_num</code>.</p></li>\n<li><p>Added <code class=\"docutils literal notranslate\">BCryptSHA256PasswordHasher</code> to resolve the password truncation issue\nwith bcrypt.</p></li>\n<li><p><a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/Pillow/\">Pillow</a> is now the preferred image manipulation library to use with\nDjango. <a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/PIL/\">PIL</a> is pending deprecation (support to be removed in Django\n1.8). To upgrade, you should <strong>first</strong> uninstall PIL, <strong>then</strong> install\nPillow.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/forms/modelforms/#django.forms.ModelForm\" title=\"django.forms.ModelForm\"><code class=\"xref py py-class docutils literal notranslate\">ModelForm</code></a> accepts several new <code class=\"docutils literal notranslate\">Meta</code>\noptions.</p>\n<ul>\n<li><p>Fields included in the <code class=\"docutils literal notranslate\">localized_fields</code> list will be localized\n(by setting <code class=\"docutils literal notranslate\">localize</code> on the form field).</p></li>\n<li><p>The  <code class=\"docutils literal notranslate\">labels</code>, <code class=\"docutils literal notranslate\">help_texts</code> and <code class=\"docutils literal notranslate\">error_messages</code> options may be used\nto customize the default fields, see\n<a class=\"reference internal\" href=\"/en/dev/topics/forms/modelforms/#modelforms-overriding-default-fields\"><span class=\"std std-ref\">Overriding the default fields</span></a> for details.</p></li>\n</ul>\n</li>\n<li><p>The <code class=\"docutils literal notranslate\">choices</code> argument to model fields now accepts an iterable of iterables\ninstead of requiring an iterable of lists or tuples.</p></li>\n<li><p>The reason phrase can be customized in HTTP responses using\n<a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpResponse.reason_phrase\" title=\"django.http.HttpResponse.reason_phrase\"><code class=\"xref py py-attr docutils literal notranslate\">reason_phrase</code></a>.</p></li>\n<li><p>When giving the URL of the next page for\n<code class=\"docutils literal notranslate\">django.contrib.auth.views.logout()</code>,\n<code class=\"docutils literal notranslate\">django.contrib.auth.views.password_reset()</code>,\n<code class=\"docutils literal notranslate\">django.contrib.auth.views.password_reset_confirm()</code>,\nand <code class=\"docutils literal notranslate\">django.contrib.auth.views.password_change()</code>, you can now pass\nURL names and they will be resolved.</p></li>\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#cmdoption-dumpdata-pks\"><code class=\"xref std std-option docutils literal notranslate\">dumpdata --pks</code></a> option specifies the primary keys of objects\nto dump. This option can only be used with one model.</p></li>\n<li><p>Added <code class=\"docutils literal notranslate\">QuerySet</code> methods <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.first\" title=\"django.db.models.query.QuerySet.first\"><code class=\"xref py py-meth docutils literal notranslate\">first()</code></a>\nand <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.last\" title=\"django.db.models.query.QuerySet.last\"><code class=\"xref py py-meth docutils literal notranslate\">last()</code></a> which are convenience\nmethods returning the first or last object matching the filters. Returns\n<code class=\"docutils literal notranslate\">None</code> if there are no objects matching.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/base/#django.views.generic.base.View\" title=\"django.views.generic.base.View\"><code class=\"xref py py-class docutils literal notranslate\">View</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/base/#django.views.generic.base.RedirectView\" title=\"django.views.generic.base.RedirectView\"><code class=\"xref py py-class docutils literal notranslate\">RedirectView</code></a> now support HTTP <code class=\"docutils literal notranslate\">PATCH</code>\nmethod.</p></li>\n<li><p><code class=\"docutils literal notranslate\">GenericForeignKey</code> now takes an optional <code class=\"docutils literal notranslate\">for_concrete_model</code> argument,\nwhich when set to <code class=\"docutils literal notranslate\">False</code> allows the field to reference proxy models. The\ndefault is <code class=\"docutils literal notranslate\">True</code> to retain the old behavior.</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 active\nlanguage in session if it is not present there. This prevents loss of\nlanguage settings after session flush, e.g. logout.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/exceptions/#django.core.exceptions.SuspiciousOperation\" title=\"django.core.exceptions.SuspiciousOperation\"><code class=\"xref py py-exc docutils literal notranslate\">SuspiciousOperation</code></a> has been differentiated\ninto a number of subclasses, and each will log to a matching named logger\nunder the <code class=\"docutils literal notranslate\">django.security</code> logging hierarchy. Along with this change,\na <code class=\"docutils literal notranslate\">handler400</code> mechanism and default view are used whenever\na <code class=\"docutils literal notranslate\">SuspiciousOperation</code> reaches the WSGI handler to return an\n<code class=\"docutils literal notranslate\">HttpResponseBadRequest</code>.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/models/class/#django.db.models.Model.DoesNotExist\" title=\"django.db.models.Model.DoesNotExist\"><code class=\"xref py py-exc docutils literal notranslate\">DoesNotExist</code></a> exception now includes a\nmessage indicating the name of the attribute used for the lookup.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.get_or_create\" title=\"django.db.models.query.QuerySet.get_or_create\"><code class=\"xref py py-meth docutils literal notranslate\">get_or_create()</code></a> method no longer\nrequires at least one keyword argument.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.SimpleTestCase\" title=\"django.test.SimpleTestCase\"><code class=\"xref py py-class docutils literal notranslate\">SimpleTestCase</code></a> class includes a new assertion\nhelper for testing formset errors:\n<code class=\"docutils literal notranslate\">django.test.SimpleTestCase.assertFormsetError()</code>.</p></li>\n<li><p>The list of related fields added to a\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet\" title=\"django.db.models.query.QuerySet\"><code class=\"xref py py-class docutils literal notranslate\">QuerySet</code></a> by\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> can be cleared using\n<code class=\"docutils literal notranslate\">select_related(None)</code>.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.InlineModelAdmin.get_extra\" title=\"django.contrib.admin.InlineModelAdmin.get_extra\"><code class=\"xref py py-meth docutils literal notranslate\">get_extra()</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.InlineModelAdmin.get_max_num\" title=\"django.contrib.admin.InlineModelAdmin.get_max_num\"><code class=\"xref py py-meth docutils literal notranslate\">get_max_num()</code></a> methods on\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.InlineModelAdmin\" title=\"django.contrib.admin.InlineModelAdmin\"><code class=\"xref py py-class docutils literal notranslate\">InlineModelAdmin</code></a> may be overridden to\ncustomize the extra and maximum number of inline forms.</p></li>\n<li><p>Formsets now have a\n<a class=\"reference internal\" href=\"/en/dev/topics/forms/formsets/#django.forms.formsets.BaseFormSet.total_error_count\" title=\"django.forms.formsets.BaseFormSet.total_error_count\"><code class=\"xref py py-meth docutils literal notranslate\">total_error_count()</code></a> method.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/forms/modelforms/#django.forms.ModelForm\" title=\"django.forms.ModelForm\"><code class=\"xref py py-class docutils literal notranslate\">ModelForm</code></a> fields can now override error messages\ndefined in model fields by using the\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.Field.error_messages\" title=\"django.forms.Field.error_messages\"><code class=\"xref py py-attr docutils literal notranslate\">error_messages</code></a> argument of a <code class=\"docutils literal notranslate\">Field</code>’s\nconstructor. To take advantage of this new feature with your custom fields,\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/validation/#raising-validation-error\"><span class=\"std std-ref\">see the updated recommendation</span></a> for raising\na <code class=\"docutils literal notranslate\">ValidationError</code>.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin\" title=\"django.contrib.admin.ModelAdmin\"><code class=\"xref py py-class docutils literal notranslate\">ModelAdmin</code></a> now preserves filters on the list\nview after creating, editing or deleting an object. It’s possible to restore\nthe previous behavior of clearing filters by setting the\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.preserve_filters\" title=\"django.contrib.admin.ModelAdmin.preserve_filters\"><code class=\"xref py py-attr docutils literal notranslate\">preserve_filters</code></a> attribute to\n<code class=\"docutils literal notranslate\">False</code>.</p></li>\n<li><p>Added\n<a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/mixins-editing/#django.views.generic.edit.FormMixin.get_prefix\" title=\"django.views.generic.edit.FormMixin.get_prefix\"><code class=\"xref py py-meth docutils literal notranslate\">FormMixin.get_prefix</code></a>\n(which returns\n<a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/mixins-editing/#django.views.generic.edit.FormMixin.prefix\" title=\"django.views.generic.edit.FormMixin.prefix\"><code class=\"xref py py-attr docutils literal notranslate\">FormMixin.prefix</code></a> by\ndefault) to allow customizing the <a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.prefix\" title=\"django.forms.Form.prefix\"><code class=\"xref py py-attr docutils literal notranslate\">prefix</code></a> of the\nform.</p></li>\n<li><p>Raw queries (<code class=\"docutils literal notranslate\">Manager.raw()</code> or <code class=\"docutils literal notranslate\">cursor.execute()</code>) can now use the\n“pyformat” parameter style, where placeholders in the query are given as\n<code class=\"docutils literal notranslate\">'%(name)s'</code> and the parameters are passed as a dictionary rather than\na list (except on SQLite). This has long been possible (but not officially\nsupported) on MySQL and PostgreSQL, and is now also available on Oracle.</p></li>\n<li><p>The default iteration count for the PBKDF2 password hasher has been\nincreased by 20%. This backwards compatible change will not affect\nexisting passwords or users who have subclassed\n<code class=\"docutils literal notranslate\">django.contrib.auth.hashers.PBKDF2PasswordHasher</code> to change the\ndefault value. Passwords <a class=\"reference internal\" href=\"/en/dev/topics/auth/passwords/#password-upgrades\"><span class=\"std std-ref\">will be upgraded</span></a> to use\nthe new iteration count as necessary.</p></li>\n</ul>\n</section>\n</section>\n<section id=\"backwards-incompatible-changes-in-1-6\">\n<span id=\"backwards-incompatible-1-6\"></span><h2>Backwards incompatible changes in 1.6<a class=\"heading-anchor\" href=\"#backwards-incompatible-changes-in-1-6\"><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-6\"><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=\"new-transaction-management-model\">\n<h3>New transaction management model<a class=\"heading-anchor\" href=\"#new-transaction-management-model\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"behavior-changes\">\n<h4>Behavior changes<a class=\"heading-anchor\" href=\"#behavior-changes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Database-level autocommit is enabled by default in Django 1.6. While this\ndoesn’t change the general spirit of Django’s transaction management, there\nare a few backwards-incompatibilities.</p>\n</section>\n<section id=\"savepoints-and-assertnumqueries\">\n<h4>Savepoints and <code class=\"docutils literal notranslate\">assertNumQueries</code><a class=\"heading-anchor\" href=\"#savepoints-and-assertnumqueries\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>The changes in transaction management may result in additional statements to\ncreate, release or rollback savepoints. This is more likely to happen with\nSQLite, since it didn’t support savepoints until this release.</p>\n<p>If tests using <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> fail\nbecause of a higher number of queries than expected, check that the extra\nqueries are related to savepoints, and adjust the expected number of queries\naccordingly.</p>\n</section>\n<section id=\"autocommit-option-for-postgresql\">\n<h4>Autocommit option for PostgreSQL<a class=\"heading-anchor\" href=\"#autocommit-option-for-postgresql\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>In previous versions, database-level autocommit was only an option for\nPostgreSQL, and it was disabled by default. This option is now ignored and can\nbe removed.</p>\n</section>\n</section>\n<section id=\"new-test-runner\">\n<span id=\"id1\"></span><h3>New test runner<a class=\"heading-anchor\" href=\"#new-test-runner\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>In order to maintain greater consistency with Python’s <code class=\"docutils literal notranslate\">unittest</code> module, the\nnew test runner (<code class=\"docutils literal notranslate\">django.test.runner.DiscoverRunner</code>) does not automatically\nsupport some types of tests that were supported by the previous runner:</p>\n<ul class=\"simple\">\n<li><p>Tests in <code class=\"docutils literal notranslate\">models.py</code> and <code class=\"docutils literal notranslate\">tests/__init__.py</code> files will no longer be\nfound and run. Move them to a file whose name begins with <code class=\"docutils literal notranslate\">test</code>.</p></li>\n<li><p>Doctests will no longer be automatically discovered. To integrate doctests in\nyour test suite, follow the <a class=\"reference external\" href=\"https://docs.python.org/3/library/doctest.html#doctest-unittest-api\" title=\"(in Python v3.14)\"><span class=\"xref std std-ref\">recommendations in the Python documentation</span></a>.</p></li>\n</ul>\n<p>Django bundles a modified version of the <a class=\"reference external\" href=\"https://docs.python.org/3/library/doctest.html#module-doctest\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">doctest</code></a> module from the Python\nstandard library (in <code class=\"docutils literal notranslate\">django.test._doctest</code>) and includes some additional\ndoctest utilities. These utilities are deprecated and will be removed in Django\n1.8; doctest suites should be updated to work with the standard library’s\ndoctest module (or converted to <code class=\"docutils literal notranslate\">unittest</code>-compatible tests).</p>\n<p>If you wish to delay updates to your test suite, you can set your\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-TEST_RUNNER\"><code class=\"xref std std-setting docutils literal notranslate\">TEST_RUNNER</code></a> setting to <code class=\"docutils literal notranslate\">django.test.simple.DjangoTestSuiteRunner</code>\nto fully restore the old test behavior. <code class=\"docutils literal notranslate\">DjangoTestSuiteRunner</code> is deprecated\nbut will not be removed from Django until version 1.8.</p>\n</section>\n<section id=\"removal-of-django-contrib-gis-tests-geodjangotestsuiterunner-geodjango-custom-test-runner\">\n<h3>Removal of <code class=\"docutils literal notranslate\">django.contrib.gis.tests.GeoDjangoTestSuiteRunner</code> GeoDjango custom test runner<a class=\"heading-anchor\" href=\"#removal-of-django-contrib-gis-tests-geodjangotestsuiterunner-geodjango-custom-test-runner\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This is for developers working on the GeoDjango application itself and related\nto the item above about changes in the test runners:</p>\n<p>The <code class=\"docutils literal notranslate\">django.contrib.gis.tests.GeoDjangoTestSuiteRunner</code> test runner has been\nremoved and the standalone GeoDjango tests execution setup it implemented isn’t\nsupported anymore. To run the GeoDjango tests simply use the new\n<code class=\"docutils literal notranslate\">DiscoverRunner</code> and specify the <code class=\"docutils literal notranslate\">django.contrib.gis</code> app.</p>\n</section>\n<section id=\"custom-user-models-in-tests\">\n<h3>Custom user models in tests<a class=\"heading-anchor\" href=\"#custom-user-models-in-tests\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The introduction of the new test runner has also slightly changed the way that\ntest models are imported. As a result, any test that overrides\n<code class=\"docutils literal notranslate\">AUTH_USER_MODEL</code> to test behavior with one of Django’s test user models (\n<code class=\"docutils literal notranslate\">django.contrib.auth.tests.custom_user.CustomUser</code> and\n<code class=\"docutils literal notranslate\">django.contrib.auth.tests.custom_user.ExtensionUser</code>) must now\nexplicitly import the User model in your test module:</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.contrib.auth.tests.custom_user</span> <span class=\"kn\">import</span> CustomUser\n\n\n<span class=\"nd\">@override_settings</span><span class=\"p\">(</span>AUTH_USER_MODEL<span class=\"o\">=</span><span class=\"s2\">&quot;auth.CustomUser&quot;</span><span class=\"p\">)</span>\n<span class=\"k\">class</span> <span class=\"nc\">CustomUserFeatureTests</span><span class=\"p\">(</span>TestCase<span class=\"p\">):</span>\n    <span class=\"k\">def</span> <span class=\"nf\">test_something</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"c1\"># Test code here</span>\n        <span class=\"o\">...</span>\n</code></pre></div>\n<p>This import forces the custom user model to be registered. Without this import,\nthe test will be unable to swap in the custom user model, and you will get an\nerror reporting:</p>\n<div class=\"code-block\" data-language=\"pytb\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Pytb</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=\"Pytb code\"><code><span class=\"x\">ImproperlyConfigured: AUTH_USER_MODEL refers to model &#39;auth.CustomUser&#39; that</span>\n<span class=\"x\">has not been installed</span>\n</code></pre></div>\n</section>\n<section id=\"time-zone-aware-day-month-and-week-day-lookups\">\n<h3>Time zone-aware <code class=\"docutils literal notranslate\">day</code>, <code class=\"docutils literal notranslate\">month</code>, and <code class=\"docutils literal notranslate\">week_day</code> lookups<a class=\"heading-anchor\" href=\"#time-zone-aware-day-month-and-week-day-lookups\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.6 introduces time zone support for <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-day\"><code class=\"xref std std-lookup docutils literal notranslate\">day</code></a>, <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-month\"><code class=\"xref std std-lookup docutils literal notranslate\">month</code></a>,\nand <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-week_day\"><code class=\"xref std std-lookup docutils literal notranslate\">week_day</code></a> lookups when <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-USE_TZ\"><code class=\"xref std std-setting docutils literal notranslate\">USE_TZ</code></a> is <code class=\"docutils literal notranslate\">True</code>. These\nlookups were previously performed in UTC regardless of the current time zone.</p>\n<p>This requires <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#database-time-zone-definitions\"><span class=\"std std-ref\">time zone definitions in the database</span></a>. If you’re using SQLite, you must install\n<a class=\"reference external\" href=\"http://pytz.sourceforge.net/\">pytz</a>. If you’re using MySQL, you must install <a class=\"reference external\" href=\"http://pytz.sourceforge.net/\">pytz</a> and load the time zone\ntables with <a class=\"reference external\" href=\"https://dev.mysql.com/doc/refman/en/mysql-tzinfo-to-sql.html\">mysql_tzinfo_to_sql</a>.</p>\n</section>\n<section id=\"addition-of-queryset-datetimes\">\n<h3>Addition of <code class=\"docutils literal notranslate\">QuerySet.datetimes()</code><a class=\"heading-anchor\" href=\"#addition-of-queryset-datetimes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>When the <a class=\"reference internal\" href=\"/en/dev/topics/i18n/timezones/\"><span class=\"doc\">time zone support</span></a> added in Django 1.4\nwas active, <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.dates\" title=\"django.db.models.query.QuerySet.dates\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.dates()</code></a>\nlookups returned unexpected results, because the aggregation was performed in\nUTC. To fix this, Django 1.6 introduces a new API, <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.datetimes\" title=\"django.db.models.query.QuerySet.datetimes\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.datetimes()</code></a>. This requires a few changes in\nyour code.</p>\n<section id=\"queryset-dates-returns-date-objects\">\n<h4><code class=\"docutils literal notranslate\">QuerySet.dates()</code> returns <code class=\"docutils literal notranslate\">date</code> objects<a class=\"heading-anchor\" href=\"#queryset-dates-returns-date-objects\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.dates\" title=\"django.db.models.query.QuerySet.dates\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.dates()</code></a> now returns a\nlist of <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>. It used to return a list of\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime</code></a>.</p>\n<p><a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.datetimes\" title=\"django.db.models.query.QuerySet.datetimes\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.datetimes()</code></a>\nreturns a list of <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime</code></a>.</p>\n</section>\n<section id=\"queryset-dates-no-longer-usable-on-datetimefield\">\n<h4><code class=\"docutils literal notranslate\">QuerySet.dates()</code> no longer usable on <code class=\"docutils literal notranslate\">DateTimeField</code><a class=\"heading-anchor\" href=\"#queryset-dates-no-longer-usable-on-datetimefield\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.dates\" title=\"django.db.models.query.QuerySet.dates\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.dates()</code></a> raises an\nerror if it’s used on <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.DateTimeField\" title=\"django.db.models.DateTimeField\"><code class=\"xref py py-class docutils literal notranslate\">DateTimeField</code></a> when time\nzone support is active. Use <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.datetimes\" title=\"django.db.models.query.QuerySet.datetimes\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.datetimes()</code></a> instead.</p>\n</section>\n<section id=\"date-hierarchy-requires-time-zone-definitions\">\n<h4><code class=\"docutils literal notranslate\">date_hierarchy</code> requires time zone definitions<a class=\"heading-anchor\" href=\"#date-hierarchy-requires-time-zone-definitions\"><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/contrib/admin/#django.contrib.admin.ModelAdmin.date_hierarchy\" title=\"django.contrib.admin.ModelAdmin.date_hierarchy\"><code class=\"xref py py-attr docutils literal notranslate\">date_hierarchy</code></a> feature of the\nadmin now relies on <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.datetimes\" title=\"django.db.models.query.QuerySet.datetimes\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.datetimes()</code></a> when it’s used on a\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.DateTimeField\" title=\"django.db.models.DateTimeField\"><code class=\"xref py py-class docutils literal notranslate\">DateTimeField</code></a>.</p>\n<p>This requires time zone definitions in the database when <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-USE_TZ\"><code class=\"xref std std-setting docutils literal notranslate\">USE_TZ</code></a> is\n<code class=\"docutils literal notranslate\">True</code>. <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#database-time-zone-definitions\"><span class=\"std std-ref\">Learn more</span></a>.</p>\n</section>\n<section id=\"date-list-in-generic-views-requires-time-zone-definitions\">\n<h4><code class=\"docutils literal notranslate\">date_list</code> in generic views requires time zone definitions<a class=\"heading-anchor\" href=\"#date-list-in-generic-views-requires-time-zone-definitions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>For the same reason, accessing <code class=\"docutils literal notranslate\">date_list</code> in the context of a date-based\ngeneric view requires time zone definitions in the database when the view is\nbased on a <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.DateTimeField\" title=\"django.db.models.DateTimeField\"><code class=\"xref py py-class docutils literal notranslate\">DateTimeField</code></a> and <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-USE_TZ\"><code class=\"xref std std-setting docutils literal notranslate\">USE_TZ</code></a> is\n<code class=\"docutils literal notranslate\">True</code>. <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#database-time-zone-definitions\"><span class=\"std std-ref\">Learn more</span></a>.</p>\n</section>\n</section>\n<section id=\"new-lookups-may-clash-with-model-fields\">\n<h3>New lookups may clash with model fields<a class=\"heading-anchor\" href=\"#new-lookups-may-clash-with-model-fields\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.6 introduces <code class=\"docutils literal notranslate\">hour</code>, <code class=\"docutils literal notranslate\">minute</code>, and <code class=\"docutils literal notranslate\">second</code> lookups on\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.DateTimeField\" title=\"django.db.models.DateTimeField\"><code class=\"xref py py-class docutils literal notranslate\">DateTimeField</code></a>. If you had model fields called\n<code class=\"docutils literal notranslate\">hour</code>, <code class=\"docutils literal notranslate\">minute</code>, or <code class=\"docutils literal notranslate\">second</code>, the new lookups will clash with you field\nnames. Append an explicit <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#std-fieldlookup-exact\"><code class=\"xref std std-lookup docutils literal notranslate\">exact</code></a> lookup if this is an issue.</p>\n</section>\n<section id=\"booleanfield-no-longer-defaults-to-false\">\n<h3><code class=\"docutils literal notranslate\">BooleanField</code> no longer defaults to <code class=\"docutils literal notranslate\">False</code><a class=\"heading-anchor\" href=\"#booleanfield-no-longer-defaults-to-false\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>When a <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.BooleanField\" title=\"django.db.models.BooleanField\"><code class=\"xref py py-class docutils literal notranslate\">BooleanField</code></a> doesn’t have an explicit\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.Field.default\" title=\"django.db.models.Field.default\"><code class=\"xref py py-attr docutils literal notranslate\">default</code></a>, the implicit default value is\n<code class=\"docutils literal notranslate\">None</code>. In previous version of Django, it was <code class=\"docutils literal notranslate\">False</code>, but that didn’t\nrepresent accurately the lack of a value.</p>\n<p>Code that relies on the default value being <code class=\"docutils literal notranslate\">False</code> may raise an exception\nwhen saving new model instances to the database, because <code class=\"docutils literal notranslate\">None</code> isn’t an\nacceptable value for a <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.BooleanField\" title=\"django.db.models.BooleanField\"><code class=\"xref py py-class docutils literal notranslate\">BooleanField</code></a>. You should\neither specify <code class=\"docutils literal notranslate\">default=False</code> in the field definition, or ensure the field\nis set to <code class=\"docutils literal notranslate\">True</code> or <code class=\"docutils literal notranslate\">False</code> before saving the object.</p>\n</section>\n<section id=\"translations-and-comments-in-templates\">\n<h3>Translations and comments in templates<a class=\"heading-anchor\" href=\"#translations-and-comments-in-templates\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<section id=\"extraction-of-translations-after-comments\">\n<h4>Extraction of translations after comments<a class=\"heading-anchor\" href=\"#extraction-of-translations-after-comments\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Extraction of translatable literals from templates with the\n<a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-makemessages\"><code class=\"xref std std-djadmin docutils literal notranslate\">makemessages</code></a> command now correctly detects i18n constructs when\nthey are located after a <code class=\"docutils literal notranslate\">{#</code> / <code class=\"docutils literal notranslate\">#}</code>-type comment on the same line. E.g.:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"c\">{# A comment #}</span><span class=\"cp\">{%</span> <span class=\"k\">trans</span> <span class=\"s2\">&quot;This literal was incorrectly ignored. Not anymore&quot;</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"location-of-translator-comments\">\n<h4>Location of translator comments<a class=\"heading-anchor\" href=\"#location-of-translator-comments\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#translator-comments-in-templates\"><span class=\"std std-ref\">Comments for translators in templates</span></a> specified using <code class=\"docutils literal notranslate\">{#</code> / <code class=\"docutils literal notranslate\">#}</code> need to\nbe at the end of a line. If they are not, the comments are ignored and\n<a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-makemessages\"><code class=\"xref std std-djadmin docutils literal notranslate\">makemessages</code></a> will generate a warning. For example:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"c\">{# Translators: This is ignored #}</span><span class=\"cp\">{%</span> <span class=\"k\">trans</span> <span class=\"s2\">&quot;Translate me&quot;</span> <span class=\"cp\">%}</span>\n<span class=\"cp\">{{</span> <span class=\"nv\">title</span> <span class=\"cp\">}}</span><span class=\"c\">{# Translators: Extracted and associated with &#39;Welcome&#39; below #}</span>\n<span class=\"p\">&lt;</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span><span class=\"cp\">{%</span> <span class=\"k\">trans</span> <span class=\"s2\">&quot;Welcome&quot;</span> <span class=\"cp\">%}</span><span class=\"p\">&lt;/</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n</section>\n</section>\n<section id=\"quoting-in-reverse\">\n<h3>Quoting in <code class=\"docutils literal notranslate\">reverse()</code><a class=\"heading-anchor\" href=\"#quoting-in-reverse\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>When reversing URLs, Django didn’t apply <code class=\"docutils literal notranslate\">django.utils.http.urlquote</code>\nto arguments before interpolating them in URL patterns. This bug is fixed in\nDjango 1.6. If you worked around this bug by applying URL quoting before\npassing arguments to <code class=\"docutils literal notranslate\">reverse()</code>, this may result in double-quoting. If this\nhappens, simply remove the URL quoting from your code. You will also have to\nreplace special characters in URLs used 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-func docutils literal notranslate\">assertRedirects()</code></a> with their encoded\nversions.</p>\n</section>\n<section id=\"storage-of-ip-addresses-in-the-comments-app\">\n<h3>Storage of IP addresses in the comments app<a class=\"heading-anchor\" href=\"#storage-of-ip-addresses-in-the-comments-app\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The comments app now uses a\n<code class=\"docutils literal notranslate\">GenericIPAddressField</code> for storing commenters’ IP addresses, to support\ncomments submitted from IPv6 addresses. Until now, it stored them in an\n<code class=\"docutils literal notranslate\">IPAddressField</code>, which is only meant to support IPv4. When saving a comment\nmade from an IPv6 address, the address would be silently truncated on MySQL\ndatabases, and raise an exception on Oracle. You will need to change the\ncolumn type in your database to benefit from this change.</p>\n<p>For MySQL, execute this query on your project’s database:</p>\n<div class=\"code-block\" data-language=\"sql\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">SQL</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=\"SQL code\"><code><span class=\"k\">ALTER</span> <span class=\"k\">TABLE</span> django_comments <span class=\"k\">MODIFY</span> ip_address <span class=\"nb\">VARCHAR</span><span class=\"p\">(</span><span class=\"mi\">39</span><span class=\"p\">);</span>\n</code></pre></div>\n<p>For Oracle, execute this query:</p>\n<div class=\"code-block\" data-language=\"sql\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">SQL</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=\"SQL code\"><code><span class=\"k\">ALTER</span> <span class=\"k\">TABLE</span> DJANGO_COMMENTS <span class=\"k\">MODIFY</span> <span class=\"p\">(</span>ip_address VARCHAR2<span class=\"p\">(</span><span class=\"mi\">39</span><span class=\"p\">));</span>\n</code></pre></div>\n<p>If you do not apply this change, the behavior is unchanged: on MySQL, IPv6\naddresses are silently truncated; on Oracle, an exception is generated. No\ndatabase change is needed for SQLite or PostgreSQL databases.</p>\n</section>\n<section id=\"percent-literals-in-cursor-execute-queries\">\n<h3>Percent literals in <code class=\"docutils literal notranslate\">cursor.execute</code> queries<a class=\"heading-anchor\" href=\"#percent-literals-in-cursor-execute-queries\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>When you are running raw SQL queries through the\n<a class=\"reference internal\" href=\"/en/dev/topics/db/sql/#executing-custom-sql\"><span class=\"std std-ref\">cursor.execute</span></a> method, the rule about doubling\npercent literals (<code class=\"docutils literal notranslate\">%</code>) inside the query has been unified. Past behavior\ndepended on the database backend. Now, across all backends, you only need to\ndouble literal percent characters if you are also providing replacement\nparameters. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"c1\"># No parameters, no percent doubling</span>\ncursor<span class=\"o\">.</span>execute<span class=\"p\">(</span><span class=\"s2\">&quot;SELECT foo FROM bar WHERE baz = &#39;30%&#39;&quot;</span><span class=\"p\">)</span>\n\n<span class=\"c1\"># Parameters passed, non-placeholders have to be doubled</span>\ncursor<span class=\"o\">.</span>execute<span class=\"p\">(</span><span class=\"s2\">&quot;SELECT foo FROM bar WHERE baz = &#39;30</span><span class=\"si\">%%</span><span class=\"s2\">&#39; and id = </span><span class=\"si\">%s</span><span class=\"s2\">&quot;</span><span class=\"p\">,</span> <span class=\"p\">[</span><span class=\"bp\">self</span><span class=\"o\">.</span>id<span class=\"p\">])</span>\n</code></pre></div>\n<p><code class=\"docutils literal notranslate\">SQLite</code> users need to check and update such queries.</p>\n</section>\n<section id=\"help-text-of-model-form-fields-for-manytomanyfield-fields\">\n<span id=\"m2m-help-text\"></span><h3>Help text of model form fields for ManyToManyField fields<a class=\"heading-anchor\" href=\"#help-text-of-model-form-fields-for-manytomanyfield-fields\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>HTML rendering of model form fields corresponding to\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> model fields used to get the\nhardcoded sentence:</p>\n<blockquote>\n<div><p><em>Hold down “Control”, or “Command” on a Mac, to select more than one.</em></p>\n</div></blockquote>\n<p>(or its translation to the active locale) imposed as the help legend shown\nalong them if neither <a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.Field.help_text\" title=\"django.db.models.Field.help_text\"><code class=\"xref py py-attr docutils literal notranslate\">model</code></a> nor\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.Field.help_text\" title=\"django.forms.Field.help_text\"><code class=\"xref py py-attr docutils literal notranslate\">form</code></a> <code class=\"docutils literal notranslate\">help_text</code> attributes were\nspecified by the user (or this string was appended to any <code class=\"docutils literal notranslate\">help_text</code> that\nwas provided).</p>\n<p>Since this happened at the model layer, there was no way to prevent the text\nfrom appearing in cases where it wasn’t applicable such as form fields that\nimplement user interactions that don’t involve a keyboard and/or a mouse.</p>\n<p>Starting with Django 1.6, as an ad-hoc temporary backward-compatibility\nprovision, the logic to add the “Hold down…” sentence has been moved to the\nmodel form field layer and modified to add the text only when the associated\nwidget is <a class=\"reference internal\" href=\"/en/dev/ref/forms/widgets/#django.forms.SelectMultiple\" title=\"django.forms.SelectMultiple\"><code class=\"xref py py-class docutils literal notranslate\">SelectMultiple</code></a> or selected subclasses.</p>\n<p>The change can affect you in a backward incompatible way if you employ custom\nmodel form fields and/or widgets for <code class=\"docutils literal notranslate\">ManyToManyField</code> model fields whose UIs\ndo rely on the automatic provision of the mentioned hardcoded sentence. These\nform field implementations need to adapt to the new scenario by providing their\nown handling of the <code class=\"docutils literal notranslate\">help_text</code> attribute.</p>\n<p>Applications that use Django <a class=\"reference internal\" href=\"/en/dev/topics/forms/modelforms/\"><span class=\"doc\">model form</span></a>\nfacilities together with Django built-in form <a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/\"><span class=\"doc\">fields</span></a>\nand <a class=\"reference internal\" href=\"/en/dev/ref/forms/widgets/\"><span class=\"doc\">widgets</span></a> aren’t affected but need to be aware of\nwhat’s described in <a class=\"reference internal\" href=\"#m2m-help-text-deprecation\"><span class=\"std std-ref\">Munging of help text of model form fields for ManyToManyField fields</span></a> below.</p>\n</section>\n<section id=\"queryset-iteration\">\n<h3>QuerySet iteration<a class=\"heading-anchor\" href=\"#queryset-iteration\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">QuerySet</code> iteration was changed to immediately convert all fetched\nrows to <code class=\"docutils literal notranslate\">Model</code> objects. In Django 1.5 and earlier the fetched rows were\nconverted to <code class=\"docutils literal notranslate\">Model</code> objects in chunks of 100.</p>\n<p>Existing code will work, but the amount of rows converted to objects\nmight change in certain use cases. Such usages include partially looping\nover a queryset or any usage which ends up doing <code class=\"docutils literal notranslate\">__bool__</code> or\n<code class=\"docutils literal notranslate\">__contains__</code>.</p>\n<p>Notably most database backends did fetch all the rows in one go already in\n1.5.</p>\n<p>It is still possible to convert the fetched rows to <code class=\"docutils literal notranslate\">Model</code> objects\nlazily by using the <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.iterator\" title=\"django.db.models.query.QuerySet.iterator\"><code class=\"xref py py-meth docutils literal notranslate\">iterator()</code></a>\nmethod.</p>\n</section>\n<section id=\"boundfield-label-tag-now-includes-the-form-s-label-suffix\">\n<h3><a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.BoundField.label_tag\" title=\"django.forms.BoundField.label_tag\"><code class=\"xref py py-meth docutils literal notranslate\">BoundField.label_tag</code></a> now includes the form’s <a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.label_suffix\" title=\"django.forms.Form.label_suffix\"><code class=\"xref py py-attr docutils literal notranslate\">label_suffix</code></a><a class=\"heading-anchor\" href=\"#boundfield-label-tag-now-includes-the-form-s-label-suffix\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This is consistent with how methods like\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.as_p\" title=\"django.forms.Form.as_p\"><code class=\"xref py py-meth docutils literal notranslate\">Form.as_p</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.Form.as_ul\" title=\"django.forms.Form.as_ul\"><code class=\"xref py py-meth docutils literal notranslate\">Form.as_ul</code></a> render labels.</p>\n<p>If you manually render <code class=\"docutils literal notranslate\">label_tag</code> in your templates:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">form.my_field.label_tag</span> <span class=\"cp\">}}</span>: <span class=\"cp\">{{</span> <span class=\"nv\">form.my_field</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>you’ll want to remove the colon (or whatever other separator you may be\nusing) to avoid duplicating it when upgrading to Django 1.6. The following\ntemplate in Django 1.6 will render identically to the above template in Django\n1.5, except that the colon will appear inside the <code class=\"docutils literal notranslate\">&lt;label&gt;</code> element.</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{{</span> <span class=\"nv\">form.my_field.label_tag</span> <span class=\"cp\">}}</span> <span class=\"cp\">{{</span> <span class=\"nv\">form.my_field</span> <span class=\"cp\">}}</span>\n</code></pre></div>\n<p>will render something like:</p>\n<div class=\"code-block\" data-language=\"html\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Html</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=\"Html code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">label</span> <span class=\"na\">for</span><span class=\"o\">=</span><span class=\"s\">&quot;id_my_field&quot;</span><span class=\"p\">&gt;</span>My Field:<span class=\"p\">&lt;/</span><span class=\"nt\">label</span><span class=\"p\">&gt;</span> <span class=\"p\">&lt;</span><span class=\"nt\">input</span> <span class=\"na\">id</span><span class=\"o\">=</span><span class=\"s\">&quot;id_my_field&quot;</span> <span class=\"na\">type</span><span class=\"o\">=</span><span class=\"s\">&quot;text&quot;</span> <span class=\"na\">name</span><span class=\"o\">=</span><span class=\"s\">&quot;my_field&quot;</span> <span class=\"p\">/&gt;</span>\n</code></pre></div>\n<p>If you want to keep the current behavior of rendering <code class=\"docutils literal notranslate\">label_tag</code> without\nthe <code class=\"docutils literal notranslate\">label_suffix</code>, instantiate the form <code class=\"docutils literal notranslate\">label_suffix=''</code>. You can also\ncustomize the <code class=\"docutils literal notranslate\">label_suffix</code> on a per-field basis using the new\n<code class=\"docutils literal notranslate\">label_suffix</code> parameter on <a class=\"reference internal\" href=\"/en/dev/ref/forms/api/#django.forms.BoundField.label_tag\" title=\"django.forms.BoundField.label_tag\"><code class=\"xref py py-meth docutils literal notranslate\">label_tag()</code></a>.</p>\n</section>\n<section id=\"admin-views-changelist-filters-get-parameter\">\n<h3>Admin views <code class=\"docutils literal notranslate\">_changelist_filters</code> GET parameter<a class=\"heading-anchor\" href=\"#admin-views-changelist-filters-get-parameter\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>To achieve preserving and restoring list view filters, admin views now\npass around the <code class=\"docutils literal notranslate\">_changelist_filters</code> GET parameter. It’s important that you\naccount for that change if you have custom admin templates or if your tests\nrely on the previous URLs. If you want to revert to the original behavior you\ncan set the\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.preserve_filters\" title=\"django.contrib.admin.ModelAdmin.preserve_filters\"><code class=\"xref py py-attr docutils literal notranslate\">preserve_filters</code></a> attribute to <code class=\"docutils literal notranslate\">False</code>.</p>\n</section>\n<section id=\"django-contrib-auth-password-reset-uses-base-64-encoding-of-user-pk\">\n<h3><code class=\"docutils literal notranslate\">django.contrib.auth</code> password reset uses base 64 encoding of <code class=\"docutils literal notranslate\">User</code> PK<a class=\"heading-anchor\" href=\"#django-contrib-auth-password-reset-uses-base-64-encoding-of-user-pk\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Past versions of Django used base 36 encoding of the <code class=\"docutils literal notranslate\">User</code> primary key in\nthe password reset views and URLs\n(<code class=\"docutils literal notranslate\">django.contrib.auth.views.password_reset_confirm()</code>). Base 36 encoding is\nsufficient if the user primary key is an integer, however, with the\nintroduction of custom user models in Django 1.5, that assumption may no longer\nbe true.</p>\n<p><code class=\"docutils literal notranslate\">django.contrib.auth.views.password_reset_confirm()</code> has been modified to\ntake a <code class=\"docutils literal notranslate\">uidb64</code> parameter instead of <code class=\"docutils literal notranslate\">uidb36</code>. If you are reversing this\nview, for example in a custom <code class=\"docutils literal notranslate\">password_reset_email.html</code> template, be sure\nto update your code.</p>\n<p>A temporary shim for <code class=\"docutils literal notranslate\">django.contrib.auth.views.password_reset_confirm()</code>\nthat will allow password reset links generated prior to Django 1.6 to continue\nto work has been added to provide backwards compatibility; this will be removed\nin Django 1.7. Thus, as long as your site has been running Django 1.6 for more\nthan <code class=\"docutils literal notranslate\">PASSWORD_RESET_TIMEOUT_DAYS</code>, this change will have no effect.\nIf not (for example, if you upgrade directly from Django 1.5 to Django 1.7),\nthen any password reset links generated before you upgrade to Django 1.7 or\nlater won’t work after the upgrade.</p>\n<p>In addition, if you have any custom password reset URLs, you will need to\nupdate them by replacing <code class=\"docutils literal notranslate\">uidb36</code> with <code class=\"docutils literal notranslate\">uidb64</code> and the dash that follows\nthat pattern with a slash. Also add <code class=\"docutils literal notranslate\">_\\-</code> to the list of characters that may\nmatch the <code class=\"docutils literal notranslate\">uidb64</code> pattern.</p>\n<p>For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>url<span class=\"p\">(</span>\n    <span class=\"sa\">r</span><span class=\"s2\">&quot;^reset/(?P&lt;uidb36&gt;[0-9A-Za-z]+)-(?P&lt;token&gt;.+)/$&quot;</span><span class=\"p\">,</span>\n    <span class=\"s2\">&quot;django.contrib.auth.views.password_reset_confirm&quot;</span><span class=\"p\">,</span>\n    name<span class=\"o\">=</span><span class=\"s2\">&quot;password_reset_confirm&quot;</span><span class=\"p\">,</span>\n<span class=\"p\">),</span>\n</code></pre></div>\n<p>becomes:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>url<span class=\"p\">(</span>\n    <span class=\"sa\">r</span><span class=\"s2\">&quot;^reset/(?P&lt;uidb64&gt;[0-9A-Za-z_\\-]+)/(?P&lt;token&gt;.+)/$&quot;</span><span class=\"p\">,</span>\n    <span class=\"s2\">&quot;django.contrib.auth.views.password_reset_confirm&quot;</span><span class=\"p\">,</span>\n    name<span class=\"o\">=</span><span class=\"s2\">&quot;password_reset_confirm&quot;</span><span class=\"p\">,</span>\n<span class=\"p\">),</span>\n</code></pre></div>\n<p>You may also want to add the shim to support the old style reset links. Using\nthe example above, you would modify the existing url by replacing\n<code class=\"docutils literal notranslate\">django.contrib.auth.views.password_reset_confirm</code> with\n<code class=\"docutils literal notranslate\">django.contrib.auth.views.password_reset_confirm_uidb36</code> and also remove\nthe <code class=\"docutils literal notranslate\">name</code> argument so it doesn’t conflict with the new url:</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>url<span class=\"p\">(</span>\n    <span class=\"sa\">r</span><span class=\"s2\">&quot;^reset/(?P&lt;uidb36&gt;[0-9A-Za-z]+)-(?P&lt;token&gt;.+)/$&quot;</span><span class=\"p\">,</span>\n    <span class=\"s2\">&quot;django.contrib.auth.views.password_reset_confirm_uidb36&quot;</span><span class=\"p\">,</span>\n<span class=\"p\">),</span>\n</code></pre></div>\n<p>You can remove this URL pattern after your app has been deployed with Django\n1.6 for <code class=\"docutils literal notranslate\">PASSWORD_RESET_TIMEOUT_DAYS</code>.</p>\n</section>\n<section id=\"default-session-serialization-switched-to-json\">\n<h3>Default session serialization switched to JSON<a class=\"heading-anchor\" href=\"#default-session-serialization-switched-to-json\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Historically, <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> used <a class=\"reference external\" href=\"https://docs.python.org/3/library/pickle.html#module-pickle\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">pickle</code></a> to serialize\nsession data before storing it in the backend. If you’re using the <a class=\"reference internal\" href=\"/en/dev/topics/http/sessions/#cookie-session-backend\"><span class=\"std std-ref\">signed\ncookie session backend</span></a> and <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-SECRET_KEY\"><code class=\"xref std std-setting docutils literal notranslate\">SECRET_KEY</code></a> is\nknown by an attacker (there isn’t an inherent vulnerability in Django that\nwould cause it to leak), the attacker could insert a string into their session\nwhich, when unpickled, executes arbitrary code on the server. The technique for\ndoing so is simple and easily available on the internet. Although the cookie\nsession storage signs the cookie-stored data to prevent tampering, a\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-SECRET_KEY\"><code class=\"xref std std-setting docutils literal notranslate\">SECRET_KEY</code></a> leak immediately escalates to a remote code execution\nvulnerability.</p>\n<p>This attack can be mitigated by serializing session data using JSON rather\nthan <a class=\"reference external\" href=\"https://docs.python.org/3/library/pickle.html#module-pickle\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">pickle</code></a>. To facilitate this, Django 1.5.3 introduced a new setting,\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-SESSION_SERIALIZER\"><code class=\"xref std std-setting docutils literal notranslate\">SESSION_SERIALIZER</code></a>, to customize the session serialization format.\nFor backwards compatibility, this setting defaulted to using <a class=\"reference external\" href=\"https://docs.python.org/3/library/pickle.html#module-pickle\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">pickle</code></a>\nin Django 1.5.3, but we’ve changed the default to JSON in 1.6. If you upgrade\nand switch from pickle to JSON, sessions created before the upgrade will be\nlost. While JSON serialization does not support all Python objects like\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/pickle.html#module-pickle\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">pickle</code></a> does, we highly recommend using JSON-serialized sessions. Be\naware of the following when checking your code to determine if JSON\nserialization will work for your application:</p>\n<ul class=\"simple\">\n<li><p>JSON requires string keys, so you will likely run into problems if you are\nusing non-string keys in <code class=\"docutils literal notranslate\">request.session</code>.</p></li>\n<li><p>Setting session expiration by passing <code class=\"docutils literal notranslate\">datetime</code> values to\n<a class=\"reference internal\" href=\"/en/dev/topics/http/sessions/#django.contrib.sessions.backends.base.SessionBase.set_expiry\" title=\"django.contrib.sessions.backends.base.SessionBase.set_expiry\"><code class=\"xref py py-meth docutils literal notranslate\">set_expiry()</code></a> will\nnot work as <code class=\"docutils literal notranslate\">datetime</code> values are not serializable in JSON. You can use\ninteger values instead.</p></li>\n</ul>\n<p>See the <a class=\"reference internal\" href=\"/en/dev/topics/http/sessions/#session-serialization\"><span class=\"std std-ref\">Session serialization</span></a> documentation for more details.</p>\n</section>\n<section id=\"object-relational-mapper-changes\">\n<h3>Object Relational Mapper changes<a class=\"heading-anchor\" href=\"#object-relational-mapper-changes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.6 contains many changes to the ORM. These changes fall mostly in\nthree categories:</p>\n<ol class=\"arabic simple\">\n<li><p>Bug fixes (e.g. proper join clauses for generic relations, query combining,\njoin promotion, and join trimming fixes)</p></li>\n<li><p>Preparation for new features. For example the ORM is now internally ready\nfor multicolumn foreign keys.</p></li>\n<li><p>General cleanup.</p></li>\n</ol>\n<p>These changes can result in some compatibility problems. For example, some\nqueries will now generate different table aliases. This can affect\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.extra\" title=\"django.db.models.query.QuerySet.extra\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet.extra()</code></a>. In addition\nsome queries will now produce different results. An example is\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.exclude\" title=\"django.db.models.query.QuerySet.exclude\"><code class=\"xref py py-meth docutils literal notranslate\">exclude(condition)</code></a>\nwhere the condition is a complex one (referencing multijoins inside\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.Q\" title=\"django.db.models.Q\"><code class=\"xref py py-class docutils literal notranslate\">Q objects</code></a>). In many cases the affected\nqueries didn’t produce correct results in Django 1.5 but do now.\nUnfortunately there are also cases that produce different results, but\nneither Django 1.5 nor 1.6 produce correct results.</p>\n<p>Finally, there have been many changes to the ORM internal APIs.</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 <code class=\"docutils literal notranslate\">django.db.models.query.EmptyQuerySet</code> can’t be instantiated any more -\nit is only usable as a marker class for checking if\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.none\" title=\"django.db.models.query.QuerySet.none\"><code class=\"xref py py-meth docutils literal notranslate\">none()</code></a> has been called:\n<code class=\"docutils literal notranslate\">isinstance(qs.none(), EmptyQuerySet)</code></p></li>\n<li><p>If your CSS/JavaScript code used to access HTML input widgets by type, you\nshould review it as <code class=\"docutils literal notranslate\">type='text'</code> widgets might be now output as\n<code class=\"docutils literal notranslate\">type='email'</code>, <code class=\"docutils literal notranslate\">type='url'</code> or <code class=\"docutils literal notranslate\">type='number'</code> depending on their\ncorresponding field type.</p></li>\n<li><p>Form field’s <a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.Field.error_messages\" title=\"django.forms.Field.error_messages\"><code class=\"xref py py-attr docutils literal notranslate\">error_messages</code></a> that contain a\nplaceholder should now always use a named placeholder (<code class=\"docutils literal notranslate\">&quot;Value '%(value)s'\nis too big&quot;</code> instead of <code class=\"docutils literal notranslate\">&quot;Value '%s' is too big&quot;</code>). See the corresponding\nfield documentation for details about the names of the placeholders. The\nchanges in 1.6 particularly affect <a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.DecimalField\" title=\"django.forms.DecimalField\"><code class=\"xref py py-class docutils literal notranslate\">DecimalField</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.ModelMultipleChoiceField\" title=\"django.forms.ModelMultipleChoiceField\"><code class=\"xref py py-class docutils literal notranslate\">ModelMultipleChoiceField</code></a>.</p></li>\n<li><p>Some <a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.Field.error_messages\" title=\"django.forms.Field.error_messages\"><code class=\"xref py py-attr docutils literal notranslate\">error_messages</code></a> for\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.IntegerField\" title=\"django.forms.IntegerField\"><code class=\"xref py py-class docutils literal notranslate\">IntegerField</code></a>, <a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.EmailField\" title=\"django.forms.EmailField\"><code class=\"xref py py-class docutils literal notranslate\">EmailField</code></a>,\n<code class=\"docutils literal notranslate\">IPAddressField</code>, <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\">GenericIPAddressField</code></a>, and\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.SlugField\" title=\"django.forms.SlugField\"><code class=\"xref py py-class docutils literal notranslate\">SlugField</code></a> have been suppressed because they\nduplicated error messages already provided by validators tied to the fields.</p></li>\n<li><p>Due to a change in the form validation workflow,\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 should always\nreturn a value present in the <code class=\"docutils literal notranslate\">choices</code> field attribute. That limitation\nshould be lifted again in Django 1.7.</p></li>\n<li><p>There have been changes in the way timeouts are handled in cache backends.\nExplicitly passing in <code class=\"docutils literal notranslate\">timeout=None</code> no longer results in using the\ndefault timeout. It will now set a non-expiring timeout. Passing 0 into the\nmemcache backend no longer uses the default timeout, and now will\nset-and-expire-immediately the value.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">django.contrib.flatpages</code> app used to set custom HTTP headers for\ndebugging purposes. This functionality was not documented and made caching\nineffective so it has been removed, along with its generic implementation,\npreviously available in <code class=\"docutils literal notranslate\">django.core.xheaders</code>.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">XViewMiddleware</code> has been moved from <code class=\"docutils literal notranslate\">django.middleware.doc</code> to\n<code class=\"docutils literal notranslate\">django.contrib.admindocs.middleware</code> because it is an implementation\ndetail of admindocs, proven not to be reusable in general.</p></li>\n<li><p><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\">GenericIPAddressField</code></a> will now only allow\n<code class=\"docutils literal notranslate\">blank</code> values if <code class=\"docutils literal notranslate\">null</code> values are also allowed. Creating a\n<code class=\"docutils literal notranslate\">GenericIPAddressField</code> where <code class=\"docutils literal notranslate\">blank</code> is allowed but <code class=\"docutils literal notranslate\">null</code> is not\nwill trigger a model validation error because <code class=\"docutils literal notranslate\">blank</code> values are always\nstored as <code class=\"docutils literal notranslate\">null</code>. Previously, storing a <code class=\"docutils literal notranslate\">blank</code> value in a field which\ndid not allow <code class=\"docutils literal notranslate\">null</code> would cause a database exception at runtime.</p></li>\n<li><p>If a <code class=\"docutils literal notranslate\">NoReverseMatch</code> exception is raised from a method when rendering a\ntemplate, it is not silenced. For example, <code class=\"docutils literal notranslate\">{{ obj.view_href }}</code> will\ncause template rendering to fail if <code class=\"docutils literal notranslate\">view_href()</code> raises\n<code class=\"docutils literal notranslate\">NoReverseMatch</code>. There is no change to the <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> tag, it\ncauses template rendering to fail like always when <code class=\"docutils literal notranslate\">NoReverseMatch</code> is\nraised.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.Client.logout\" title=\"django.test.Client.logout\"><code class=\"xref py py-meth docutils literal notranslate\">django.test.Client.logout()</code></a> now calls\n<a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#django.contrib.auth.logout\" title=\"django.contrib.auth.logout\"><code class=\"xref py py-meth docutils literal notranslate\">django.contrib.auth.logout()</code></a> which will send the\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/auth/#django.contrib.auth.signals.user_logged_out\" title=\"django.contrib.auth.signals.user_logged_out\"><code class=\"xref py py-func docutils literal notranslate\">user_logged_out()</code></a> signal.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#built-in-auth-views\"><span class=\"std std-ref\">Authentication views</span></a> are now reversed by name,\nnot their locations in <code class=\"docutils literal notranslate\">django.contrib.auth.views</code>. If you are using the\nviews without a <code class=\"docutils literal notranslate\">name</code>, you should update your <code class=\"docutils literal notranslate\">urlpatterns</code> to use\n<code class=\"docutils literal notranslate\">django.conf.urls.url()</code> with the <code class=\"docutils literal notranslate\">name</code> parameter. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^reset/done/$&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;django.contrib.auth.views.password_reset_complete&quot;</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>becomes:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>url<span class=\"p\">(</span>\n    <span class=\"sa\">r</span><span class=\"s2\">&quot;^reset/done/$&quot;</span><span class=\"p\">,</span>\n    <span class=\"s2\">&quot;django.contrib.auth.views.password_reset_complete&quot;</span><span class=\"p\">,</span>\n    name<span class=\"o\">=</span><span class=\"s2\">&quot;password_reset_complete&quot;</span><span class=\"p\">,</span>\n<span class=\"p\">)</span>\n</code></pre></div>\n</li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/base/#django.views.generic.base.RedirectView\" title=\"django.views.generic.base.RedirectView\"><code class=\"xref py py-class docutils literal notranslate\">RedirectView</code></a> now has a <code class=\"docutils literal notranslate\">pattern_name</code>\nattribute which allows it to choose the target by reversing the URL.</p></li>\n<li><p>In Django 1.4 and 1.5, a blank string was unintentionally not considered to\nbe a valid password. This meant\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/auth/#django.contrib.auth.models.User.set_password\" title=\"django.contrib.auth.models.User.set_password\"><code class=\"xref py py-meth docutils literal notranslate\">set_password()</code></a> would save a blank\npassword as an unusable password like\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/auth/#django.contrib.auth.models.User.set_unusable_password\" title=\"django.contrib.auth.models.User.set_unusable_password\"><code class=\"xref py py-meth docutils literal notranslate\">set_unusable_password()</code></a> does, and\nthus <a class=\"reference internal\" href=\"/en/dev/ref/contrib/auth/#django.contrib.auth.models.User.check_password\" title=\"django.contrib.auth.models.User.check_password\"><code class=\"xref py py-meth docutils literal notranslate\">check_password()</code></a> always\nreturned <code class=\"docutils literal notranslate\">False</code> for blank passwords. This has been corrected in this\nrelease: blank passwords are now valid.</p></li>\n<li><p>The admin <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.changelist_view\" title=\"django.contrib.admin.ModelAdmin.changelist_view\"><code class=\"xref py py-attr docutils literal notranslate\">changelist_view</code></a> previously\naccepted a <code class=\"docutils literal notranslate\">pop</code> GET parameter to signify it was to be displayed in a\npopup. This parameter has been renamed to <code class=\"docutils literal notranslate\">_popup</code> to be consistent with\nthe rest of the admin views. You should update your custom templates if they\nuse the previous parameter name.</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-meth docutils literal notranslate\">validate_email()</code></a> now accepts email addresses\nwith <code class=\"docutils literal notranslate\">localhost</code> as the domain.</p></li>\n<li><p>The new <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#cmdoption-makemessages-keep-pot\"><code class=\"xref std std-option docutils literal notranslate\">makemessages --keep-pot</code></a> option prevents deleting the\ntemporary <code class=\"docutils literal notranslate\">.pot</code> file generated before creating the <code class=\"docutils literal notranslate\">.po</code> file.</p></li>\n<li><p>The undocumented <code class=\"docutils literal notranslate\">django.core.servers.basehttp.WSGIServerException</code> has\nbeen removed. Use <code class=\"docutils literal notranslate\">socket.error</code> provided by the standard library instead.\nThis change was also released in Django 1.5.5.</p></li>\n<li><p>The signature of\n<a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/base/#django.views.generic.base.RedirectView.get_redirect_url\" title=\"django.views.generic.base.RedirectView.get_redirect_url\"><code class=\"xref py py-meth docutils literal notranslate\">django.views.generic.base.RedirectView.get_redirect_url()</code></a> has changed\nand now accepts positional arguments as well (<code class=\"docutils literal notranslate\">*args, **kwargs</code>). Any\nunnamed captured group will now be passed to <code class=\"docutils literal notranslate\">get_redirect_url()</code> which may\nresult in a <code class=\"docutils literal notranslate\">TypeError</code> if you don’t update the signature of your custom\nmethod.</p></li>\n</ul>\n</section>\n</section>\n<section id=\"features-deprecated-in-1-6\">\n<span id=\"deprecated-features-1-6\"></span><h2>Features deprecated in 1.6<a class=\"heading-anchor\" href=\"#features-deprecated-in-1-6\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"transaction-management-apis\">\n<h3>Transaction management APIs<a class=\"heading-anchor\" href=\"#transaction-management-apis\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Transaction management was completely overhauled in Django 1.6, and the\ncurrent APIs are deprecated:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">django.middleware.transaction.TransactionMiddleware</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">django.db.transaction.autocommit</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">django.db.transaction.commit_on_success</code></p></li>\n<li><p><code class=\"docutils literal notranslate\">django.db.transaction.commit_manually</code></p></li>\n<li><p>the <code class=\"docutils literal notranslate\">TRANSACTIONS_MANAGED</code> setting</p></li>\n</ul>\n</section>\n<section id=\"django-contrib-comments\">\n<h3><code class=\"docutils literal notranslate\">django.contrib.comments</code><a class=\"heading-anchor\" href=\"#django-contrib-comments\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django’s comment framework has been deprecated and is no longer supported. It\nwill be available in Django 1.6 and 1.7, and removed in Django 1.8. Most users\nwill be better served with a custom solution, or a hosted product like\n<a class=\"reference external\" href=\"https://disqus.com/\">Disqus</a>.</p>\n<p>The code formerly known as <code class=\"docutils literal notranslate\">django.contrib.comments</code> is <a class=\"reference external\" href=\"https://github.com/django/django-contrib-comments\">still available\nin an external repository</a>.</p>\n</section>\n<section id=\"support-for-postgresql-versions-older-than-8-4\">\n<h3>Support for PostgreSQL versions older than 8.4<a class=\"heading-anchor\" href=\"#support-for-postgresql-versions-older-than-8-4\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The end of upstream support periods was reached in December 2011 for\nPostgreSQL 8.2 and in February 2013 for 8.3. As a consequence, Django 1.6 sets\n8.4 as the minimum PostgreSQL version it officially supports.</p>\n<p>You’re strongly encouraged to use the most recent version of PostgreSQL\navailable, because of performance improvements and to take advantage of the\nnative streaming replication available in PostgreSQL 9.x.</p>\n</section>\n<section id=\"changes-to-cycle-and-firstof\">\n<h3>Changes to <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-cycle\"><code class=\"xref std std-ttag docutils literal notranslate\">cycle</code></a> and <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-firstof\"><code class=\"xref std std-ttag docutils literal notranslate\">firstof</code></a><a class=\"heading-anchor\" href=\"#changes-to-cycle-and-firstof\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The template system generally escapes all variables to avoid XSS attacks.\nHowever, due to an accident of history, the <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-cycle\"><code class=\"xref std std-ttag docutils literal notranslate\">cycle</code></a> and <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-firstof\"><code class=\"xref std std-ttag docutils literal notranslate\">firstof</code></a>\ntags render their arguments as-is.</p>\n<p>Django 1.6 starts a process to correct this inconsistency. The <code class=\"docutils literal notranslate\">future</code>\ntemplate library provides alternate implementations of <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-cycle\"><code class=\"xref std std-ttag docutils literal notranslate\">cycle</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-firstof\"><code class=\"xref std std-ttag docutils literal notranslate\">firstof</code></a> that autoescape their inputs. If you’re using these tags,\nyou’re encouraged to include the following line at the top of your templates to\nenable the new behavior:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">load</span> <span class=\"nv\">cycle</span> <span class=\"nv\">from</span> <span class=\"nv\">future</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>or:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">load</span> <span class=\"nv\">firstof</span> <span class=\"nv\">from</span> <span class=\"nv\">future</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>The tags implementing the old behavior have been deprecated, and in Django\n1.8, the old behavior will be replaced with the new behavior. To ensure\ncompatibility with future versions of Django, existing templates should be\nmodified to use the <code class=\"docutils literal notranslate\">future</code> versions.</p>\n<p>If necessary, you can temporarily disable auto-escaping with\n<a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.safestring.mark_safe\" title=\"django.utils.safestring.mark_safe\"><code class=\"xref py py-func docutils literal notranslate\">mark_safe()</code></a> or <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-autoescape\"><code class=\"xref std std-ttag docutils literal notranslate\">{% autoescape off %}</code></a>.</p>\n</section>\n<section id=\"cache-middleware-anonymous-only-setting\">\n<h3><code class=\"docutils literal notranslate\">CACHE_MIDDLEWARE_ANONYMOUS_ONLY</code> setting<a class=\"heading-anchor\" href=\"#cache-middleware-anonymous-only-setting\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">CacheMiddleware</code> and <code class=\"docutils literal notranslate\">UpdateCacheMiddleware</code> used to provide a way to\ncache requests only if they weren’t made by a logged-in user. This mechanism\nwas largely ineffective because the middleware correctly takes into account the\n<code class=\"docutils literal notranslate\">Vary: Cookie</code> HTTP header, and this header is being set on a variety of\noccasions, such as:</p>\n<ul class=\"simple\">\n<li><p>accessing the session, or</p></li>\n<li><p>using CSRF protection, which is turned on by default, or</p></li>\n<li><p>using a client-side library which sets cookies, like <a class=\"reference external\" href=\"https://marketingplatform.google.com/about/analytics/\">Google Analytics</a>.</p></li>\n</ul>\n<p>This makes the cache effectively work on a per-session basis regardless of the\n<code class=\"docutils literal notranslate\">CACHE_MIDDLEWARE_ANONYMOUS_ONLY</code> setting.</p>\n</section>\n<section id=\"send-broken-link-emails-setting\">\n<h3><code class=\"docutils literal notranslate\">SEND_BROKEN_LINK_EMAILS</code> setting<a class=\"heading-anchor\" href=\"#send-broken-link-emails-setting\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.middleware.common.CommonMiddleware\" title=\"django.middleware.common.CommonMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">CommonMiddleware</code></a> used to provide basic\nreporting of broken links by email when <code class=\"docutils literal notranslate\">SEND_BROKEN_LINK_EMAILS</code> is set to\n<code class=\"docutils literal notranslate\">True</code>.</p>\n<p>Because of intractable ordering problems between\n<a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.middleware.common.CommonMiddleware\" title=\"django.middleware.common.CommonMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">CommonMiddleware</code></a> and\n<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>, this feature was split\nout into a new middleware:\n<a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.middleware.common.BrokenLinkEmailsMiddleware\" title=\"django.middleware.common.BrokenLinkEmailsMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">BrokenLinkEmailsMiddleware</code></a>.</p>\n<p>If you’re relying on this feature, you should add\n<code class=\"docutils literal notranslate\">'django.middleware.common.BrokenLinkEmailsMiddleware'</code> to your\n<code class=\"docutils literal notranslate\">MIDDLEWARE_CLASSES</code> setting and remove <code class=\"docutils literal notranslate\">SEND_BROKEN_LINK_EMAILS</code>\nfrom your settings.</p>\n</section>\n<section id=\"has-changed-method-on-widgets\">\n<h3><code class=\"docutils literal notranslate\">_has_changed</code> method on widgets<a class=\"heading-anchor\" href=\"#has-changed-method-on-widgets\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>If you defined your own form widgets and defined the <code class=\"docutils literal notranslate\">_has_changed</code> method\non a widget, you should now define this method on the form field itself.</p>\n</section>\n<section id=\"module-name-model-meta-attribute\">\n<h3><code class=\"docutils literal notranslate\">module_name</code> model _meta attribute<a class=\"heading-anchor\" href=\"#module-name-model-meta-attribute\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">Model._meta.module_name</code> was renamed to <code class=\"docutils literal notranslate\">model_name</code>. Despite being a\nprivate API, it will go through a regular deprecation path.</p>\n</section>\n<section id=\"get-add-change-delete-permission-model-meta-methods\">\n<h3><code class=\"docutils literal notranslate\">get_(add|change|delete)_permission</code> model _meta methods<a class=\"heading-anchor\" href=\"#get-add-change-delete-permission-model-meta-methods\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">Model._meta.get_(add|change|delete)_permission</code> methods were deprecated.\nEven if they were not part of the public API they’ll also go through\na regular deprecation path. You can replace them with\n<code class=\"docutils literal notranslate\">django.contrib.auth.get_permission_codename('action', Model._meta)</code> where\n<code class=\"docutils literal notranslate\">'action'</code> is <code class=\"docutils literal notranslate\">'add'</code>, <code class=\"docutils literal notranslate\">'change'</code>, or <code class=\"docutils literal notranslate\">'delete'</code>.</p>\n</section>\n<section id=\"get-query-set-and-similar-methods-renamed-to-get-queryset\">\n<h3><code class=\"docutils literal notranslate\">get_query_set</code> and similar methods renamed to <code class=\"docutils literal notranslate\">get_queryset</code><a class=\"heading-anchor\" href=\"#get-query-set-and-similar-methods-renamed-to-get-queryset\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Methods that return a <code class=\"docutils literal notranslate\">QuerySet</code> such as <code class=\"docutils literal notranslate\">Manager.get_query_set</code> or\n<code class=\"docutils literal notranslate\">ModelAdmin.queryset</code> have been renamed to <code class=\"docutils literal notranslate\">get_queryset</code>.</p>\n<p>If you are writing a library that implements, for example, a\n<code class=\"docutils literal notranslate\">Manager.get_query_set</code> method, and you need to support old Django versions,\nyou should rename the method and conditionally add an alias with the old name:</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\">CustomManager</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Manager<span class=\"p\">):</span>\n    <span class=\"k\">def</span> <span class=\"nf\">get_queryset</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"k\">pass</span>  <span class=\"c1\"># ...</span>\n\n    <span class=\"k\">if</span> django<span class=\"o\">.</span>VERSION <span class=\"o\">&lt;</span> <span class=\"p\">(</span><span class=\"mi\">1</span><span class=\"p\">,</span> <span class=\"mi\">6</span><span class=\"p\">):</span>\n        get_query_set <span class=\"o\">=</span> get_queryset\n\n    <span class=\"c1\"># For Django &gt;= 1.6, models.Manager provides a get_query_set fallback</span>\n    <span class=\"c1\"># that emits a warning when used.</span>\n</code></pre></div>\n<p>If you are writing a library that needs to call the <code class=\"docutils literal notranslate\">get_queryset</code> method and\nmust support old Django versions, you should write:</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>get_queryset <span class=\"o\">=</span> <span class=\"p\">(</span>\n    some_manager<span class=\"o\">.</span>get_query_set\n    <span class=\"k\">if</span> <span class=\"nb\">hasattr</span><span class=\"p\">(</span>some_manager<span class=\"p\">,</span> <span class=\"s2\">&quot;get_query_set&quot;</span><span class=\"p\">)</span>\n    <span class=\"k\">else</span> some_manager<span class=\"o\">.</span>get_queryset\n<span class=\"p\">)</span>\n<span class=\"k\">return</span> get_queryset<span class=\"p\">()</span>  <span class=\"c1\"># etc</span>\n</code></pre></div>\n<p>In the general case of a custom manager that both implements its own\n<code class=\"docutils literal notranslate\">get_queryset</code> method and calls that method, and needs to work with older\nDjango versions, and libraries that have not been updated yet, it is useful to\ndefine a <code class=\"docutils literal notranslate\">get_queryset_compat</code> method as below and use it internally to your\nmanager:</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\">YourCustomManager</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Manager<span class=\"p\">):</span>\n    <span class=\"k\">def</span> <span class=\"nf\">get_queryset</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"k\">return</span> YourCustomQuerySet<span class=\"p\">()</span>  <span class=\"c1\"># for example</span>\n\n    <span class=\"k\">if</span> django<span class=\"o\">.</span>VERSION <span class=\"o\">&lt;</span> <span class=\"p\">(</span><span class=\"mi\">1</span><span class=\"p\">,</span> <span class=\"mi\">6</span><span class=\"p\">):</span>\n        get_query_set <span class=\"o\">=</span> get_queryset\n\n    <span class=\"k\">def</span> <span class=\"nf\">active</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>  <span class=\"c1\"># for example</span>\n        <span class=\"k\">return</span> <span class=\"bp\">self</span><span class=\"o\">.</span>get_queryset_compat<span class=\"p\">()</span><span class=\"o\">.</span>filter<span class=\"p\">(</span>active<span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">)</span>\n\n    <span class=\"k\">def</span> <span class=\"nf\">get_queryset_compat</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        get_queryset <span class=\"o\">=</span> <span class=\"p\">(</span>\n            <span class=\"bp\">self</span><span class=\"o\">.</span>get_query_set <span class=\"k\">if</span> <span class=\"nb\">hasattr</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">,</span> <span class=\"s2\">&quot;get_query_set&quot;</span><span class=\"p\">)</span> <span class=\"k\">else</span> <span class=\"bp\">self</span><span class=\"o\">.</span>get_queryset\n        <span class=\"p\">)</span>\n        <span class=\"k\">return</span> get_queryset<span class=\"p\">()</span>\n</code></pre></div>\n<p>This helps to minimize the changes that are needed, but also works correctly in\nthe case of subclasses (such as <code class=\"docutils literal notranslate\">RelatedManagers</code> from Django 1.5) which\nmight override either <code class=\"docutils literal notranslate\">get_query_set</code> or <code class=\"docutils literal notranslate\">get_queryset</code>.</p>\n</section>\n<section id=\"shortcut-view-and-urlconf\">\n<h3><code class=\"docutils literal notranslate\">shortcut</code> view and URLconf<a class=\"heading-anchor\" href=\"#shortcut-view-and-urlconf\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">shortcut</code> view was moved from <code class=\"docutils literal notranslate\">django.views.defaults</code> to\n<code class=\"docutils literal notranslate\">django.contrib.contenttypes.views</code> shortly after the 1.0 release, but the\nold location was never deprecated. This oversight was corrected in Django 1.6\nand you should now use the new location.</p>\n<p>The URLconf <code class=\"docutils literal notranslate\">django.conf.urls.shortcut</code> was also deprecated. If you’re\nincluding it in an URLconf, simply replace:</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=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^prefix/&quot;</span><span class=\"p\">,</span> include<span class=\"p\">(</span><span class=\"s2\">&quot;django.conf.urls.shortcut&quot;</span><span class=\"p\">)),</span>\n</code></pre></div>\n<p>with:</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=\"p\">(</span>\n    <span class=\"sa\">r</span><span class=\"s2\">&quot;^prefix/(?P&lt;content_type_id&gt;\\d+)/(?P&lt;object_id&gt;.*)/$&quot;</span><span class=\"p\">,</span>\n    <span class=\"s2\">&quot;django.contrib.contenttypes.views.shortcut&quot;</span><span class=\"p\">,</span>\n<span class=\"p\">),</span>\n</code></pre></div>\n</section>\n<section id=\"modelform-without-fields-or-exclude\">\n<h3><code class=\"docutils literal notranslate\">ModelForm</code> without <code class=\"docutils literal notranslate\">fields</code> or <code class=\"docutils literal notranslate\">exclude</code><a class=\"heading-anchor\" href=\"#modelform-without-fields-or-exclude\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Previously, if you wanted a <a class=\"reference internal\" href=\"/en/dev/topics/forms/modelforms/#django.forms.ModelForm\" title=\"django.forms.ModelForm\"><code class=\"xref py py-class docutils literal notranslate\">ModelForm</code></a> to use all fields\non the model, you could simply omit the <code class=\"docutils literal notranslate\">Meta.fields</code> attribute, and all\nfields would be used.</p>\n<p>This can lead to security problems where fields are added to the model and,\nunintentionally, automatically become editable by end users. In some cases,\nparticular with boolean fields, it is possible for this problem to be\ncompletely invisible. This is a form of <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/Mass_assignment_vulnerability\">Mass assignment vulnerability</a>.</p>\n<p>For this reason, this behavior is deprecated, and using the <code class=\"docutils literal notranslate\">Meta.exclude</code>\noption is strongly discouraged. Instead, all fields that are intended for\ninclusion in the form should be listed explicitly in the <code class=\"docutils literal notranslate\">fields</code> attribute.</p>\n<p>If this security concern really does not apply in your case, there is a\nshortcut to explicitly indicate that all fields should be used - use the\nspecial value <code class=\"docutils literal notranslate\">&quot;__all__&quot;</code> for the fields attribute:</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\">MyModelForm</span><span class=\"p\">(</span>ModelForm<span class=\"p\">):</span>\n    <span class=\"k\">class</span> <span class=\"nc\">Meta</span><span class=\"p\">:</span>\n        fields <span class=\"o\">=</span> <span class=\"s2\">&quot;__all__&quot;</span>\n        model <span class=\"o\">=</span> MyModel\n</code></pre></div>\n<p>If you have custom <code class=\"docutils literal notranslate\">ModelForms</code> that only need to be used in the admin, there\nis another option. The admin has its own methods for defining fields\n(<code class=\"docutils literal notranslate\">fieldsets</code> etc.), and so adding a list of fields to the <code class=\"docutils literal notranslate\">ModelForm</code> is\nredundant. Instead, simply omit the <code class=\"docutils literal notranslate\">Meta</code> inner class of the <code class=\"docutils literal notranslate\">ModelForm</code>,\nor omit the <code class=\"docutils literal notranslate\">Meta.model</code> attribute. Since the <code class=\"docutils literal notranslate\">ModelAdmin</code> subclass knows\nwhich model it is for, it can add the necessary attributes to derive a\nfunctioning <code class=\"docutils literal notranslate\">ModelForm</code>. This behavior also works for earlier Django\nversions.</p>\n</section>\n<section id=\"updateview-and-createview-without-explicit-fields\">\n<h3><code class=\"docutils literal notranslate\">UpdateView</code> and <code class=\"docutils literal notranslate\">CreateView</code> without explicit fields<a class=\"heading-anchor\" href=\"#updateview-and-createview-without-explicit-fields\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The generic views <a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/generic-editing/#django.views.generic.edit.CreateView\" title=\"django.views.generic.edit.CreateView\"><code class=\"xref py py-class docutils literal notranslate\">CreateView</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/generic-editing/#django.views.generic.edit.UpdateView\" title=\"django.views.generic.edit.UpdateView\"><code class=\"xref py py-class docutils literal notranslate\">UpdateView</code></a>, and anything else derived from\n<a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/mixins-editing/#django.views.generic.edit.ModelFormMixin\" title=\"django.views.generic.edit.ModelFormMixin\"><code class=\"xref py py-class docutils literal notranslate\">ModelFormMixin</code></a>, are vulnerable to the\nsecurity problem described in the section above, because they can automatically\ncreate a <code class=\"docutils literal notranslate\">ModelForm</code> that uses all fields for a model.</p>\n<p>For this reason, if you use these views for editing models, you must also\nsupply the <code class=\"docutils literal notranslate\">fields</code> attribute (new in Django 1.6), which is a list of model\nfields and works in the same way as the <a class=\"reference internal\" href=\"/en/dev/topics/forms/modelforms/#django.forms.ModelForm\" title=\"django.forms.ModelForm\"><code class=\"xref py py-class docutils literal notranslate\">ModelForm</code></a>\n<code class=\"docutils literal notranslate\">Meta.fields</code> attribute. Alternatively, you can set the <code class=\"docutils literal notranslate\">form_class</code>\nattribute to a <code class=\"docutils literal notranslate\">ModelForm</code> that explicitly defines the fields to be used.\nDefining an <code class=\"docutils literal notranslate\">UpdateView</code> or <code class=\"docutils literal notranslate\">CreateView</code> subclass to be used with a model\nbut without an explicit list of fields is deprecated.</p>\n</section>\n<section id=\"munging-of-help-text-of-model-form-fields-for-manytomanyfield-fields\">\n<span id=\"m2m-help-text-deprecation\"></span><h3>Munging of help text of model form fields for <code class=\"docutils literal notranslate\">ManyToManyField</code> fields<a class=\"heading-anchor\" href=\"#munging-of-help-text-of-model-form-fields-for-manytomanyfield-fields\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>All special handling of the <code class=\"docutils literal notranslate\">help_text</code> attribute of <code class=\"docutils literal notranslate\">ManyToManyField</code>\nmodel fields performed by standard model or model form fields as described in\n<a class=\"reference internal\" href=\"#m2m-help-text\"><span class=\"std std-ref\">Help text of model form fields for ManyToManyField fields</span></a> above is deprecated and will be removed in Django 1.8.</p>\n<p>Help text of these fields will need to be handled either by applications,\ncustom form fields or widgets, just like happens with the rest of the model\nfield types.</p>\n</section>\n</section>","rootId":"django-1-6-release-notes","toc":[{"title":"Python compatibility","anchor":"python-compatibility","children":[]},{"title":"What’s new in Django 1.6","anchor":"what-s-new-in-django-1-6","children":[{"title":"Simplified default project and app templates","anchor":"simplified-default-project-and-app-templates","children":[]},{"title":"Improved transaction management","anchor":"improved-transaction-management","children":[]},{"title":"Persistent database connections","anchor":"persistent-database-connections","children":[]},{"title":"Discovery of tests in any test module","anchor":"discovery-of-tests-in-any-test-module","children":[]},{"title":"Time zone aware aggregation","anchor":"time-zone-aware-aggregation","children":[]},{"title":"Support for savepoints in SQLite","anchor":"support-for-savepoints-in-sqlite","children":[]},{"title":"BinaryField model field","anchor":"binaryfield-model-field","children":[]},{"title":"GeoDjango form widgets","anchor":"geodjango-form-widgets","children":[]},{"title":"check management command added for verifying compatibility","anchor":"check-management-command-added-for-verifying-compatibility","children":[]},{"title":"Model.save() algorithm changed","anchor":"model-save-algorithm-changed","children":[]},{"title":"Minor features","anchor":"minor-features","children":[]}]},{"title":"Backwards incompatible changes in 1.6","anchor":"backwards-incompatible-changes-in-1-6","children":[{"title":"New transaction management model","anchor":"new-transaction-management-model","children":[{"title":"Behavior changes","anchor":"behavior-changes","children":[]},{"title":"Savepoints and assertNumQueries","anchor":"savepoints-and-assertnumqueries","children":[]},{"title":"Autocommit option for PostgreSQL","anchor":"autocommit-option-for-postgresql","children":[]}]},{"title":"New test runner","anchor":"new-test-runner","children":[]},{"title":"Removal of django.contrib.gis.tests.GeoDjangoTestSuiteRunner GeoDjango custom test runner","anchor":"removal-of-django-contrib-gis-tests-geodjangotestsuiterunner-geodjango-custom-test-runner","children":[]},{"title":"Custom user models in tests","anchor":"custom-user-models-in-tests","children":[]},{"title":"Time zone-aware day, month, and week_day lookups","anchor":"time-zone-aware-day-month-and-week-day-lookups","children":[]},{"title":"Addition of QuerySet.datetimes()","anchor":"addition-of-queryset-datetimes","children":[{"title":"QuerySet.dates() returns date objects","anchor":"queryset-dates-returns-date-objects","children":[]},{"title":"QuerySet.dates() no longer usable on DateTimeField","anchor":"queryset-dates-no-longer-usable-on-datetimefield","children":[]},{"title":"date_hierarchy requires time zone definitions","anchor":"date-hierarchy-requires-time-zone-definitions","children":[]},{"title":"date_list in generic views requires time zone definitions","anchor":"date-list-in-generic-views-requires-time-zone-definitions","children":[]}]},{"title":"New lookups may clash with model fields","anchor":"new-lookups-may-clash-with-model-fields","children":[]},{"title":"BooleanField no longer defaults to False","anchor":"booleanfield-no-longer-defaults-to-false","children":[]},{"title":"Translations and comments in templates","anchor":"translations-and-comments-in-templates","children":[{"title":"Extraction of translations after comments","anchor":"extraction-of-translations-after-comments","children":[]},{"title":"Location of translator comments","anchor":"location-of-translator-comments","children":[]}]},{"title":"Quoting in reverse()","anchor":"quoting-in-reverse","children":[]},{"title":"Storage of IP addresses in the comments app","anchor":"storage-of-ip-addresses-in-the-comments-app","children":[]},{"title":"Percent literals in cursor.execute queries","anchor":"percent-literals-in-cursor-execute-queries","children":[]},{"title":"Help text of model form fields for ManyToManyField fields","anchor":"help-text-of-model-form-fields-for-manytomanyfield-fields","children":[]},{"title":"QuerySet iteration","anchor":"queryset-iteration","children":[]},{"title":"BoundField.label_tag now includes the form’s label_suffix","anchor":"boundfield-label-tag-now-includes-the-form-s-label-suffix","children":[]},{"title":"Admin views _changelist_filters GET parameter","anchor":"admin-views-changelist-filters-get-parameter","children":[]},{"title":"django.contrib.auth password reset uses base 64 encoding of User PK","anchor":"django-contrib-auth-password-reset-uses-base-64-encoding-of-user-pk","children":[]},{"title":"Default session serialization switched to JSON","anchor":"default-session-serialization-switched-to-json","children":[]},{"title":"Object Relational Mapper changes","anchor":"object-relational-mapper-changes","children":[]},{"title":"Miscellaneous","anchor":"miscellaneous","children":[]}]},{"title":"Features deprecated in 1.6","anchor":"features-deprecated-in-1-6","children":[{"title":"Transaction management APIs","anchor":"transaction-management-apis","children":[]},{"title":"django.contrib.comments","anchor":"django-contrib-comments","children":[]},{"title":"Support for PostgreSQL versions older than 8.4","anchor":"support-for-postgresql-versions-older-than-8-4","children":[]},{"title":"Changes to cycle and firstof","anchor":"changes-to-cycle-and-firstof","children":[]},{"title":"CACHE_MIDDLEWARE_ANONYMOUS_ONLY setting","anchor":"cache-middleware-anonymous-only-setting","children":[]},{"title":"SEND_BROKEN_LINK_EMAILS setting","anchor":"send-broken-link-emails-setting","children":[]},{"title":"_has_changed method on widgets","anchor":"has-changed-method-on-widgets","children":[]},{"title":"module_name model _meta attribute","anchor":"module-name-model-meta-attribute","children":[]},{"title":"get_(add|change|delete)_permission model _meta methods","anchor":"get-add-change-delete-permission-model-meta-methods","children":[]},{"title":"get_query_set and similar methods renamed to get_queryset","anchor":"get-query-set-and-similar-methods-renamed-to-get-queryset","children":[]},{"title":"shortcut view and URLconf","anchor":"shortcut-view-and-urlconf","children":[]},{"title":"ModelForm without fields or exclude","anchor":"modelform-without-fields-or-exclude","children":[]},{"title":"UpdateView and CreateView without explicit fields","anchor":"updateview-and-createview-without-explicit-fields","children":[]},{"title":"Munging of help text of model form fields for ManyToManyField fields","anchor":"munging-of-help-text-of-model-form-fields-for-manytomanyfield-fields","children":[]}]}],"breadcrumbs":[{"docname":"releases/index","title":"Release notes","url":"/en/dev/releases/"}],"prev":{"docname":"releases/1.6.1","title":"Django 1.6.1 release notes","url":"/en/dev/releases/1.6.1/"},"next":{"docname":"releases/1.5.12","title":"Django 1.5.12 release notes","url":"/en/dev/releases/1.5.12/"},"formats":{"html":"/en/dev/releases/1.6/","markdown":"/en/dev/releases/1.6.md","json":"/en/dev/releases/1.6.json"},"source":"https://github.com/django/django/blob/main/docs/releases/1.6.txt","official":"https://docs.djangoproject.com/en/dev/releases/1.6/","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"]}