{"title":"Django 1.4 release notes","version":"dev","locale":"en","docname":"releases/1.4","url":"/en/dev/releases/1.4/","canonical":"https://djangodocs.dev/en/dev/releases/1.4/","summary":"Welcome to Django 1.4! 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.4 release notes<a class=\"heading-anchor\" href=\"#django-1-4-release-notes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p><em>March 23, 2012</em></p>\n<p>Welcome to Django 1.4!</p>\n<p>These release notes cover the <a class=\"reference internal\" href=\"#whats-new-1-4\"><span class=\"std std-ref\">new features</span></a>, as well as\nsome <a class=\"reference internal\" href=\"#backwards-incompatible-1-4\"><span class=\"std std-ref\">backwards incompatible changes</span></a> you’ll\nwant to be aware of when upgrading from Django 1.3 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-4\"><span class=\"std std-ref\">our deprecation plan</span></a>, and we’ve <a class=\"reference internal\" href=\"#deprecated-features-1-4\"><span class=\"std std-ref\">begun the deprecation process\nfor some features</span></a>.</p>\n<section id=\"overview\">\n<h2>Overview<a class=\"heading-anchor\" href=\"#overview\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>The biggest new feature in Django 1.4 is <a class=\"reference internal\" href=\"#support-for-time-zones\">support for time zones</a> when\nhandling date/times. When enabled, this Django will store date/times in UTC,\nuse timezone-aware objects internally, and translate them to users’ local\ntimezones for display.</p>\n<p>If you’re upgrading an existing project to Django 1.4, switching to the\ntimezone aware mode may take some care: the new mode disallows some rather\nsloppy behavior that used to be accepted. We encourage anyone who’s upgrading\nto check out the <a class=\"reference internal\" href=\"/en/dev/topics/i18n/timezones/#time-zones-migration-guide\"><span class=\"std std-ref\">timezone migration guide</span></a>\nand the\n<a class=\"reference internal\" href=\"/en/dev/topics/i18n/timezones/#time-zones-faq\"><span class=\"std std-ref\">timezone FAQ</span></a> for useful pointers.</p>\n<p>Other notable new features in Django 1.4 include:</p>\n<ul class=\"simple\">\n<li><p>A number of ORM improvements, including <a class=\"reference internal\" href=\"#select-for-update-support\">SELECT FOR UPDATE support</a>,\nthe ability to <a class=\"reference external\" href=\"#model-objects-bulk-create-in-the-orm\">bulk insert</a>\nlarge datasets for improved performance, and\n<a class=\"reference internal\" href=\"#queryset-prefetch-related\">QuerySet.prefetch_related</a>, a method to batch-load related objects\nin areas where <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>\ndoesn’t work.</p></li>\n<li><p>Some nice security additions, including <a class=\"reference internal\" href=\"#improved-password-hashing\">improved password hashing</a>\n(featuring <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/PBKDF2\">PBKDF2</a> and <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/Bcrypt\">bcrypt</a> support), new <a class=\"reference internal\" href=\"#tools-for-cryptographic-signing\">tools for cryptographic\nsigning</a>, several <a class=\"reference internal\" href=\"#csrf-improvements\">CSRF improvements</a>, and <a class=\"reference internal\" href=\"#simple-clickjacking-protection\">simple clickjacking\nprotection</a>.</p></li>\n<li><p>An <a class=\"reference internal\" href=\"#updated-default-project-layout-and-manage-py\">updated default project layout and manage.py</a> that removes the “magic”\nfrom prior versions. And for those who don’t like the new layout, you can\nuse <a class=\"reference internal\" href=\"#custom-project-and-app-templates\">custom project and app templates</a> instead!</p></li>\n<li><p><a class=\"reference internal\" href=\"#support-for-in-browser-testing-frameworks\">Support for in-browser testing frameworks</a> (like <a class=\"reference external\" href=\"https://www.selenium.dev/\">Selenium</a>).</p></li>\n<li><p>… and a whole lot more; <a class=\"reference external\" href=\"#what-s-new-in-django-1-4\">see below</a>!</p></li>\n</ul>\n<p>Wherever possible we try to introduce new features in a backwards-compatible\nmanner per <a class=\"reference internal\" href=\"/en/dev/misc/api-stability/\"><span class=\"doc\">our API stability policy</span></a> policy.\nHowever, as with previous releases, Django 1.4 ships with some minor\n<a class=\"reference internal\" href=\"#backwards-incompatible-1-4\"><span class=\"std std-ref\">backwards incompatible changes</span></a>; people\nupgrading from previous versions of Django should read that list carefully.</p>\n</section>\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.4 has dropped support for Python 2.4. Python 2.5 is now the minimum\nrequired Python version. Django is tested and supported on Python 2.5, 2.6 and\n2.7.</p>\n<p>This change should affect only a small number of Django users, as most\noperating-system vendors today are shipping Python 2.5 or newer as their\ndefault version. If you’re still using Python 2.4, however, you’ll need to\nstick to Django 1.3 until you can upgrade. Per <a class=\"reference internal\" href=\"/en/dev/internals/release-process/\"><span class=\"doc\">our support policy</span></a>, Django 1.3 will continue to receive security\nsupport until the release of Django 1.5.</p>\n<p>Django does not support Python 3.x at this time. At some point before the\nrelease of Django 1.4, we plan to publish a document outlining our full\ntimeline for deprecating Python 2.x and moving to Python 3.x.</p>\n</section>\n<section id=\"what-s-new-in-django-1-4\">\n<span id=\"whats-new-1-4\"></span><h2>What’s new in Django 1.4<a class=\"heading-anchor\" href=\"#what-s-new-in-django-1-4\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"support-for-time-zones\">\n<h3>Support for time zones<a class=\"heading-anchor\" href=\"#support-for-time-zones\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>In previous versions, Django used “naive” date/times (that is, date/times\nwithout an associated time zone), leaving it up to each developer to interpret\nwhat a given date/time “really means”. This can cause all sorts of subtle\ntimezone-related bugs.</p>\n<p>In Django 1.4, you can now switch Django into a more correct, time-zone aware\nmode. In this mode, Django stores date and  time information in UTC in the\ndatabase, uses time-zone-aware datetime objects internally and translates them\nto the end user’s time zone in templates and forms. Reasons for using this\nfeature include:</p>\n<ul class=\"simple\">\n<li><p>Customizing date and time display for users around the world.</p></li>\n<li><p>Storing datetimes in UTC for database portability and interoperability.\n(This argument doesn’t apply to PostgreSQL, because it already stores\ntimestamps with time zone information in Django 1.3.)</p></li>\n<li><p>Avoiding data corruption problems around DST transitions.</p></li>\n</ul>\n<p>Time zone support is enabled by default in new projects created with\n<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>. If you want to use this feature in an existing\nproject, read the <a class=\"reference internal\" href=\"/en/dev/topics/i18n/timezones/#time-zones-migration-guide\"><span class=\"std std-ref\">migration guide</span></a>. If you\nencounter problems, there’s a helpful <a class=\"reference internal\" href=\"/en/dev/topics/i18n/timezones/#time-zones-faq\"><span class=\"std std-ref\">FAQ</span></a>.</p>\n</section>\n<section id=\"support-for-in-browser-testing-frameworks\">\n<h3>Support for in-browser testing frameworks<a class=\"heading-anchor\" href=\"#support-for-in-browser-testing-frameworks\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.4 supports integration with in-browser testing frameworks like\n<a class=\"reference external\" href=\"https://www.selenium.dev/\">Selenium</a>. The new <a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.LiveServerTestCase\" title=\"django.test.LiveServerTestCase\"><code class=\"xref py py-class docutils literal notranslate\">django.test.LiveServerTestCase</code></a> base class lets you\ntest the interactions between your site’s front and back ends more\ncomprehensively. See the\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.LiveServerTestCase\" title=\"django.test.LiveServerTestCase\"><code class=\"xref py py-class docutils literal notranslate\">documentation</code></a> for more details and\nconcrete examples.</p>\n</section>\n<section id=\"updated-default-project-layout-and-manage-py\">\n<h3>Updated default project layout and <code class=\"docutils literal notranslate\">manage.py</code><a class=\"heading-anchor\" href=\"#updated-default-project-layout-and-manage-py\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.4 ships with an updated default project layout and <code class=\"docutils literal notranslate\">manage.py</code> file\nfor the <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> management command. These fix some issues with\nthe previous <code class=\"docutils literal notranslate\">manage.py</code> handling of Python import paths that caused double\nimports, trouble moving from development to deployment, and other\ndifficult-to-debug path issues.</p>\n<p>The previous <code class=\"docutils literal notranslate\">manage.py</code> called functions that are now deprecated, and thus\nprojects upgrading to Django 1.4 should update their <code class=\"docutils literal notranslate\">manage.py</code>. (The\nold-style <code class=\"docutils literal notranslate\">manage.py</code> will continue to work as before until Django 1.6. In\n1.5 it will raise <code class=\"docutils literal notranslate\">DeprecationWarning</code>).</p>\n<p>The new recommended <code class=\"docutils literal notranslate\">manage.py</code> file should look like this:</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=\"ch\">#!/usr/bin/env python</span>\n<span class=\"kn\">import</span> <span class=\"nn\">os</span><span class=\"o\">,</span> <span class=\"nn\">sys</span>\n\n<span class=\"k\">if</span> <span class=\"vm\">__name__</span> <span class=\"o\">==</span> <span class=\"s2\">&quot;__main__&quot;</span><span class=\"p\">:</span>\n    os<span class=\"o\">.</span>environ<span class=\"o\">.</span>setdefault<span class=\"p\">(</span><span class=\"s2\">&quot;DJANGO_SETTINGS_MODULE&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;{{ project_name }}.settings&quot;</span><span class=\"p\">)</span>\n\n    <span class=\"kn\">from</span> <span class=\"nn\">django.core.management</span> <span class=\"kn\">import</span> execute_from_command_line\n\n    execute_from_command_line<span class=\"p\">(</span>sys<span class=\"o\">.</span>argv<span class=\"p\">)</span>\n</code></pre></div>\n<p><code class=\"docutils literal notranslate\">{{ project_name }}</code> should be replaced with the Python package name of the\nactual project.</p>\n<p>If settings, URLconfs and apps within the project are imported or referenced\nusing the project name prefix (e.g. <code class=\"docutils literal notranslate\">myproject.settings</code>, <code class=\"docutils literal notranslate\">ROOT_URLCONF =\n&quot;myproject.urls&quot;</code>, etc.), the new <code class=\"docutils literal notranslate\">manage.py</code> will need to be moved one\ndirectory up, so it is outside the project package rather than adjacent to\n<code class=\"docutils literal notranslate\">settings.py</code> and <code class=\"docutils literal notranslate\">urls.py</code>.</p>\n<p>For instance, with the following layout:</p>\n<div class=\"code-block\" data-language=\"text\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Text</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Text code\"><code>manage.py\nmysite/\n    __init__.py\n    settings.py\n    urls.py\n    myapp/\n        __init__.py\n        models.py\n</code></pre></div>\n<p>You could import <code class=\"docutils literal notranslate\">mysite.settings</code>, <code class=\"docutils literal notranslate\">mysite.urls</code>, and <code class=\"docutils literal notranslate\">mysite.myapp</code>,\nbut not <code class=\"docutils literal notranslate\">settings</code>, <code class=\"docutils literal notranslate\">urls</code>, or <code class=\"docutils literal notranslate\">myapp</code> as top-level modules.</p>\n<p>Anything imported as a top-level module can be placed adjacent to the new\n<code class=\"docutils literal notranslate\">manage.py</code>. For instance, to decouple <code class=\"docutils literal notranslate\">myapp</code> from the project module and\nimport it as just <code class=\"docutils literal notranslate\">myapp</code>, place it outside the <code class=\"docutils literal notranslate\">mysite/</code> directory:</p>\n<div class=\"code-block\" data-language=\"text\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Text</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Text code\"><code>manage.py\nmyapp/\n    __init__.py\n    models.py\nmysite/\n    __init__.py\n    settings.py\n    urls.py\n</code></pre></div>\n<p>If the same code is imported inconsistently (some places with the project\nprefix, some places without it), the imports will need to be cleaned up when\nswitching to the new <code class=\"docutils literal notranslate\">manage.py</code>.</p>\n</section>\n<section id=\"custom-project-and-app-templates\">\n<h3>Custom project and app templates<a class=\"heading-anchor\" href=\"#custom-project-and-app-templates\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-startapp\"><code class=\"xref std std-djadmin docutils literal notranslate\">startapp</code></a> and <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> management commands\nnow have a <code class=\"docutils literal notranslate\">--template</code> option for specifying a path or URL to a custom app\nor project template.</p>\n<p>For example, Django will use the <code class=\"docutils literal notranslate\">/path/to/my_project_template</code> directory\nwhen you run the following command:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>django-admin.py startproject --template<span class=\"o\">=</span>/path/to/my_project_template myproject\n</code></pre></div>\n<p>You can also now provide a destination directory as the second\nargument to both <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> and <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>:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>django-admin.py startapp myapp /path/to/new/app\ndjango-admin.py startproject myproject /path/to/new/project\n</code></pre></div>\n<p>For more information, see the <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-startapp\"><code class=\"xref std std-djadmin docutils literal notranslate\">startapp</code></a> and <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>\ndocumentation.</p>\n</section>\n<section id=\"improved-wsgi-support\">\n<h3>Improved WSGI support<a class=\"heading-anchor\" href=\"#improved-wsgi-support\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-startproject\"><code class=\"xref std std-djadmin docutils literal notranslate\">startproject</code></a> management command now adds a <code class=\"file docutils literal notranslate\">wsgi.py</code>\nmodule to the initial project layout, containing a simple WSGI application that\ncan be used for <a class=\"reference internal\" href=\"/en/dev/howto/deployment/wsgi/\"><span class=\"doc\">deploying with WSGI app\nservers</span></a>.</p>\n<p>The <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\">built-in development server</code></a> now supports using an\nexternally-defined WSGI callable, which makes it possible to run <code class=\"docutils literal notranslate\">runserver</code>\nwith the same WSGI configuration that is used for deployment. The new\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-WSGI_APPLICATION\"><code class=\"xref std std-setting docutils literal notranslate\">WSGI_APPLICATION</code></a> setting lets you configure which WSGI callable\n<a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\">runserver</code></a> uses.</p>\n<p>(The <code class=\"docutils literal notranslate\">runfcgi</code> management command also internally wraps the WSGI\ncallable configured via <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-WSGI_APPLICATION\"><code class=\"xref std std-setting docutils literal notranslate\">WSGI_APPLICATION</code></a>.)</p>\n</section>\n<section id=\"select-for-update-support\">\n<h3><code class=\"docutils literal notranslate\">SELECT FOR UPDATE</code> support<a class=\"heading-anchor\" href=\"#select-for-update-support\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.4 includes a <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\">QuerySet.select_for_update()</code></a> method, which generates a\n<code class=\"docutils literal notranslate\">SELECT ... FOR UPDATE</code> SQL query. This will lock rows until the end of the\ntransaction, meaning other transactions cannot modify or delete rows matched by\na <code class=\"docutils literal notranslate\">FOR UPDATE</code> query.</p>\n<p>For more details, see the documentation for\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>.</p>\n</section>\n<section id=\"model-objects-bulk-create-in-the-orm\">\n<h3><code class=\"docutils literal notranslate\">Model.objects.bulk_create</code> in the ORM<a class=\"heading-anchor\" href=\"#model-objects-bulk-create-in-the-orm\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This method lets you create multiple objects more efficiently. It can result in\nsignificant performance increases if you have many objects.</p>\n<p>Django makes use of this internally, meaning some operations (such as database\nsetup for test suites) have seen a performance benefit as a result.</p>\n<p>See the <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> docs for more\ninformation.</p>\n</section>\n<section id=\"queryset-prefetch-related\">\n<h3><code class=\"docutils literal notranslate\">QuerySet.prefetch_related</code><a class=\"heading-anchor\" href=\"#queryset-prefetch-related\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Similar to <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> but with a\ndifferent strategy and broader scope,\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.prefetch_related\" title=\"django.db.models.query.QuerySet.prefetch_related\"><code class=\"xref py py-meth docutils literal notranslate\">prefetch_related()</code></a> has been added to\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>. This method returns a new\n<code class=\"docutils literal notranslate\">QuerySet</code> that will prefetch each of the specified related lookups in a\nsingle batch as soon as the query begins to be evaluated. Unlike\n<code class=\"docutils literal notranslate\">select_related</code>, it does the joins in Python, not in the database, and\nsupports many-to-many relationships, <code class=\"docutils literal notranslate\">GenericForeignKey</code> and more. This\nallows you to fix a very common performance problem in which your code ends up\ndoing O(n) database queries (or worse) if objects on your primary <code class=\"docutils literal notranslate\">QuerySet</code>\neach have many related objects that you also need to fetch.</p>\n</section>\n<section id=\"improved-password-hashing\">\n<h3>Improved password hashing<a class=\"heading-anchor\" href=\"#improved-password-hashing\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django’s auth system (<code class=\"docutils literal notranslate\">django.contrib.auth</code>) stores passwords using a one-way\nalgorithm. Django 1.3 uses the <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/SHA1\">SHA1</a> algorithm, but increasing processor speeds\nand theoretical attacks have revealed that SHA1 isn’t as secure as we’d like.\nThus, Django 1.4 introduces a new password storage system: by default Django\nnow uses the <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/PBKDF2\">PBKDF2</a> algorithm (as recommended by <a class=\"reference external\" href=\"https://csrc.nist.gov/publications/detail/sp/800-132/final\">NIST</a>). You can also easily\nchoose a different algorithm (including the popular <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/Bcrypt\">bcrypt</a> algorithm). For\nmore details, see <a class=\"reference internal\" href=\"/en/dev/topics/auth/passwords/#auth-password-storage\"><span class=\"std std-ref\">How Django stores passwords</span></a>.</p>\n</section>\n<section id=\"html5-doctype\">\n<h3>HTML5 doctype<a class=\"heading-anchor\" href=\"#html5-doctype\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>We’ve switched the admin and other bundled templates to use the HTML5\ndoctype. While Django will be careful to maintain compatibility with older\nbrowsers, this change means that you can use any HTML5 features you need in\nadmin pages without having to lose HTML validity or override the provided\ntemplates to change the doctype.</p>\n</section>\n<section id=\"list-filters-in-admin-interface\">\n<h3>List filters in admin interface<a class=\"heading-anchor\" href=\"#list-filters-in-admin-interface\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Prior to Django 1.4, the <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#module-django.contrib.admin\" title=\"django.contrib.admin: Django's admin site.\"><code class=\"xref py py-mod docutils literal notranslate\">admin</code></a> app let you specify\nchange list filters by specifying a field lookup, but it didn’t allow you to\ncreate custom filters. This has been rectified with a simple API (previously\nused internally and known as “FilterSpec”). For more details, see the\ndocumentation for <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter\" title=\"django.contrib.admin.ModelAdmin.list_filter\"><code class=\"xref py py-attr docutils literal notranslate\">list_filter</code></a>.</p>\n</section>\n<section id=\"multiple-sort-in-admin-interface\">\n<h3>Multiple sort in admin interface<a class=\"heading-anchor\" href=\"#multiple-sort-in-admin-interface\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The admin change list now supports sorting on multiple columns. It respects all\nelements of the <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.ordering\" title=\"django.contrib.admin.ModelAdmin.ordering\"><code class=\"xref py py-attr docutils literal notranslate\">ordering</code></a> attribute,\nand sorting on multiple columns by clicking on headers is designed to mimic the\nbehavior of desktop GUIs. We also added a\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_ordering\" title=\"django.contrib.admin.ModelAdmin.get_ordering\"><code class=\"xref py py-meth docutils literal notranslate\">get_ordering()</code></a> method for specifying the\nordering dynamically (i.e., depending on the request).</p>\n</section>\n<section id=\"new-modeladmin-methods\">\n<h3>New <code class=\"docutils literal notranslate\">ModelAdmin</code> methods<a class=\"heading-anchor\" href=\"#new-modeladmin-methods\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>We added a <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_related\" title=\"django.contrib.admin.ModelAdmin.save_related\"><code class=\"xref py py-meth docutils literal notranslate\">save_related()</code></a> method to\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin\" title=\"django.contrib.admin.ModelAdmin\"><code class=\"xref py py-mod docutils literal notranslate\">ModelAdmin</code></a> to ease customization of how\nrelated objects are saved in the admin.</p>\n<p>Two other new <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> methods,\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_list_display\" title=\"django.contrib.admin.ModelAdmin.get_list_display\"><code class=\"xref py py-meth docutils literal notranslate\">get_list_display()</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_list_display_links\" title=\"django.contrib.admin.ModelAdmin.get_list_display_links\"><code class=\"xref py py-meth docutils literal notranslate\">get_list_display_links()</code></a>\nenable dynamic customization of fields and links displayed on the admin\nchange list.</p>\n</section>\n<section id=\"admin-inlines-respect-user-permissions\">\n<h3>Admin inlines respect user permissions<a class=\"heading-anchor\" href=\"#admin-inlines-respect-user-permissions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Admin inlines now only allow those actions for which the user has\npermission. For <code class=\"docutils literal notranslate\">ManyToMany</code> relationships with an auto-created intermediate\nmodel (which does not have its own permissions), the change permission for the\nrelated model determines if the user has the permission to add, change or\ndelete relationships.</p>\n</section>\n<section id=\"tools-for-cryptographic-signing\">\n<h3>Tools for cryptographic signing<a class=\"heading-anchor\" href=\"#tools-for-cryptographic-signing\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.4 adds both a low-level API for signing values and a high-level API\nfor setting and reading signed cookies, one of the most common uses of\nsigning in web applications.</p>\n<p>See the <a class=\"reference internal\" href=\"/en/dev/topics/signing/\"><span class=\"doc\">cryptographic signing</span></a> docs for more\ninformation.</p>\n</section>\n<section id=\"cookie-based-session-backend\">\n<h3>Cookie-based session backend<a class=\"heading-anchor\" href=\"#cookie-based-session-backend\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.4 introduces a cookie-based session backend that uses the tools for\n<a class=\"reference internal\" href=\"/en/dev/topics/signing/\"><span class=\"doc\">cryptographic signing</span></a> to store the session data in\nthe client’s browser.</p>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Warning</p>\n<p>Session data is signed and validated by the server, but it’s not\nencrypted. This means a user can view any data stored in the\nsession but cannot change it. Please read the documentation for\nfurther clarification before using this backend.</p>\n</aside>\n<p>See the <a class=\"reference internal\" href=\"/en/dev/topics/http/sessions/#cookie-session-backend\"><span class=\"std std-ref\">cookie-based session backend</span></a> docs for\nmore information.</p>\n</section>\n<section id=\"new-form-wizard\">\n<h3>New form wizard<a class=\"heading-anchor\" href=\"#new-form-wizard\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The previous <code class=\"docutils literal notranslate\">FormWizard</code> from <code class=\"docutils literal notranslate\">django.contrib.formtools</code> has been\nreplaced with a new implementation based on the class-based views\nintroduced in Django 1.3. It features a pluggable storage API and doesn’t\nrequire the wizard to pass around hidden fields for every previous step.</p>\n<p>Django 1.4 ships with a session-based storage backend and a cookie-based\nstorage backend. The latter uses the tools for\n<a class=\"reference internal\" href=\"/en/dev/topics/signing/\"><span class=\"doc\">cryptographic signing</span></a> also introduced in\nDjango 1.4 to store the wizard’s state in the user’s cookies.</p>\n</section>\n<section id=\"reverse-lazy\">\n<h3><code class=\"docutils literal notranslate\">reverse_lazy</code><a class=\"heading-anchor\" href=\"#reverse-lazy\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>A lazily evaluated version of <code class=\"docutils literal notranslate\">reverse()</code> was added to allow using URL\nreversals before the project’s URLconf gets loaded.</p>\n</section>\n<section id=\"translating-url-patterns\">\n<h3>Translating URL patterns<a class=\"heading-anchor\" href=\"#translating-url-patterns\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django can now look for a language prefix in the URLpattern when using the new\n<a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#django.conf.urls.i18n.i18n_patterns\" title=\"django.conf.urls.i18n.i18n_patterns\"><code class=\"xref py py-func docutils literal notranslate\">i18n_patterns()</code></a> helper function.\nIt’s also now possible to define translatable URL patterns using\n<code class=\"docutils literal notranslate\">django.utils.translation.ugettext_lazy()</code>. See\n<a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#url-internationalization\"><span class=\"std std-ref\">Internationalization: in URL patterns</span></a> for more information about the language prefix\nand how to internationalize URL patterns.</p>\n</section>\n<section id=\"contextual-translation-support-for-trans-and-blocktrans\">\n<h3>Contextual translation support for <code class=\"docutils literal notranslate\">{% trans %}</code> and <code class=\"docutils literal notranslate\">{% blocktrans %}</code><a class=\"heading-anchor\" href=\"#contextual-translation-support-for-trans-and-blocktrans\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#contextual-markers\"><span class=\"std std-ref\">contextual translation</span></a> support introduced in\nDjango 1.3 via the <code class=\"docutils literal notranslate\">pgettext</code> function has been extended to the\n<a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#std-templatetag-trans\"><code class=\"xref std std-ttag docutils literal notranslate\">trans</code></a> and <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 tags using the new <code class=\"docutils literal notranslate\">context</code>\nkeyword.</p>\n</section>\n<section id=\"customizable-singleobjectmixin-urlconf-kwargs\">\n<h3>Customizable <code class=\"docutils literal notranslate\">SingleObjectMixin</code> URLConf kwargs<a class=\"heading-anchor\" href=\"#customizable-singleobjectmixin-urlconf-kwargs\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Two new attributes,\n<a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectMixin.pk_url_kwarg\" title=\"django.views.generic.detail.SingleObjectMixin.pk_url_kwarg\"><code class=\"xref py py-attr docutils literal notranslate\">pk_url_kwarg</code></a>\nand\n<a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectMixin.slug_url_kwarg\" title=\"django.views.generic.detail.SingleObjectMixin.slug_url_kwarg\"><code class=\"xref py py-attr docutils literal notranslate\">slug_url_kwarg</code></a>,\nhave been added to <a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectMixin\" title=\"django.views.generic.detail.SingleObjectMixin\"><code class=\"xref py py-class docutils literal notranslate\">SingleObjectMixin</code></a> to\nenable the customization of URLconf keyword arguments used for single\nobject generic views.</p>\n</section>\n<section id=\"assignment-template-tags\">\n<h3>Assignment template tags<a class=\"heading-anchor\" href=\"#assignment-template-tags\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>A new <code class=\"docutils literal notranslate\">assignment_tag</code> helper function was added to <code class=\"docutils literal notranslate\">template.Library</code> to\nease the creation of template tags that store data in a specified context\nvariable.</p>\n</section>\n<section id=\"args-and-kwargs-support-for-template-tag-helper-functions\">\n<h3><code class=\"docutils literal notranslate\">*args</code> and <code class=\"docutils literal notranslate\">**kwargs</code> support for template tag helper functions<a class=\"heading-anchor\" href=\"#args-and-kwargs-support-for-template-tag-helper-functions\"><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/howto/custom-template-tags/#howto-custom-template-tags-simple-tags\"><span class=\"std std-ref\">simple_tag</span></a>,\n<a class=\"reference internal\" href=\"/en/dev/howto/custom-template-tags/#howto-custom-template-tags-inclusion-tags\"><span class=\"std std-ref\">inclusion_tag</span></a> and newly\nintroduced <code class=\"docutils literal notranslate\">assignment_tag</code> template helper functions may now accept any\nnumber of positional or keyword arguments. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"nd\">@register</span><span class=\"o\">.</span>simple_tag\n<span class=\"k\">def</span> <span class=\"nf\">my_tag</span><span class=\"p\">(</span>a<span class=\"p\">,</span> b<span class=\"p\">,</span> <span class=\"o\">*</span>args<span class=\"p\">,</span> <span class=\"o\">**</span>kwargs<span class=\"p\">):</span>\n    warning <span class=\"o\">=</span> kwargs<span class=\"p\">[</span><span class=\"s2\">&quot;warning&quot;</span><span class=\"p\">]</span>\n    profile <span class=\"o\">=</span> kwargs<span class=\"p\">[</span><span class=\"s2\">&quot;profile&quot;</span><span class=\"p\">]</span>\n    <span class=\"o\">...</span>\n    <span class=\"k\">return</span> <span class=\"o\">...</span>\n</code></pre></div>\n<p>Then, in the template, any number of arguments may be passed to the template\ntag. 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=\"cp\">{%</span> <span class=\"k\">my_tag</span> <span class=\"m\">123</span> <span class=\"s2\">&quot;abcd&quot;</span> <span class=\"nv\">book.title</span> <span class=\"nv\">warning</span><span class=\"o\">=</span><span class=\"nv\">message</span><span class=\"o\">|</span><span class=\"nf\">lower</span> <span class=\"nv\">profile</span><span class=\"o\">=</span><span class=\"nv\">user.profile</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n</section>\n<section id=\"no-wrapping-of-exceptions-in-template-debug-mode\">\n<h3>No wrapping of exceptions in <code class=\"docutils literal notranslate\">TEMPLATE_DEBUG</code> mode<a class=\"heading-anchor\" href=\"#no-wrapping-of-exceptions-in-template-debug-mode\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>In previous versions of Django, whenever the <code class=\"docutils literal notranslate\">TEMPLATE_DEBUG</code> setting\nwas <code class=\"docutils literal notranslate\">True</code>, any exception raised during template rendering (even exceptions\nunrelated to template syntax) were wrapped in <code class=\"docutils literal notranslate\">TemplateSyntaxError</code> and\nre-raised. This was done in order to provide detailed template source location\ninformation in the debug 500 page.</p>\n<p>In Django 1.4, exceptions are no longer wrapped. Instead, the original\nexception is annotated with the source information. This means that catching\nexceptions from template rendering is now consistent regardless of the value of\n<code class=\"docutils literal notranslate\">TEMPLATE_DEBUG</code>, and there’s no need to catch and unwrap\n<code class=\"docutils literal notranslate\">TemplateSyntaxError</code> in order to catch other errors.</p>\n</section>\n<section id=\"truncatechars-template-filter\">\n<h3><code class=\"docutils literal notranslate\">truncatechars</code> template filter<a class=\"heading-anchor\" href=\"#truncatechars-template-filter\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This new filter truncates a string to be no longer than the specified\nnumber of characters. Truncated strings end with a translatable ellipsis\nsequence (”…”). See the documentation for <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatefilter-truncatechars\"><code class=\"xref std std-tfilter docutils literal notranslate\">truncatechars</code></a> for\nmore details.</p>\n</section>\n<section id=\"static-template-tag\">\n<h3><code class=\"docutils literal notranslate\">static</code> template tag<a class=\"heading-anchor\" href=\"#static-template-tag\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#module-django.contrib.staticfiles\" title=\"django.contrib.staticfiles: An app for handling static files.\"><code class=\"xref py py-mod docutils literal notranslate\">staticfiles</code></a> contrib app has a new\n<code class=\"docutils literal notranslate\">static</code> template tag to refer to files saved with the\n<code class=\"docutils literal notranslate\">STATICFILES_STORAGE</code> storage backend. It uses the storage backend’s\n<code class=\"docutils literal notranslate\">url</code> method and therefore supports advanced features such as <a class=\"reference internal\" href=\"/en/dev/howto/static-files/deployment/#staticfiles-from-cdn\"><span class=\"std std-ref\">serving\nfiles from a cloud service</span></a>.</p>\n</section>\n<section id=\"cachedstaticfilesstorage-storage-backend\">\n<h3><code class=\"docutils literal notranslate\">CachedStaticFilesStorage</code> storage backend<a class=\"heading-anchor\" href=\"#cachedstaticfilesstorage-storage-backend\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#module-django.contrib.staticfiles\" title=\"django.contrib.staticfiles: An app for handling static files.\"><code class=\"xref py py-mod docutils literal notranslate\">staticfiles</code></a> contrib app now has a\n<code class=\"docutils literal notranslate\">django.contrib.staticfiles.storage.CachedStaticFilesStorage</code> backend\nthat caches the files it saves (when running the <a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\">collectstatic</code></a>\nmanagement command) by appending the MD5 hash of the file’s content to the\nfilename. For example, the file <code class=\"docutils literal notranslate\">css/styles.css</code> would also be saved as\n<code class=\"docutils literal notranslate\">css/styles.55e7cbb9ba48.css</code></p>\n</section>\n<section id=\"simple-clickjacking-protection\">\n<h3>Simple clickjacking protection<a class=\"heading-anchor\" href=\"#simple-clickjacking-protection\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>We’ve added a middleware to provide easy protection against <a class=\"reference external\" href=\"https://en.wikipedia.org/wiki/Clickjacking\">clickjacking</a> using the <code class=\"docutils literal notranslate\">X-Frame-Options</code>\nheader. It’s not enabled by default for backwards compatibility reasons, but\nyou’ll almost certainly want to <a class=\"reference internal\" href=\"/en/dev/ref/clickjacking/\"><span class=\"doc\">enable it</span></a> to help\nplug that security hole for browsers that support the header.</p>\n</section>\n<section id=\"csrf-improvements\">\n<h3>CSRF improvements<a class=\"heading-anchor\" href=\"#csrf-improvements\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>We’ve made various improvements to our CSRF features, including the\n<a class=\"reference internal\" href=\"/en/dev/ref/csrf/#django.views.decorators.csrf.ensure_csrf_cookie\" title=\"django.views.decorators.csrf.ensure_csrf_cookie\"><code class=\"xref py py-func docutils literal notranslate\">ensure_csrf_cookie()</code></a> decorator, which can\nhelp with AJAX-heavy sites; protection for PUT and DELETE requests; and the\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CSRF_COOKIE_SECURE\"><code class=\"xref std std-setting docutils literal notranslate\">CSRF_COOKIE_SECURE</code></a> and <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-CSRF_COOKIE_PATH\"><code class=\"xref std std-setting docutils literal notranslate\">CSRF_COOKIE_PATH</code></a> settings, which\ncan improve the security and usefulness of CSRF protection. See the <a class=\"reference internal\" href=\"/en/dev/ref/csrf/\"><span class=\"doc\">CSRF\ndocs</span></a> for more information.</p>\n</section>\n<section id=\"error-report-filtering\">\n<h3>Error report filtering<a class=\"heading-anchor\" href=\"#error-report-filtering\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>We added two function decorators,\n<a class=\"reference internal\" href=\"/en/dev/howto/error-reporting/#django.views.decorators.debug.sensitive_variables\" title=\"django.views.decorators.debug.sensitive_variables\"><code class=\"xref py py-func docutils literal notranslate\">sensitive_variables()</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/howto/error-reporting/#django.views.decorators.debug.sensitive_post_parameters\" title=\"django.views.decorators.debug.sensitive_post_parameters\"><code class=\"xref py py-func docutils literal notranslate\">sensitive_post_parameters()</code></a>, to allow\ndesignating the local variables and POST parameters that may contain sensitive\ninformation and should be filtered out of error reports.</p>\n<p>All POST parameters are now systematically filtered out of error reports for\ncertain views (<code class=\"docutils literal notranslate\">login</code>, <code class=\"docutils literal notranslate\">password_reset_confirm</code>, <code class=\"docutils literal notranslate\">password_change</code> and\n<code class=\"docutils literal notranslate\">add_view</code> in <a class=\"reference internal\" href=\"/en/dev/topics/auth/default/#module-django.contrib.auth.views\" title=\"django.contrib.auth.views\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.auth.views</code></a>, as well as\n<code class=\"docutils literal notranslate\">user_change_password</code> in the admin app) to prevent the leaking of sensitive\ninformation such as user passwords.</p>\n<p>You can override or customize the default filtering by writing a <a class=\"reference internal\" href=\"/en/dev/howto/error-reporting/#custom-error-reports\"><span class=\"std std-ref\">custom\nfilter</span></a>. For more information see the docs on\n<a class=\"reference internal\" href=\"/en/dev/howto/error-reporting/#filtering-error-reports\"><span class=\"std std-ref\">Filtering error reports</span></a>.</p>\n</section>\n<section id=\"extended-ipv6-support\">\n<h3>Extended IPv6 support<a class=\"heading-anchor\" href=\"#extended-ipv6-support\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.4 can now better handle IPv6 addresses with the new\n<a class=\"reference internal\" href=\"/en/dev/ref/models/fields/#django.db.models.GenericIPAddressField\" title=\"django.db.models.GenericIPAddressField\"><code class=\"xref py py-class docutils literal notranslate\">GenericIPAddressField</code></a> model field,\n<a class=\"reference internal\" href=\"/en/dev/ref/forms/fields/#django.forms.GenericIPAddressField\" title=\"django.forms.GenericIPAddressField\"><code class=\"xref py py-class docutils literal notranslate\">GenericIPAddressField</code></a> form field and\nthe validators <a class=\"reference internal\" href=\"/en/dev/ref/validators/#django.core.validators.validate_ipv46_address\" title=\"django.core.validators.validate_ipv46_address\"><code class=\"xref py py-data docutils literal notranslate\">validate_ipv46_address</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/validators/#django.core.validators.validate_ipv6_address\" title=\"django.core.validators.validate_ipv6_address\"><code class=\"xref py py-data docutils literal notranslate\">validate_ipv6_address</code></a>.</p>\n</section>\n<section id=\"html-comparisons-in-tests\">\n<h3>HTML comparisons in tests<a class=\"heading-anchor\" href=\"#html-comparisons-in-tests\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The base classes in <a class=\"reference internal\" href=\"/en/dev/topics/testing/overview/#module-django.test\" title=\"django.test: Testing tools for Django applications.\"><code class=\"xref py py-mod docutils literal notranslate\">django.test</code></a> now have some helpers to\ncompare HTML without tripping over irrelevant differences in whitespace,\nargument quoting/ordering and closing of self-closing tags. You can either\ncompare HTML directly with the new\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertHTMLEqual\" title=\"django.test.SimpleTestCase.assertHTMLEqual\"><code class=\"xref py py-meth docutils literal notranslate\">assertHTMLEqual()</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertHTMLNotEqual\" title=\"django.test.SimpleTestCase.assertHTMLNotEqual\"><code class=\"xref py py-meth docutils literal notranslate\">assertHTMLNotEqual()</code></a> assertions, or use\nthe <code class=\"docutils literal notranslate\">html=True</code> flag with\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertContains\" title=\"django.test.SimpleTestCase.assertContains\"><code class=\"xref py py-meth docutils literal notranslate\">assertContains()</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertNotContains\" title=\"django.test.SimpleTestCase.assertNotContains\"><code class=\"xref py py-meth docutils literal notranslate\">assertNotContains()</code></a> to test whether the\nclient’s response contains a given HTML fragment. See the <a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#assertions\"><span class=\"std std-ref\">assertions\ndocumentation</span></a> for more.</p>\n</section>\n<section id=\"two-new-date-format-strings\">\n<h3>Two new date format strings<a class=\"heading-anchor\" href=\"#two-new-date-format-strings\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Two new <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatefilter-date\"><code class=\"xref std std-tfilter docutils literal notranslate\">date</code></a> formats were added for use in template filters,\ntemplate tags and <a class=\"reference internal\" href=\"/en/dev/topics/i18n/formatting/\"><span class=\"doc\">Format localization</span></a>:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">e</code> – the name of the timezone of the given datetime object</p></li>\n<li><p><code class=\"docutils literal notranslate\">o</code> – the ISO 8601 year number</p></li>\n</ul>\n<p>Please make sure to update your <a class=\"reference internal\" href=\"/en/dev/topics/i18n/formatting/#custom-format-files\"><span class=\"std std-ref\">custom format files</span></a> if they contain either <code class=\"docutils literal notranslate\">e</code> or <code class=\"docutils literal notranslate\">o</code> in a format\nstring. For example a Spanish localization format previously only escaped the\n<code class=\"docutils literal notranslate\">d</code> format character:</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>DATE_FORMAT <span class=\"o\">=</span> <span class=\"sa\">r</span><span class=\"s2\">&quot;j \\de F \\de Y&quot;</span>\n</code></pre></div>\n<p>But now it needs to also escape <code class=\"docutils literal notranslate\">e</code> and <code class=\"docutils literal notranslate\">o</code>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code>DATE_FORMAT <span class=\"o\">=</span> <span class=\"sa\">r</span><span class=\"s2\">&quot;j \\d\\e F \\d\\e Y&quot;</span>\n</code></pre></div>\n<p>For more information, see the <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatefilter-date\"><code class=\"xref std std-tfilter docutils literal notranslate\">date</code></a> documentation.</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<p>Django 1.4 also includes several smaller improvements worth noting:</p>\n<ul>\n<li><p>A more usable stacktrace in the technical 500 page. Frames in the\nstack trace that reference Django’s framework code are dimmed out,\nwhile frames in application code are slightly emphasized. This change\nmakes it easier to scan a stacktrace for issues in application code.</p></li>\n<li><p><a class=\"reference internal\" href=\"/en/dev/topics/db/tablespaces/\"><span class=\"doc\">Tablespace support</span></a> in PostgreSQL.</p></li>\n<li><p>Customizable names for <a class=\"reference internal\" href=\"/en/dev/howto/custom-template-tags/#django.template.Library.simple_tag\" title=\"django.template.Library.simple_tag\"><code class=\"xref py py-meth docutils literal notranslate\">simple_tag()</code></a>.</p></li>\n<li><p>In the documentation, a helpful <a class=\"reference internal\" href=\"/en/dev/topics/security/\"><span class=\"doc\">security overview</span></a>\npage.</p></li>\n<li><p>The <code class=\"docutils literal notranslate\">django.contrib.auth.models.check_password</code> function has been moved\nto the <a class=\"reference internal\" href=\"/en/dev/topics/auth/passwords/#module-django.contrib.auth.hashers\" title=\"django.contrib.auth.hashers\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.auth.hashers</code></a> module. Importing it from the old\nlocation will still work, but you should update your imports.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/contrib/staticfiles/#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\">collectstatic</code></a> management command now has a <code class=\"docutils literal notranslate\">--clear</code> option\nto delete all files at the destination before copying or linking the static\nfiles.</p></li>\n<li><p>It’s now possible to load fixtures containing forward references when using\nMySQL with the InnoDB database engine.</p></li>\n<li><p>A new 403 response handler has been added as\n<code class=\"docutils literal notranslate\">'django.views.defaults.permission_denied'</code>. You can set your own handler\nby setting the value of <a class=\"reference internal\" href=\"/en/dev/ref/urls/#django.conf.urls.handler403\" title=\"django.conf.urls.handler403\"><code class=\"xref py py-data docutils literal notranslate\">django.conf.urls.handler403</code></a>. See the\ndocumentation about <a class=\"reference internal\" href=\"/en/dev/ref/views/#http-forbidden-view\"><span class=\"std std-ref\">the 403 (HTTP Forbidden) view</span></a>\nfor more information.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-makemessages\"><code class=\"xref std std-djadmin docutils literal notranslate\">makemessages</code></a> command uses a new and more accurate lexer,\n<a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/jslex/\">JsLex</a>, for extracting translatable strings from JavaScript\nfiles.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/topics/i18n/translation/#std-templatetag-trans\"><code class=\"xref std std-ttag docutils literal notranslate\">trans</code></a> template tag now takes an optional <code class=\"docutils literal notranslate\">as</code> argument to\nbe able to retrieve a translation string without displaying it but setting\na template context variable instead.</p></li>\n<li><p>The <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-if\"><code class=\"xref std std-ttag docutils literal notranslate\">if</code></a> template tag now supports <code class=\"docutils literal notranslate\">{% elif %}</code> clauses.</p></li>\n<li><p>If your Django app is behind a proxy, you might find the new\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-SECURE_PROXY_SSL_HEADER\"><code class=\"xref std std-setting docutils literal notranslate\">SECURE_PROXY_SSL_HEADER</code></a> setting useful. It solves the problem of\nyour proxy “eating” the fact that a request came in via HTTPS. But only use\nthis setting if you know what you’re doing.</p></li>\n<li><p>A new, plain-text, version of the HTTP 500 status code internal error page\nserved when <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a> is <code class=\"docutils literal notranslate\">True</code> is now sent to the client when\nDjango detects that the request has originated in JavaScript code.\n(<code class=\"docutils literal notranslate\">is_ajax()</code> is used for this.)</p>\n<p>Like its HTML counterpart, it contains a collection of different\npieces of information about the state of the application.</p>\n<p>This should make it easier to read when debugging interaction with\nclient-side JavaScript.</p>\n</li>\n<li><p>Added the <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#cmdoption-makemessages-no-location\"><code class=\"xref std std-option docutils literal notranslate\">makemessages --no-location</code></a> option.</p></li>\n<li><p>Changed the <code class=\"docutils literal notranslate\">locmem</code> cache backend to use\n<code class=\"docutils literal notranslate\">pickle.HIGHEST_PROTOCOL</code> for better compatibility with the other\ncache backends.</p></li>\n<li><p>Added support in the ORM for generating <code class=\"docutils literal notranslate\">SELECT</code> queries containing\n<code class=\"docutils literal notranslate\">DISTINCT ON</code>.</p>\n<p>The <code class=\"docutils literal notranslate\">distinct()</code> <code class=\"docutils literal notranslate\">QuerySet</code> method now accepts an optional list of model\nfield names. If specified, then the <code class=\"docutils literal notranslate\">DISTINCT</code> statement is limited to\nthese fields. This is only supported in PostgreSQL.</p>\n<p>For more details, see the documentation for\n<a class=\"reference internal\" href=\"/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.distinct\" title=\"django.db.models.query.QuerySet.distinct\"><code class=\"xref py py-meth docutils literal notranslate\">distinct()</code></a>.</p>\n</li>\n<li><p>The admin login page will add a password reset link if you include a URL with\nthe name <code class=\"docutils literal notranslate\">'admin_password_reset'</code> in your <code class=\"docutils literal notranslate\">urls.py</code>, so plugging in the\nbuilt-in password reset mechanism and making it available is now much easier.\nFor details, see <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#auth-password-reset\"><span class=\"std std-ref\">Adding a password reset feature</span></a>.</p></li>\n<li><p>The MySQL database backend can now make use of the savepoint feature\nimplemented by MySQL version 5.0.3 or newer with the InnoDB storage engine.</p></li>\n<li><p>It’s now possible to pass initial values to the model forms that are part of\nboth model formsets and inline model formsets as returned from factory\nfunctions <code class=\"docutils literal notranslate\">modelformset_factory</code> and <code class=\"docutils literal notranslate\">inlineformset_factory</code> respectively\njust like with regular formsets. However, initial values only apply to extra\nforms, i.e. those which are not bound to an existing model instance.</p></li>\n<li><p>The sitemaps framework can now handle HTTPS links using the new\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/sitemaps/#django.contrib.sitemaps.Sitemap.protocol\" title=\"django.contrib.sitemaps.Sitemap.protocol\"><code class=\"xref py py-attr docutils literal notranslate\">Sitemap.protocol</code></a> class\nattribute.</p></li>\n<li><p>A new <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\">django.test.SimpleTestCase</code></a> subclass of\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/unittest.html#unittest.TestCase\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">unittest.TestCase</code></a>\nthat’s lighter than <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\">django.test.TestCase</code></a> and company. It can be\nuseful in tests that don’t need to hit a database. See\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#testcase-hierarchy-diagram\"><span class=\"std std-ref\">Hierarchy of Django unit testing classes</span></a>.</p></li>\n</ul>\n</section>\n</section>\n<section id=\"backwards-incompatible-changes-in-1-4\">\n<span id=\"backwards-incompatible-1-4\"></span><h2>Backwards incompatible changes in 1.4<a class=\"heading-anchor\" href=\"#backwards-incompatible-changes-in-1-4\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"secret-key-setting-is-required\">\n<h3>SECRET_KEY setting is required<a class=\"heading-anchor\" href=\"#secret-key-setting-is-required\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Running Django with an empty or known <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> disables many of\nDjango’s security protections and can lead to remote-code-execution\nvulnerabilities. No Django site should ever be run without 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>.</p>\n<p>In Django 1.4, starting Django with an empty <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> will raise a\n<code class=\"docutils literal notranslate\">DeprecationWarning</code>. In Django 1.5, it will raise an exception and Django\nwill refuse to start. This is slightly accelerated from the usual deprecation\npath due to the severity of the consequences of running Django with no\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>.</p>\n</section>\n<section id=\"django-contrib-admin\">\n<h3><code class=\"docutils literal notranslate\">django.contrib.admin</code><a class=\"heading-anchor\" href=\"#django-contrib-admin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The included administration app <code class=\"docutils literal notranslate\">django.contrib.admin</code> has for a long time\nshipped with a default set of static files such as JavaScript, images and\nstylesheets. Django 1.3 added a new contrib app <code class=\"docutils literal notranslate\">django.contrib.staticfiles</code>\nto handle such files in a generic way and defined conventions for static\nfiles included in apps.</p>\n<p>Starting in Django 1.4, the admin’s static files also follow this\nconvention, to make the files easier to deploy. In previous versions of Django,\nit was also common to define an <code class=\"docutils literal notranslate\">ADMIN_MEDIA_PREFIX</code> setting to point to the\nURL where the admin’s static files live on a web server. This setting has now\nbeen deprecated and replaced by the more general setting <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_URL</code></a>.\nDjango will now expect to find the admin static files under the URL\n<code class=\"docutils literal notranslate\">&lt;STATIC_URL&gt;/admin/</code>.</p>\n<p>If you’ve previously used a URL path for <code class=\"docutils literal notranslate\">ADMIN_MEDIA_PREFIX</code> (e.g.\n<code class=\"docutils literal notranslate\">/media/</code>) simply make sure <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_URL</code></a> and <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-STATIC_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_ROOT</code></a>\nare configured and your web server serves those files correctly. The\ndevelopment server continues to serve the admin files just like before. Read\nthe <a class=\"reference internal\" href=\"/en/dev/howto/static-files/\"><span class=\"doc\">static files howto</span></a> for more details.</p>\n<p>If your <code class=\"docutils literal notranslate\">ADMIN_MEDIA_PREFIX</code> is set to a specific domain (e.g.\n<code class=\"docutils literal notranslate\">http://media.example.com/admin/</code>), make sure to also set your\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_URL</code></a> setting to the correct URL – for example,\n<code class=\"docutils literal notranslate\">http://media.example.com/</code>.</p>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Warning</p>\n<p>If you’re implicitly relying on the path of the admin static files within\nDjango’s source code, you’ll need to update that path. The files were moved\nfrom <code class=\"file docutils literal notranslate\">django/contrib/admin/media/</code> to\n<code class=\"file docutils literal notranslate\">django/contrib/admin/static/admin/</code>.</p>\n</aside>\n</section>\n<section id=\"supported-browsers-for-the-admin\">\n<h3>Supported browsers for the admin<a class=\"heading-anchor\" href=\"#supported-browsers-for-the-admin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django hasn’t had a clear policy on which browsers are supported by the\nadmin app. Our new policy formalizes existing practices: <a class=\"reference external\" href=\"https://github.com/yui/yui3/wiki/Graded-Browser-Support\">YUI’s A-grade</a>\nbrowsers should provide a fully-functional admin experience, with the notable\nexception of Internet Explorer 6, which is no longer supported.</p>\n<p>Released over 10 years ago, IE6 imposes many limitations on modern web\ndevelopment. The practical implications of this policy are that contributors\nare free to improve the admin without consideration for these limitations.</p>\n<p>This new policy <strong>has no impact</strong> on sites you develop using Django. It only\napplies to the Django admin. Feel free to develop apps compatible with any\nrange of browsers.</p>\n</section>\n<section id=\"removed-admin-icons\">\n<h3>Removed admin icons<a class=\"heading-anchor\" href=\"#removed-admin-icons\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>As part of an effort to improve the performance and usability of the admin’s\nchange-list sorting interface and <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.filter_horizontal\" title=\"django.contrib.admin.ModelAdmin.filter_horizontal\"><code class=\"xref py py-attr docutils literal notranslate\">horizontal</code></a> and <a class=\"reference internal\" href=\"/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.filter_vertical\" title=\"django.contrib.admin.ModelAdmin.filter_vertical\"><code class=\"xref py py-attr docutils literal notranslate\">vertical</code></a> “filter” widgets, some icon\nfiles were removed and grouped into two sprite files.</p>\n<p>Specifically: <code class=\"docutils literal notranslate\">selector-add.gif</code>, <code class=\"docutils literal notranslate\">selector-addall.gif</code>,\n<code class=\"docutils literal notranslate\">selector-remove.gif</code>, <code class=\"docutils literal notranslate\">selector-removeall.gif</code>,\n<code class=\"docutils literal notranslate\">selector_stacked-add.gif</code> and <code class=\"docutils literal notranslate\">selector_stacked-remove.gif</code> were\ncombined into <code class=\"docutils literal notranslate\">selector-icons.gif</code>; and <code class=\"docutils literal notranslate\">arrow-up.gif</code> and\n<code class=\"docutils literal notranslate\">arrow-down.gif</code> were combined into <code class=\"docutils literal notranslate\">sorting-icons.gif</code>.</p>\n<p>If you used those icons to customize the admin, then you’ll need to replace\nthem with your own icons or get the files from a previous release.</p>\n</section>\n<section id=\"css-class-names-in-admin-forms\">\n<h3>CSS class names in admin forms<a class=\"heading-anchor\" href=\"#css-class-names-in-admin-forms\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>To avoid conflicts with other common CSS class names (e.g. “button”), we added\na prefix (“field-”) to all CSS class names automatically generated from the\nform field names in the main admin forms, stacked inline forms and tabular\ninline cells. You’ll need to take that prefix into account in your custom\nstyle sheets or JavaScript files if you previously used plain field names as\nselectors for custom styles or JavaScript transformations.</p>\n</section>\n<section id=\"compatibility-with-old-signed-data\">\n<h3>Compatibility with old signed data<a class=\"heading-anchor\" href=\"#compatibility-with-old-signed-data\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.3 changed the cryptographic signing mechanisms used in a number of\nplaces in Django. While Django 1.3 kept fallbacks that would accept hashes\nproduced by the previous methods, these fallbacks are removed in Django 1.4.</p>\n<p>So, if you upgrade to Django 1.4 directly from 1.2 or earlier, you may\nlose/invalidate certain pieces of data that have been cryptographically signed\nusing an old method. To avoid this, use Django 1.3 first for a period of time\nto allow the signed data to expire naturally. The affected parts are detailed\nbelow, with 1) the consequences of ignoring this advice and 2) the amount of\ntime you need to run Django 1.3 for the data to expire or become irrelevant.</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">contrib.sessions</code> data integrity check</p>\n<ul>\n<li><p>Consequences: The user will be logged out, and session data will be lost.</p></li>\n<li><p>Time period: Defined by <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-SESSION_COOKIE_AGE\"><code class=\"xref std std-setting docutils literal notranslate\">SESSION_COOKIE_AGE</code></a>.</p></li>\n</ul>\n</li>\n<li><p><code class=\"docutils literal notranslate\">contrib.auth</code> password reset hash</p>\n<ul>\n<li><p>Consequences: Password reset links from before the upgrade will not work.</p></li>\n<li><p>Time period: Defined by <code class=\"docutils literal notranslate\">PASSWORD_RESET_TIMEOUT_DAYS</code>.</p></li>\n</ul>\n</li>\n</ul>\n<p>Form-related hashes: these have a much shorter lifetime and are relevant\nonly for the short window where a user might fill in a form generated by the\npre-upgrade Django instance and try to submit it to the upgraded Django\ninstance:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">contrib.comments</code> form security hash</p>\n<ul>\n<li><p>Consequences: The user will see the validation error “Security hash\nfailed.”</p></li>\n<li><p>Time period: The amount of time you expect users to take filling out\ncomment forms.</p></li>\n</ul>\n</li>\n<li><p><code class=\"docutils literal notranslate\">FormWizard</code> security hash</p>\n<ul>\n<li><p>Consequences: The user will see an error about the form having expired\nand will be sent back to the first page of the wizard, losing the data\nentered so far.</p></li>\n<li><p>Time period: The amount of time you expect users to take filling out the\naffected forms.</p></li>\n</ul>\n</li>\n<li><p>CSRF check</p>\n<ul>\n<li><p>Note: This is actually a Django 1.1 fallback, not Django 1.2,\nand it applies only if you’re upgrading from 1.1.</p></li>\n<li><p>Consequences: The user will see a 403 error with any CSRF-protected POST\nform.</p></li>\n<li><p>Time period: The amount of time you expect user to take filling out\nsuch forms.</p></li>\n</ul>\n</li>\n<li><p><code class=\"docutils literal notranslate\">contrib.auth</code> user password hash-upgrade sequence</p>\n<ul>\n<li><p>Consequences: Each user’s password will be updated to a stronger password\nhash when it’s written to the database in 1.4. This means that if you\nupgrade to 1.4 and then need to downgrade to 1.3, version 1.3 won’t be able\nto read the updated passwords.</p></li>\n<li><p>Remedy: Set <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-PASSWORD_HASHERS\"><code class=\"xref std std-setting docutils literal notranslate\">PASSWORD_HASHERS</code></a> to use your original password\nhashing when you initially upgrade to 1.4. After you confirm your app works\nwell with Django 1.4 and you won’t have to roll back to 1.3, enable the new\npassword hashes.</p></li>\n</ul>\n</li>\n</ul>\n</section>\n<section id=\"django-contrib-flatpages\">\n<h3><code class=\"docutils literal notranslate\">django.contrib.flatpages</code><a class=\"heading-anchor\" href=\"#django-contrib-flatpages\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Starting in 1.4, the\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/flatpages/#django.contrib.flatpages.middleware.FlatpageFallbackMiddleware\" title=\"django.contrib.flatpages.middleware.FlatpageFallbackMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">FlatpageFallbackMiddleware</code></a> only\nadds a trailing slash and redirects if the resulting URL refers to an existing\nflatpage. For example, requesting <code class=\"docutils literal notranslate\">/notaflatpageoravalidurl</code> in a previous\nversion would redirect to <code class=\"docutils literal notranslate\">/notaflatpageoravalidurl/</code>, which would\nsubsequently raise a 404. Requesting <code class=\"docutils literal notranslate\">/notaflatpageoravalidurl</code> now will\nimmediately raise a 404.</p>\n<p>Also, redirects returned by flatpages are now permanent (with 301 status code),\nto match the behavior of <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>.</p>\n</section>\n<section id=\"serialization-of-datetime-and-time\">\n<h3>Serialization 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> and <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.time\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">time</code></a><a class=\"heading-anchor\" href=\"#serialization-of-datetime-and-time\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>As a consequence of time-zone support, and according to the ECMA-262\nspecification, we made changes to the JSON serializer:</p>\n<ul class=\"simple\">\n<li><p>It includes the time zone for aware datetime objects. It raises an exception\nfor aware time objects.</p></li>\n<li><p>It includes milliseconds for datetime and time objects. There is still\nsome precision loss, because Python stores microseconds (6 digits) and JSON\nonly supports milliseconds (3 digits). However, it’s better than discarding\nmicroseconds entirely.</p></li>\n</ul>\n<p>We changed the XML serializer to use the ISO8601 format for datetimes.\nThe letter <code class=\"docutils literal notranslate\">T</code> is used to separate the date part from the time part, instead\nof a space. Time zone information is included in the <code class=\"docutils literal notranslate\">[+-]HH:MM</code> format.</p>\n<p>Though the serializers now use these new formats when creating fixtures, they\ncan still load fixtures that use the old format.</p>\n</section>\n<section id=\"supports-timezone-changed-to-false-for-sqlite\">\n<h3><code class=\"docutils literal notranslate\">supports_timezone</code> changed to <code class=\"docutils literal notranslate\">False</code> for SQLite<a class=\"heading-anchor\" href=\"#supports-timezone-changed-to-false-for-sqlite\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The database feature <code class=\"docutils literal notranslate\">supports_timezone</code> used to be <code class=\"docutils literal notranslate\">True</code> for SQLite.\nIndeed, if you saved an aware datetime object, SQLite stored a string that\nincluded an UTC offset. However, this offset was ignored when loading the value\nback from the database, which could corrupt the data.</p>\n<p>In the context of time-zone support, this flag was changed to <code class=\"docutils literal notranslate\">False</code>, and\ndatetimes are now stored without time-zone information in SQLite. When\n<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\">False</code>, if you attempt to save an aware datetime\nobject, Django raises an exception.</p>\n</section>\n<section id=\"mysqldb-specific-exceptions\">\n<h3><code class=\"docutils literal notranslate\">MySQLdb</code>-specific exceptions<a class=\"heading-anchor\" href=\"#mysqldb-specific-exceptions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The MySQL backend historically has raised <code class=\"docutils literal notranslate\">MySQLdb.OperationalError</code>\nwhen a query triggered an exception. We’ve fixed this bug, and we now raise\n<a class=\"reference internal\" href=\"/en/dev/ref/exceptions/#django.db.DatabaseError\" title=\"django.db.DatabaseError\"><code class=\"xref py py-exc docutils literal notranslate\">django.db.DatabaseError</code></a> instead. If you were testing for\n<code class=\"docutils literal notranslate\">MySQLdb.OperationalError</code>, you’ll need to update your <code class=\"docutils literal notranslate\">except</code>\nclauses.</p>\n</section>\n<section id=\"database-connection-s-thread-locality\">\n<h3>Database connection’s thread-locality<a class=\"heading-anchor\" href=\"#database-connection-s-thread-locality\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">DatabaseWrapper</code> objects (i.e. the connection objects referenced by\n<code class=\"docutils literal notranslate\">django.db.connection</code> and <code class=\"docutils literal notranslate\">django.db.connections[&quot;some_alias&quot;]</code>) used to\nbe thread-local. They are now global objects in order to be potentially shared\nbetween multiple threads. While the individual connection objects are now\nglobal, the <code class=\"docutils literal notranslate\">django.db.connections</code> dictionary referencing those objects is\nstill thread-local. Therefore if you just use the ORM or\n<code class=\"docutils literal notranslate\">DatabaseWrapper.cursor()</code> then the behavior is still the same as before.\nNote, however, that <code class=\"docutils literal notranslate\">django.db.connection</code> does not directly reference the\ndefault <code class=\"docutils literal notranslate\">DatabaseWrapper</code> object anymore and is now a proxy to access that\nobject’s attributes. If you need to access the actual <code class=\"docutils literal notranslate\">DatabaseWrapper</code>\nobject, use <code class=\"docutils literal notranslate\">django.db.connections[DEFAULT_DB_ALIAS]</code> instead.</p>\n<p>As part of this change, all underlying SQLite connections are now enabled for\npotential thread-sharing (by passing the <code class=\"docutils literal notranslate\">check_same_thread=False</code> attribute\nto <code class=\"docutils literal notranslate\">pysqlite</code>). <code class=\"docutils literal notranslate\">DatabaseWrapper</code> however preserves the previous behavior\nby disabling thread-sharing by default, so this does not affect any existing\ncode that purely relies on the ORM or on <code class=\"docutils literal notranslate\">DatabaseWrapper.cursor()</code>.</p>\n<p>Finally, while it’s now possible to pass connections between threads, Django\ndoesn’t make any effort to synchronize access to the underlying backend.\nConcurrency behavior is defined by the underlying backend implementation.\nCheck their documentation for details.</p>\n</section>\n<section id=\"comments-banned-users-group-setting\">\n<h3><code class=\"docutils literal notranslate\">COMMENTS_BANNED_USERS_GROUP</code> setting<a class=\"heading-anchor\" href=\"#comments-banned-users-group-setting\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django’s comments has historically\nsupported excluding the comments of a special user group, but we’ve never\ndocumented the feature properly and didn’t enforce the exclusion in other parts\nof the app such as the template tags. To fix this problem, we removed the code\nfrom the feed class.</p>\n<p>If you rely on the feature and want to restore the old behavior, use a custom\ncomment model manager to exclude the user group, like this:</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.conf</span> <span class=\"kn\">import</span> settings\n<span class=\"kn\">from</span> <span class=\"nn\">django.contrib.comments.managers</span> <span class=\"kn\">import</span> CommentManager\n\n\n<span class=\"k\">class</span> <span class=\"nc\">BanningCommentManager</span><span class=\"p\">(</span>CommentManager<span class=\"p\">):</span>\n    <span class=\"k\">def</span> <span class=\"nf\">get_query_set</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        qs <span class=\"o\">=</span> <span class=\"nb\">super</span><span class=\"p\">()</span><span class=\"o\">.</span>get_query_set<span class=\"p\">()</span>\n        <span class=\"k\">if</span> <span class=\"nb\">getattr</span><span class=\"p\">(</span>settings<span class=\"p\">,</span> <span class=\"s2\">&quot;COMMENTS_BANNED_USERS_GROUP&quot;</span><span class=\"p\">,</span> <span class=\"kc\">None</span><span class=\"p\">):</span>\n            where <span class=\"o\">=</span> <span class=\"p\">[</span>\n                <span class=\"s2\">&quot;user_id NOT IN (SELECT user_id FROM auth_user_groups WHERE group_id = </span><span class=\"si\">%s</span><span class=\"s2\">)&quot;</span>\n            <span class=\"p\">]</span>\n            params <span class=\"o\">=</span> <span class=\"p\">[</span>settings<span class=\"o\">.</span>COMMENTS_BANNED_USERS_GROUP<span class=\"p\">]</span>\n            qs <span class=\"o\">=</span> qs<span class=\"o\">.</span>extra<span class=\"p\">(</span>where<span class=\"o\">=</span>where<span class=\"p\">,</span> params<span class=\"o\">=</span>params<span class=\"p\">)</span>\n        <span class=\"k\">return</span> qs\n</code></pre></div>\n<p>Save this model manager in your custom comment app (e.g., in\n<code class=\"docutils literal notranslate\">my_comments_app/managers.py</code>) and add it your custom comment app model:</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.db</span> <span class=\"kn\">import</span> models\n<span class=\"kn\">from</span> <span class=\"nn\">django.contrib.comments.models</span> <span class=\"kn\">import</span> Comment\n\n<span class=\"kn\">from</span> <span class=\"nn\">my_comments_app.managers</span> <span class=\"kn\">import</span> BanningCommentManager\n\n\n<span class=\"k\">class</span> <span class=\"nc\">CommentWithTitle</span><span class=\"p\">(</span>Comment<span class=\"p\">):</span>\n    title <span class=\"o\">=</span> models<span class=\"o\">.</span>CharField<span class=\"p\">(</span>max_length<span class=\"o\">=</span><span class=\"mi\">300</span><span class=\"p\">)</span>\n\n    objects <span class=\"o\">=</span> BanningCommentManager<span class=\"p\">()</span>\n</code></pre></div>\n</section>\n<section id=\"ignorable-404-starts-and-ignorable-404-ends-settings\">\n<h3><code class=\"docutils literal notranslate\">IGNORABLE_404_STARTS</code> and <code class=\"docutils literal notranslate\">IGNORABLE_404_ENDS</code> settings<a class=\"heading-anchor\" href=\"#ignorable-404-starts-and-ignorable-404-ends-settings\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Until Django 1.3, it was possible to exclude some URLs from Django’s\n<a class=\"reference internal\" href=\"/en/dev/howto/error-reporting/\"><span class=\"doc\">404 error reporting</span></a> by adding prefixes to\n<code class=\"docutils literal notranslate\">IGNORABLE_404_STARTS</code> and suffixes to <code class=\"docutils literal notranslate\">IGNORABLE_404_ENDS</code>.</p>\n<p>In Django 1.4, these two settings are superseded by\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-IGNORABLE_404_URLS\"><code class=\"xref std std-setting docutils literal notranslate\">IGNORABLE_404_URLS</code></a>, which is a list of compiled regular\nexpressions. Django won’t send an email for 404 errors on URLs that match any\nof them.</p>\n<p>Furthermore, the previous settings had some rather arbitrary default values:</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>IGNORABLE_404_STARTS <span class=\"o\">=</span> <span class=\"p\">(</span><span class=\"s2\">&quot;/cgi-bin/&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;/_vti_bin&quot;</span><span class=\"p\">,</span> <span class=\"s2\">&quot;/_vti_inf&quot;</span><span class=\"p\">)</span>\nIGNORABLE_404_ENDS <span class=\"o\">=</span> <span class=\"p\">(</span>\n    <span class=\"s2\">&quot;mail.pl&quot;</span><span class=\"p\">,</span>\n    <span class=\"s2\">&quot;mailform.pl&quot;</span><span class=\"p\">,</span>\n    <span class=\"s2\">&quot;mail.cgi&quot;</span><span class=\"p\">,</span>\n    <span class=\"s2\">&quot;mailform.cgi&quot;</span><span class=\"p\">,</span>\n    <span class=\"s2\">&quot;favicon.ico&quot;</span><span class=\"p\">,</span>\n    <span class=\"s2\">&quot;.php&quot;</span><span class=\"p\">,</span>\n<span class=\"p\">)</span>\n</code></pre></div>\n<p>It’s not Django’s role to decide if your website has a legacy <code class=\"docutils literal notranslate\">/cgi-bin/</code>\nsection or a <code class=\"docutils literal notranslate\">favicon.ico</code>. As a consequence, the default values of\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-IGNORABLE_404_URLS\"><code class=\"xref std std-setting docutils literal notranslate\">IGNORABLE_404_URLS</code></a>, <code class=\"docutils literal notranslate\">IGNORABLE_404_STARTS</code>, and\n<code class=\"docutils literal notranslate\">IGNORABLE_404_ENDS</code> are all now empty.</p>\n<p>If you have customized <code class=\"docutils literal notranslate\">IGNORABLE_404_STARTS</code> or <code class=\"docutils literal notranslate\">IGNORABLE_404_ENDS</code>, or\nif you want to keep the old default value, you should add the following lines\nin your settings file:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">import</span> <span class=\"nn\">re</span>\n\nIGNORABLE_404_URLS <span class=\"o\">=</span> <span class=\"p\">(</span>\n    <span class=\"c1\"># for each &lt;prefix&gt; in IGNORABLE_404_STARTS</span>\n    re<span class=\"o\">.</span>compile<span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^&lt;prefix&gt;&quot;</span><span class=\"p\">),</span>\n    <span class=\"c1\"># for each &lt;suffix&gt; in IGNORABLE_404_ENDS</span>\n    re<span class=\"o\">.</span>compile<span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;&lt;suffix&gt;$&quot;</span><span class=\"p\">),</span>\n<span class=\"p\">)</span>\n</code></pre></div>\n<p>Don’t forget to escape characters that have a special meaning in a regular\nexpression, such as periods.</p>\n</section>\n<section id=\"csrf-protection-extended-to-put-and-delete\">\n<h3>CSRF protection extended to PUT and DELETE<a class=\"heading-anchor\" href=\"#csrf-protection-extended-to-put-and-delete\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Previously, Django’s <a class=\"reference internal\" href=\"/en/dev/ref/csrf/\"><span class=\"doc\">CSRF protection</span></a> provided\nprotection only against POST requests. Since use of PUT and DELETE methods in\nAJAX applications is becoming more common, we now protect all methods not\ndefined as safe by <span class=\"target\" id=\"index-0\"></span><a class=\"rfc reference external\" href=\"https://datatracker.ietf.org/doc/html/rfc2616.html\"><strong>RFC 2616</strong></a> – i.e., we exempt GET, HEAD, OPTIONS and TRACE,\nand we enforce protection on everything else.</p>\n<p>If you’re using PUT or DELETE methods in AJAX applications, please see the\n<a class=\"reference internal\" href=\"/en/dev/howto/csrf/#csrf-ajax\"><span class=\"std std-ref\">instructions about using AJAX and CSRF</span></a>.</p>\n</section>\n<section id=\"password-reset-view-now-accepts-subject-template-name\">\n<h3>Password reset view now accepts <code class=\"docutils literal notranslate\">subject_template_name</code><a class=\"heading-anchor\" href=\"#password-reset-view-now-accepts-subject-template-name\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">password_reset</code> view in <code class=\"docutils literal notranslate\">django.contrib.auth</code> now accepts a\n<code class=\"docutils literal notranslate\">subject_template_name</code> parameter, which is passed to the password save form\nas a keyword argument. If you are using this view with a custom password reset\nform, then you will need to ensure your form’s <code class=\"docutils literal notranslate\">save()</code> method accepts this\nkeyword argument.</p>\n</section>\n<section id=\"django-core-template-loaders\">\n<h3><code class=\"docutils literal notranslate\">django.core.template_loaders</code><a class=\"heading-anchor\" href=\"#django-core-template-loaders\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This was an alias to <code class=\"docutils literal notranslate\">django.template.loader</code> since 2005, and we’ve removed\nit without emitting a warning due to the length of the deprecation. If your\ncode still referenced this, please use <code class=\"docutils literal notranslate\">django.template.loader</code> instead.</p>\n</section>\n<section id=\"django-db-models-fields-urlfield-verify-exists\">\n<h3><code class=\"docutils literal notranslate\">django.db.models.fields.URLField.verify_exists</code><a class=\"heading-anchor\" href=\"#django-db-models-fields-urlfield-verify-exists\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This functionality has been removed due to intractable performance and\nsecurity issues. Any existing usage of <code class=\"docutils literal notranslate\">verify_exists</code> should be\nremoved.</p>\n</section>\n<section id=\"django-core-files-storage-storage-open\">\n<h3><code class=\"docutils literal notranslate\">django.core.files.storage.Storage.open</code><a class=\"heading-anchor\" href=\"#django-core-files-storage-storage-open\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\">open</code> method of the base Storage class used to take an obscure parameter\n<code class=\"docutils literal notranslate\">mixin</code> that allowed you to dynamically change the base classes of the\nreturned file object. This has been removed. In the rare case you relied on the\n<code class=\"docutils literal notranslate\">mixin</code> parameter, you can easily achieve the same by overriding the <code class=\"docutils literal notranslate\">open</code>\nmethod, like this:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.core.files</span> <span class=\"kn\">import</span> File\n<span class=\"kn\">from</span> <span class=\"nn\">django.core.files.storage</span> <span class=\"kn\">import</span> FileSystemStorage\n\n\n<span class=\"k\">class</span> <span class=\"nc\">Spam</span><span class=\"p\">(</span>File<span class=\"p\">):</span>\n    <span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    Spam, spam, spam, spam and spam.</span>\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n\n    <span class=\"k\">def</span> <span class=\"nf\">ham</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"k\">return</span> <span class=\"s2\">&quot;eggs&quot;</span>\n\n\n<span class=\"k\">class</span> <span class=\"nc\">SpamStorage</span><span class=\"p\">(</span>FileSystemStorage<span class=\"p\">):</span>\n    <span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    A custom file storage backend.</span>\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n\n    <span class=\"k\">def</span> <span class=\"nf\">open</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">,</span> name<span class=\"p\">,</span> mode<span class=\"o\">=</span><span class=\"s2\">&quot;rb&quot;</span><span class=\"p\">):</span>\n        <span class=\"k\">return</span> Spam<span class=\"p\">(</span><span class=\"nb\">open</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"o\">.</span>path<span class=\"p\">(</span>name<span class=\"p\">),</span> mode<span class=\"p\">))</span>\n</code></pre></div>\n</section>\n<section id=\"yaml-deserializer-now-uses-yaml-safe-load\">\n<h3>YAML deserializer now uses <code class=\"docutils literal notranslate\">yaml.safe_load</code><a class=\"heading-anchor\" href=\"#yaml-deserializer-now-uses-yaml-safe-load\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><code class=\"docutils literal notranslate\">yaml.load</code> is able to construct any Python object, which may trigger\narbitrary code execution if you process a YAML document that comes from an\nuntrusted source. This feature isn’t necessary for Django’s YAML deserializer,\nwhose primary use is to load fixtures consisting of simple objects. Even though\nfixtures are trusted data, the YAML deserializer now uses <code class=\"docutils literal notranslate\">yaml.safe_load</code>\nfor additional security.</p>\n</section>\n<section id=\"session-cookies-now-have-the-httponly-flag-by-default\">\n<h3>Session cookies now have the <code class=\"docutils literal notranslate\">httponly</code> flag by default<a class=\"heading-anchor\" href=\"#session-cookies-now-have-the-httponly-flag-by-default\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Session cookies now include the <code class=\"docutils literal notranslate\">httponly</code> attribute by default to\nhelp reduce the impact of potential XSS attacks. As a consequence of\nthis change, session cookie data, including <code class=\"docutils literal notranslate\">sessionid</code>, is no longer\naccessible from JavaScript in many browsers. For strict backwards\ncompatibility, use <code class=\"docutils literal notranslate\">SESSION_COOKIE_HTTPONLY = False</code> in your\nsettings file.</p>\n</section>\n<section id=\"the-urlize-filter-no-longer-escapes-every-url\">\n<h3>The <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatefilter-urlize\"><code class=\"xref std std-tfilter docutils literal notranslate\">urlize</code></a> filter no longer escapes every URL<a class=\"heading-anchor\" href=\"#the-urlize-filter-no-longer-escapes-every-url\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>When a URL contains a <code class=\"docutils literal notranslate\">%xx</code> sequence, where <code class=\"docutils literal notranslate\">xx</code> are two hexadecimal\ndigits, <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatefilter-urlize\"><code class=\"xref std std-tfilter docutils literal notranslate\">urlize</code></a> now assumes that the URL is already escaped and\ndoesn’t apply URL escaping again. This is wrong for URLs whose unquoted form\ncontains a <code class=\"docutils literal notranslate\">%xx</code> sequence, but such URLs are very unlikely to happen in the\nwild, because they would confuse browsers too.</p>\n</section>\n<section id=\"asserttemplateused-and-asserttemplatenotused-as-context-manager\">\n<h3><code class=\"docutils literal notranslate\">assertTemplateUsed</code> and <code class=\"docutils literal notranslate\">assertTemplateNotUsed</code> as context manager<a class=\"heading-anchor\" href=\"#asserttemplateused-and-asserttemplatenotused-as-context-manager\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>It’s now possible to check whether a template was used within a block of\ncode with <a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertTemplateUsed\" title=\"django.test.SimpleTestCase.assertTemplateUsed\"><code class=\"xref py py-meth docutils literal notranslate\">assertTemplateUsed()</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#django.test.SimpleTestCase.assertTemplateNotUsed\" title=\"django.test.SimpleTestCase.assertTemplateNotUsed\"><code class=\"xref py py-meth docutils literal notranslate\">assertTemplateNotUsed()</code></a>. And they\ncan be used as a context manager:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">with</span> <span class=\"bp\">self</span><span class=\"o\">.</span>assertTemplateUsed<span class=\"p\">(</span><span class=\"s2\">&quot;index.html&quot;</span><span class=\"p\">):</span>\n    render_to_string<span class=\"p\">(</span><span class=\"s2\">&quot;index.html&quot;</span><span class=\"p\">)</span>\n<span class=\"k\">with</span> <span class=\"bp\">self</span><span class=\"o\">.</span>assertTemplateNotUsed<span class=\"p\">(</span><span class=\"s2\">&quot;base.html&quot;</span><span class=\"p\">):</span>\n    render_to_string<span class=\"p\">(</span><span class=\"s2\">&quot;index.html&quot;</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>See the <a class=\"reference internal\" href=\"/en/dev/topics/testing/tools/#assertions\"><span class=\"std std-ref\">assertion documentation</span></a> for more.</p>\n</section>\n<section id=\"database-connections-after-running-the-test-suite\">\n<h3>Database connections after running the test suite<a class=\"heading-anchor\" href=\"#database-connections-after-running-the-test-suite\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The default test runner no longer restores the database connections after\ntests’ execution. This prevents the production database from being exposed to\npotential threads that would still be running and attempting to create new\nconnections.</p>\n<p>If your code relied on connections to the production database being created\nafter tests’ execution, then you can restore the previous behavior by\nsubclassing <code class=\"docutils literal notranslate\">DjangoTestRunner</code> and overriding its <code class=\"docutils literal notranslate\">teardown_databases()</code>\nmethod.</p>\n</section>\n<section id=\"output-of-manage-py-help\">\n<h3>Output of <a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-help\"><code class=\"xref std std-djadmin docutils literal notranslate\">manage.py help</code></a><a class=\"heading-anchor\" href=\"#output-of-manage-py-help\"><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/django-admin/#django-admin-help\"><code class=\"xref std std-djadmin docutils literal notranslate\">manage.py help</code></a> now groups available commands by application.\nIf you depended on the output of this command – if you parsed it, for example\n– then you’ll need to update your code. To get a list of all available\nmanagement commands in a script, use\n<a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#django-admin-help\"><code class=\"xref std std-djadmin docutils literal notranslate\">manage.py help --commands</code></a> instead.</p>\n</section>\n<section id=\"extends-template-tag\">\n<h3><code class=\"docutils literal notranslate\">extends</code> template tag<a class=\"heading-anchor\" href=\"#extends-template-tag\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Previously, the <a class=\"reference internal\" href=\"/en/dev/ref/templates/builtins/#std-templatetag-extends\"><code class=\"xref std std-ttag docutils literal notranslate\">extends</code></a> tag used a buggy method of parsing arguments,\nwhich could lead to it erroneously considering an argument as a string literal\nwhen it wasn’t. It now uses <code class=\"docutils literal notranslate\">parser.compile_filter</code>, like other tags.</p>\n<p>The internals of the tag aren’t part of the official stable API, but in the\ninterests of full disclosure, the <code class=\"docutils literal notranslate\">ExtendsNode.__init__</code> definition has\nchanged, which may break any custom tags that use this class.</p>\n</section>\n<section id=\"loading-some-incomplete-fixtures-no-longer-works\">\n<h3>Loading some incomplete fixtures no longer works<a class=\"heading-anchor\" href=\"#loading-some-incomplete-fixtures-no-longer-works\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Prior to 1.4, a default value was inserted for fixture objects that were\nmissing a specific date or datetime value when auto_now or auto_now_add was set\nfor the field. This was something that should not have worked, and in 1.4\nloading such incomplete fixtures will fail. Because fixtures are a raw import,\nthey should explicitly specify all field values, regardless of field options on\nthe model.</p>\n</section>\n<section id=\"development-server-multithreading\">\n<h3>Development Server Multithreading<a class=\"heading-anchor\" href=\"#development-server-multithreading\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The development server is now is multithreaded by default. Use the\n<a class=\"reference internal\" href=\"/en/dev/ref/django-admin/#cmdoption-runserver-nothreading\"><code class=\"xref std std-option docutils literal notranslate\">runserver --nothreading</code></a> option to disable the use of threading in the\ndevelopment server:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>django-admin.py runserver --nothreading\n</code></pre></div>\n</section>\n<section id=\"attributes-disabled-in-markdown-when-safe-mode-set\">\n<h3>Attributes disabled in markdown when safe mode set<a class=\"heading-anchor\" href=\"#attributes-disabled-in-markdown-when-safe-mode-set\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Prior to Django 1.4, attributes were included in any markdown output regardless\nof safe mode setting of the filter. With version &gt; 2.1 of the Python-Markdown\nlibrary, an enable_attributes option was added. When the safe argument is\npassed to the markdown filter, both the <code class=\"docutils literal notranslate\">safe_mode=True</code> and\n<code class=\"docutils literal notranslate\">enable_attributes=False</code> options are set. If using a version of the\nPython-Markdown library less than 2.1, a warning is issued that the output is\ninsecure.</p>\n</section>\n<section id=\"formmixin-get-initial-returns-an-instance-specific-dictionary\">\n<h3>FormMixin get_initial returns an instance-specific dictionary<a class=\"heading-anchor\" href=\"#formmixin-get-initial-returns-an-instance-specific-dictionary\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>In Django 1.3, the <code class=\"docutils literal notranslate\">get_initial</code> method of the\n<a class=\"reference internal\" href=\"/en/dev/ref/class-based-views/mixins-editing/#django.views.generic.edit.FormMixin\" title=\"django.views.generic.edit.FormMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.edit.FormMixin</code></a> class was returning the\nclass <code class=\"docutils literal notranslate\">initial</code> dictionary. This has been fixed to return a copy of this\ndictionary, so form instances can modify their initial data without messing\nwith the class variable.</p>\n</section>\n</section>\n<section id=\"features-deprecated-in-1-4\">\n<span id=\"deprecated-features-1-4\"></span><h2>Features deprecated in 1.4<a class=\"heading-anchor\" href=\"#features-deprecated-in-1-4\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"old-styles-of-calling-cache-page-decorator\">\n<h3>Old styles of calling <code class=\"docutils literal notranslate\">cache_page</code> decorator<a class=\"heading-anchor\" href=\"#old-styles-of-calling-cache-page-decorator\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Some legacy ways of calling <a class=\"reference internal\" href=\"/en/dev/topics/cache/#django.views.decorators.cache.cache_page\" title=\"django.views.decorators.cache.cache_page\"><code class=\"xref py py-func docutils literal notranslate\">cache_page()</code></a>\nhave been deprecated. Please see the documentation for the correct way to use\nthis decorator.</p>\n</section>\n<section id=\"support-for-postgresql-versions-older-than-8-2\">\n<h3>Support for PostgreSQL versions older than 8.2<a class=\"heading-anchor\" href=\"#support-for-postgresql-versions-older-than-8-2\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Django 1.3 dropped support for PostgreSQL versions older than 8.0, and we\nsuggested using a more recent version because of performance improvements\nand, more importantly, the end of upstream support periods for 8.0 and 8.1\nwas near (November 2010).</p>\n<p>Django 1.4 takes that policy further and sets 8.2 as the minimum PostgreSQL\nversion it officially supports.</p>\n</section>\n<section id=\"request-exceptions-are-now-always-logged\">\n<h3>Request exceptions are now always logged<a class=\"heading-anchor\" href=\"#request-exceptions-are-now-always-logged\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>When we added <a class=\"reference internal\" href=\"/en/dev/topics/logging/\"><span class=\"doc\">logging support</span></a> in Django in 1.3, the\nadmin error email support was moved into the\n<a class=\"reference internal\" href=\"/en/dev/ref/logging/#django.utils.log.AdminEmailHandler\" title=\"django.utils.log.AdminEmailHandler\"><code class=\"xref py py-class docutils literal notranslate\">django.utils.log.AdminEmailHandler</code></a>, attached to the\n<code class=\"docutils literal notranslate\">'django.request'</code> logger. In order to maintain the established behavior of\nerror emails, the <code class=\"docutils literal notranslate\">'django.request'</code> logger was called only when\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a> was <code class=\"docutils literal notranslate\">False</code>.</p>\n<p>To increase the flexibility of error logging for requests, the\n<code class=\"docutils literal notranslate\">'django.request'</code> logger is now called regardless of the value of\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a>, and the default settings file for new projects now includes a\nseparate filter attached to <a class=\"reference internal\" href=\"/en/dev/ref/logging/#django.utils.log.AdminEmailHandler\" title=\"django.utils.log.AdminEmailHandler\"><code class=\"xref py py-class docutils literal notranslate\">django.utils.log.AdminEmailHandler</code></a> to\nprevent admin error emails in <code class=\"docutils literal notranslate\">DEBUG</code> mode:</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>LOGGING <span class=\"o\">=</span> <span class=\"p\">{</span>\n    <span class=\"c1\"># ...</span>\n    <span class=\"s2\">&quot;filters&quot;</span><span class=\"p\">:</span> <span class=\"p\">{</span>\n        <span class=\"s2\">&quot;require_debug_false&quot;</span><span class=\"p\">:</span> <span class=\"p\">{</span>\n            <span class=\"s2\">&quot;()&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;django.utils.log.RequireDebugFalse&quot;</span><span class=\"p\">,</span>\n        <span class=\"p\">}</span>\n    <span class=\"p\">},</span>\n    <span class=\"s2\">&quot;handlers&quot;</span><span class=\"p\">:</span> <span class=\"p\">{</span>\n        <span class=\"s2\">&quot;mail_admins&quot;</span><span class=\"p\">:</span> <span class=\"p\">{</span>\n            <span class=\"s2\">&quot;level&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;ERROR&quot;</span><span class=\"p\">,</span>\n            <span class=\"s2\">&quot;filters&quot;</span><span class=\"p\">:</span> <span class=\"p\">[</span><span class=\"s2\">&quot;require_debug_false&quot;</span><span class=\"p\">],</span>\n            <span class=\"s2\">&quot;class&quot;</span><span class=\"p\">:</span> <span class=\"s2\">&quot;django.utils.log.AdminEmailHandler&quot;</span><span class=\"p\">,</span>\n        <span class=\"p\">}</span>\n    <span class=\"p\">},</span>\n<span class=\"p\">}</span>\n</code></pre></div>\n<p>If your project was created prior to this change, your <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-LOGGING\"><code class=\"xref std std-setting docutils literal notranslate\">LOGGING</code></a>\nsetting will not include this new filter. In order to maintain\nbackwards-compatibility, Django will detect that your <code class=\"docutils literal notranslate\">'mail_admins'</code> handler\nconfiguration includes no <code class=\"docutils literal notranslate\">'filters'</code> section and will automatically add\nthis filter for you and issue a pending-deprecation warning. This will become a\ndeprecation warning in Django 1.5, and in Django 1.6 the\nbackwards-compatibility shim will be removed entirely.</p>\n<p>The existence of any <code class=\"docutils literal notranslate\">'filters'</code> key under the <code class=\"docutils literal notranslate\">'mail_admins'</code> handler will\ndisable this backward-compatibility shim and deprecation warning.</p>\n</section>\n<section id=\"django-conf-urls-defaults\">\n<h3><code class=\"docutils literal notranslate\">django.conf.urls.defaults</code><a class=\"heading-anchor\" href=\"#django-conf-urls-defaults\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Until Django 1.3, the <code class=\"docutils literal notranslate\">include()</code>, <code class=\"docutils literal notranslate\">patterns()</code>, and <code class=\"docutils literal notranslate\">url()</code> functions,\nplus <a class=\"reference internal\" href=\"/en/dev/ref/urls/#django.conf.urls.handler404\" title=\"django.conf.urls.handler404\"><code class=\"xref py py-data docutils literal notranslate\">handler404</code></a> and\n<a class=\"reference internal\" href=\"/en/dev/ref/urls/#django.conf.urls.handler500\" title=\"django.conf.urls.handler500\"><code class=\"xref py py-data docutils literal notranslate\">handler500</code></a> were located in a\n<code class=\"docutils literal notranslate\">django.conf.urls.defaults</code> module.</p>\n<p>In Django 1.4, they live in <a class=\"reference internal\" href=\"/en/dev/ref/urls/#module-django.conf.urls\" title=\"django.conf.urls\"><code class=\"xref py py-mod docutils literal notranslate\">django.conf.urls</code></a>.</p>\n</section>\n<section id=\"django-contrib-databrowse\">\n<h3><code class=\"docutils literal notranslate\">django.contrib.databrowse</code><a class=\"heading-anchor\" href=\"#django-contrib-databrowse\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Databrowse has not seen active development for some time, and this does not\nshow any sign of changing. There had been a suggestion for a <a class=\"reference external\" href=\"https://code.djangoproject.com/wiki/SummerOfCode2011#Integratedatabrowseintotheadmin\">GSOC project</a> to\nintegrate the functionality of databrowse into the admin, but no progress was\nmade. While Databrowse has been deprecated, an enhancement of\n<code class=\"docutils literal notranslate\">django.contrib.admin</code> providing a similar feature set is still possible.</p>\n<p>The code that powers Databrowse is licensed under the same terms as Django\nitself, so it’s available to be adopted by an individual or group as\na third-party project.</p>\n</section>\n<section id=\"django-core-management-setup-environ\">\n<h3><code class=\"docutils literal notranslate\">django.core.management.setup_environ</code><a class=\"heading-anchor\" href=\"#django-core-management-setup-environ\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This function temporarily modified <code class=\"docutils literal notranslate\">sys.path</code> in order to make the parent\n“project” directory importable under the old flat <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>\nlayout. This function is now deprecated, as its path workarounds are no longer\nneeded with the new <code class=\"docutils literal notranslate\">manage.py</code> and default project layout.</p>\n<p>This function was never documented or part of the public API, but it was widely\nrecommended for use in setting up a “Django environment” for a user script.\nThese uses should be replaced by setting the <span class=\"target\" id=\"index-1\"></span><a class=\"reference internal\" href=\"/en/dev/topics/settings/#envvar-DJANGO_SETTINGS_MODULE\"><code class=\"xref std std-envvar docutils literal notranslate\">DJANGO_SETTINGS_MODULE</code></a>\nenvironment variable or using <a class=\"reference internal\" href=\"/en/dev/topics/settings/#django.conf.settings.configure\" title=\"django.conf.settings.configure\"><code class=\"xref py py-func docutils literal notranslate\">django.conf.settings.configure()</code></a>.</p>\n</section>\n<section id=\"django-core-management-execute-manager\">\n<h3><code class=\"docutils literal notranslate\">django.core.management.execute_manager</code><a class=\"heading-anchor\" href=\"#django-core-management-execute-manager\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This function was previously used by <code class=\"docutils literal notranslate\">manage.py</code> to execute a management\ncommand. It is identical to\n<code class=\"docutils literal notranslate\">django.core.management.execute_from_command_line</code>, except that it first\ncalls <code class=\"docutils literal notranslate\">setup_environ</code>, which is now deprecated. As such, <code class=\"docutils literal notranslate\">execute_manager</code>\nis also deprecated; <code class=\"docutils literal notranslate\">execute_from_command_line</code> can be used instead. Neither\nof these functions is documented as part of the public API, but a deprecation\npath is needed due to use in existing <code class=\"docutils literal notranslate\">manage.py</code> files.</p>\n</section>\n<section id=\"is-safe-and-needs-autoescape-attributes-of-template-filters\">\n<h3><code class=\"docutils literal notranslate\">is_safe</code> and <code class=\"docutils literal notranslate\">needs_autoescape</code> attributes of template filters<a class=\"heading-anchor\" href=\"#is-safe-and-needs-autoescape-attributes-of-template-filters\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Two flags, <code class=\"docutils literal notranslate\">is_safe</code> and <code class=\"docutils literal notranslate\">needs_autoescape</code>, define how each template\nfilter interacts with Django’s auto-escaping behavior. They used to be\nattributes of the filter function:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"nd\">@register</span><span class=\"o\">.</span>filter\n<span class=\"k\">def</span> <span class=\"nf\">noop</span><span class=\"p\">(</span>value<span class=\"p\">):</span>\n    <span class=\"k\">return</span> value\n\n\nnoop<span class=\"o\">.</span>is_safe <span class=\"o\">=</span> <span class=\"kc\">True</span>\n</code></pre></div>\n<p>However, this technique caused some problems in combination with decorators,\nespecially <a class=\"reference internal\" href=\"/en/dev/howto/custom-template-tags/#django.template.defaultfilters.stringfilter\" title=\"django.template.defaultfilters.stringfilter\"><code class=\"xref py py-func docutils literal notranslate\">&#64;stringfilter</code></a>.\nNow, the flags are keyword arguments of <a class=\"reference internal\" href=\"/en/dev/howto/custom-template-tags/#django.template.Library.filter\" title=\"django.template.Library.filter\"><code class=\"xref py py-meth docutils literal notranslate\">&#64;register.filter</code></a>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"nd\">@register</span><span class=\"o\">.</span>filter<span class=\"p\">(</span>is_safe<span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">)</span>\n<span class=\"k\">def</span> <span class=\"nf\">noop</span><span class=\"p\">(</span>value<span class=\"p\">):</span>\n    <span class=\"k\">return</span> value\n</code></pre></div>\n<p>See <a class=\"reference internal\" href=\"/en/dev/howto/custom-template-tags/#filters-auto-escaping\"><span class=\"std std-ref\">filters and auto-escaping</span></a> for more\ninformation.</p>\n</section>\n<section id=\"wildcard-expansion-of-application-names-in-installed-apps\">\n<h3>Wildcard expansion of application names in <code class=\"docutils literal notranslate\">INSTALLED_APPS</code><a class=\"heading-anchor\" href=\"#wildcard-expansion-of-application-names-in-installed-apps\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Until Django 1.3, <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> accepted wildcards in application\nnames, like <code class=\"docutils literal notranslate\">django.contrib.*</code>. The expansion was performed by a\nfilesystem-based implementation of <code class=\"docutils literal notranslate\">from &lt;package&gt; import *</code>. Unfortunately,\nthis can’t be done reliably.</p>\n<p>This behavior was never documented. Since it is unpythonic, it was removed in\nDjango 1.4. If you relied on it, you must edit your settings file to list all\nyour applications explicitly.</p>\n</section>\n<section id=\"httprequest-raw-post-data-renamed-to-httprequest-body\">\n<h3><code class=\"docutils literal notranslate\">HttpRequest.raw_post_data</code> renamed to <code class=\"docutils literal notranslate\">HttpRequest.body</code><a class=\"heading-anchor\" href=\"#httprequest-raw-post-data-renamed-to-httprequest-body\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>This attribute was confusingly named <code class=\"docutils literal notranslate\">HttpRequest.raw_post_data</code>, but it\nactually provided the body of the HTTP request. It’s been renamed to\n<code class=\"docutils literal notranslate\">HttpRequest.body</code>, and <code class=\"docutils literal notranslate\">HttpRequest.raw_post_data</code> has been deprecated.</p>\n</section>\n<section id=\"django-contrib-sitemaps-bug-fix-with-potential-performance-implications\">\n<h3><code class=\"docutils literal notranslate\">django.contrib.sitemaps</code> bug fix with potential performance implications<a class=\"heading-anchor\" href=\"#django-contrib-sitemaps-bug-fix-with-potential-performance-implications\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>In previous versions, <code class=\"docutils literal notranslate\">Paginator</code> objects used in sitemap classes were\ncached, which could result in stale site maps. We’ve removed the caching, so\neach request to a site map now creates a new Paginator object and calls the\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/sitemaps/#django.contrib.sitemaps.Sitemap.items\" title=\"django.contrib.sitemaps.Sitemap.items\"><code class=\"xref py py-attr docutils literal notranslate\">items</code></a> method of the\n<a class=\"reference internal\" href=\"/en/dev/ref/contrib/sitemaps/#django.contrib.sitemaps.Sitemap\" title=\"django.contrib.sitemaps.Sitemap\"><code class=\"xref py py-class docutils literal notranslate\">Sitemap</code></a> subclass. Depending on what your\n<code class=\"docutils literal notranslate\">items()</code> method is doing, this may have a negative performance impact.\nTo mitigate the performance impact, consider using the <a class=\"reference internal\" href=\"/en/dev/topics/cache/\"><span class=\"doc\">caching\nframework</span></a> within your <code class=\"docutils literal notranslate\">Sitemap</code> subclass.</p>\n</section>\n<section id=\"versions-of-python-markdown-earlier-than-2-1\">\n<h3>Versions of Python-Markdown earlier than 2.1<a class=\"heading-anchor\" href=\"#versions-of-python-markdown-earlier-than-2-1\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Versions of Python-Markdown earlier than 2.1 do not support the option to\ndisable attributes. As a security issue, earlier versions of this library will\nnot be supported by the markup contrib app in 1.5 under an accelerated\ndeprecation timeline.</p>\n</section>\n</section>","rootId":"django-1-4-release-notes","toc":[{"title":"Overview","anchor":"overview","children":[]},{"title":"Python compatibility","anchor":"python-compatibility","children":[]},{"title":"What’s new in Django 1.4","anchor":"what-s-new-in-django-1-4","children":[{"title":"Support for time zones","anchor":"support-for-time-zones","children":[]},{"title":"Support for in-browser testing frameworks","anchor":"support-for-in-browser-testing-frameworks","children":[]},{"title":"Updated default project layout and manage.py","anchor":"updated-default-project-layout-and-manage-py","children":[]},{"title":"Custom project and app templates","anchor":"custom-project-and-app-templates","children":[]},{"title":"Improved WSGI support","anchor":"improved-wsgi-support","children":[]},{"title":"SELECT FOR UPDATE support","anchor":"select-for-update-support","children":[]},{"title":"Model.objects.bulk_create in the ORM","anchor":"model-objects-bulk-create-in-the-orm","children":[]},{"title":"QuerySet.prefetch_related","anchor":"queryset-prefetch-related","children":[]},{"title":"Improved password hashing","anchor":"improved-password-hashing","children":[]},{"title":"HTML5 doctype","anchor":"html5-doctype","children":[]},{"title":"List filters in admin interface","anchor":"list-filters-in-admin-interface","children":[]},{"title":"Multiple sort in admin interface","anchor":"multiple-sort-in-admin-interface","children":[]},{"title":"New ModelAdmin methods","anchor":"new-modeladmin-methods","children":[]},{"title":"Admin inlines respect user permissions","anchor":"admin-inlines-respect-user-permissions","children":[]},{"title":"Tools for cryptographic signing","anchor":"tools-for-cryptographic-signing","children":[]},{"title":"Cookie-based session backend","anchor":"cookie-based-session-backend","children":[]},{"title":"New form wizard","anchor":"new-form-wizard","children":[]},{"title":"reverse_lazy","anchor":"reverse-lazy","children":[]},{"title":"Translating URL patterns","anchor":"translating-url-patterns","children":[]},{"title":"Contextual translation support for {% trans %} and {% blocktrans %}","anchor":"contextual-translation-support-for-trans-and-blocktrans","children":[]},{"title":"Customizable SingleObjectMixin URLConf kwargs","anchor":"customizable-singleobjectmixin-urlconf-kwargs","children":[]},{"title":"Assignment template tags","anchor":"assignment-template-tags","children":[]},{"title":"*args and **kwargs support for template tag helper functions","anchor":"args-and-kwargs-support-for-template-tag-helper-functions","children":[]},{"title":"No wrapping of exceptions in TEMPLATE_DEBUG mode","anchor":"no-wrapping-of-exceptions-in-template-debug-mode","children":[]},{"title":"truncatechars template filter","anchor":"truncatechars-template-filter","children":[]},{"title":"static template tag","anchor":"static-template-tag","children":[]},{"title":"CachedStaticFilesStorage storage backend","anchor":"cachedstaticfilesstorage-storage-backend","children":[]},{"title":"Simple clickjacking protection","anchor":"simple-clickjacking-protection","children":[]},{"title":"CSRF improvements","anchor":"csrf-improvements","children":[]},{"title":"Error report filtering","anchor":"error-report-filtering","children":[]},{"title":"Extended IPv6 support","anchor":"extended-ipv6-support","children":[]},{"title":"HTML comparisons in tests","anchor":"html-comparisons-in-tests","children":[]},{"title":"Two new date format strings","anchor":"two-new-date-format-strings","children":[]},{"title":"Minor features","anchor":"minor-features","children":[]}]},{"title":"Backwards incompatible changes in 1.4","anchor":"backwards-incompatible-changes-in-1-4","children":[{"title":"SECRET_KEY setting is required","anchor":"secret-key-setting-is-required","children":[]},{"title":"django.contrib.admin","anchor":"django-contrib-admin","children":[]},{"title":"Supported browsers for the admin","anchor":"supported-browsers-for-the-admin","children":[]},{"title":"Removed admin icons","anchor":"removed-admin-icons","children":[]},{"title":"CSS class names in admin forms","anchor":"css-class-names-in-admin-forms","children":[]},{"title":"Compatibility with old signed data","anchor":"compatibility-with-old-signed-data","children":[]},{"title":"django.contrib.flatpages","anchor":"django-contrib-flatpages","children":[]},{"title":"Serialization of datetime and time","anchor":"serialization-of-datetime-and-time","children":[]},{"title":"supports_timezone changed to False for SQLite","anchor":"supports-timezone-changed-to-false-for-sqlite","children":[]},{"title":"MySQLdb-specific exceptions","anchor":"mysqldb-specific-exceptions","children":[]},{"title":"Database connection’s thread-locality","anchor":"database-connection-s-thread-locality","children":[]},{"title":"COMMENTS_BANNED_USERS_GROUP setting","anchor":"comments-banned-users-group-setting","children":[]},{"title":"IGNORABLE_404_STARTS and IGNORABLE_404_ENDS settings","anchor":"ignorable-404-starts-and-ignorable-404-ends-settings","children":[]},{"title":"CSRF protection extended to PUT and DELETE","anchor":"csrf-protection-extended-to-put-and-delete","children":[]},{"title":"Password reset view now accepts subject_template_name","anchor":"password-reset-view-now-accepts-subject-template-name","children":[]},{"title":"django.core.template_loaders","anchor":"django-core-template-loaders","children":[]},{"title":"django.db.models.fields.URLField.verify_exists","anchor":"django-db-models-fields-urlfield-verify-exists","children":[]},{"title":"django.core.files.storage.Storage.open","anchor":"django-core-files-storage-storage-open","children":[]},{"title":"YAML deserializer now uses yaml.safe_load","anchor":"yaml-deserializer-now-uses-yaml-safe-load","children":[]},{"title":"Session cookies now have the httponly flag by default","anchor":"session-cookies-now-have-the-httponly-flag-by-default","children":[]},{"title":"The urlize filter no longer escapes every URL","anchor":"the-urlize-filter-no-longer-escapes-every-url","children":[]},{"title":"assertTemplateUsed and assertTemplateNotUsed as context manager","anchor":"asserttemplateused-and-asserttemplatenotused-as-context-manager","children":[]},{"title":"Database connections after running the test suite","anchor":"database-connections-after-running-the-test-suite","children":[]},{"title":"Output of manage.py help","anchor":"output-of-manage-py-help","children":[]},{"title":"extends template tag","anchor":"extends-template-tag","children":[]},{"title":"Loading some incomplete fixtures no longer works","anchor":"loading-some-incomplete-fixtures-no-longer-works","children":[]},{"title":"Development Server Multithreading","anchor":"development-server-multithreading","children":[]},{"title":"Attributes disabled in markdown when safe mode set","anchor":"attributes-disabled-in-markdown-when-safe-mode-set","children":[]},{"title":"FormMixin get_initial returns an instance-specific dictionary","anchor":"formmixin-get-initial-returns-an-instance-specific-dictionary","children":[]}]},{"title":"Features deprecated in 1.4","anchor":"features-deprecated-in-1-4","children":[{"title":"Old styles of calling cache_page decorator","anchor":"old-styles-of-calling-cache-page-decorator","children":[]},{"title":"Support for PostgreSQL versions older than 8.2","anchor":"support-for-postgresql-versions-older-than-8-2","children":[]},{"title":"Request exceptions are now always logged","anchor":"request-exceptions-are-now-always-logged","children":[]},{"title":"django.conf.urls.defaults","anchor":"django-conf-urls-defaults","children":[]},{"title":"django.contrib.databrowse","anchor":"django-contrib-databrowse","children":[]},{"title":"django.core.management.setup_environ","anchor":"django-core-management-setup-environ","children":[]},{"title":"django.core.management.execute_manager","anchor":"django-core-management-execute-manager","children":[]},{"title":"is_safe and needs_autoescape attributes of template filters","anchor":"is-safe-and-needs-autoescape-attributes-of-template-filters","children":[]},{"title":"Wildcard expansion of application names in INSTALLED_APPS","anchor":"wildcard-expansion-of-application-names-in-installed-apps","children":[]},{"title":"HttpRequest.raw_post_data renamed to HttpRequest.body","anchor":"httprequest-raw-post-data-renamed-to-httprequest-body","children":[]},{"title":"django.contrib.sitemaps bug fix with potential performance implications","anchor":"django-contrib-sitemaps-bug-fix-with-potential-performance-implications","children":[]},{"title":"Versions of Python-Markdown earlier than 2.1","anchor":"versions-of-python-markdown-earlier-than-2-1","children":[]}]}],"breadcrumbs":[{"docname":"releases/index","title":"Release notes","url":"/en/dev/releases/"}],"prev":{"docname":"releases/1.4.1","title":"Django 1.4.1 release notes","url":"/en/dev/releases/1.4.1/"},"next":{"docname":"releases/1.3.7","title":"Django 1.3.7 release notes","url":"/en/dev/releases/1.3.7/"},"formats":{"html":"/en/dev/releases/1.4/","markdown":"/en/dev/releases/1.4.md","json":"/en/dev/releases/1.4.json"},"source":"https://github.com/django/django/blob/main/docs/releases/1.4.txt","official":"https://docs.djangoproject.com/en/dev/releases/1.4/","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"]}