{"title":"Django 1.6.3 release notes","version":"dev","locale":"en","docname":"releases/1.6.3","url":"/en/dev/releases/1.6.3/","canonical":"https://djangodocs.dev/en/dev/releases/1.6.3/","summary":"Django 1.6.3 fixes several bugs in 1.6.2, including three security issues, and makes one backwards-incompatible change.","html":"<h1>Django 1.6.3 release notes<a class=\"heading-anchor\" href=\"#django-1-6-3-release-notes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p><em>April 21, 2014</em></p>\n<p>Django 1.6.3 fixes several bugs in 1.6.2, including three security issues,\nand makes one backwards-incompatible change:</p>\n<section id=\"unexpected-code-execution-using-reverse\">\n<h2>Unexpected code execution using <code class=\"docutils literal notranslate\">reverse()</code><a class=\"heading-anchor\" href=\"#unexpected-code-execution-using-reverse\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django’s URL handling is based on a mapping of regex patterns\n(representing the URLs) to callable views, and Django’s own processing\nconsists of matching a requested URL against those patterns to\ndetermine the appropriate view to invoke.</p>\n<p>Django also provides a convenience function – <code class=\"docutils literal notranslate\">reverse()</code> – which performs\nthis process in the opposite direction. The <code class=\"docutils literal notranslate\">reverse()</code> function takes\ninformation about a view and returns a URL which would invoke that view. Use\nof <code class=\"docutils literal notranslate\">reverse()</code> is encouraged for application developers, as the output of\n<code class=\"docutils literal notranslate\">reverse()</code> is always based on the current URL patterns, meaning developers\ndo not need to change other code when making changes to URLs.</p>\n<p>One argument signature for <code class=\"docutils literal notranslate\">reverse()</code> is to pass a dotted Python\npath to the desired view. In this situation, Django will import the\nmodule indicated by that dotted path as part of generating the\nresulting URL. If such a module has import-time side effects, those\nside effects will occur.</p>\n<p>Thus it is possible for an attacker to cause unexpected code\nexecution, given the following conditions:</p>\n<ol class=\"arabic simple\">\n<li><p>One or more views are present which construct a URL based on user\ninput (commonly, a “next” parameter in a querystring indicating\nwhere to redirect upon successful completion of an action).</p></li>\n<li><p>One or more modules are known to an attacker to exist on the\nserver’s Python import path, which perform code execution with side\neffects on importing.</p></li>\n</ol>\n<p>To remedy this, <code class=\"docutils literal notranslate\">reverse()</code> will now only accept and import dotted\npaths based on the view-containing modules listed in the project’s <a class=\"reference internal\" href=\"/en/dev/topics/http/urls/\"><span class=\"doc\">URL\npattern configuration</span></a>, so as to ensure that only modules\nthe developer intended to be imported in this fashion can or will be imported.</p>\n</section>\n<section id=\"caching-of-anonymous-pages-could-reveal-csrf-token\">\n<h2>Caching of anonymous pages could reveal CSRF token<a class=\"heading-anchor\" href=\"#caching-of-anonymous-pages-could-reveal-csrf-token\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django includes both a <a class=\"reference internal\" href=\"/en/dev/topics/cache/\"><span class=\"doc\">caching framework</span></a> and a system\nfor <a class=\"reference internal\" href=\"/en/dev/ref/csrf/\"><span class=\"doc\">preventing cross-site request forgery (CSRF) attacks</span></a>. The CSRF-protection system is based on a random nonce\nsent to the client in a cookie which must be sent by the client on future\nrequests and, in forms, a hidden value which must be submitted back with the\nform.</p>\n<p>The caching framework includes an option to cache responses to\nanonymous (i.e., unauthenticated) clients.</p>\n<p>When the first anonymous request to a given page is by a client which\ndid not have a CSRF cookie, the cache framework will also cache the\nCSRF cookie and serve the same nonce to other anonymous clients who\ndo not have a CSRF cookie. This can allow an attacker to obtain a\nvalid CSRF cookie value and perform attacks which bypass the check for\nthe cookie.</p>\n<p>To remedy this, the caching framework will no longer cache such\nresponses. The heuristic for this will be:</p>\n<ol class=\"arabic simple\">\n<li><p>If the incoming request did not submit any cookies, and</p></li>\n<li><p>If the response did send one or more cookies, and</p></li>\n<li><p>If the <code class=\"docutils literal notranslate\">Vary: Cookie</code> header is set on the response, then the\nresponse will not be cached.</p></li>\n</ol>\n</section>\n<section id=\"mysql-typecasting\">\n<h2>MySQL typecasting<a class=\"heading-anchor\" href=\"#mysql-typecasting\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>The MySQL database is known to “typecast” on certain queries; for\nexample, when querying a table which contains string values, but using\na query which filters based on an integer value, MySQL will first\nsilently coerce the strings to integers and return a result based on that.</p>\n<p>If a query is performed without first converting values to the\nappropriate type, this can produce unexpected results, similar to what\nwould occur if the query itself had been manipulated.</p>\n<p>Django’s model field classes are aware of their own types and most\nsuch classes perform explicit conversion of query arguments to the\ncorrect database-level type before querying. However, three model\nfield classes did not correctly convert their arguments:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.FilePathField\" title=\"django.db.models.FilePathField\"><code class=\"xref py py-class docutils literal notranslate\">FilePathField</code></a></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></p></li>\n<li><p><code class=\"docutils literal notranslate\">IPAddressField</code></p></li>\n</ul>\n<p>These three fields have been updated to convert their arguments to the\ncorrect types before querying.</p>\n<p>Additionally, developers of custom model fields are now warned via\ndocumentation to ensure their custom field classes will perform\nappropriate type conversions, and users of the <a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.raw\" title=\"django.db.models.query.QuerySet.raw\"><code class=\"xref py py-meth docutils literal notranslate\">raw()</code></a> and <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\">extra()</code></a> query methods – which allow the\ndeveloper to supply raw SQL or SQL fragments – will be advised to ensure they\nperform appropriate manual type conversions prior to executing queries.</p>\n</section>\n<section id=\"select-for-update-requires-a-transaction\">\n<h2><code class=\"docutils literal notranslate\">select_for_update()</code> requires a transaction<a class=\"heading-anchor\" href=\"#select-for-update-requires-a-transaction\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Historically, queries that use\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.select_for_update\" title=\"django.db.models.query.QuerySet.select_for_update\"><code class=\"xref py py-meth docutils literal notranslate\">select_for_update()</code></a> could be\nexecuted in autocommit mode, outside of a transaction. Before Django\n1.6, Django’s automatic transactions mode allowed this to be used to\nlock records until the next write operation. Django 1.6 introduced\ndatabase-level autocommit; since then, execution in such a context\nvoids the effect of <code class=\"docutils literal notranslate\">select_for_update()</code>. It is, therefore, assumed\nnow to be an error and raises an exception.</p>\n<p>This change was made because such errors can be caused by including an\napp which expects global transactions (e.g. <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-DATABASE-ATOMIC_REQUESTS\"><code class=\"xref std std-setting docutils literal notranslate\">ATOMIC_REQUESTS</code></a> set to <code class=\"docutils literal notranslate\">True</code>), or Django’s old autocommit\nbehavior, in a project which runs without them; and further, such\nerrors may manifest as data-corruption bugs.</p>\n<p>This change may cause test failures if you use <code class=\"docutils literal notranslate\">select_for_update()</code>\nin a test class which is a subclass of\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.TransactionTestCase\" title=\"django.test.TransactionTestCase\"><code class=\"xref py py-class docutils literal notranslate\">TransactionTestCase</code></a> rather than\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.TestCase\" title=\"django.test.TestCase\"><code class=\"xref py py-class docutils literal notranslate\">TestCase</code></a>.</p>\n</section>\n<section id=\"other-bugfixes-and-changes\">\n<h2>Other bugfixes and changes<a class=\"heading-anchor\" href=\"#other-bugfixes-and-changes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<ul class=\"simple\">\n<li><p>Content retrieved from the GeoIP library is now properly decoded from its\ndefault <code class=\"docutils literal notranslate\">iso-8859-1</code> encoding\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/21996\">#21996</a>).</p></li>\n<li><p>Fixed <code class=\"docutils literal notranslate\">AttributeError</code> when using\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.bulk_create\" title=\"django.db.models.query.QuerySet.bulk_create\"><code class=\"xref py py-meth docutils literal notranslate\">bulk_create()</code></a> with <code class=\"docutils literal notranslate\">ForeignObject</code>\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/21566\">#21566</a>).</p></li>\n<li><p>Fixed crash of <code class=\"docutils literal notranslate\">QuerySet</code>s that use <code class=\"docutils literal notranslate\">F() + timedelta()</code> when their query\nwas compiled more once\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/21643\">#21643</a>).</p></li>\n<li><p>Prevented custom <code class=\"docutils literal notranslate\">widget</code> class attribute of\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> subclasses from being overwritten by the\ncode in their <code class=\"docutils literal notranslate\">__init__</code> method\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/22245\">#22245</a>).</p></li>\n<li><p>Improved <a class=\"reference internal\" href=\"/en/dev/ref/utils/#django.utils.html.strip_tags\" title=\"django.utils.html.strip_tags\"><code class=\"xref py py-func docutils literal notranslate\">strip_tags()</code></a> accuracy (but it still cannot\nguarantee an HTML-safe result, as stated in the documentation).</p></li>\n<li><p>Fixed a regression in the <a class=\"reference internal\" href=\"/en/dev/ref/contrib/gis/#module-django.contrib.gis\" title=\"django.contrib.gis: Geographic Information System (GIS) extensions for Django\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.gis</code></a> SQL compiler for\nnon-concrete fields (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/22250\">#22250</a>).</p></li>\n<li><p>Fixed <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\">ModelAdmin.preserve_filters</code></a> when running a site with\na URL prefix (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/21795\">#21795</a>).</p></li>\n<li><p>Fixed a crash in the <code class=\"docutils literal notranslate\">find_command</code> management utility when the <code class=\"docutils literal notranslate\">PATH</code>\nenvironment variable wasn’t set\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/22256\">#22256</a>).</p></li>\n<li><p>Fixed <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-changepassword\"><code class=\"xref std std-djadmin docutils literal notranslate\">changepassword</code></a> on Windows\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/22364\">#22364</a>).</p></li>\n<li><p>Avoided shadowing deadlock exceptions on MySQL\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/22291\">#22291</a>).</p></li>\n<li><p>Wrapped database exceptions in <code class=\"docutils literal notranslate\">_set_autocommit</code>\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/22321\">#22321</a>).</p></li>\n<li><p>Fixed atomicity when closing a database connection or when the database\nserver disconnects (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/21239\">#21239</a> and <a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/21202\">#21202</a>)</p></li>\n<li><p>Fixed regression in <code class=\"docutils literal notranslate\">prefetch_related</code> that caused the related objects\nquery to include an unnecessary join\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/21760\">#21760</a>).</p></li>\n</ul>\n<p>Additionally, Django’s vendored version of six, <code class=\"docutils literal notranslate\">django.utils.six</code> has been\nupgraded to the latest release (1.6.1).</p>\n</section>","rootId":"django-1-6-3-release-notes","toc":[{"title":"Unexpected code execution using reverse()","anchor":"unexpected-code-execution-using-reverse","children":[]},{"title":"Caching of anonymous pages could reveal CSRF token","anchor":"caching-of-anonymous-pages-could-reveal-csrf-token","children":[]},{"title":"MySQL typecasting","anchor":"mysql-typecasting","children":[]},{"title":"select_for_update() requires a transaction","anchor":"select-for-update-requires-a-transaction","children":[]},{"title":"Other bugfixes and changes","anchor":"other-bugfixes-and-changes","children":[]}],"breadcrumbs":[{"docname":"releases/index","title":"Release notes","url":"/en/dev/releases/"}],"prev":{"docname":"releases/1.6.4","title":"Django 1.6.4 release notes","url":"/en/dev/releases/1.6.4/"},"next":{"docname":"releases/1.6.2","title":"Django 1.6.2 release notes","url":"/en/dev/releases/1.6.2/"},"formats":{"html":"/en/dev/releases/1.6.3/","markdown":"/en/dev/releases/1.6.3.md","json":"/en/dev/releases/1.6.3.json"},"source":"https://github.com/django/django/blob/main/docs/releases/1.6.3.txt","official":"https://docs.djangoproject.com/en/dev/releases/1.6.3/","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"]}