Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- testbed/django__django/docs/releases/0.96.txt +247 -0
- testbed/django__django/docs/releases/1.0-porting-guide.txt +779 -0
- testbed/django__django/docs/releases/1.0.2.txt +51 -0
- testbed/django__django/docs/releases/1.0.txt +244 -0
- testbed/django__django/docs/releases/1.1.2.txt +56 -0
- testbed/django__django/docs/releases/1.1.txt +459 -0
- testbed/django__django/docs/releases/1.10.3.txt +68 -0
- testbed/django__django/docs/releases/1.10.txt +1384 -0
- testbed/django__django/docs/releases/1.11.1.txt +112 -0
- testbed/django__django/docs/releases/1.11.13.txt +22 -0
- testbed/django__django/docs/releases/1.11.5.txt +57 -0
- testbed/django__django/docs/releases/1.11.9.txt +23 -0
- testbed/django__django/docs/releases/1.11.txt +889 -0
- testbed/django__django/docs/releases/1.2.6.txt +16 -0
- testbed/django__django/docs/releases/1.2.txt +1200 -0
- testbed/django__django/docs/releases/1.3.1.txt +16 -0
- testbed/django__django/docs/releases/1.3.4.txt +39 -0
- testbed/django__django/docs/releases/1.3.6.txt +78 -0
- testbed/django__django/docs/releases/1.3.txt +899 -0
- testbed/django__django/docs/releases/1.4.12.txt +13 -0
- testbed/django__django/docs/releases/1.4.13.txt +47 -0
- testbed/django__django/docs/releases/1.4.14.txt +64 -0
- testbed/django__django/docs/releases/1.4.2.txt +58 -0
- testbed/django__django/docs/releases/1.4.4.txt +88 -0
- testbed/django__django/docs/releases/1.4.txt +1363 -0
- testbed/django__django/docs/releases/1.5.1.txt +23 -0
- testbed/django__django/docs/releases/1.5.7.txt +13 -0
- testbed/django__django/docs/releases/1.5.8.txt +47 -0
- testbed/django__django/docs/releases/1.5.9.txt +64 -0
- testbed/django__django/docs/releases/1.5.txt +814 -0
- testbed/django__django/docs/releases/1.6.1.txt +62 -0
- testbed/django__django/docs/releases/1.6.4.txt +20 -0
- testbed/django__django/docs/releases/1.6.5.txt +63 -0
- testbed/django__django/docs/releases/1.6.6.txt +97 -0
- testbed/django__django/docs/releases/1.6.txt +1242 -0
- testbed/django__django/docs/releases/1.7.1.txt +137 -0
- testbed/django__django/docs/releases/1.7.2.txt +194 -0
- testbed/django__django/docs/releases/1.7.9.txt +65 -0
- testbed/django__django/docs/releases/1.7.txt +1856 -0
- testbed/django__django/docs/releases/1.8.11.txt +8 -0
- testbed/django__django/docs/releases/1.8.2.txt +62 -0
- testbed/django__django/docs/releases/1.8.3.txt +155 -0
- testbed/django__django/docs/releases/1.8.txt +1801 -0
- testbed/django__django/docs/releases/1.9.5.txt +51 -0
- testbed/django__django/docs/releases/1.9.txt +1527 -0
- testbed/django__django/docs/releases/2.0.txt +860 -0
- testbed/django__django/docs/releases/2.1.10.txt +27 -0
- testbed/django__django/docs/releases/2.1.6.txt +25 -0
- testbed/django__django/docs/releases/2.2.1.txt +80 -0
- testbed/django__django/docs/releases/2.2.11.txt +22 -0
testbed/django__django/docs/releases/0.96.txt
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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| 5 |
+
Welcome to Django 0.96!
|
| 6 |
+
|
| 7 |
+
The primary goal for 0.96 is a cleanup and stabilization of the features
|
| 8 |
+
introduced in 0.95. There have been a few small `backwards-incompatible
|
| 9 |
+
changes`_ since 0.95, but the upgrade process should be fairly simple
|
| 10 |
+
and should not require major changes to existing applications.
|
| 11 |
+
|
| 12 |
+
However, we're also releasing 0.96 now because we have a set of
|
| 13 |
+
backwards-incompatible changes scheduled for the near future. Once
|
| 14 |
+
completed, they will involve some code changes for application
|
| 15 |
+
developers, so we recommend that you stick with Django 0.96 until the
|
| 16 |
+
next official release; then you'll be able to upgrade in one step
|
| 17 |
+
instead of needing to make incremental changes to keep up with the
|
| 18 |
+
development version of Django.
|
| 19 |
+
|
| 20 |
+
Backwards-incompatible changes
|
| 21 |
+
==============================
|
| 22 |
+
|
| 23 |
+
The following changes may require you to update your code when you switch from
|
| 24 |
+
0.95 to 0.96:
|
| 25 |
+
|
| 26 |
+
``MySQLdb`` version requirement
|
| 27 |
+
-------------------------------
|
| 28 |
+
|
| 29 |
+
Due to a bug in older versions of the ``MySQLdb`` Python module (which
|
| 30 |
+
Django uses to connect to MySQL databases), Django's MySQL backend now
|
| 31 |
+
requires version 1.2.1p2 or higher of ``MySQLdb``, and will raise
|
| 32 |
+
exceptions if you attempt to use an older version.
|
| 33 |
+
|
| 34 |
+
If you're currently unable to upgrade your copy of ``MySQLdb`` to meet
|
| 35 |
+
this requirement, a separate, backwards-compatible backend, called
|
| 36 |
+
"mysql_old", has been added to Django. To use this backend, change
|
| 37 |
+
the ``DATABASE_ENGINE`` setting in your Django settings file from this::
|
| 38 |
+
|
| 39 |
+
DATABASE_ENGINE = "mysql"
|
| 40 |
+
|
| 41 |
+
to this::
|
| 42 |
+
|
| 43 |
+
DATABASE_ENGINE = "mysql_old"
|
| 44 |
+
|
| 45 |
+
However, we strongly encourage MySQL users to upgrade to a more recent
|
| 46 |
+
version of ``MySQLdb`` as soon as possible, The "mysql_old" backend is
|
| 47 |
+
provided only to ease this transition, and is considered deprecated;
|
| 48 |
+
aside from any necessary security fixes, it will not be actively
|
| 49 |
+
maintained, and it will be removed in a future release of Django.
|
| 50 |
+
|
| 51 |
+
Also, note that some features, like the new ``DATABASE_OPTIONS``
|
| 52 |
+
setting (see the :doc:`databases documentation </ref/databases>` for details),
|
| 53 |
+
are only available on the "mysql" backend, and will not be made available for
|
| 54 |
+
"mysql_old".
|
| 55 |
+
|
| 56 |
+
Database constraint names changed
|
| 57 |
+
---------------------------------
|
| 58 |
+
|
| 59 |
+
The format of the constraint names Django generates for foreign key
|
| 60 |
+
references have changed slightly. These names are generally only used
|
| 61 |
+
when it is not possible to put the reference directly on the affected
|
| 62 |
+
column, so they are not always visible.
|
| 63 |
+
|
| 64 |
+
The effect of this change is that running ``manage.py reset`` and
|
| 65 |
+
similar commands against an existing database may generate SQL with
|
| 66 |
+
the new form of constraint name, while the database itself contains
|
| 67 |
+
constraints named in the old form; this will cause the database server
|
| 68 |
+
to raise an error message about modifying nonexistent constraints.
|
| 69 |
+
|
| 70 |
+
If you need to work around this, there are two methods available:
|
| 71 |
+
|
| 72 |
+
1. Redirect the output of ``manage.py`` to a file, and edit the
|
| 73 |
+
generated SQL to use the correct constraint names before
|
| 74 |
+
executing it.
|
| 75 |
+
|
| 76 |
+
2. Examine the output of ``manage.py sqlall`` to see the new-style
|
| 77 |
+
constraint names, and use that as a guide to rename existing
|
| 78 |
+
constraints in your database.
|
| 79 |
+
|
| 80 |
+
Name changes in ``manage.py``
|
| 81 |
+
-----------------------------
|
| 82 |
+
|
| 83 |
+
A few of the options to ``manage.py`` have changed with the addition of fixture
|
| 84 |
+
support:
|
| 85 |
+
|
| 86 |
+
* There are new ``dumpdata`` and ``loaddata`` commands which, as
|
| 87 |
+
you might expect, will dump and load data to/from the
|
| 88 |
+
database. These commands can operate against any of Django's
|
| 89 |
+
supported serialization formats.
|
| 90 |
+
|
| 91 |
+
* The ``sqlinitialdata`` command has been renamed to ``sqlcustom`` to
|
| 92 |
+
emphasize that ``loaddata`` should be used for data (and ``sqlcustom`` for
|
| 93 |
+
other custom SQL -- views, stored procedures, etc.).
|
| 94 |
+
|
| 95 |
+
* The vestigial ``install`` command has been removed. Use ``syncdb``.
|
| 96 |
+
|
| 97 |
+
Backslash escaping changed
|
| 98 |
+
--------------------------
|
| 99 |
+
|
| 100 |
+
The Django database API now escapes backslashes given as query parameters. If
|
| 101 |
+
you have any database API code that matches backslashes, and it was working before
|
| 102 |
+
(despite the lack of escaping), you'll have to change your code to "unescape" the
|
| 103 |
+
slashes one level.
|
| 104 |
+
|
| 105 |
+
For example, this used to work::
|
| 106 |
+
|
| 107 |
+
# Find text containing a single backslash
|
| 108 |
+
MyModel.objects.filter(text__contains="\\\\")
|
| 109 |
+
|
| 110 |
+
The above is now incorrect, and should be rewritten as::
|
| 111 |
+
|
| 112 |
+
# Find text containing a single backslash
|
| 113 |
+
MyModel.objects.filter(text__contains="\\")
|
| 114 |
+
|
| 115 |
+
Removed ENABLE_PSYCO setting
|
| 116 |
+
----------------------------
|
| 117 |
+
|
| 118 |
+
The ``ENABLE_PSYCO`` setting no longer exists. If your settings file includes
|
| 119 |
+
``ENABLE_PSYCO`` it will have no effect; to use Psyco_, we recommend
|
| 120 |
+
writing a middleware class to activate it.
|
| 121 |
+
|
| 122 |
+
.. _psyco: http://psyco.sourceforge.net/
|
| 123 |
+
|
| 124 |
+
What's new in 0.96?
|
| 125 |
+
===================
|
| 126 |
+
|
| 127 |
+
This revision represents over a thousand source commits and over four hundred
|
| 128 |
+
bug fixes, so we can't possibly catalog all the changes. Here, we describe the
|
| 129 |
+
most notable changes in this release.
|
| 130 |
+
|
| 131 |
+
New forms library
|
| 132 |
+
-----------------
|
| 133 |
+
|
| 134 |
+
``django.newforms`` is Django's new form-handling library. It's a
|
| 135 |
+
replacement for ``django.forms``, the old form/manipulator/validation
|
| 136 |
+
framework. Both APIs are available in 0.96, but over the next two
|
| 137 |
+
releases we plan to switch completely to the new forms system, and
|
| 138 |
+
deprecate and remove the old system.
|
| 139 |
+
|
| 140 |
+
There are three elements to this transition:
|
| 141 |
+
|
| 142 |
+
* We've copied the current ``django.forms`` to
|
| 143 |
+
``django.oldforms``. This allows you to upgrade your code *now*
|
| 144 |
+
rather than waiting for the backwards-incompatible change and
|
| 145 |
+
rushing to fix your code after the fact. Just change your
|
| 146 |
+
import statements like this::
|
| 147 |
+
|
| 148 |
+
from django import forms # 0.95-style
|
| 149 |
+
from django import oldforms as forms # 0.96-style
|
| 150 |
+
|
| 151 |
+
* The next official release of Django will move the current
|
| 152 |
+
``django.newforms`` to ``django.forms``. This will be a
|
| 153 |
+
backwards-incompatible change, and anyone still using the old
|
| 154 |
+
version of ``django.forms`` at that time will need to change
|
| 155 |
+
their import statements as described above.
|
| 156 |
+
|
| 157 |
+
* The next release after that will completely remove
|
| 158 |
+
``django.oldforms``.
|
| 159 |
+
|
| 160 |
+
Although the ``newforms`` library will continue to evolve, it's ready for use
|
| 161 |
+
for most common cases. We recommend that anyone new to form handling skip the
|
| 162 |
+
old forms system and start with the new.
|
| 163 |
+
|
| 164 |
+
For more information about ``django.newforms``, read the :doc:`newforms
|
| 165 |
+
documentation </topics/forms/index>`.
|
| 166 |
+
|
| 167 |
+
URLconf improvements
|
| 168 |
+
--------------------
|
| 169 |
+
|
| 170 |
+
You can now use any callable as the callback in URLconfs (previously, only
|
| 171 |
+
strings that referred to callables were allowed). This allows a much more
|
| 172 |
+
natural use of URLconfs. For example, this URLconf::
|
| 173 |
+
|
| 174 |
+
from django.conf.urls.defaults import *
|
| 175 |
+
|
| 176 |
+
urlpatterns = patterns("", ("^myview/$", "mysite.myapp.views.myview"))
|
| 177 |
+
|
| 178 |
+
can now be rewritten as::
|
| 179 |
+
|
| 180 |
+
from django.conf.urls.defaults import *
|
| 181 |
+
from mysite.myapp.views import myview
|
| 182 |
+
|
| 183 |
+
urlpatterns = patterns("", ("^myview/$", myview))
|
| 184 |
+
|
| 185 |
+
One useful application of this can be seen when using decorators; this
|
| 186 |
+
change allows you to apply decorators to views *in your
|
| 187 |
+
URLconf*. Thus, you can make a generic view require login very
|
| 188 |
+
easily::
|
| 189 |
+
|
| 190 |
+
from django.conf.urls.defaults import *
|
| 191 |
+
from django.contrib.auth.decorators import login_required
|
| 192 |
+
from django.views.generic.list_detail import object_list
|
| 193 |
+
from mysite.myapp.models import MyModel
|
| 194 |
+
|
| 195 |
+
info = {
|
| 196 |
+
"queryset": MyModel.objects.all(),
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
urlpatterns = patterns("", ("^myview/$", login_required(object_list), info))
|
| 200 |
+
|
| 201 |
+
Note that both syntaxes (strings and callables) are valid, and will continue to
|
| 202 |
+
be valid for the foreseeable future.
|
| 203 |
+
|
| 204 |
+
The test framework
|
| 205 |
+
------------------
|
| 206 |
+
|
| 207 |
+
Django now includes a test framework so you can start transmuting fear into
|
| 208 |
+
boredom (with apologies to Kent Beck). You can write tests based on
|
| 209 |
+
:mod:`doctest` or :mod:`unittest` and test your views with a simple test client.
|
| 210 |
+
|
| 211 |
+
There is also new support for "fixtures" -- initial data, stored in any of the
|
| 212 |
+
supported :doc:`serialization formats </topics/serialization>`, that will be
|
| 213 |
+
loaded into your database at the start of your tests. This makes testing with
|
| 214 |
+
real data much easier.
|
| 215 |
+
|
| 216 |
+
See :doc:`the testing documentation </topics/testing/index>` for the full details.
|
| 217 |
+
|
| 218 |
+
Improvements to the admin interface
|
| 219 |
+
-----------------------------------
|
| 220 |
+
|
| 221 |
+
A small change, but a very nice one: dedicated views for adding and
|
| 222 |
+
updating users have been added to the admin interface, so you no
|
| 223 |
+
longer need to worry about working with hashed passwords in the admin.
|
| 224 |
+
|
| 225 |
+
Thanks
|
| 226 |
+
======
|
| 227 |
+
|
| 228 |
+
Since 0.95, a number of people have stepped forward and taken a major
|
| 229 |
+
new role in Django's development. We'd like to thank these people for
|
| 230 |
+
all their hard work:
|
| 231 |
+
|
| 232 |
+
* Russell Keith-Magee and Malcolm Tredinnick for their major code
|
| 233 |
+
contributions. This release wouldn't have been possible without them.
|
| 234 |
+
|
| 235 |
+
* Our new release manager, James Bennett, for his work in getting out
|
| 236 |
+
0.95.1, 0.96, and (hopefully) future release.
|
| 237 |
+
|
| 238 |
+
* Our ticket managers Chris Beaven (aka SmileyChris), Simon Greenhill,
|
| 239 |
+
Michael Radziej, and Gary Wilson. They agreed to take on the monumental
|
| 240 |
+
task of wrangling our tickets into nicely cataloged submission. Figuring
|
| 241 |
+
out what to work on is now about a million times easier; thanks again,
|
| 242 |
+
guys.
|
| 243 |
+
|
| 244 |
+
* Everyone who submitted a bug report, patch or ticket comment. We can't
|
| 245 |
+
possibly thank everyone by name -- over 200 developers submitted patches
|
| 246 |
+
that went into 0.96 -- but everyone who's contributed to Django is listed
|
| 247 |
+
in :source:`AUTHORS`.
|
testbed/django__django/docs/releases/1.0-porting-guide.txt
ADDED
|
@@ -0,0 +1,779 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
=========================================
|
| 2 |
+
Porting your apps from Django 0.96 to 1.0
|
| 3 |
+
=========================================
|
| 4 |
+
|
| 5 |
+
Django 1.0 breaks compatibility with 0.96 in some areas.
|
| 6 |
+
|
| 7 |
+
This guide will help you port 0.96 projects and apps to 1.0. The first part of
|
| 8 |
+
this document includes the common changes needed to run with 1.0. If after going
|
| 9 |
+
through the first part your code still breaks, check the section `Less-common
|
| 10 |
+
Changes`_ for a list of a bunch of less-common compatibility issues.
|
| 11 |
+
|
| 12 |
+
.. seealso::
|
| 13 |
+
|
| 14 |
+
The :doc:`1.0 release notes </releases/1.0>`. That document explains the new
|
| 15 |
+
features in 1.0 more deeply; the porting guide is more concerned with
|
| 16 |
+
helping you quickly update your code.
|
| 17 |
+
|
| 18 |
+
Common changes
|
| 19 |
+
==============
|
| 20 |
+
|
| 21 |
+
This section describes the changes between 0.96 and 1.0 that most users will
|
| 22 |
+
need to make.
|
| 23 |
+
|
| 24 |
+
Use Unicode
|
| 25 |
+
-----------
|
| 26 |
+
|
| 27 |
+
Change string literals (``'foo'``) into Unicode literals (``u'foo'``). Django
|
| 28 |
+
now uses Unicode strings throughout. In most places, raw strings will continue
|
| 29 |
+
to work, but updating to use Unicode literals will prevent some obscure
|
| 30 |
+
problems.
|
| 31 |
+
|
| 32 |
+
See :doc:`/ref/unicode` for full details.
|
| 33 |
+
|
| 34 |
+
Models
|
| 35 |
+
------
|
| 36 |
+
|
| 37 |
+
Common changes to your models file:
|
| 38 |
+
|
| 39 |
+
Rename ``maxlength`` to ``max_length``
|
| 40 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 41 |
+
|
| 42 |
+
Rename your ``maxlength`` argument to ``max_length`` (this was changed to be
|
| 43 |
+
consistent with form fields):
|
| 44 |
+
|
| 45 |
+
Replace ``__str__`` with ``__unicode__``
|
| 46 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 47 |
+
|
| 48 |
+
Replace your model's ``__str__`` function with a ``__unicode__`` method, and
|
| 49 |
+
make sure you `use Unicode`_ (``u'foo'``) in that method.
|
| 50 |
+
|
| 51 |
+
Remove ``prepopulated_from``
|
| 52 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 53 |
+
|
| 54 |
+
Remove the ``prepopulated_from`` argument on model fields. It's no longer valid
|
| 55 |
+
and has been moved to the ``ModelAdmin`` class in ``admin.py``. See `the
|
| 56 |
+
admin`_, below, for more details about changes to the admin.
|
| 57 |
+
|
| 58 |
+
Remove ``core``
|
| 59 |
+
~~~~~~~~~~~~~~~
|
| 60 |
+
|
| 61 |
+
Remove the ``core`` argument from your model fields. It is no longer
|
| 62 |
+
necessary, since the equivalent functionality (part of :ref:`inline editing
|
| 63 |
+
<admin-inlines>`) is handled differently by the admin interface now. You don't
|
| 64 |
+
have to worry about inline editing until you get to `the admin`_ section,
|
| 65 |
+
below. For now, remove all references to ``core``.
|
| 66 |
+
|
| 67 |
+
Replace ``class Admin:`` with ``admin.py``
|
| 68 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 69 |
+
|
| 70 |
+
Remove all your inner ``class Admin`` declarations from your models. They won't
|
| 71 |
+
break anything if you leave them, but they also won't do anything. To register
|
| 72 |
+
apps with the admin you'll move those declarations to an ``admin.py`` file;
|
| 73 |
+
see `the admin`_ below for more details.
|
| 74 |
+
|
| 75 |
+
.. seealso::
|
| 76 |
+
|
| 77 |
+
A contributor to djangosnippets__ has written a script that'll `scan your
|
| 78 |
+
models.py and generate a corresponding admin.py`__.
|
| 79 |
+
|
| 80 |
+
__ https://djangosnippets.org/
|
| 81 |
+
__ https://djangosnippets.org/snippets/603/
|
| 82 |
+
|
| 83 |
+
Example
|
| 84 |
+
~~~~~~~
|
| 85 |
+
|
| 86 |
+
Below is an example ``models.py`` file with all the changes you'll need to make:
|
| 87 |
+
|
| 88 |
+
Old (0.96) ``models.py``::
|
| 89 |
+
|
| 90 |
+
class Author(models.Model):
|
| 91 |
+
first_name = models.CharField(maxlength=30)
|
| 92 |
+
last_name = models.CharField(maxlength=30)
|
| 93 |
+
slug = models.CharField(maxlength=60, prepopulate_from=("first_name", "last_name"))
|
| 94 |
+
|
| 95 |
+
class Admin:
|
| 96 |
+
list_display = ["first_name", "last_name"]
|
| 97 |
+
|
| 98 |
+
def __str__(self):
|
| 99 |
+
return "%s %s" % (self.first_name, self.last_name)
|
| 100 |
+
|
| 101 |
+
New (1.0) ``models.py``::
|
| 102 |
+
|
| 103 |
+
class Author(models.Model):
|
| 104 |
+
first_name = models.CharField(max_length=30)
|
| 105 |
+
last_name = models.CharField(max_length=30)
|
| 106 |
+
slug = models.CharField(max_length=60)
|
| 107 |
+
|
| 108 |
+
def __unicode__(self):
|
| 109 |
+
return "%s %s" % (self.first_name, self.last_name)
|
| 110 |
+
|
| 111 |
+
New (1.0) ``admin.py``::
|
| 112 |
+
|
| 113 |
+
from django.contrib import admin
|
| 114 |
+
from models import Author
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
class AuthorAdmin(admin.ModelAdmin):
|
| 118 |
+
list_display = ["first_name", "last_name"]
|
| 119 |
+
prepopulated_fields = {"slug": ("first_name", "last_name")}
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
admin.site.register(Author, AuthorAdmin)
|
| 123 |
+
|
| 124 |
+
The Admin
|
| 125 |
+
---------
|
| 126 |
+
|
| 127 |
+
One of the biggest changes in 1.0 is the new admin. The Django administrative
|
| 128 |
+
interface (``django.contrib.admin``) has been completely refactored; admin
|
| 129 |
+
definitions are now completely decoupled from model definitions, the framework
|
| 130 |
+
has been rewritten to use Django's new form-handling library and redesigned with
|
| 131 |
+
extensibility and customization in mind.
|
| 132 |
+
|
| 133 |
+
Practically, this means you'll need to rewrite all of your ``class Admin``
|
| 134 |
+
declarations. You've already seen in `models`_ above how to replace your ``class
|
| 135 |
+
Admin`` with an ``admin.site.register()`` call in an ``admin.py`` file. Below are
|
| 136 |
+
some more details on how to rewrite that ``Admin`` declaration into the new
|
| 137 |
+
syntax.
|
| 138 |
+
|
| 139 |
+
Use new inline syntax
|
| 140 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 141 |
+
|
| 142 |
+
The new ``edit_inline`` options have all been moved to ``admin.py``. Here's an
|
| 143 |
+
example:
|
| 144 |
+
|
| 145 |
+
Old (0.96)::
|
| 146 |
+
|
| 147 |
+
class Parent(models.Model):
|
| 148 |
+
...
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
class Child(models.Model):
|
| 152 |
+
parent = models.ForeignKey(Parent, edit_inline=models.STACKED, num_in_admin=3)
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
New (1.0)::
|
| 156 |
+
|
| 157 |
+
class ChildInline(admin.StackedInline):
|
| 158 |
+
model = Child
|
| 159 |
+
extra = 3
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
class ParentAdmin(admin.ModelAdmin):
|
| 163 |
+
model = Parent
|
| 164 |
+
inlines = [ChildInline]
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
admin.site.register(Parent, ParentAdmin)
|
| 168 |
+
|
| 169 |
+
See :ref:`admin-inlines` for more details.
|
| 170 |
+
|
| 171 |
+
Simplify ``fields``, or use ``fieldsets``
|
| 172 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 173 |
+
|
| 174 |
+
The old ``fields`` syntax was quite confusing, and has been simplified. The old
|
| 175 |
+
syntax still works, but you'll need to use ``fieldsets`` instead.
|
| 176 |
+
|
| 177 |
+
Old (0.96)::
|
| 178 |
+
|
| 179 |
+
class ModelOne(models.Model):
|
| 180 |
+
...
|
| 181 |
+
|
| 182 |
+
class Admin:
|
| 183 |
+
fields = ((None, {"fields": ("foo", "bar")}),)
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
class ModelTwo(models.Model):
|
| 187 |
+
...
|
| 188 |
+
|
| 189 |
+
class Admin:
|
| 190 |
+
fields = (
|
| 191 |
+
("group1", {"fields": ("foo", "bar"), "classes": "collapse"}),
|
| 192 |
+
("group2", {"fields": ("spam", "eggs"), "classes": "collapse wide"}),
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
New (1.0)::
|
| 197 |
+
|
| 198 |
+
class ModelOneAdmin(admin.ModelAdmin):
|
| 199 |
+
fields = ("foo", "bar")
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
class ModelTwoAdmin(admin.ModelAdmin):
|
| 203 |
+
fieldsets = (
|
| 204 |
+
("group1", {"fields": ("foo", "bar"), "classes": "collapse"}),
|
| 205 |
+
("group2", {"fields": ("spam", "eggs"), "classes": "collapse wide"}),
|
| 206 |
+
)
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
.. seealso::
|
| 210 |
+
|
| 211 |
+
* More detailed information about the changes and the reasons behind them
|
| 212 |
+
can be found on the `NewformsAdminBranch wiki page`__
|
| 213 |
+
|
| 214 |
+
* The new admin comes with a ton of new features; you can read about them in
|
| 215 |
+
the :doc:`admin documentation </ref/contrib/admin/index>`.
|
| 216 |
+
|
| 217 |
+
__ https://code.djangoproject.com/wiki/NewformsAdminBranch
|
| 218 |
+
|
| 219 |
+
URLs
|
| 220 |
+
----
|
| 221 |
+
|
| 222 |
+
Update your root ``urls.py``
|
| 223 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 224 |
+
|
| 225 |
+
If you're using the admin site, you need to update your root ``urls.py``.
|
| 226 |
+
|
| 227 |
+
Old (0.96) ``urls.py``::
|
| 228 |
+
|
| 229 |
+
from django.conf.urls.defaults import *
|
| 230 |
+
|
| 231 |
+
urlpatterns = patterns(
|
| 232 |
+
"",
|
| 233 |
+
(r"^admin/", include("django.contrib.admin.urls")),
|
| 234 |
+
# ... the rest of your URLs here ...
|
| 235 |
+
)
|
| 236 |
+
|
| 237 |
+
New (1.0) ``urls.py``::
|
| 238 |
+
|
| 239 |
+
from django.conf.urls.defaults import *
|
| 240 |
+
|
| 241 |
+
# The next two lines enable the admin and load each admin.py file:
|
| 242 |
+
from django.contrib import admin
|
| 243 |
+
|
| 244 |
+
admin.autodiscover()
|
| 245 |
+
|
| 246 |
+
urlpatterns = patterns(
|
| 247 |
+
"",
|
| 248 |
+
(r"^admin/(.*)", admin.site.root),
|
| 249 |
+
# ... the rest of your URLs here ...
|
| 250 |
+
)
|
| 251 |
+
|
| 252 |
+
Views
|
| 253 |
+
-----
|
| 254 |
+
|
| 255 |
+
Use ``django.forms`` instead of ``newforms``
|
| 256 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 257 |
+
|
| 258 |
+
Replace ``django.newforms`` with ``django.forms`` -- Django 1.0 renamed the
|
| 259 |
+
``newforms`` module (introduced in 0.96) to plain old ``forms``. The
|
| 260 |
+
``oldforms`` module was also removed.
|
| 261 |
+
|
| 262 |
+
If you're already using the ``newforms`` library, and you used our recommended
|
| 263 |
+
``import`` statement syntax, all you have to do is change your import
|
| 264 |
+
statements.
|
| 265 |
+
|
| 266 |
+
Old::
|
| 267 |
+
|
| 268 |
+
from django import newforms as forms
|
| 269 |
+
|
| 270 |
+
New::
|
| 271 |
+
|
| 272 |
+
from django import forms
|
| 273 |
+
|
| 274 |
+
If you're using the old forms system (formerly known as ``django.forms`` and
|
| 275 |
+
``django.oldforms``), you'll have to rewrite your forms. A good place to start
|
| 276 |
+
is the :doc:`forms documentation </topics/forms/index>`
|
| 277 |
+
|
| 278 |
+
Handle uploaded files using the new API
|
| 279 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 280 |
+
|
| 281 |
+
Replace use of uploaded files -- that is, entries in ``request.FILES`` -- as
|
| 282 |
+
simple dictionaries with the new
|
| 283 |
+
:class:`~django.core.files.uploadedfile.UploadedFile`. The old dictionary
|
| 284 |
+
syntax no longer works.
|
| 285 |
+
|
| 286 |
+
Thus, in a view like::
|
| 287 |
+
|
| 288 |
+
def my_view(request):
|
| 289 |
+
f = request.FILES["file_field_name"]
|
| 290 |
+
...
|
| 291 |
+
|
| 292 |
+
...you'd need to make the following changes:
|
| 293 |
+
|
| 294 |
+
===================== =====================
|
| 295 |
+
Old (0.96) New (1.0)
|
| 296 |
+
===================== =====================
|
| 297 |
+
``f['content']`` ``f.read()``
|
| 298 |
+
``f['filename']`` ``f.name``
|
| 299 |
+
``f['content-type']`` ``f.content_type``
|
| 300 |
+
===================== =====================
|
| 301 |
+
|
| 302 |
+
Work with file fields using the new API
|
| 303 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 304 |
+
|
| 305 |
+
The internal implementation of :class:`django.db.models.FileField` have changed.
|
| 306 |
+
A visible result of this is that the way you access special attributes (URL,
|
| 307 |
+
filename, image size, etc.) of these model fields has changed. You will need to
|
| 308 |
+
make the following changes, assuming your model's
|
| 309 |
+
:class:`~django.db.models.FileField` is called ``myfile``:
|
| 310 |
+
|
| 311 |
+
=================================== ========================
|
| 312 |
+
Old (0.96) New (1.0)
|
| 313 |
+
=================================== ========================
|
| 314 |
+
``myfile.get_content_filename()`` ``myfile.content.path``
|
| 315 |
+
``myfile.get_content_url()`` ``myfile.content.url``
|
| 316 |
+
``myfile.get_content_size()`` ``myfile.content.size``
|
| 317 |
+
``myfile.save_content_file()`` ``myfile.content.save()``
|
| 318 |
+
``myfile.get_content_width()`` ``myfile.content.width``
|
| 319 |
+
``myfile.get_content_height()`` ``myfile.content.height``
|
| 320 |
+
=================================== ========================
|
| 321 |
+
|
| 322 |
+
Note that the ``width`` and ``height`` attributes only make sense for
|
| 323 |
+
:class:`~django.db.models.ImageField` fields. More details can be found in the
|
| 324 |
+
:doc:`model API </ref/models/fields>` documentation.
|
| 325 |
+
|
| 326 |
+
Use ``Paginator`` instead of ``ObjectPaginator``
|
| 327 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 328 |
+
|
| 329 |
+
The ``ObjectPaginator`` in 0.96 has been removed and replaced with an improved
|
| 330 |
+
version, :class:`django.core.paginator.Paginator`.
|
| 331 |
+
|
| 332 |
+
Templates
|
| 333 |
+
---------
|
| 334 |
+
|
| 335 |
+
Learn to love autoescaping
|
| 336 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 337 |
+
|
| 338 |
+
By default, the template system now automatically HTML-escapes the output of
|
| 339 |
+
every variable. To learn more, see :ref:`automatic-html-escaping`.
|
| 340 |
+
|
| 341 |
+
To disable auto-escaping for an individual variable, use the :tfilter:`safe`
|
| 342 |
+
filter:
|
| 343 |
+
|
| 344 |
+
.. code-block:: html+django
|
| 345 |
+
|
| 346 |
+
This will be escaped: {{ data }}
|
| 347 |
+
This will not be escaped: {{ data|safe }}
|
| 348 |
+
|
| 349 |
+
To disable auto-escaping for an entire template, wrap the template (or just a
|
| 350 |
+
particular section of the template) in the :ttag:`autoescape` tag:
|
| 351 |
+
|
| 352 |
+
.. code-block:: html+django
|
| 353 |
+
|
| 354 |
+
{% autoescape off %}
|
| 355 |
+
... unescaped template content here ...
|
| 356 |
+
{% endautoescape %}
|
| 357 |
+
|
| 358 |
+
Less-common changes
|
| 359 |
+
===================
|
| 360 |
+
|
| 361 |
+
The following changes are smaller, more localized changes. They should only
|
| 362 |
+
affect more advanced users, but it's probably worth reading through the list and
|
| 363 |
+
checking your code for these things.
|
| 364 |
+
|
| 365 |
+
Signals
|
| 366 |
+
-------
|
| 367 |
+
|
| 368 |
+
* Add ``**kwargs`` to any registered signal handlers.
|
| 369 |
+
|
| 370 |
+
* Connect, disconnect, and send signals via methods on the
|
| 371 |
+
:class:`~django.dispatch.Signal` object instead of through module methods in
|
| 372 |
+
``django.dispatch.dispatcher``.
|
| 373 |
+
|
| 374 |
+
* Remove any use of the ``Anonymous`` and ``Any`` sender options; they no longer
|
| 375 |
+
exist. You can still receive signals sent by any sender by using
|
| 376 |
+
``sender=None``
|
| 377 |
+
|
| 378 |
+
* Make any custom signals you've declared into instances of
|
| 379 |
+
:class:`django.dispatch.Signal` instead of anonymous objects.
|
| 380 |
+
|
| 381 |
+
Here's quick summary of the code changes you'll need to make:
|
| 382 |
+
|
| 383 |
+
================================================= ======================================
|
| 384 |
+
Old (0.96) New (1.0)
|
| 385 |
+
================================================= ======================================
|
| 386 |
+
``def callback(sender)`` ``def callback(sender, **kwargs)``
|
| 387 |
+
``sig = object()`` ``sig = django.dispatch.Signal()``
|
| 388 |
+
``dispatcher.connect(callback, sig)`` ``sig.connect(callback)``
|
| 389 |
+
``dispatcher.send(sig, sender)`` ``sig.send(sender)``
|
| 390 |
+
``dispatcher.connect(callback, sig, sender=Any)`` ``sig.connect(callback, sender=None)``
|
| 391 |
+
================================================= ======================================
|
| 392 |
+
|
| 393 |
+
Comments
|
| 394 |
+
--------
|
| 395 |
+
|
| 396 |
+
If you were using Django 0.96's ``django.contrib.comments`` app, you'll need to
|
| 397 |
+
upgrade to the new comments app introduced in 1.0. See the upgrade guide
|
| 398 |
+
for details.
|
| 399 |
+
|
| 400 |
+
Template tags
|
| 401 |
+
-------------
|
| 402 |
+
|
| 403 |
+
:ttag:`spaceless` tag
|
| 404 |
+
~~~~~~~~~~~~~~~~~~~~~
|
| 405 |
+
|
| 406 |
+
The ``spaceless`` template tag now removes *all* spaces between HTML tags,
|
| 407 |
+
instead of preserving a single space.
|
| 408 |
+
|
| 409 |
+
Local flavors
|
| 410 |
+
-------------
|
| 411 |
+
|
| 412 |
+
U.S. local flavor
|
| 413 |
+
~~~~~~~~~~~~~~~~~
|
| 414 |
+
|
| 415 |
+
``django.contrib.localflavor.usa`` has been renamed to
|
| 416 |
+
``django.contrib.localflavor.us``. This change was made to match the naming
|
| 417 |
+
scheme of other local flavors. To migrate your code, all you need to do is
|
| 418 |
+
change the imports.
|
| 419 |
+
|
| 420 |
+
Sessions
|
| 421 |
+
--------
|
| 422 |
+
|
| 423 |
+
Getting a new session key
|
| 424 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 425 |
+
|
| 426 |
+
``SessionBase.get_new_session_key()`` has been renamed to
|
| 427 |
+
``_get_new_session_key()``. ``get_new_session_object()`` no longer exists.
|
| 428 |
+
|
| 429 |
+
Fixtures
|
| 430 |
+
--------
|
| 431 |
+
|
| 432 |
+
Loading a row no longer calls ``save()``
|
| 433 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 434 |
+
|
| 435 |
+
Previously, loading a row automatically ran the model's ``save()`` method. This
|
| 436 |
+
is no longer the case, so any fields (for example: timestamps) that were
|
| 437 |
+
auto-populated by a ``save()`` now need explicit values in any fixture.
|
| 438 |
+
|
| 439 |
+
Settings
|
| 440 |
+
--------
|
| 441 |
+
|
| 442 |
+
Better exceptions
|
| 443 |
+
~~~~~~~~~~~~~~~~~
|
| 444 |
+
|
| 445 |
+
The old :exc:`EnvironmentError` has split into an
|
| 446 |
+
:exc:`ImportError` when Django fails to find the settings module
|
| 447 |
+
and a :exc:`RuntimeError` when you try to reconfigure settings
|
| 448 |
+
after having already used them.
|
| 449 |
+
|
| 450 |
+
:setting:`LOGIN_URL` has moved
|
| 451 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 452 |
+
|
| 453 |
+
The :setting:`LOGIN_URL` constant moved from ``django.contrib.auth`` into the
|
| 454 |
+
``settings`` module. Instead of using ``from django.contrib.auth import
|
| 455 |
+
LOGIN_URL`` refer to :setting:`settings.LOGIN_URL <LOGIN_URL>`.
|
| 456 |
+
|
| 457 |
+
:setting:`APPEND_SLASH` behavior has been updated
|
| 458 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 459 |
+
|
| 460 |
+
In 0.96, if a URL didn't end in a slash or have a period in the final
|
| 461 |
+
component of its path, and :setting:`APPEND_SLASH` was True, Django would
|
| 462 |
+
redirect to the same URL, but with a slash appended to the end. Now, Django
|
| 463 |
+
checks to see whether the pattern without the trailing slash would be matched
|
| 464 |
+
by something in your URL patterns. If so, no redirection takes place, because
|
| 465 |
+
it is assumed you deliberately wanted to catch that pattern.
|
| 466 |
+
|
| 467 |
+
For most people, this won't require any changes. Some people, though, have URL
|
| 468 |
+
patterns that look like this::
|
| 469 |
+
|
| 470 |
+
r"/some_prefix/(.*)$"
|
| 471 |
+
|
| 472 |
+
Previously, those patterns would have been redirected to have a trailing
|
| 473 |
+
slash. If you always want a slash on such URLs, rewrite the pattern as::
|
| 474 |
+
|
| 475 |
+
r"/some_prefix/(.*/)$"
|
| 476 |
+
|
| 477 |
+
Smaller model changes
|
| 478 |
+
---------------------
|
| 479 |
+
|
| 480 |
+
Different exception from ``get()``
|
| 481 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 482 |
+
|
| 483 |
+
Managers now return a :exc:`~django.core.exceptions.MultipleObjectsReturned`
|
| 484 |
+
exception instead of :exc:`AssertionError`:
|
| 485 |
+
|
| 486 |
+
Old (0.96)::
|
| 487 |
+
|
| 488 |
+
try:
|
| 489 |
+
Model.objects.get(...)
|
| 490 |
+
except AssertionError:
|
| 491 |
+
handle_the_error()
|
| 492 |
+
|
| 493 |
+
New (1.0)::
|
| 494 |
+
|
| 495 |
+
try:
|
| 496 |
+
Model.objects.get(...)
|
| 497 |
+
except Model.MultipleObjectsReturned:
|
| 498 |
+
handle_the_error()
|
| 499 |
+
|
| 500 |
+
``LazyDate`` has been fired
|
| 501 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 502 |
+
|
| 503 |
+
The ``LazyDate`` helper class no longer exists.
|
| 504 |
+
|
| 505 |
+
Default field values and query arguments can both be callable objects, so
|
| 506 |
+
instances of ``LazyDate`` can be replaced with a reference to ``datetime.datetime.now``:
|
| 507 |
+
|
| 508 |
+
Old (0.96)::
|
| 509 |
+
|
| 510 |
+
class Article(models.Model):
|
| 511 |
+
title = models.CharField(maxlength=100)
|
| 512 |
+
published = models.DateField(default=LazyDate())
|
| 513 |
+
|
| 514 |
+
New (1.0)::
|
| 515 |
+
|
| 516 |
+
import datetime
|
| 517 |
+
|
| 518 |
+
|
| 519 |
+
class Article(models.Model):
|
| 520 |
+
title = models.CharField(max_length=100)
|
| 521 |
+
published = models.DateField(default=datetime.datetime.now)
|
| 522 |
+
|
| 523 |
+
``DecimalField`` is new, and ``FloatField`` is now a proper float
|
| 524 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 525 |
+
|
| 526 |
+
Old (0.96)::
|
| 527 |
+
|
| 528 |
+
class MyModel(models.Model):
|
| 529 |
+
field_name = models.FloatField(max_digits=10, decimal_places=3)
|
| 530 |
+
...
|
| 531 |
+
|
| 532 |
+
New (1.0)::
|
| 533 |
+
|
| 534 |
+
class MyModel(models.Model):
|
| 535 |
+
field_name = models.DecimalField(max_digits=10, decimal_places=3)
|
| 536 |
+
...
|
| 537 |
+
|
| 538 |
+
If you forget to make this change, you will see errors about ``FloatField``
|
| 539 |
+
not taking a ``max_digits`` attribute in ``__init__``, because the new
|
| 540 |
+
``FloatField`` takes no precision-related arguments.
|
| 541 |
+
|
| 542 |
+
If you're using MySQL or PostgreSQL, no further changes are needed. The
|
| 543 |
+
database column types for ``DecimalField`` are the same as for the old
|
| 544 |
+
``FloatField``.
|
| 545 |
+
|
| 546 |
+
If you're using SQLite, you need to force the database to view the
|
| 547 |
+
appropriate columns as decimal types, rather than floats. To do this, you'll
|
| 548 |
+
need to reload your data. Do this after you have made the change to using
|
| 549 |
+
``DecimalField`` in your code and updated the Django code.
|
| 550 |
+
|
| 551 |
+
.. warning::
|
| 552 |
+
|
| 553 |
+
**Back up your database first!**
|
| 554 |
+
|
| 555 |
+
For SQLite, this means making a copy of the single file that stores the
|
| 556 |
+
database (the name of that file is the ``DATABASE_NAME`` in your
|
| 557 |
+
``settings.py`` file).
|
| 558 |
+
|
| 559 |
+
To upgrade each application to use a ``DecimalField``, you can do the
|
| 560 |
+
following, replacing ``<app>`` in the code below with each app's name:
|
| 561 |
+
|
| 562 |
+
.. code-block:: console
|
| 563 |
+
|
| 564 |
+
$ ./manage.py dumpdata --format=xml <app> > data-dump.xml
|
| 565 |
+
$ ./manage.py reset <app>
|
| 566 |
+
$ ./manage.py loaddata data-dump.xml
|
| 567 |
+
|
| 568 |
+
Notes:
|
| 569 |
+
|
| 570 |
+
1. It's important that you remember to use XML format in the first step of
|
| 571 |
+
this process. We are exploiting a feature of the XML data dumps that makes
|
| 572 |
+
porting floats to decimals with SQLite possible.
|
| 573 |
+
|
| 574 |
+
2. In the second step you will be asked to confirm that you are prepared to
|
| 575 |
+
lose the data for the application(s) in question. Say yes; we'll restore
|
| 576 |
+
this data in the third step.
|
| 577 |
+
|
| 578 |
+
3. ``DecimalField`` is not used in any of the apps shipped with Django prior
|
| 579 |
+
to this change being made, so you do not need to worry about performing
|
| 580 |
+
this procedure for any of the standard Django models.
|
| 581 |
+
|
| 582 |
+
If something goes wrong in the above process, just copy your backed up
|
| 583 |
+
database file over the original file and start again.
|
| 584 |
+
|
| 585 |
+
Internationalization
|
| 586 |
+
--------------------
|
| 587 |
+
|
| 588 |
+
:func:`django.views.i18n.set_language` now requires a POST request
|
| 589 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 590 |
+
|
| 591 |
+
Previously, a GET request was used. The old behavior meant that state (the
|
| 592 |
+
locale used to display the site) could be changed by a GET request, which is
|
| 593 |
+
against the HTTP specification's recommendations. Code calling this view must
|
| 594 |
+
ensure that a POST request is now made, instead of a GET. This means you can
|
| 595 |
+
no longer use a link to access the view, but must use a form submission of
|
| 596 |
+
some kind (e.g. a button).
|
| 597 |
+
|
| 598 |
+
``_()`` is no longer in builtins
|
| 599 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 600 |
+
|
| 601 |
+
``_()`` (the callable object whose name is a single underscore) is no longer
|
| 602 |
+
monkeypatched into builtins -- that is, it's no longer available magically in
|
| 603 |
+
every module.
|
| 604 |
+
|
| 605 |
+
If you were previously relying on ``_()`` always being present, you should now
|
| 606 |
+
explicitly import ``ugettext`` or ``ugettext_lazy``, if appropriate, and alias
|
| 607 |
+
it to ``_`` yourself::
|
| 608 |
+
|
| 609 |
+
from django.utils.translation import ugettext as _
|
| 610 |
+
|
| 611 |
+
HTTP request/response objects
|
| 612 |
+
-----------------------------
|
| 613 |
+
|
| 614 |
+
Dictionary access to ``HttpRequest``
|
| 615 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 616 |
+
|
| 617 |
+
``HttpRequest`` objects no longer directly support dictionary-style
|
| 618 |
+
access; previously, both ``GET`` and ``POST`` data were directly
|
| 619 |
+
available on the ``HttpRequest`` object (e.g., you could check for a
|
| 620 |
+
piece of form data by using ``if 'some_form_key' in request`` or by
|
| 621 |
+
reading ``request['some_form_key']``. This is no longer supported; if
|
| 622 |
+
you need access to the combined ``GET`` and ``POST`` data, use
|
| 623 |
+
``request.REQUEST`` instead.
|
| 624 |
+
|
| 625 |
+
It is strongly suggested, however, that you always explicitly look in
|
| 626 |
+
the appropriate dictionary for the type of request you expect to
|
| 627 |
+
receive (``request.GET`` or ``request.POST``); relying on the combined
|
| 628 |
+
``request.REQUEST`` dictionary can mask the origin of incoming data.
|
| 629 |
+
|
| 630 |
+
Accessing ``HTTPResponse`` headers
|
| 631 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 632 |
+
|
| 633 |
+
``django.http.HttpResponse.headers`` has been renamed to ``_headers`` and
|
| 634 |
+
:class:`~django.http.HttpResponse` now supports containment checking directly.
|
| 635 |
+
So use ``if header in response:`` instead of ``if header in response.headers:``.
|
| 636 |
+
|
| 637 |
+
Generic relations
|
| 638 |
+
-----------------
|
| 639 |
+
|
| 640 |
+
Generic relations have been moved out of core
|
| 641 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 642 |
+
|
| 643 |
+
The generic relation classes -- ``GenericForeignKey`` and ``GenericRelation``
|
| 644 |
+
-- have moved into the :mod:`django.contrib.contenttypes` module.
|
| 645 |
+
|
| 646 |
+
Testing
|
| 647 |
+
-------
|
| 648 |
+
|
| 649 |
+
:meth:`django.test.Client.login` has changed
|
| 650 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 651 |
+
|
| 652 |
+
Old (0.96)::
|
| 653 |
+
|
| 654 |
+
from django.test import Client
|
| 655 |
+
|
| 656 |
+
c = Client()
|
| 657 |
+
c.login("/path/to/login", "myuser", "mypassword")
|
| 658 |
+
|
| 659 |
+
New (1.0)::
|
| 660 |
+
|
| 661 |
+
# ... same as above, but then:
|
| 662 |
+
c.login(username="myuser", password="mypassword")
|
| 663 |
+
|
| 664 |
+
Management commands
|
| 665 |
+
-------------------
|
| 666 |
+
|
| 667 |
+
Running management commands from your code
|
| 668 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 669 |
+
|
| 670 |
+
:mod:`django.core.management` has been greatly refactored.
|
| 671 |
+
|
| 672 |
+
Calls to management services in your code now need to use
|
| 673 |
+
``call_command``. For example, if you have some test code that calls flush and
|
| 674 |
+
load_data::
|
| 675 |
+
|
| 676 |
+
from django.core import management
|
| 677 |
+
|
| 678 |
+
management.flush(verbosity=0, interactive=False)
|
| 679 |
+
management.load_data(["test_data"], verbosity=0)
|
| 680 |
+
|
| 681 |
+
...you'll need to change this code to read::
|
| 682 |
+
|
| 683 |
+
from django.core import management
|
| 684 |
+
|
| 685 |
+
management.call_command("flush", verbosity=0, interactive=False)
|
| 686 |
+
management.call_command("loaddata", "test_data", verbosity=0)
|
| 687 |
+
|
| 688 |
+
Subcommands must now precede options
|
| 689 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 690 |
+
|
| 691 |
+
``django-admin.py`` and ``manage.py`` now require subcommands to precede
|
| 692 |
+
options. So:
|
| 693 |
+
|
| 694 |
+
.. code-block:: console
|
| 695 |
+
|
| 696 |
+
$ django-admin.py --settings=foo.bar runserver
|
| 697 |
+
|
| 698 |
+
...no longer works and should be changed to:
|
| 699 |
+
|
| 700 |
+
.. code-block:: console
|
| 701 |
+
|
| 702 |
+
$ django-admin.py runserver --settings=foo.bar
|
| 703 |
+
|
| 704 |
+
Syndication
|
| 705 |
+
-----------
|
| 706 |
+
|
| 707 |
+
``Feed.__init__`` has changed
|
| 708 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 709 |
+
|
| 710 |
+
The ``__init__()`` method of the syndication framework's ``Feed`` class now
|
| 711 |
+
takes an ``HttpRequest`` object as its second parameter, instead of the feed's
|
| 712 |
+
URL. This allows the syndication framework to work without requiring the sites
|
| 713 |
+
framework. This only affects code that subclasses ``Feed`` and overrides the
|
| 714 |
+
``__init__()`` method, and code that calls ``Feed.__init__()`` directly.
|
| 715 |
+
|
| 716 |
+
Data structures
|
| 717 |
+
---------------
|
| 718 |
+
|
| 719 |
+
``SortedDictFromList`` is gone
|
| 720 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 721 |
+
|
| 722 |
+
``django.newforms.forms.SortedDictFromList`` was removed.
|
| 723 |
+
``django.utils.datastructures.SortedDict`` can now be instantiated with
|
| 724 |
+
a sequence of tuples.
|
| 725 |
+
|
| 726 |
+
To update your code:
|
| 727 |
+
|
| 728 |
+
1. Use ``django.utils.datastructures.SortedDict`` wherever you were
|
| 729 |
+
using ``django.newforms.forms.SortedDictFromList``.
|
| 730 |
+
|
| 731 |
+
2. Because ``django.utils.datastructures.SortedDict.copy`` doesn't
|
| 732 |
+
return a deepcopy as ``SortedDictFromList.copy()`` did, you will need
|
| 733 |
+
to update your code if you were relying on a deepcopy. Do this by using
|
| 734 |
+
``copy.deepcopy`` directly.
|
| 735 |
+
|
| 736 |
+
Database backend functions
|
| 737 |
+
--------------------------
|
| 738 |
+
|
| 739 |
+
Database backend functions have been renamed
|
| 740 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 741 |
+
|
| 742 |
+
Almost *all* of the database backend-level functions have been renamed and/or
|
| 743 |
+
relocated. None of these were documented, but you'll need to change your code
|
| 744 |
+
if you're using any of these functions, all of which are in :mod:`django.db`:
|
| 745 |
+
|
| 746 |
+
======================================= ===================================================
|
| 747 |
+
Old (0.96) New (1.0)
|
| 748 |
+
======================================= ===================================================
|
| 749 |
+
``backend.get_autoinc_sql`` ``connection.ops.autoinc_sql``
|
| 750 |
+
``backend.get_date_extract_sql`` ``connection.ops.date_extract_sql``
|
| 751 |
+
``backend.get_date_trunc_sql`` ``connection.ops.date_trunc_sql``
|
| 752 |
+
``backend.get_datetime_cast_sql`` ``connection.ops.datetime_cast_sql``
|
| 753 |
+
``backend.get_deferrable_sql`` ``connection.ops.deferrable_sql``
|
| 754 |
+
``backend.get_drop_foreignkey_sql`` ``connection.ops.drop_foreignkey_sql``
|
| 755 |
+
``backend.get_fulltext_search_sql`` ``connection.ops.fulltext_search_sql``
|
| 756 |
+
``backend.get_last_insert_id`` ``connection.ops.last_insert_id``
|
| 757 |
+
``backend.get_limit_offset_sql`` ``connection.ops.limit_offset_sql``
|
| 758 |
+
``backend.get_max_name_length`` ``connection.ops.max_name_length``
|
| 759 |
+
``backend.get_pk_default_value`` ``connection.ops.pk_default_value``
|
| 760 |
+
``backend.get_random_function_sql`` ``connection.ops.random_function_sql``
|
| 761 |
+
``backend.get_sql_flush`` ``connection.ops.sql_flush``
|
| 762 |
+
``backend.get_sql_sequence_reset`` ``connection.ops.sequence_reset_sql``
|
| 763 |
+
``backend.get_start_transaction_sql`` ``connection.ops.start_transaction_sql``
|
| 764 |
+
``backend.get_tablespace_sql`` ``connection.ops.tablespace_sql``
|
| 765 |
+
``backend.quote_name`` ``connection.ops.quote_name``
|
| 766 |
+
``backend.get_query_set_class`` ``connection.ops.query_set_class``
|
| 767 |
+
``backend.get_field_cast_sql`` ``connection.ops.field_cast_sql``
|
| 768 |
+
``backend.get_drop_sequence`` ``connection.ops.drop_sequence_sql``
|
| 769 |
+
``backend.OPERATOR_MAPPING`` ``connection.operators``
|
| 770 |
+
``backend.allows_group_by_ordinal`` ``connection.features.allows_group_by_ordinal``
|
| 771 |
+
``backend.allows_unique_and_pk`` ``connection.features.allows_unique_and_pk``
|
| 772 |
+
``backend.autoindexes_primary_keys`` ``connection.features.autoindexes_primary_keys``
|
| 773 |
+
``backend.needs_datetime_string_cast`` ``connection.features.needs_datetime_string_cast``
|
| 774 |
+
``backend.needs_upper_for_iops`` ``connection.features.needs_upper_for_iops``
|
| 775 |
+
``backend.supports_constraints`` ``connection.features.supports_constraints``
|
| 776 |
+
``backend.supports_tablespaces`` ``connection.features.supports_tablespaces``
|
| 777 |
+
``backend.uses_case_insensitive_names`` ``connection.features.uses_case_insensitive_names``
|
| 778 |
+
``backend.uses_custom_queryset`` ``connection.features.uses_custom_queryset``
|
| 779 |
+
======================================= ===================================================
|
testbed/django__django/docs/releases/1.0.2.txt
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.0.2 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
Welcome to Django 1.0.2!
|
| 6 |
+
|
| 7 |
+
This is the second "bugfix" release in the Django 1.0 series,
|
| 8 |
+
improving the stability and performance of the Django 1.0 codebase. As
|
| 9 |
+
such, Django 1.0.2 contains no new features (and, pursuant to
|
| 10 |
+
:doc:`our compatibility policy </misc/api-stability>`, maintains backwards compatibility with Django
|
| 11 |
+
1.0.0), but does contain a number of fixes and other
|
| 12 |
+
improvements. Django 1.0.2 is a recommended upgrade for any
|
| 13 |
+
development or deployment currently using or targeting Django 1.0.
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
Fixes and improvements in Django 1.0.2
|
| 17 |
+
======================================
|
| 18 |
+
|
| 19 |
+
The primary reason behind this release is to remedy an issue in the
|
| 20 |
+
recently-released Django 1.0.1; the packaging scripts used for Django
|
| 21 |
+
1.0.1 omitted some directories from the final release package,
|
| 22 |
+
including one directory required by ``django.contrib.gis`` and part of
|
| 23 |
+
Django's unit-test suite.
|
| 24 |
+
|
| 25 |
+
Django 1.0.2 contains updated packaging scripts, and the release
|
| 26 |
+
package contains the directories omitted from Django 1.0.1. As such,
|
| 27 |
+
this release contains all of the fixes and improvements from Django
|
| 28 |
+
1.0.1; see :doc:`the Django 1.0.1 release notes </releases/1.0.1>` for
|
| 29 |
+
details.
|
| 30 |
+
|
| 31 |
+
Additionally, in the period since Django 1.0.1 was released:
|
| 32 |
+
|
| 33 |
+
* Updated Hebrew and Danish translations have been added.
|
| 34 |
+
|
| 35 |
+
* The default ``__repr__`` method of Django models has been made more
|
| 36 |
+
robust in the face of bad Unicode data coming from the
|
| 37 |
+
``__unicode__`` method; rather than raise an exception in such
|
| 38 |
+
cases, ``repr()`` will now contain the string "[Bad Unicode data]"
|
| 39 |
+
in place of the invalid Unicode.
|
| 40 |
+
|
| 41 |
+
* A bug involving the interaction of Django's ``SafeUnicode`` class
|
| 42 |
+
and the MySQL adapter has been resolved; ``SafeUnicode`` instances
|
| 43 |
+
(generated, for example, by template rendering) can now be assigned
|
| 44 |
+
to model attributes and saved to MySQL without requiring an explicit
|
| 45 |
+
intermediate cast to ``unicode``.
|
| 46 |
+
|
| 47 |
+
* A bug affecting filtering on a nullable ``DateField`` in SQLite has
|
| 48 |
+
been resolved.
|
| 49 |
+
|
| 50 |
+
* Several updates and improvements have been made to Django's
|
| 51 |
+
documentation.
|
testbed/django__django/docs/releases/1.0.txt
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========================
|
| 2 |
+
Django 1.0 release notes
|
| 3 |
+
========================
|
| 4 |
+
|
| 5 |
+
Welcome to Django 1.0!
|
| 6 |
+
|
| 7 |
+
We've been looking forward to this moment for over three years, and it's finally
|
| 8 |
+
here. Django 1.0 represents the largest milestone in Django's development to
|
| 9 |
+
date: a web framework that a group of perfectionists can truly be proud of.
|
| 10 |
+
|
| 11 |
+
Django 1.0 represents over three years of community development as an Open
|
| 12 |
+
Source project. Django's received contributions from hundreds of developers,
|
| 13 |
+
been translated into fifty languages, and today is used by developers on every
|
| 14 |
+
continent and in every kind of job.
|
| 15 |
+
|
| 16 |
+
An interesting historical note: when Django was first released in July 2005, the
|
| 17 |
+
initial released version of Django came from an internal repository at revision
|
| 18 |
+
number 8825. Django 1.0 represents revision 8961 of our public repository. It
|
| 19 |
+
seems fitting that our 1.0 release comes at the moment where community
|
| 20 |
+
contributions overtake those made privately.
|
| 21 |
+
|
| 22 |
+
Stability and forwards-compatibility
|
| 23 |
+
====================================
|
| 24 |
+
|
| 25 |
+
The release of Django 1.0 comes with a promise of API
|
| 26 |
+
stability and forwards-compatibility. In a nutshell, this means that code you
|
| 27 |
+
develop against Django 1.0 will continue to work against 1.1 unchanged, and you
|
| 28 |
+
should need to make only minor changes for any 1.X release.
|
| 29 |
+
|
| 30 |
+
See the :doc:`API stability guide </misc/api-stability>` for full details.
|
| 31 |
+
|
| 32 |
+
Backwards-incompatible changes
|
| 33 |
+
==============================
|
| 34 |
+
|
| 35 |
+
Django 1.0 has a number of backwards-incompatible changes from Django 0.96. If
|
| 36 |
+
you have apps written against Django 0.96 that you need to port, see our
|
| 37 |
+
detailed porting guide:
|
| 38 |
+
|
| 39 |
+
.. toctree::
|
| 40 |
+
:maxdepth: 1
|
| 41 |
+
|
| 42 |
+
1.0-porting-guide
|
| 43 |
+
|
| 44 |
+
A complete list of backwards-incompatible changes can be found at
|
| 45 |
+
https://code.djangoproject.com/wiki/BackwardsIncompatibleChanges.
|
| 46 |
+
|
| 47 |
+
What's new in Django 1.0
|
| 48 |
+
========================
|
| 49 |
+
|
| 50 |
+
A *lot*!
|
| 51 |
+
|
| 52 |
+
Since Django 0.96, we've made over 4,000 code commits, fixed more than 2,000
|
| 53 |
+
bugs, and edited, added, or removed around 350,000 lines of code. We've also
|
| 54 |
+
added 40,000 lines of new documentation, and greatly improved what was already
|
| 55 |
+
there.
|
| 56 |
+
|
| 57 |
+
In fact, new documentation is one of our favorite features of Django 1.0, so we
|
| 58 |
+
might as well start there. First, there's a new documentation site:
|
| 59 |
+
|
| 60 |
+
* https://docs.djangoproject.com/
|
| 61 |
+
|
| 62 |
+
The documentation has been greatly improved, cleaned up, and generally made
|
| 63 |
+
awesome. There's now dedicated search, indexes, and more.
|
| 64 |
+
|
| 65 |
+
We can't possibly document everything that's new in 1.0, but the documentation
|
| 66 |
+
will be your definitive guide. Anywhere you see something like:
|
| 67 |
+
|
| 68 |
+
.. versionadded:: 1.0
|
| 69 |
+
|
| 70 |
+
This feature is new in Django 1.0
|
| 71 |
+
|
| 72 |
+
You'll know that you're looking at something new or changed.
|
| 73 |
+
|
| 74 |
+
The other major highlights of Django 1.0 are:
|
| 75 |
+
|
| 76 |
+
Refactored admin application
|
| 77 |
+
----------------------------
|
| 78 |
+
|
| 79 |
+
The Django administrative interface (``django.contrib.admin``) has been
|
| 80 |
+
completely refactored; admin definitions are now completely decoupled from model
|
| 81 |
+
definitions (no more ``class Admin`` declaration in models!), rewritten to use
|
| 82 |
+
Django's new form-handling library (introduced in the 0.96 release as
|
| 83 |
+
``django.newforms``, and now available as simply ``django.forms``) and
|
| 84 |
+
redesigned with extensibility and customization in mind. Full documentation for
|
| 85 |
+
the admin application is available online in the official Django documentation:
|
| 86 |
+
|
| 87 |
+
See the :doc:`admin reference </ref/contrib/admin/index>` for details
|
| 88 |
+
|
| 89 |
+
Improved Unicode handling
|
| 90 |
+
-------------------------
|
| 91 |
+
|
| 92 |
+
Django's internals have been refactored to use Unicode throughout; this
|
| 93 |
+
drastically simplifies the task of dealing with non-Western-European content and
|
| 94 |
+
data in Django. Additionally, utility functions have been provided to ease
|
| 95 |
+
interoperability with third-party libraries and systems which may or may not
|
| 96 |
+
handle Unicode gracefully. Details are available in Django's Unicode-handling
|
| 97 |
+
documentation.
|
| 98 |
+
|
| 99 |
+
See :doc:`/ref/unicode`.
|
| 100 |
+
|
| 101 |
+
An improved ORM
|
| 102 |
+
---------------
|
| 103 |
+
|
| 104 |
+
Django's object-relational mapper -- the component which provides the mapping
|
| 105 |
+
between Django model classes and your database, and which mediates your database
|
| 106 |
+
queries -- has been dramatically improved by a massive refactoring. For most
|
| 107 |
+
users of Django this is backwards-compatible; the public-facing API for database
|
| 108 |
+
querying underwent a few minor changes, but most of the updates took place in
|
| 109 |
+
the ORM's internals. A guide to the changes, including backwards-incompatible
|
| 110 |
+
modifications and mentions of new features opened up by this refactoring, is
|
| 111 |
+
`available on the Django wiki`__.
|
| 112 |
+
|
| 113 |
+
__ https://code.djangoproject.com/wiki/QuerysetRefactorBranch
|
| 114 |
+
|
| 115 |
+
Automatic escaping of template variables
|
| 116 |
+
----------------------------------------
|
| 117 |
+
|
| 118 |
+
To provide improved security against cross-site scripting (XSS) vulnerabilities,
|
| 119 |
+
Django's template system now automatically escapes the output of variables. This
|
| 120 |
+
behavior is configurable, and allows both variables and larger template
|
| 121 |
+
constructs to be marked as safe (requiring no escaping) or unsafe (requiring
|
| 122 |
+
escaping). A full guide to this feature is in the documentation for the
|
| 123 |
+
:ttag:`autoescape` tag.
|
| 124 |
+
|
| 125 |
+
``django.contrib.gis`` (GeoDjango)
|
| 126 |
+
----------------------------------
|
| 127 |
+
|
| 128 |
+
A project over a year in the making, this adds world-class GIS (`Geographic
|
| 129 |
+
Information Systems`_) support to Django, in the form of a ``contrib``
|
| 130 |
+
application. Its documentation is currently being maintained externally, and
|
| 131 |
+
will be merged into the main Django documentation shortly. Huge thanks go to
|
| 132 |
+
Justin Bronn, Jeremy Dunck, Brett Hoerner and Travis Pinney for their efforts in
|
| 133 |
+
creating and completing this feature.
|
| 134 |
+
|
| 135 |
+
See :doc:`GeoDjango </ref/contrib/gis/index>` for details.
|
| 136 |
+
|
| 137 |
+
.. _Geographic Information Systems: https://en.wikipedia.org/wiki/Geographic_information_system
|
| 138 |
+
|
| 139 |
+
Pluggable file storage
|
| 140 |
+
----------------------
|
| 141 |
+
|
| 142 |
+
Django's built-in ``FileField`` and ``ImageField`` now can take advantage of
|
| 143 |
+
pluggable file-storage backends, allowing extensive customization of where and
|
| 144 |
+
how uploaded files get stored by Django. For details, see :doc:`the files
|
| 145 |
+
documentation </topics/files>`; big thanks go to Marty Alchin for putting in the
|
| 146 |
+
hard work to get this completed.
|
| 147 |
+
|
| 148 |
+
Jython compatibility
|
| 149 |
+
--------------------
|
| 150 |
+
|
| 151 |
+
Thanks to a lot of work from Leo Soto during a Google Summer of Code project,
|
| 152 |
+
Django's codebase has been refactored to remove incompatibilities with
|
| 153 |
+
`Jython`_, an implementation of Python written in Java, which runs Python code
|
| 154 |
+
on the Java Virtual Machine. Django is now compatible with the forthcoming
|
| 155 |
+
Jython 2.5 release.
|
| 156 |
+
|
| 157 |
+
.. _Jython: https://www.jython.org/
|
| 158 |
+
|
| 159 |
+
Generic relations in forms and admin
|
| 160 |
+
------------------------------------
|
| 161 |
+
|
| 162 |
+
Classes are now included in ``django.contrib.contenttypes`` which can be used to
|
| 163 |
+
support generic relations in both the admin interface and in end-user forms. See
|
| 164 |
+
:ref:`the documentation for generic relations <generic-relations>` for details.
|
| 165 |
+
|
| 166 |
+
``INSERT``/``UPDATE`` distinction
|
| 167 |
+
---------------------------------
|
| 168 |
+
|
| 169 |
+
Although Django's default behavior of having a model's ``save()`` method
|
| 170 |
+
automatically determine whether to perform an ``INSERT`` or an ``UPDATE`` at the
|
| 171 |
+
SQL level is suitable for the majority of cases, there are occasional situations
|
| 172 |
+
where forcing one or the other is useful. As a result, models can now support an
|
| 173 |
+
additional parameter to ``save()`` which can force a specific operation.
|
| 174 |
+
|
| 175 |
+
See :ref:`ref-models-force-insert` for details.
|
| 176 |
+
|
| 177 |
+
Split ``CacheMiddleware``
|
| 178 |
+
-------------------------
|
| 179 |
+
|
| 180 |
+
Django's ``CacheMiddleware`` has been split into three classes:
|
| 181 |
+
``CacheMiddleware`` itself still exists and retains all of its previous
|
| 182 |
+
functionality, but it is now built from two separate middleware classes which
|
| 183 |
+
handle the two parts of caching (inserting into and reading from the cache)
|
| 184 |
+
separately, offering additional flexibility for situations where combining these
|
| 185 |
+
functions into a single middleware posed problems.
|
| 186 |
+
|
| 187 |
+
Full details, including updated notes on appropriate use, are in :doc:`the
|
| 188 |
+
caching documentation </topics/cache>`.
|
| 189 |
+
|
| 190 |
+
Refactored ``django.contrib.comments``
|
| 191 |
+
--------------------------------------
|
| 192 |
+
|
| 193 |
+
As part of a Google Summer of Code project, Thejaswi Puthraya carried out a
|
| 194 |
+
major rewrite and refactoring of Django's bundled comment system, greatly
|
| 195 |
+
increasing its flexibility and customizability.
|
| 196 |
+
|
| 197 |
+
Removal of deprecated features
|
| 198 |
+
------------------------------
|
| 199 |
+
|
| 200 |
+
A number of features and methods which had previously been marked as deprecated,
|
| 201 |
+
and which were scheduled for removal prior to the 1.0 release, are no longer
|
| 202 |
+
present in Django. These include imports of the form library from
|
| 203 |
+
``django.newforms`` (now located simply at ``django.forms``), the
|
| 204 |
+
``form_for_model`` and ``form_for_instance`` helper functions (which have been
|
| 205 |
+
replaced by ``ModelForm``) and a number of deprecated features which were
|
| 206 |
+
replaced by the dispatcher, file-uploading and file-storage refactoring
|
| 207 |
+
introduced in the Django 1.0 alpha releases.
|
| 208 |
+
|
| 209 |
+
Known issues
|
| 210 |
+
============
|
| 211 |
+
|
| 212 |
+
We've done our best to make Django 1.0 as solid as possible, but unfortunately
|
| 213 |
+
there are a couple of issues that we know about in the release.
|
| 214 |
+
|
| 215 |
+
Multi-table model inheritance with ``to_field``
|
| 216 |
+
-----------------------------------------------
|
| 217 |
+
|
| 218 |
+
If you're using :ref:`multiple table model inheritance
|
| 219 |
+
<multi-table-inheritance>`, be aware of this caveat: child models using a custom
|
| 220 |
+
``parent_link`` and ``to_field`` will cause database integrity errors. A set of
|
| 221 |
+
models like the following are **not valid**::
|
| 222 |
+
|
| 223 |
+
class Parent(models.Model):
|
| 224 |
+
name = models.CharField(max_length=10)
|
| 225 |
+
other_value = models.IntegerField(unique=True)
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
class Child(Parent):
|
| 229 |
+
father = models.OneToOneField(
|
| 230 |
+
Parent, primary_key=True, to_field="other_value", parent_link=True
|
| 231 |
+
)
|
| 232 |
+
value = models.IntegerField()
|
| 233 |
+
|
| 234 |
+
This bug will be fixed in the next release of Django.
|
| 235 |
+
|
| 236 |
+
Caveats with support of certain databases
|
| 237 |
+
-----------------------------------------
|
| 238 |
+
|
| 239 |
+
Django attempts to support as many features as possible on all database
|
| 240 |
+
backends. However, not all database backends are alike, and in particular many of the supported database differ greatly from version to version. It's a good idea to checkout our :doc:`notes on supported database </ref/databases>`:
|
| 241 |
+
|
| 242 |
+
- :ref:`mysql-notes`
|
| 243 |
+
- :ref:`sqlite-notes`
|
| 244 |
+
- :ref:`oracle-notes`
|
testbed/django__django/docs/releases/1.1.2.txt
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.1.2 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
Welcome to Django 1.1.2!
|
| 6 |
+
|
| 7 |
+
This is the second "bugfix" release in the Django 1.1 series,
|
| 8 |
+
improving the stability and performance of the Django 1.1 codebase.
|
| 9 |
+
|
| 10 |
+
Django 1.1.2 maintains backwards compatibility with Django
|
| 11 |
+
1.1.0, but contain a number of fixes and other
|
| 12 |
+
improvements. Django 1.1.2 is a recommended upgrade for any
|
| 13 |
+
development or deployment currently using or targeting Django 1.1.
|
| 14 |
+
|
| 15 |
+
For full details on the new features, backwards incompatibilities, and
|
| 16 |
+
deprecated features in the 1.1 branch, see the :doc:`/releases/1.1`.
|
| 17 |
+
|
| 18 |
+
Backwards-incompatible changes in 1.1.2
|
| 19 |
+
=======================================
|
| 20 |
+
|
| 21 |
+
Test runner exit status code
|
| 22 |
+
----------------------------
|
| 23 |
+
|
| 24 |
+
The exit status code of the test runners (``tests/runtests.py`` and ``python
|
| 25 |
+
manage.py test``) no longer represents the number of failed tests, since a
|
| 26 |
+
failure of 256 or more tests resulted in a wrong exit status code. The exit
|
| 27 |
+
status code for the test runner is now 0 for success (no failing tests) and 1
|
| 28 |
+
for any number of test failures. If needed, the number of test failures can be
|
| 29 |
+
found at the end of the test runner's output.
|
| 30 |
+
|
| 31 |
+
Cookie encoding
|
| 32 |
+
---------------
|
| 33 |
+
|
| 34 |
+
To fix bugs with cookies in Internet Explorer, Safari, and possibly other
|
| 35 |
+
browsers, our encoding of cookie values was changed so that the characters
|
| 36 |
+
comma and semi-colon are treated as non-safe characters, and are therefore
|
| 37 |
+
encoded as ``\054`` and ``\073`` respectively. This could produce backwards
|
| 38 |
+
incompatibilities, especially if you are storing comma or semi-colon in
|
| 39 |
+
cookies and have JavaScript code that parses and manipulates cookie values
|
| 40 |
+
client-side.
|
| 41 |
+
|
| 42 |
+
One new feature
|
| 43 |
+
===============
|
| 44 |
+
|
| 45 |
+
Ordinarily, a point release would not include new features, but in the
|
| 46 |
+
case of Django 1.1.2, we have made an exception to this rule. Django
|
| 47 |
+
1.2 (the next major release of Django) will contain a feature that
|
| 48 |
+
will improve protection against Cross-Site Request Forgery (CSRF)
|
| 49 |
+
attacks. This feature requires the use of a new :ttag:`csrf_token`
|
| 50 |
+
template tag in all forms that Django renders.
|
| 51 |
+
|
| 52 |
+
To make it easier to support both 1.1.X and 1.2.X versions of Django with
|
| 53 |
+
the same templates, we have decided to introduce the :ttag:`csrf_token` template
|
| 54 |
+
tag to the 1.1.X branch. In the 1.1.X branch, :ttag:`csrf_token` does nothing -
|
| 55 |
+
it has no effect on templates or form processing. However, it means that the
|
| 56 |
+
same template will work with Django 1.2.
|
testbed/django__django/docs/releases/1.1.txt
ADDED
|
@@ -0,0 +1,459 @@
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========================
|
| 2 |
+
Django 1.1 release notes
|
| 3 |
+
========================
|
| 4 |
+
|
| 5 |
+
July 29, 2009
|
| 6 |
+
|
| 7 |
+
Welcome to Django 1.1!
|
| 8 |
+
|
| 9 |
+
Django 1.1 includes a number of nifty :ref:`new features <whats-new-1.1>`, lots
|
| 10 |
+
of bug fixes, and an easy upgrade path from Django 1.0.
|
| 11 |
+
|
| 12 |
+
.. _backwards-incompatible-changes-1.1:
|
| 13 |
+
|
| 14 |
+
Backwards-incompatible changes in 1.1
|
| 15 |
+
=====================================
|
| 16 |
+
|
| 17 |
+
Django has a policy of :doc:`API stability </misc/api-stability>`. This means
|
| 18 |
+
that, in general, code you develop against Django 1.0 should continue to work
|
| 19 |
+
against 1.1 unchanged. However, we do sometimes make backwards-incompatible
|
| 20 |
+
changes if they're necessary to resolve bugs, and there are a handful of such
|
| 21 |
+
(minor) changes between Django 1.0 and Django 1.1.
|
| 22 |
+
|
| 23 |
+
Before upgrading to Django 1.1 you should double-check that the following
|
| 24 |
+
changes don't impact you, and upgrade your code if they do.
|
| 25 |
+
|
| 26 |
+
Changes to constraint names
|
| 27 |
+
---------------------------
|
| 28 |
+
|
| 29 |
+
Django 1.1 modifies the method used to generate database constraint names so
|
| 30 |
+
that names are consistent regardless of machine word size. This change is
|
| 31 |
+
backwards incompatible for some users.
|
| 32 |
+
|
| 33 |
+
If you are using a 32-bit platform, you're off the hook; you'll observe no
|
| 34 |
+
differences as a result of this change.
|
| 35 |
+
|
| 36 |
+
However, **users on 64-bit platforms may experience some problems** using the
|
| 37 |
+
``reset`` management command. Prior to this change, 64-bit platforms
|
| 38 |
+
would generate a 64-bit, 16 character digest in the constraint name; for
|
| 39 |
+
example:
|
| 40 |
+
|
| 41 |
+
.. code-block:: sql
|
| 42 |
+
|
| 43 |
+
ALTER TABLE myapp_sometable ADD CONSTRAINT object_id_refs_id_5e8f10c132091d1e FOREIGN KEY ...
|
| 44 |
+
|
| 45 |
+
Following this change, all platforms, regardless of word size, will generate a
|
| 46 |
+
32-bit, 8 character digest in the constraint name; for example:
|
| 47 |
+
|
| 48 |
+
.. code-block:: sql
|
| 49 |
+
|
| 50 |
+
ALTER TABLE myapp_sometable ADD CONSTRAINT object_id_refs_id_32091d1e FOREIGN KEY ...
|
| 51 |
+
|
| 52 |
+
As a result of this change, you will not be able to use the ``reset``
|
| 53 |
+
management command on any table made by a 64-bit machine. This is because the
|
| 54 |
+
new generated name will not match the historically generated name; as a
|
| 55 |
+
result, the SQL constructed by the reset command will be invalid.
|
| 56 |
+
|
| 57 |
+
If you need to reset an application that was created with 64-bit constraints,
|
| 58 |
+
you will need to manually drop the old constraint prior to invoking
|
| 59 |
+
``reset``.
|
| 60 |
+
|
| 61 |
+
Test cases are now run in a transaction
|
| 62 |
+
---------------------------------------
|
| 63 |
+
|
| 64 |
+
Django 1.1 runs tests inside a transaction, allowing better test performance
|
| 65 |
+
(see `test performance improvements`_ for details).
|
| 66 |
+
|
| 67 |
+
This change is slightly backwards incompatible if existing tests need to test
|
| 68 |
+
transactional behavior, if they rely on invalid assumptions about the test
|
| 69 |
+
environment, or if they require a specific test case ordering.
|
| 70 |
+
|
| 71 |
+
For these cases, :class:`~django.test.TransactionTestCase` can be used instead.
|
| 72 |
+
This is a just a quick fix to get around test case errors revealed by the new
|
| 73 |
+
rollback approach; in the long-term tests should be rewritten to correct the
|
| 74 |
+
test case.
|
| 75 |
+
|
| 76 |
+
.. _removed-setremoteaddrfromforwardedfor-middleware:
|
| 77 |
+
|
| 78 |
+
Removed ``SetRemoteAddrFromForwardedFor`` middleware
|
| 79 |
+
----------------------------------------------------
|
| 80 |
+
|
| 81 |
+
For convenience, Django 1.0 included an optional middleware class --
|
| 82 |
+
``django.middleware.http.SetRemoteAddrFromForwardedFor`` -- which updated the
|
| 83 |
+
value of ``REMOTE_ADDR`` based on the HTTP ``X-Forwarded-For`` header commonly
|
| 84 |
+
set by some proxy configurations.
|
| 85 |
+
|
| 86 |
+
It has been demonstrated that this mechanism cannot be made reliable enough for
|
| 87 |
+
general-purpose use, and that (despite documentation to the contrary) its
|
| 88 |
+
inclusion in Django may lead application developers to assume that the value of
|
| 89 |
+
``REMOTE_ADDR`` is "safe" or in some way reliable as a source of authentication.
|
| 90 |
+
|
| 91 |
+
While not directly a security issue, we've decided to remove this middleware
|
| 92 |
+
with the Django 1.1 release. It has been replaced with a class that does nothing
|
| 93 |
+
other than raise a ``DeprecationWarning``.
|
| 94 |
+
|
| 95 |
+
If you've been relying on this middleware, the easiest upgrade path is:
|
| 96 |
+
|
| 97 |
+
* Examine `the code as it existed before it was removed`__.
|
| 98 |
+
|
| 99 |
+
* Verify that it works correctly with your upstream proxy, modifying
|
| 100 |
+
it to support your particular proxy (if necessary).
|
| 101 |
+
|
| 102 |
+
* Introduce your modified version of ``SetRemoteAddrFromForwardedFor`` as a
|
| 103 |
+
piece of middleware in your own project.
|
| 104 |
+
|
| 105 |
+
__ https://github.com/django/django/blob/91f18400cc0fb37659e2dbaab5484ff2081f1f30/django/middleware/http.py#L33
|
| 106 |
+
|
| 107 |
+
Names of uploaded files are available later
|
| 108 |
+
-------------------------------------------
|
| 109 |
+
|
| 110 |
+
.. currentmodule:: django.db.models
|
| 111 |
+
|
| 112 |
+
In Django 1.0, files uploaded and stored in a model's :class:`FileField` were
|
| 113 |
+
saved to disk before the model was saved to the database. This meant that the
|
| 114 |
+
actual file name assigned to the file was available before saving. For example,
|
| 115 |
+
it was available in a model's pre-save signal handler.
|
| 116 |
+
|
| 117 |
+
In Django 1.1 the file is saved as part of saving the model in the database, so
|
| 118 |
+
the actual file name used on disk cannot be relied on until *after* the model
|
| 119 |
+
has been saved.
|
| 120 |
+
|
| 121 |
+
Changes to how model formsets are saved
|
| 122 |
+
---------------------------------------
|
| 123 |
+
|
| 124 |
+
In Django 1.1, :class:`~django.forms.models.BaseModelFormSet` now calls
|
| 125 |
+
``ModelForm.save()``.
|
| 126 |
+
|
| 127 |
+
This is backwards-incompatible if you were modifying ``self.initial`` in a model
|
| 128 |
+
formset's ``__init__``, or if you relied on the internal ``_total_form_count``
|
| 129 |
+
or ``_initial_form_count`` attributes of BaseFormSet. Those attributes are now
|
| 130 |
+
public methods.
|
| 131 |
+
|
| 132 |
+
Fixed the ``join`` filter's escaping behavior
|
| 133 |
+
---------------------------------------------
|
| 134 |
+
|
| 135 |
+
The :tfilter:`join` filter no longer escapes the literal value that is
|
| 136 |
+
passed in for the connector.
|
| 137 |
+
|
| 138 |
+
This is backwards incompatible for the special situation of the literal string
|
| 139 |
+
containing one of the five special HTML characters. Thus, if you were writing
|
| 140 |
+
``{{ foo|join:"&" }}``, you now have to write ``{{ foo|join:"&" }}``.
|
| 141 |
+
|
| 142 |
+
The previous behavior was a bug and contrary to what was documented
|
| 143 |
+
and expected.
|
| 144 |
+
|
| 145 |
+
Permanent redirects and the ``redirect_to()`` generic view
|
| 146 |
+
----------------------------------------------------------
|
| 147 |
+
|
| 148 |
+
Django 1.1 adds a ``permanent`` argument to the
|
| 149 |
+
``django.views.generic.simple.redirect_to()`` view. This is technically
|
| 150 |
+
backwards-incompatible if you were using the ``redirect_to`` view with a
|
| 151 |
+
format-string key called 'permanent', which is highly unlikely.
|
| 152 |
+
|
| 153 |
+
.. _deprecated-features-1.1:
|
| 154 |
+
|
| 155 |
+
Features deprecated in 1.1
|
| 156 |
+
==========================
|
| 157 |
+
|
| 158 |
+
One feature has been marked as deprecated in Django 1.1:
|
| 159 |
+
|
| 160 |
+
* You should no longer use ``AdminSite.root()`` to register that admin
|
| 161 |
+
views. That is, if your URLconf contains the line::
|
| 162 |
+
|
| 163 |
+
(r"^admin/(.*)", admin.site.root),
|
| 164 |
+
|
| 165 |
+
You should change it to read::
|
| 166 |
+
|
| 167 |
+
(r"^admin/", include(admin.site.urls)),
|
| 168 |
+
|
| 169 |
+
You should begin to remove use of this feature from your code immediately.
|
| 170 |
+
|
| 171 |
+
``AdminSite.root`` will raise a ``PendingDeprecationWarning`` if used in
|
| 172 |
+
Django 1.1. This warning is hidden by default. In Django 1.2, this warning will
|
| 173 |
+
be upgraded to a ``DeprecationWarning``, which will be displayed loudly. Django
|
| 174 |
+
1.3 will remove ``AdminSite.root()`` entirely.
|
| 175 |
+
|
| 176 |
+
For more details on our deprecation policies and strategy, see
|
| 177 |
+
:doc:`/internals/release-process`.
|
| 178 |
+
|
| 179 |
+
.. _whats-new-1.1:
|
| 180 |
+
|
| 181 |
+
What's new in Django 1.1
|
| 182 |
+
========================
|
| 183 |
+
|
| 184 |
+
Quite a bit: since Django 1.0, we've made 1,290 code commits, fixed 1,206 bugs,
|
| 185 |
+
and added roughly 10,000 lines of documentation.
|
| 186 |
+
|
| 187 |
+
The major new features in Django 1.1 are:
|
| 188 |
+
|
| 189 |
+
ORM improvements
|
| 190 |
+
----------------
|
| 191 |
+
|
| 192 |
+
.. currentmodule:: django.db.models
|
| 193 |
+
|
| 194 |
+
Two major enhancements have been added to Django's object-relational mapper
|
| 195 |
+
(ORM): aggregate support, and query expressions.
|
| 196 |
+
|
| 197 |
+
Aggregate support
|
| 198 |
+
~~~~~~~~~~~~~~~~~
|
| 199 |
+
|
| 200 |
+
It's now possible to run SQL aggregate queries (i.e. ``COUNT()``, ``MAX()``,
|
| 201 |
+
``MIN()``, etc.) from within Django's ORM. You can choose to either return the
|
| 202 |
+
results of the aggregate directly, or else annotate the objects in a
|
| 203 |
+
:class:`~django.db.models.query.QuerySet` with the results of the aggregate
|
| 204 |
+
query.
|
| 205 |
+
|
| 206 |
+
This feature is available as new
|
| 207 |
+
:meth:`~django.db.models.query.QuerySet.aggregate` and
|
| 208 |
+
:meth:`~django.db.models.query.QuerySet.annotate` methods, and is covered in
|
| 209 |
+
detail in :doc:`the ORM aggregation documentation </topics/db/aggregation>`.
|
| 210 |
+
|
| 211 |
+
Query expressions
|
| 212 |
+
~~~~~~~~~~~~~~~~~
|
| 213 |
+
|
| 214 |
+
Queries can now refer to another field on the query and can traverse
|
| 215 |
+
relationships to refer to fields on related models. This is implemented in the
|
| 216 |
+
new :class:`~django.db.models.F` object; for full details, including examples,
|
| 217 |
+
consult the :class:`F expressions documentation <django.db.models.F>`.
|
| 218 |
+
|
| 219 |
+
Model improvements
|
| 220 |
+
------------------
|
| 221 |
+
|
| 222 |
+
A number of features have been added to Django's model layer:
|
| 223 |
+
|
| 224 |
+
"Unmanaged" models
|
| 225 |
+
~~~~~~~~~~~~~~~~~~
|
| 226 |
+
|
| 227 |
+
You can now control whether or not Django manages the life-cycle of the database
|
| 228 |
+
tables for a model using the :attr:`~Options.managed` model option. This
|
| 229 |
+
defaults to ``True``, meaning that Django will create the appropriate database
|
| 230 |
+
tables in ``syncdb`` and remove them as part of the ``reset``
|
| 231 |
+
command. That is, Django *manages* the database table's lifecycle.
|
| 232 |
+
|
| 233 |
+
If you set this to ``False``, however, no database table creating or deletion
|
| 234 |
+
will be automatically performed for this model. This is useful if the model
|
| 235 |
+
represents an existing table or a database view that has been created by some
|
| 236 |
+
other means.
|
| 237 |
+
|
| 238 |
+
For more details, see the documentation for the :attr:`~Options.managed`
|
| 239 |
+
option.
|
| 240 |
+
|
| 241 |
+
Proxy models
|
| 242 |
+
~~~~~~~~~~~~
|
| 243 |
+
|
| 244 |
+
You can now create :ref:`proxy models <proxy-models>`: subclasses of existing
|
| 245 |
+
models that only add Python-level (rather than database-level) behavior and
|
| 246 |
+
aren't represented by a new table. That is, the new model is a *proxy* for some
|
| 247 |
+
underlying model, which stores all the real data.
|
| 248 |
+
|
| 249 |
+
All the details can be found in the :ref:`proxy models documentation
|
| 250 |
+
<proxy-models>`. This feature is similar on the surface to unmanaged models,
|
| 251 |
+
so the documentation has an explanation of :ref:`how proxy models differ from
|
| 252 |
+
unmanaged models <proxy-vs-unmanaged-models>`.
|
| 253 |
+
|
| 254 |
+
Deferred fields
|
| 255 |
+
~~~~~~~~~~~~~~~
|
| 256 |
+
|
| 257 |
+
In some complex situations, your models might contain fields which could
|
| 258 |
+
contain a lot of data (for example, large text fields), or require expensive
|
| 259 |
+
processing to convert them to Python objects. If you know you don't need those
|
| 260 |
+
particular fields, you can now tell Django not to retrieve them from the
|
| 261 |
+
database.
|
| 262 |
+
|
| 263 |
+
You'll do this with the new queryset methods
|
| 264 |
+
:meth:`~django.db.models.query.QuerySet.defer` and
|
| 265 |
+
:meth:`~django.db.models.query.QuerySet.only`.
|
| 266 |
+
|
| 267 |
+
Testing improvements
|
| 268 |
+
--------------------
|
| 269 |
+
|
| 270 |
+
A few notable improvements have been made to the :doc:`testing framework
|
| 271 |
+
</topics/testing/index>`.
|
| 272 |
+
|
| 273 |
+
Test performance improvements
|
| 274 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 275 |
+
|
| 276 |
+
.. currentmodule:: django.test
|
| 277 |
+
|
| 278 |
+
Tests written using Django's :doc:`testing framework </topics/testing/index>` now run
|
| 279 |
+
dramatically faster (as much as 10 times faster in many cases).
|
| 280 |
+
|
| 281 |
+
This was accomplished through the introduction of transaction-based tests: when
|
| 282 |
+
using :class:`django.test.TestCase`, your tests will now be run in a transaction
|
| 283 |
+
which is rolled back when finished, instead of by flushing and re-populating the
|
| 284 |
+
database. This results in an immense speedup for most types of unit tests. See
|
| 285 |
+
the documentation for :class:`TestCase` and :class:`TransactionTestCase` for a
|
| 286 |
+
full description, and some important notes on database support.
|
| 287 |
+
|
| 288 |
+
Test client improvements
|
| 289 |
+
------------------------
|
| 290 |
+
|
| 291 |
+
A couple of small -- but highly useful -- improvements have been made to the
|
| 292 |
+
test client:
|
| 293 |
+
|
| 294 |
+
* The test :class:`Client` now can automatically follow redirects with the
|
| 295 |
+
``follow`` argument to :meth:`Client.get` and :meth:`Client.post`. This
|
| 296 |
+
makes testing views that issue redirects simpler.
|
| 297 |
+
|
| 298 |
+
* It's now easier to get at the template context in the response returned
|
| 299 |
+
the test client: you'll simply access the context as
|
| 300 |
+
``request.context[key]``. The old way, which treats ``request.context`` as
|
| 301 |
+
a list of contexts, one for each rendered template in the inheritance
|
| 302 |
+
chain, is still available if you need it.
|
| 303 |
+
|
| 304 |
+
New admin features
|
| 305 |
+
------------------
|
| 306 |
+
|
| 307 |
+
Django 1.1 adds a couple of nifty new features to Django's admin interface:
|
| 308 |
+
|
| 309 |
+
Editable fields on the change list
|
| 310 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 311 |
+
|
| 312 |
+
You can now make fields editable on the admin list views via the new
|
| 313 |
+
:ref:`list_editable <admin-list-editable>` admin option. These fields will show
|
| 314 |
+
up as form widgets on the list pages, and can be edited and saved in bulk.
|
| 315 |
+
|
| 316 |
+
Admin "actions"
|
| 317 |
+
~~~~~~~~~~~~~~~
|
| 318 |
+
|
| 319 |
+
You can now define :doc:`admin actions </ref/contrib/admin/actions>` that can
|
| 320 |
+
perform some action to a group of models in bulk. Users will be able to select
|
| 321 |
+
objects on the change list page and then apply these bulk actions to all
|
| 322 |
+
selected objects.
|
| 323 |
+
|
| 324 |
+
Django ships with one pre-defined admin action to delete a group of objects in
|
| 325 |
+
one fell swoop.
|
| 326 |
+
|
| 327 |
+
Conditional view processing
|
| 328 |
+
---------------------------
|
| 329 |
+
|
| 330 |
+
Django now has much better support for :doc:`conditional view processing
|
| 331 |
+
</topics/conditional-view-processing>` using the standard ``ETag`` and
|
| 332 |
+
``Last-Modified`` HTTP headers. This means you can now easily short-circuit
|
| 333 |
+
view processing by testing less-expensive conditions. For many views this can
|
| 334 |
+
lead to a serious improvement in speed and reduction in bandwidth.
|
| 335 |
+
|
| 336 |
+
URL namespaces
|
| 337 |
+
--------------
|
| 338 |
+
|
| 339 |
+
Django 1.1 improves :ref:`named URL patterns <naming-url-patterns>` with the
|
| 340 |
+
introduction of URL "namespaces."
|
| 341 |
+
|
| 342 |
+
In short, this feature allows the same group of URLs, from the same application,
|
| 343 |
+
to be included in a Django URLConf multiple times, with varying (and potentially
|
| 344 |
+
nested) named prefixes which will be used when performing reverse resolution. In
|
| 345 |
+
other words, reusable applications like Django's admin interface may be
|
| 346 |
+
registered multiple times without URL conflicts.
|
| 347 |
+
|
| 348 |
+
For full details, see :ref:`the documentation on defining URL namespaces
|
| 349 |
+
<topics-http-defining-url-namespaces>`.
|
| 350 |
+
|
| 351 |
+
GeoDjango
|
| 352 |
+
---------
|
| 353 |
+
|
| 354 |
+
In Django 1.1, :doc:`GeoDjango </ref/contrib/gis/index>` (i.e.
|
| 355 |
+
``django.contrib.gis``) has several new features:
|
| 356 |
+
|
| 357 |
+
* Support for SpatiaLite_ -- a spatial database for SQLite -- as a spatial
|
| 358 |
+
backend.
|
| 359 |
+
|
| 360 |
+
* Geographic aggregates (``Collect``, ``Extent``, ``MakeLine``, ``Union``)
|
| 361 |
+
and ``F`` expressions.
|
| 362 |
+
|
| 363 |
+
* New ``GeoQuerySet`` methods: ``collect``, ``geojson``, and
|
| 364 |
+
``snap_to_grid``.
|
| 365 |
+
|
| 366 |
+
* A new list interface methods for ``GEOSGeometry`` objects.
|
| 367 |
+
|
| 368 |
+
For more details, see the GeoDjango documentation.
|
| 369 |
+
|
| 370 |
+
.. _spatialite: https://www.gaia-gis.it/gaia-sins/
|
| 371 |
+
|
| 372 |
+
Other improvements
|
| 373 |
+
------------------
|
| 374 |
+
|
| 375 |
+
Other new features and changes introduced since Django 1.0 include:
|
| 376 |
+
|
| 377 |
+
* The :doc:`CSRF protection middleware </ref/csrf>` has been split into
|
| 378 |
+
two classes -- ``CsrfViewMiddleware`` checks incoming requests, and
|
| 379 |
+
``CsrfResponseMiddleware`` processes outgoing responses. The combined
|
| 380 |
+
``CsrfMiddleware`` class (which does both) remains for
|
| 381 |
+
backwards-compatibility, but using the split classes is now recommended in
|
| 382 |
+
order to allow fine-grained control of when and where the CSRF processing
|
| 383 |
+
takes place.
|
| 384 |
+
|
| 385 |
+
* ``reverse()`` and code which uses it (e.g., the ``{% url %}`` template tag)
|
| 386 |
+
now works with URLs in Django's administrative site, provided that the admin
|
| 387 |
+
URLs are set up via ``include(admin.site.urls)`` (sending admin requests to
|
| 388 |
+
the ``admin.site.root`` view still works, but URLs in the admin will not be
|
| 389 |
+
"reversible" when configured this way).
|
| 390 |
+
|
| 391 |
+
* The ``include()`` function in Django URLconf modules can now accept sequences
|
| 392 |
+
of URL patterns (generated by ``patterns()``) in addition to module names.
|
| 393 |
+
|
| 394 |
+
* Instances of Django forms (see :doc:`the forms overview </topics/forms/index>`)
|
| 395 |
+
now have two additional methods, ``hidden_fields()`` and ``visible_fields()``,
|
| 396 |
+
which return the list of hidden -- i.e., ``<input type="hidden">`` -- and
|
| 397 |
+
visible fields on the form, respectively.
|
| 398 |
+
|
| 399 |
+
* The ``redirect_to`` generic view
|
| 400 |
+
now accepts an additional keyword argument
|
| 401 |
+
``permanent``. If ``permanent`` is ``True``, the view will emit an HTTP
|
| 402 |
+
permanent redirect (status code 301). If ``False``, the view will emit an HTTP
|
| 403 |
+
temporary redirect (status code 302).
|
| 404 |
+
|
| 405 |
+
* A new database lookup type -- ``week_day`` -- has been added for ``DateField``
|
| 406 |
+
and ``DateTimeField``. This type of lookup accepts a number between 1 (Sunday)
|
| 407 |
+
and 7 (Saturday), and returns objects where the field value matches that day
|
| 408 |
+
of the week. See :ref:`the full list of lookup types <field-lookups>` for
|
| 409 |
+
details.
|
| 410 |
+
|
| 411 |
+
* The ``{% for %}`` tag in Django's template language now accepts an optional
|
| 412 |
+
``{% empty %}`` clause, to be displayed when ``{% for %}`` is asked to loop
|
| 413 |
+
over an empty sequence. See :doc:`the list of built-in template tags
|
| 414 |
+
</ref/templates/builtins>` for examples of this.
|
| 415 |
+
|
| 416 |
+
* The :djadmin:`dumpdata` management command now accepts individual
|
| 417 |
+
model names as arguments, allowing you to export the data just from
|
| 418 |
+
particular models.
|
| 419 |
+
|
| 420 |
+
* There's a new :tfilter:`safeseq` template filter which works just like
|
| 421 |
+
:tfilter:`safe` for lists, marking each item in the list as safe.
|
| 422 |
+
|
| 423 |
+
* :doc:`Cache backends </topics/cache>` now support ``incr()`` and
|
| 424 |
+
``decr()`` commands to increment and decrement the value of a cache key.
|
| 425 |
+
On cache backends that support atomic increment/decrement -- most
|
| 426 |
+
notably, the memcached backend -- these operations will be atomic, and
|
| 427 |
+
quite fast.
|
| 428 |
+
|
| 429 |
+
* Django now can :doc:`easily delegate authentication to the web server
|
| 430 |
+
</howto/auth-remote-user>` via a new authentication backend that supports
|
| 431 |
+
the standard ``REMOTE_USER`` environment variable used for this purpose.
|
| 432 |
+
|
| 433 |
+
* There's a new :func:`django.shortcuts.redirect` function that makes it
|
| 434 |
+
easier to issue redirects given an object, a view name, or a URL.
|
| 435 |
+
|
| 436 |
+
* The ``postgresql_psycopg2`` backend now supports :ref:`native PostgreSQL
|
| 437 |
+
autocommit <postgresql-notes>`. This is an advanced, PostgreSQL-specific
|
| 438 |
+
feature, that can make certain read-heavy applications a good deal
|
| 439 |
+
faster.
|
| 440 |
+
|
| 441 |
+
What's next?
|
| 442 |
+
============
|
| 443 |
+
|
| 444 |
+
We'll take a short break, and then work on Django 1.2 will begin -- no rest for
|
| 445 |
+
the weary! If you'd like to help, discussion of Django development, including
|
| 446 |
+
progress toward the 1.2 release, takes place daily on the |django-developers|
|
| 447 |
+
mailing list and in the ``#django-dev`` IRC channel on ``irc.libera.chat``.
|
| 448 |
+
Feel free to join the discussions!
|
| 449 |
+
|
| 450 |
+
Django's online documentation also includes pointers on how to contribute to
|
| 451 |
+
Django:
|
| 452 |
+
|
| 453 |
+
* :doc:`How to contribute to Django </internals/contributing/index>`
|
| 454 |
+
|
| 455 |
+
Contributions on any level -- developing code, writing documentation or simply
|
| 456 |
+
triaging tickets and helping to test proposed bugfixes -- are always welcome and
|
| 457 |
+
appreciated.
|
| 458 |
+
|
| 459 |
+
And that's the way it is.
|
testbed/django__django/docs/releases/1.10.3.txt
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
===========================
|
| 2 |
+
Django 1.10.3 release notes
|
| 3 |
+
===========================
|
| 4 |
+
|
| 5 |
+
*November 1, 2016*
|
| 6 |
+
|
| 7 |
+
Django 1.10.3 fixes two security issues and several bugs in 1.10.2.
|
| 8 |
+
|
| 9 |
+
User with hardcoded password created when running tests on Oracle
|
| 10 |
+
=================================================================
|
| 11 |
+
|
| 12 |
+
When running tests with an Oracle database, Django creates a temporary database
|
| 13 |
+
user. In older versions, if a password isn't manually specified in the database
|
| 14 |
+
settings ``TEST`` dictionary, a hardcoded password is used. This could allow
|
| 15 |
+
an attacker with network access to the database server to connect.
|
| 16 |
+
|
| 17 |
+
This user is usually dropped after the test suite completes, but not when using
|
| 18 |
+
the ``manage.py test --keepdb`` option or if the user has an active session
|
| 19 |
+
(such as an attacker's connection).
|
| 20 |
+
|
| 21 |
+
A randomly generated password is now used for each test run.
|
| 22 |
+
|
| 23 |
+
DNS rebinding vulnerability when ``DEBUG=True``
|
| 24 |
+
===============================================
|
| 25 |
+
|
| 26 |
+
Older versions of Django don't validate the ``Host`` header against
|
| 27 |
+
``settings.ALLOWED_HOSTS`` when ``settings.DEBUG=True``. This makes them
|
| 28 |
+
vulnerable to a `DNS rebinding attack
|
| 29 |
+
<https://benmmurphy.github.io/blog/2016/07/11/rails-webconsole-dns-rebinding/>`_.
|
| 30 |
+
|
| 31 |
+
While Django doesn't ship a module that allows remote code execution, this is
|
| 32 |
+
at least a cross-site scripting vector, which could be quite serious if
|
| 33 |
+
developers load a copy of the production database in development or connect to
|
| 34 |
+
some production services for which there's no development instance, for
|
| 35 |
+
example. If a project uses a package like the ``django-debug-toolbar``, then
|
| 36 |
+
the attacker could execute arbitrary SQL, which could be especially bad if the
|
| 37 |
+
developers connect to the database with a superuser account.
|
| 38 |
+
|
| 39 |
+
``settings.ALLOWED_HOSTS`` is now validated regardless of ``DEBUG``. For
|
| 40 |
+
convenience, if ``ALLOWED_HOSTS`` is empty and ``DEBUG=True``, the following
|
| 41 |
+
variations of localhost are allowed ``['localhost', '127.0.0.1', '::1']``. If
|
| 42 |
+
your local settings file has your production ``ALLOWED_HOSTS`` value, you must
|
| 43 |
+
now omit it to get those fallback values.
|
| 44 |
+
|
| 45 |
+
Bugfixes
|
| 46 |
+
========
|
| 47 |
+
|
| 48 |
+
* Allowed ``User.is_authenticated`` and ``User.is_anonymous`` properties to be
|
| 49 |
+
tested for ``set`` membership (:ticket:`27309`).
|
| 50 |
+
|
| 51 |
+
* Fixed a performance regression when running ``migrate`` in projects
|
| 52 |
+
with ``RenameModel`` operations (:ticket:`27279`).
|
| 53 |
+
|
| 54 |
+
* Added ``model_name`` to the ``allow_migrate()`` calls in ``makemigrations``
|
| 55 |
+
(:ticket:`27200`).
|
| 56 |
+
|
| 57 |
+
* Made the ``JavaScriptCatalog`` view respect the ``packages`` argument;
|
| 58 |
+
previously it was ignored (:ticket:`27374`).
|
| 59 |
+
|
| 60 |
+
* Fixed ``QuerySet.bulk_create()`` on PostgreSQL when the number of objects is
|
| 61 |
+
a multiple plus one of ``batch_size`` (:ticket:`27385`).
|
| 62 |
+
|
| 63 |
+
* Prevented ``i18n_patterns()`` from using too much of the URL as the language
|
| 64 |
+
to fix a use case for ``prefix_default_language=False`` (:ticket:`27063`).
|
| 65 |
+
|
| 66 |
+
* Replaced a possibly incorrect redirect from ``SessionMiddleware`` when a
|
| 67 |
+
session is destroyed in a concurrent request with a ``SuspiciousOperation``
|
| 68 |
+
to indicate that the request can't be completed (:ticket:`27363`).
|
testbed/django__django/docs/releases/1.10.txt
ADDED
|
@@ -0,0 +1,1384 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 |
+
|
| 9 |
+
These release notes cover the :ref:`new features <whats-new-1.10>`, as well as
|
| 10 |
+
some :ref:`backwards incompatible changes <backwards-incompatible-1.10>` you'll
|
| 11 |
+
want to be aware of when upgrading from Django 1.9 or older versions. We've
|
| 12 |
+
:ref:`dropped some features <removed-features-1.10>` that have reached the end
|
| 13 |
+
of their deprecation cycle, and we've :ref:`begun the deprecation process for
|
| 14 |
+
some features <deprecated-features-1.10>`.
|
| 15 |
+
|
| 16 |
+
See the :doc:`/howto/upgrade-version` guide if you're updating an existing
|
| 17 |
+
project.
|
| 18 |
+
|
| 19 |
+
Python compatibility
|
| 20 |
+
====================
|
| 21 |
+
|
| 22 |
+
Like Django 1.9, Django 1.10 requires Python 2.7, 3.4, or 3.5. We **highly
|
| 23 |
+
recommend** and only officially support the latest release of each series.
|
| 24 |
+
|
| 25 |
+
.. _whats-new-1.10:
|
| 26 |
+
|
| 27 |
+
What's new in Django 1.10
|
| 28 |
+
=========================
|
| 29 |
+
|
| 30 |
+
Full text search for PostgreSQL
|
| 31 |
+
-------------------------------
|
| 32 |
+
|
| 33 |
+
``django.contrib.postgres`` now includes a :doc:`collection of database
|
| 34 |
+
functions </ref/contrib/postgres/search>` to allow the use of the full text
|
| 35 |
+
search engine. You can search across multiple fields in your relational
|
| 36 |
+
database, combine the searches with other lookups, use different language
|
| 37 |
+
configurations and weightings, and rank the results by relevance.
|
| 38 |
+
|
| 39 |
+
It also now includes trigram support, using the :lookup:`trigram_similar`
|
| 40 |
+
lookup, and the :class:`~django.contrib.postgres.search.TrigramSimilarity` and
|
| 41 |
+
:class:`~django.contrib.postgres.search.TrigramDistance` expressions.
|
| 42 |
+
|
| 43 |
+
New-style middleware
|
| 44 |
+
--------------------
|
| 45 |
+
|
| 46 |
+
:doc:`A new style of middleware is introduced </topics/http/middleware>` to
|
| 47 |
+
solve the lack of strict request/response layering of the old-style of
|
| 48 |
+
middleware described in `DEP 0005
|
| 49 |
+
<https://github.com/django/deps/blob/main/final/0005-improved-middleware.rst>`_.
|
| 50 |
+
You'll need to :ref:`adapt old, custom middleware <upgrading-middleware>` and
|
| 51 |
+
switch from the ``MIDDLEWARE_CLASSES`` setting to the new :setting:`MIDDLEWARE`
|
| 52 |
+
setting to take advantage of the improvements.
|
| 53 |
+
|
| 54 |
+
Official support for Unicode usernames
|
| 55 |
+
--------------------------------------
|
| 56 |
+
|
| 57 |
+
The :class:`~django.contrib.auth.models.User` model in ``django.contrib.auth``
|
| 58 |
+
originally only accepted ASCII letters and numbers in usernames. Although it
|
| 59 |
+
wasn't a deliberate choice, Unicode characters have always been accepted when
|
| 60 |
+
using Python 3.
|
| 61 |
+
|
| 62 |
+
The username validator now explicitly accepts Unicode characters by
|
| 63 |
+
default on Python 3 only.
|
| 64 |
+
|
| 65 |
+
Custom user models may use the new
|
| 66 |
+
:class:`~django.contrib.auth.validators.ASCIIUsernameValidator` or
|
| 67 |
+
:class:`~django.contrib.auth.validators.UnicodeUsernameValidator`.
|
| 68 |
+
|
| 69 |
+
Minor features
|
| 70 |
+
--------------
|
| 71 |
+
|
| 72 |
+
:mod:`django.contrib.admin`
|
| 73 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 74 |
+
|
| 75 |
+
* For sites running on a subpath, the default :attr:`URL for the "View site"
|
| 76 |
+
link <django.contrib.admin.AdminSite.site_url>` at the top of each admin page
|
| 77 |
+
will now point to ``request.META['SCRIPT_NAME']`` if set, instead of ``/``.
|
| 78 |
+
|
| 79 |
+
* The success message that appears after adding or editing an object now
|
| 80 |
+
contains a link to the object's change form.
|
| 81 |
+
|
| 82 |
+
* All inline JavaScript is removed so you can enable the
|
| 83 |
+
``Content-Security-Policy`` HTTP header if you wish.
|
| 84 |
+
|
| 85 |
+
* The new :attr:`InlineModelAdmin.classes
|
| 86 |
+
<django.contrib.admin.InlineModelAdmin.classes>` attribute allows specifying
|
| 87 |
+
classes on inline fieldsets. Inlines with a ``collapse`` class will be
|
| 88 |
+
initially collapsed and their header will have a small "show" link.
|
| 89 |
+
|
| 90 |
+
* If a user doesn't have the add permission, the ``object-tools`` block on a
|
| 91 |
+
model's changelist will now be rendered (without the add button). This makes
|
| 92 |
+
it easier to add custom tools in this case.
|
| 93 |
+
|
| 94 |
+
* The :class:`~django.contrib.admin.models.LogEntry` model now stores change
|
| 95 |
+
messages in a JSON structure so that the message can be dynamically translated
|
| 96 |
+
using the current active language. A new ``LogEntry.get_change_message()``
|
| 97 |
+
method is now the preferred way of retrieving the change message.
|
| 98 |
+
|
| 99 |
+
* Selected objects for fields in ``ModelAdmin.raw_id_fields`` now have a link
|
| 100 |
+
to object's change form.
|
| 101 |
+
|
| 102 |
+
* Added "No date" and "Has date" choices for ``DateFieldListFilter`` if the
|
| 103 |
+
field is nullable.
|
| 104 |
+
|
| 105 |
+
* The jQuery library embedded in the admin is upgraded from version 2.1.4 to
|
| 106 |
+
2.2.3.
|
| 107 |
+
|
| 108 |
+
:mod:`django.contrib.auth`
|
| 109 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 110 |
+
|
| 111 |
+
* Added support for the :ref:`Argon2 password hash <argon2_usage>`. It's
|
| 112 |
+
recommended over PBKDF2, however, it's not the default as it requires a
|
| 113 |
+
third-party library.
|
| 114 |
+
|
| 115 |
+
* The default iteration count for the PBKDF2 password hasher has been increased
|
| 116 |
+
by 25%. This backwards compatible change will not affect users who have
|
| 117 |
+
subclassed ``django.contrib.auth.hashers.PBKDF2PasswordHasher`` to change the
|
| 118 |
+
default value.
|
| 119 |
+
|
| 120 |
+
* The ``django.contrib.auth.views.logout()`` view sends "no-cache" headers
|
| 121 |
+
to prevent an issue where Safari caches redirects and prevents a user from
|
| 122 |
+
being able to log out.
|
| 123 |
+
|
| 124 |
+
* Added the optional ``backend`` argument to :func:`django.contrib.auth.login`
|
| 125 |
+
to allow using it without credentials.
|
| 126 |
+
|
| 127 |
+
* The new :setting:`LOGOUT_REDIRECT_URL` setting controls the redirect of the
|
| 128 |
+
``django.contrib.auth.views.logout()`` view, if the view doesn't get a
|
| 129 |
+
``next_page`` argument.
|
| 130 |
+
|
| 131 |
+
* The new ``redirect_authenticated_user`` parameter for the
|
| 132 |
+
``django.contrib.auth.views.login()`` view allows redirecting
|
| 133 |
+
authenticated users visiting the login page.
|
| 134 |
+
|
| 135 |
+
* The new :class:`~django.contrib.auth.backends.AllowAllUsersModelBackend` and
|
| 136 |
+
:class:`~django.contrib.auth.backends.AllowAllUsersRemoteUserBackend` ignore
|
| 137 |
+
the value of ``User.is_active``, while
|
| 138 |
+
:class:`~django.contrib.auth.backends.ModelBackend` and
|
| 139 |
+
:class:`~django.contrib.auth.backends.RemoteUserBackend` now reject inactive
|
| 140 |
+
users.
|
| 141 |
+
|
| 142 |
+
:mod:`django.contrib.gis`
|
| 143 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 144 |
+
|
| 145 |
+
* :ref:`Distance lookups <distance-lookups>` now accept expressions as the
|
| 146 |
+
distance value parameter.
|
| 147 |
+
|
| 148 |
+
* The new :attr:`GEOSGeometry.unary_union
|
| 149 |
+
<django.contrib.gis.geos.GEOSGeometry.unary_union>` property computes the
|
| 150 |
+
union of all the elements of this geometry.
|
| 151 |
+
|
| 152 |
+
* Added the :meth:`GEOSGeometry.covers()
|
| 153 |
+
<django.contrib.gis.geos.GEOSGeometry.covers>` binary predicate.
|
| 154 |
+
|
| 155 |
+
* Added the :meth:`GDALBand.statistics()
|
| 156 |
+
<django.contrib.gis.gdal.GDALBand.statistics>` method and
|
| 157 |
+
:attr:`~django.contrib.gis.gdal.GDALBand.mean`
|
| 158 |
+
and :attr:`~django.contrib.gis.gdal.GDALBand.std` attributes.
|
| 159 |
+
|
| 160 |
+
* Added support for the :class:`~django.contrib.gis.db.models.MakeLine`
|
| 161 |
+
aggregate and :class:`~django.contrib.gis.db.models.functions.GeoHash`
|
| 162 |
+
function on SpatiaLite.
|
| 163 |
+
|
| 164 |
+
* Added support for the
|
| 165 |
+
:class:`~django.contrib.gis.db.models.functions.Difference`,
|
| 166 |
+
:class:`~django.contrib.gis.db.models.functions.Intersection`, and
|
| 167 |
+
:class:`~django.contrib.gis.db.models.functions.SymDifference`
|
| 168 |
+
functions on MySQL.
|
| 169 |
+
|
| 170 |
+
* Added support for instantiating empty GEOS geometries.
|
| 171 |
+
|
| 172 |
+
* The new :attr:`~django.contrib.gis.geos.WKTWriter.trim` and
|
| 173 |
+
:attr:`~django.contrib.gis.geos.WKTWriter.precision` properties
|
| 174 |
+
of :class:`~django.contrib.gis.geos.WKTWriter` allow controlling
|
| 175 |
+
output of the fractional part of the coordinates in WKT.
|
| 176 |
+
|
| 177 |
+
* Added the :attr:`LineString.closed
|
| 178 |
+
<django.contrib.gis.geos.LineString.closed>` and
|
| 179 |
+
:attr:`MultiLineString.closed
|
| 180 |
+
<django.contrib.gis.geos.MultiLineString.closed>` properties.
|
| 181 |
+
|
| 182 |
+
* The :doc:`GeoJSON serializer </ref/contrib/gis/serializers>` now outputs the
|
| 183 |
+
primary key of objects in the ``properties`` dictionary if specific fields
|
| 184 |
+
aren't specified.
|
| 185 |
+
|
| 186 |
+
* The ability to replicate input data on the :meth:`GDALBand.data()
|
| 187 |
+
<django.contrib.gis.gdal.GDALBand.data>` method was added. Band data can
|
| 188 |
+
now be updated with repeated values efficiently.
|
| 189 |
+
|
| 190 |
+
* Added database functions
|
| 191 |
+
:class:`~django.contrib.gis.db.models.functions.IsValid` and
|
| 192 |
+
:class:`~django.contrib.gis.db.models.functions.MakeValid`, as well as the
|
| 193 |
+
:lookup:`isvalid` lookup, all for PostGIS. This allows filtering and
|
| 194 |
+
repairing invalid geometries on the database side.
|
| 195 |
+
|
| 196 |
+
* Added raster support for all :doc:`spatial lookups
|
| 197 |
+
</ref/contrib/gis/geoquerysets>`.
|
| 198 |
+
|
| 199 |
+
:mod:`django.contrib.postgres`
|
| 200 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 201 |
+
|
| 202 |
+
* For convenience, :class:`~django.contrib.postgres.fields.HStoreField` now
|
| 203 |
+
casts its keys and values to strings.
|
| 204 |
+
|
| 205 |
+
:mod:`django.contrib.sessions`
|
| 206 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 207 |
+
|
| 208 |
+
* The :djadmin:`clearsessions` management command now removes file-based
|
| 209 |
+
sessions.
|
| 210 |
+
|
| 211 |
+
:mod:`django.contrib.sites`
|
| 212 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 213 |
+
|
| 214 |
+
* The :class:`~django.contrib.sites.models.Site` model now supports
|
| 215 |
+
:ref:`natural keys <topics-serialization-natural-keys>`.
|
| 216 |
+
|
| 217 |
+
:mod:`django.contrib.staticfiles`
|
| 218 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 219 |
+
|
| 220 |
+
* The :ttag:`static` template tag now uses ``django.contrib.staticfiles``
|
| 221 |
+
if it's in ``INSTALLED_APPS``. This is especially useful for third-party apps
|
| 222 |
+
which can now always use ``{% load static %}`` (instead of
|
| 223 |
+
``{% load staticfiles %}`` or ``{% load static from staticfiles %}``) and
|
| 224 |
+
not worry about whether or not the ``staticfiles`` app is installed.
|
| 225 |
+
|
| 226 |
+
* You can :ref:`more easily customize <customize-staticfiles-ignore-patterns>`
|
| 227 |
+
the ``collectstatic --ignore`` option with a custom ``AppConfig``.
|
| 228 |
+
|
| 229 |
+
Cache
|
| 230 |
+
~~~~~
|
| 231 |
+
|
| 232 |
+
* The file-based cache backend now uses the highest pickling protocol.
|
| 233 |
+
|
| 234 |
+
CSRF
|
| 235 |
+
~~~~
|
| 236 |
+
|
| 237 |
+
* The default :setting:`CSRF_FAILURE_VIEW`, ``views.csrf.csrf_failure()`` now
|
| 238 |
+
accepts an optional ``template_name`` parameter, defaulting to
|
| 239 |
+
``'403_csrf.html'``, to control the template used to render the page.
|
| 240 |
+
|
| 241 |
+
* To protect against `BREACH`_ attacks, the CSRF protection mechanism now
|
| 242 |
+
changes the form token value on every request (while keeping an invariant
|
| 243 |
+
secret which can be used to validate the different tokens).
|
| 244 |
+
|
| 245 |
+
.. _BREACH: https://www.breachattack.com/
|
| 246 |
+
|
| 247 |
+
Database backends
|
| 248 |
+
~~~~~~~~~~~~~~~~~
|
| 249 |
+
|
| 250 |
+
* Temporal data subtraction was unified on all backends.
|
| 251 |
+
|
| 252 |
+
* If the database supports it, backends can set
|
| 253 |
+
``DatabaseFeatures.can_return_ids_from_bulk_insert=True`` and implement
|
| 254 |
+
``DatabaseOperations.fetch_returned_insert_ids()`` to set primary keys
|
| 255 |
+
on objects created using ``QuerySet.bulk_create()``.
|
| 256 |
+
|
| 257 |
+
* Added keyword arguments to the ``as_sql()`` methods of various expressions
|
| 258 |
+
(``Func``, ``When``, ``Case``, and ``OrderBy``) to allow database backends to
|
| 259 |
+
customize them without mutating ``self``, which isn't safe when using
|
| 260 |
+
different database backends. See the ``arg_joiner`` and ``**extra_context``
|
| 261 |
+
parameters of :meth:`Func.as_sql() <django.db.models.Func.as_sql>` for an
|
| 262 |
+
example.
|
| 263 |
+
|
| 264 |
+
File Storage
|
| 265 |
+
~~~~~~~~~~~~
|
| 266 |
+
|
| 267 |
+
* Storage backends now present a timezone-aware API with new methods
|
| 268 |
+
:meth:`~django.core.files.storage.Storage.get_accessed_time`,
|
| 269 |
+
:meth:`~django.core.files.storage.Storage.get_created_time`, and
|
| 270 |
+
:meth:`~django.core.files.storage.Storage.get_modified_time`. They return a
|
| 271 |
+
timezone-aware ``datetime`` if :setting:`USE_TZ` is ``True`` and a naive
|
| 272 |
+
``datetime`` in the local timezone otherwise.
|
| 273 |
+
|
| 274 |
+
* The new :meth:`Storage.generate_filename()
|
| 275 |
+
<django.core.files.storage.Storage.generate_filename>` method makes it easier
|
| 276 |
+
to implement custom storages that don't use the ``os.path`` calls previously
|
| 277 |
+
in :class:`~django.db.models.FileField`.
|
| 278 |
+
|
| 279 |
+
Forms
|
| 280 |
+
~~~~~
|
| 281 |
+
|
| 282 |
+
* Form and widget ``Media`` is now served using
|
| 283 |
+
:mod:`django.contrib.staticfiles` if installed.
|
| 284 |
+
|
| 285 |
+
* The ``<input>`` tag rendered by :class:`~django.forms.CharField` now includes
|
| 286 |
+
a ``minlength`` attribute if the field has a ``min_length``.
|
| 287 |
+
|
| 288 |
+
* Required form fields now have the ``required`` HTML attribute. Set the new
|
| 289 |
+
:attr:`Form.use_required_attribute <django.forms.Form.use_required_attribute>`
|
| 290 |
+
attribute to ``False`` to disable it. The ``required`` attribute isn't
|
| 291 |
+
included on forms of formsets because the browser validation may not be
|
| 292 |
+
correct when adding and deleting formsets.
|
| 293 |
+
|
| 294 |
+
Generic Views
|
| 295 |
+
~~~~~~~~~~~~~
|
| 296 |
+
|
| 297 |
+
* The :class:`~django.views.generic.base.View` class can now be imported from
|
| 298 |
+
``django.views``.
|
| 299 |
+
|
| 300 |
+
Internationalization
|
| 301 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 302 |
+
|
| 303 |
+
* The :func:`~django.conf.urls.i18n.i18n_patterns` helper function can now be
|
| 304 |
+
used in a root URLConf specified using :attr:`request.urlconf
|
| 305 |
+
<django.http.HttpRequest.urlconf>`.
|
| 306 |
+
|
| 307 |
+
* By setting the new ``prefix_default_language`` parameter for
|
| 308 |
+
:func:`~django.conf.urls.i18n.i18n_patterns` to ``False``, you can allow
|
| 309 |
+
accessing the default language without a URL prefix.
|
| 310 |
+
|
| 311 |
+
* :func:`~django.views.i18n.set_language` now returns a 204 status code (No
|
| 312 |
+
Content) for AJAX requests when there is no ``next`` parameter in ``POST`` or
|
| 313 |
+
``GET``.
|
| 314 |
+
|
| 315 |
+
* The :class:`~django.views.i18n.JavaScriptCatalog` and
|
| 316 |
+
:class:`~django.views.i18n.JSONCatalog` class-based views supersede the
|
| 317 |
+
deprecated ``javascript_catalog()`` and ``json_catalog()`` function-based
|
| 318 |
+
views. The new views are almost equivalent to the old ones except that by
|
| 319 |
+
default the new views collect all JavaScript strings in the ``djangojs``
|
| 320 |
+
translation domain from all installed apps rather than only the JavaScript
|
| 321 |
+
strings from :setting:`LOCALE_PATHS`.
|
| 322 |
+
|
| 323 |
+
Management Commands
|
| 324 |
+
~~~~~~~~~~~~~~~~~~~
|
| 325 |
+
|
| 326 |
+
* :func:`~django.core.management.call_command` now returns the value returned
|
| 327 |
+
from the ``command.handle()`` method.
|
| 328 |
+
|
| 329 |
+
* The new :option:`check --fail-level` option allows specifying the message
|
| 330 |
+
level that will cause the command to exit with a non-zero status.
|
| 331 |
+
|
| 332 |
+
* The new :option:`makemigrations --check` option makes the command exit
|
| 333 |
+
with a non-zero status when model changes without migrations are detected.
|
| 334 |
+
|
| 335 |
+
* :djadmin:`makemigrations` now displays the path to the migration files that
|
| 336 |
+
it generates.
|
| 337 |
+
|
| 338 |
+
* The :option:`shell --interface` option now accepts ``python`` to force use of
|
| 339 |
+
the "plain" Python interpreter.
|
| 340 |
+
|
| 341 |
+
* The new :option:`shell --command` option lets you run a command as Django and
|
| 342 |
+
exit, instead of opening the interactive shell.
|
| 343 |
+
|
| 344 |
+
* Added a warning to :djadmin:`dumpdata` if a proxy model is specified (which
|
| 345 |
+
results in no output) without its concrete parent.
|
| 346 |
+
|
| 347 |
+
* The new :attr:`BaseCommand.requires_migrations_checks
|
| 348 |
+
<django.core.management.BaseCommand.requires_migrations_checks>` attribute
|
| 349 |
+
may be set to ``True`` if you want your command to print a warning, like
|
| 350 |
+
:djadmin:`runserver` does, if the set of migrations on disk don't match the
|
| 351 |
+
migrations in the database.
|
| 352 |
+
|
| 353 |
+
* To assist with testing, :func:`~django.core.management.call_command` now
|
| 354 |
+
accepts a command object as the first argument.
|
| 355 |
+
|
| 356 |
+
* The :djadmin:`shell` command supports tab completion on systems using
|
| 357 |
+
``libedit``, e.g. macOS.
|
| 358 |
+
|
| 359 |
+
* The :djadmin:`inspectdb` command lets you choose what tables should be
|
| 360 |
+
inspected by specifying their names as arguments.
|
| 361 |
+
|
| 362 |
+
Migrations
|
| 363 |
+
~~~~~~~~~~
|
| 364 |
+
|
| 365 |
+
* Added support for serialization of ``enum.Enum`` objects.
|
| 366 |
+
|
| 367 |
+
* Added the ``elidable`` argument to the
|
| 368 |
+
:class:`~django.db.migrations.operations.RunSQL` and
|
| 369 |
+
:class:`~django.db.migrations.operations.RunPython` operations to allow them
|
| 370 |
+
to be removed when squashing migrations.
|
| 371 |
+
|
| 372 |
+
* Added support for :ref:`non-atomic migrations <non-atomic-migrations>` by
|
| 373 |
+
setting the ``atomic`` attribute on a ``Migration``.
|
| 374 |
+
|
| 375 |
+
* The ``migrate`` and ``makemigrations`` commands now :ref:`check for a
|
| 376 |
+
consistent migration history <migration-history-consistency>`. If they find
|
| 377 |
+
some unapplied dependencies of an applied migration,
|
| 378 |
+
``InconsistentMigrationHistory`` is raised.
|
| 379 |
+
|
| 380 |
+
* The :func:`~django.db.models.signals.pre_migrate` and
|
| 381 |
+
:func:`~django.db.models.signals.post_migrate` signals now dispatch their
|
| 382 |
+
migration ``plan`` and ``apps``.
|
| 383 |
+
|
| 384 |
+
Models
|
| 385 |
+
~~~~~~
|
| 386 |
+
|
| 387 |
+
* Reverse foreign keys from proxy models are now propagated to their
|
| 388 |
+
concrete class. The reverse relation attached by a
|
| 389 |
+
:class:`~django.db.models.ForeignKey` pointing to a proxy model is now
|
| 390 |
+
accessible as a descriptor on the proxied model class and may be referenced in
|
| 391 |
+
queryset filtering.
|
| 392 |
+
|
| 393 |
+
* The new :meth:`Field.rel_db_type() <django.db.models.Field.rel_db_type>`
|
| 394 |
+
method returns the database column data type for fields such as ``ForeignKey``
|
| 395 |
+
and ``OneToOneField`` that point to another field.
|
| 396 |
+
|
| 397 |
+
* The :attr:`~django.db.models.Func.arity` class attribute is added to
|
| 398 |
+
:class:`~django.db.models.Func`. This attribute can be used to set the number
|
| 399 |
+
of arguments the function accepts.
|
| 400 |
+
|
| 401 |
+
* Added :class:`~django.db.models.BigAutoField` which acts much like an
|
| 402 |
+
:class:`~django.db.models.AutoField` except that it is guaranteed
|
| 403 |
+
to fit numbers from ``1`` to ``9223372036854775807``.
|
| 404 |
+
|
| 405 |
+
* :meth:`QuerySet.in_bulk() <django.db.models.query.QuerySet.in_bulk>`
|
| 406 |
+
may be called without any arguments to return all objects in the queryset.
|
| 407 |
+
|
| 408 |
+
* :attr:`~django.db.models.ForeignKey.related_query_name` now supports
|
| 409 |
+
app label and class interpolation using the ``'%(app_label)s'`` and
|
| 410 |
+
``'%(class)s'`` strings.
|
| 411 |
+
|
| 412 |
+
* Allowed overriding model fields inherited from abstract base classes.
|
| 413 |
+
|
| 414 |
+
* The :func:`~django.db.models.prefetch_related_objects` function is now a
|
| 415 |
+
public API.
|
| 416 |
+
|
| 417 |
+
* :meth:`QuerySet.bulk_create() <django.db.models.query.QuerySet.bulk_create>`
|
| 418 |
+
sets the primary key on objects when using PostgreSQL.
|
| 419 |
+
|
| 420 |
+
* Added the :class:`~django.db.models.functions.Cast` database function.
|
| 421 |
+
|
| 422 |
+
* A proxy model may now inherit multiple proxy models that share a common
|
| 423 |
+
non-abstract parent class.
|
| 424 |
+
|
| 425 |
+
* Added :class:`~django.db.models.functions.Extract` functions to extract
|
| 426 |
+
datetime components as integers, such as year and hour.
|
| 427 |
+
|
| 428 |
+
* Added :class:`~django.db.models.functions.Trunc` functions to truncate a date
|
| 429 |
+
or datetime to a significant component. They enable queries like
|
| 430 |
+
sales-per-day or sales-per-hour.
|
| 431 |
+
|
| 432 |
+
* ``Model.__init__()`` now sets values of virtual fields from its keyword
|
| 433 |
+
arguments.
|
| 434 |
+
|
| 435 |
+
* The new :attr:`Meta.base_manager_name
|
| 436 |
+
<django.db.models.Options.base_manager_name>` and
|
| 437 |
+
:attr:`Meta.default_manager_name
|
| 438 |
+
<django.db.models.Options.default_manager_name>` options allow controlling
|
| 439 |
+
the :attr:`~django.db.models.Model._base_manager` and
|
| 440 |
+
:attr:`~django.db.models.Model._default_manager`, respectively.
|
| 441 |
+
|
| 442 |
+
Requests and Responses
|
| 443 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 444 |
+
|
| 445 |
+
* Added ``request.user`` to the debug view.
|
| 446 |
+
|
| 447 |
+
* Added :class:`~django.http.HttpResponse` methods
|
| 448 |
+
:meth:`~django.http.HttpResponse.readable()` and
|
| 449 |
+
:meth:`~django.http.HttpResponse.seekable()` to make an instance a
|
| 450 |
+
stream-like object and allow wrapping it with :py:class:`io.TextIOWrapper`.
|
| 451 |
+
|
| 452 |
+
* Added the :attr:`HttpRequest.content_type
|
| 453 |
+
<django.http.HttpRequest.content_type>` and
|
| 454 |
+
:attr:`~django.http.HttpRequest.content_params` attributes which are
|
| 455 |
+
parsed from the ``CONTENT_TYPE`` header.
|
| 456 |
+
|
| 457 |
+
* The parser for ``request.COOKIES`` is simplified to better match the behavior
|
| 458 |
+
of browsers. ``request.COOKIES`` may now contain cookies that are invalid
|
| 459 |
+
according to :rfc:`6265` but are possible to set via ``document.cookie``.
|
| 460 |
+
|
| 461 |
+
Serialization
|
| 462 |
+
~~~~~~~~~~~~~
|
| 463 |
+
|
| 464 |
+
* The ``django.core.serializers.json.DjangoJSONEncoder`` now knows how to
|
| 465 |
+
serialize lazy strings, typically used for translatable content.
|
| 466 |
+
|
| 467 |
+
Templates
|
| 468 |
+
~~~~~~~~~
|
| 469 |
+
|
| 470 |
+
* Added the ``autoescape`` option to the
|
| 471 |
+
:class:`~django.template.backends.django.DjangoTemplates` backend and the
|
| 472 |
+
:class:`~django.template.Engine` class.
|
| 473 |
+
|
| 474 |
+
* Added the ``is`` and ``is not`` comparison operators to the :ttag:`if` tag.
|
| 475 |
+
|
| 476 |
+
* Allowed :tfilter:`dictsort` to order a list of lists by an element at a
|
| 477 |
+
specified index.
|
| 478 |
+
|
| 479 |
+
* The :func:`~django.template.context_processors.debug` context processor
|
| 480 |
+
contains queries for all database aliases instead of only the default alias.
|
| 481 |
+
|
| 482 |
+
* Added relative path support for string arguments of the :ttag:`extends` and
|
| 483 |
+
:ttag:`include` template tags.
|
| 484 |
+
|
| 485 |
+
Tests
|
| 486 |
+
~~~~~
|
| 487 |
+
|
| 488 |
+
* To better catch bugs, :class:`~django.test.TestCase` now checks deferrable
|
| 489 |
+
database constraints at the end of each test.
|
| 490 |
+
|
| 491 |
+
* Tests and test cases can be :ref:`marked with tags <topics-tagging-tests>`
|
| 492 |
+
and run selectively with the new :option:`test --tag` and :option:`test
|
| 493 |
+
--exclude-tag` options.
|
| 494 |
+
|
| 495 |
+
* You can now login and use sessions with the test client even if
|
| 496 |
+
:mod:`django.contrib.sessions` is not in :setting:`INSTALLED_APPS`.
|
| 497 |
+
|
| 498 |
+
URLs
|
| 499 |
+
~~~~
|
| 500 |
+
|
| 501 |
+
* An addition in :func:`django.setup()` allows URL resolving that happens
|
| 502 |
+
outside of the request/response cycle (e.g. in management commands and
|
| 503 |
+
standalone scripts) to take :setting:`FORCE_SCRIPT_NAME` into account when it
|
| 504 |
+
is set.
|
| 505 |
+
|
| 506 |
+
Validators
|
| 507 |
+
~~~~~~~~~~
|
| 508 |
+
|
| 509 |
+
* :class:`~django.core.validators.URLValidator` now limits the length of
|
| 510 |
+
domain name labels to 63 characters and the total length of domain
|
| 511 |
+
names to 253 characters per :rfc:`1034`.
|
| 512 |
+
|
| 513 |
+
* :func:`~django.core.validators.int_list_validator` now accepts an optional
|
| 514 |
+
``allow_negative`` boolean parameter, defaulting to ``False``, to allow
|
| 515 |
+
negative integers.
|
| 516 |
+
|
| 517 |
+
.. _backwards-incompatible-1.10:
|
| 518 |
+
|
| 519 |
+
Backwards incompatible changes in 1.10
|
| 520 |
+
======================================
|
| 521 |
+
|
| 522 |
+
.. warning::
|
| 523 |
+
|
| 524 |
+
In addition to the changes outlined in this section, be sure to review the
|
| 525 |
+
:ref:`removed-features-1.10` for the features that have reached the end of
|
| 526 |
+
their deprecation cycle and therefore been removed. If you haven't updated
|
| 527 |
+
your code within the deprecation timeline for a given feature, its removal
|
| 528 |
+
may appear as a backwards incompatible change.
|
| 529 |
+
|
| 530 |
+
Database backend API
|
| 531 |
+
--------------------
|
| 532 |
+
|
| 533 |
+
* GIS's ``AreaField`` uses an unspecified underlying numeric type that could in
|
| 534 |
+
practice be any numeric Python type. ``decimal.Decimal`` values retrieved
|
| 535 |
+
from the database are now converted to ``float`` to make it easier to combine
|
| 536 |
+
them with values used by the GIS libraries.
|
| 537 |
+
|
| 538 |
+
* In order to enable temporal subtraction you must set the
|
| 539 |
+
``supports_temporal_subtraction`` database feature flag to ``True`` and
|
| 540 |
+
implement the ``DatabaseOperations.subtract_temporals()`` method. This
|
| 541 |
+
method should return the SQL and parameters required to compute the
|
| 542 |
+
difference in microseconds between the ``lhs`` and ``rhs`` arguments in the
|
| 543 |
+
datatype used to store :class:`~django.db.models.DurationField`.
|
| 544 |
+
|
| 545 |
+
``select_related()`` prohibits non-relational fields for nested relations
|
| 546 |
+
-------------------------------------------------------------------------
|
| 547 |
+
|
| 548 |
+
Django 1.8 added validation for non-relational fields in ``select_related()``:
|
| 549 |
+
|
| 550 |
+
.. code-block:: pycon
|
| 551 |
+
|
| 552 |
+
>>> Book.objects.select_related("title")
|
| 553 |
+
Traceback (most recent call last):
|
| 554 |
+
...
|
| 555 |
+
FieldError: Non-relational field given in select_related: 'title'
|
| 556 |
+
|
| 557 |
+
But it didn't prohibit nested non-relation fields as it does now:
|
| 558 |
+
|
| 559 |
+
.. code-block:: pycon
|
| 560 |
+
|
| 561 |
+
>>> Book.objects.select_related("author__name")
|
| 562 |
+
Traceback (most recent call last):
|
| 563 |
+
...
|
| 564 |
+
FieldError: Non-relational field given in select_related: 'name'
|
| 565 |
+
|
| 566 |
+
``_meta.get_fields()`` returns consistent reverse fields for proxy models
|
| 567 |
+
-------------------------------------------------------------------------
|
| 568 |
+
|
| 569 |
+
Before Django 1.10, the :meth:`~django.db.models.options.Options.get_fields`
|
| 570 |
+
method returned different reverse fields when called on a proxy model compared
|
| 571 |
+
to its proxied concrete class. This inconsistency was fixed by returning the
|
| 572 |
+
full set of fields pointing to a concrete class or one of its proxies in both
|
| 573 |
+
cases.
|
| 574 |
+
|
| 575 |
+
:attr:`AbstractUser.username <django.contrib.auth.models.User.username>` ``max_length`` increased to 150
|
| 576 |
+
--------------------------------------------------------------------------------------------------------
|
| 577 |
+
|
| 578 |
+
A migration for :attr:`django.contrib.auth.models.User.username` is included.
|
| 579 |
+
If you have a custom user model inheriting from ``AbstractUser``, you'll need
|
| 580 |
+
to generate and apply a database migration for your user model.
|
| 581 |
+
|
| 582 |
+
We considered an increase to 254 characters to more easily allow the use of
|
| 583 |
+
email addresses (which are limited to 254 characters) as usernames but rejected
|
| 584 |
+
it due to a MySQL limitation. When using the ``utf8mb4`` encoding (recommended
|
| 585 |
+
for proper Unicode support), MySQL can only create unique indexes with 191
|
| 586 |
+
characters by default. Therefore, if you need a longer length, please use a
|
| 587 |
+
custom user model.
|
| 588 |
+
|
| 589 |
+
If you want to preserve the 30 character limit for usernames, use a custom form
|
| 590 |
+
when creating a user or changing usernames::
|
| 591 |
+
|
| 592 |
+
from django.contrib.auth.forms import UserCreationForm
|
| 593 |
+
|
| 594 |
+
|
| 595 |
+
class MyUserCreationForm(UserCreationForm):
|
| 596 |
+
username = forms.CharField(
|
| 597 |
+
max_length=30,
|
| 598 |
+
help_text="Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.",
|
| 599 |
+
)
|
| 600 |
+
|
| 601 |
+
If you wish to keep this restriction in the admin, set ``UserAdmin.add_form``
|
| 602 |
+
to use this form::
|
| 603 |
+
|
| 604 |
+
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
| 605 |
+
from django.contrib.auth.models import User
|
| 606 |
+
|
| 607 |
+
|
| 608 |
+
class UserAdmin(BaseUserAdmin):
|
| 609 |
+
add_form = MyUserCreationForm
|
| 610 |
+
|
| 611 |
+
|
| 612 |
+
admin.site.unregister(User)
|
| 613 |
+
admin.site.register(User, UserAdmin)
|
| 614 |
+
|
| 615 |
+
Dropped support for PostgreSQL 9.1
|
| 616 |
+
----------------------------------
|
| 617 |
+
|
| 618 |
+
Upstream support for PostgreSQL 9.1 ends in September 2016. As a consequence,
|
| 619 |
+
Django 1.10 sets PostgreSQL 9.2 as the minimum version it officially supports.
|
| 620 |
+
|
| 621 |
+
``runserver`` output goes through logging
|
| 622 |
+
-----------------------------------------
|
| 623 |
+
|
| 624 |
+
Request and response handling of the ``runserver`` command is sent to the
|
| 625 |
+
:ref:`django-server-logger` logger instead of to ``sys.stderr``. If you
|
| 626 |
+
disable Django's logging configuration or override it with your own, you'll
|
| 627 |
+
need to add the appropriate logging configuration if you want to see that
|
| 628 |
+
output::
|
| 629 |
+
|
| 630 |
+
LOGGING = {
|
| 631 |
+
# ...
|
| 632 |
+
"formatters": {
|
| 633 |
+
"django.server": {
|
| 634 |
+
"()": "django.utils.log.ServerFormatter",
|
| 635 |
+
"format": "[%(server_time)s] %(message)s",
|
| 636 |
+
}
|
| 637 |
+
},
|
| 638 |
+
"handlers": {
|
| 639 |
+
"django.server": {
|
| 640 |
+
"level": "INFO",
|
| 641 |
+
"class": "logging.StreamHandler",
|
| 642 |
+
"formatter": "django.server",
|
| 643 |
+
},
|
| 644 |
+
},
|
| 645 |
+
"loggers": {
|
| 646 |
+
"django.server": {
|
| 647 |
+
"handlers": ["django.server"],
|
| 648 |
+
"level": "INFO",
|
| 649 |
+
"propagate": False,
|
| 650 |
+
}
|
| 651 |
+
},
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
``auth.CustomUser`` and ``auth.ExtensionUser`` test models were removed
|
| 655 |
+
-----------------------------------------------------------------------
|
| 656 |
+
|
| 657 |
+
Since the introduction of migrations for the contrib apps in Django 1.8, the
|
| 658 |
+
tables of these custom user test models were not created anymore making them
|
| 659 |
+
unusable in a testing context.
|
| 660 |
+
|
| 661 |
+
Apps registry is no longer auto-populated when unpickling models outside of Django
|
| 662 |
+
----------------------------------------------------------------------------------
|
| 663 |
+
|
| 664 |
+
The apps registry is no longer auto-populated when unpickling models. This was
|
| 665 |
+
added in Django 1.7.2 as an attempt to allow unpickling models outside of
|
| 666 |
+
Django, such as in an RQ worker, without calling ``django.setup()``, but it
|
| 667 |
+
creates the possibility of a deadlock. To adapt your code in the case of RQ,
|
| 668 |
+
you can `provide your own worker script <https://python-rq.org/docs/workers/>`_
|
| 669 |
+
that calls ``django.setup()``.
|
| 670 |
+
|
| 671 |
+
Removed null assignment check for non-null foreign key fields
|
| 672 |
+
-------------------------------------------------------------
|
| 673 |
+
|
| 674 |
+
In older versions, assigning ``None`` to a non-nullable ``ForeignKey`` or
|
| 675 |
+
``OneToOneField`` raised ``ValueError('Cannot assign None: "model.field" does
|
| 676 |
+
not allow null values.')``. For consistency with other model fields which don't
|
| 677 |
+
have a similar check, this check is removed.
|
| 678 |
+
|
| 679 |
+
Removed weak password hashers from the default ``PASSWORD_HASHERS`` setting
|
| 680 |
+
---------------------------------------------------------------------------
|
| 681 |
+
|
| 682 |
+
Django 0.90 stored passwords as unsalted MD5. Django 0.91 added support for
|
| 683 |
+
salted SHA1 with automatic upgrade of passwords when a user logs in. Django 1.4
|
| 684 |
+
added PBKDF2 as the default password hasher.
|
| 685 |
+
|
| 686 |
+
If you have an old Django project with MD5 or SHA1 (even salted) encoded
|
| 687 |
+
passwords, be aware that these can be cracked fairly easily with today's
|
| 688 |
+
hardware. To make Django users acknowledge continued use of weak hashers, the
|
| 689 |
+
following hashers are removed from the default :setting:`PASSWORD_HASHERS`
|
| 690 |
+
setting::
|
| 691 |
+
|
| 692 |
+
"django.contrib.auth.hashers.SHA1PasswordHasher"
|
| 693 |
+
"django.contrib.auth.hashers.MD5PasswordHasher"
|
| 694 |
+
"django.contrib.auth.hashers.UnsaltedSHA1PasswordHasher"
|
| 695 |
+
"django.contrib.auth.hashers.UnsaltedMD5PasswordHasher"
|
| 696 |
+
"django.contrib.auth.hashers.CryptPasswordHasher"
|
| 697 |
+
|
| 698 |
+
Consider using a :ref:`wrapped password hasher <wrapping-password-hashers>` to
|
| 699 |
+
strengthen the hashes in your database. If that's not feasible, add the
|
| 700 |
+
:setting:`PASSWORD_HASHERS` setting to your project and add back any hashers
|
| 701 |
+
that you need.
|
| 702 |
+
|
| 703 |
+
You can check if your database has any of the removed hashers like this::
|
| 704 |
+
|
| 705 |
+
from django.contrib.auth import get_user_model
|
| 706 |
+
|
| 707 |
+
User = get_user_model()
|
| 708 |
+
|
| 709 |
+
# Unsalted MD5/SHA1:
|
| 710 |
+
User.objects.filter(password__startswith="md5$$")
|
| 711 |
+
User.objects.filter(password__startswith="sha1$$")
|
| 712 |
+
# Salted MD5/SHA1:
|
| 713 |
+
User.objects.filter(password__startswith="md5$").exclude(password__startswith="md5$$")
|
| 714 |
+
User.objects.filter(password__startswith="sha1$").exclude(password__startswith="sha1$$")
|
| 715 |
+
# Crypt hasher:
|
| 716 |
+
User.objects.filter(password__startswith="crypt$$")
|
| 717 |
+
|
| 718 |
+
from django.db.models import CharField
|
| 719 |
+
from django.db.models.functions import Length
|
| 720 |
+
|
| 721 |
+
CharField.register_lookup(Length)
|
| 722 |
+
# Unsalted MD5 passwords might not have an 'md5$$' prefix:
|
| 723 |
+
User.objects.filter(password__length=32)
|
| 724 |
+
|
| 725 |
+
``Field.get_prep_lookup()`` and ``Field.get_db_prep_lookup()`` methods are removed
|
| 726 |
+
----------------------------------------------------------------------------------
|
| 727 |
+
|
| 728 |
+
If you have a custom field that implements either of these methods, register a
|
| 729 |
+
custom lookup for it. For example::
|
| 730 |
+
|
| 731 |
+
from django.db.models import Field
|
| 732 |
+
from django.db.models.lookups import Exact
|
| 733 |
+
|
| 734 |
+
|
| 735 |
+
class MyField(Field):
|
| 736 |
+
...
|
| 737 |
+
|
| 738 |
+
|
| 739 |
+
class MyFieldExact(Exact):
|
| 740 |
+
def get_prep_lookup(self):
|
| 741 |
+
# do_custom_stuff_for_myfield
|
| 742 |
+
...
|
| 743 |
+
|
| 744 |
+
|
| 745 |
+
MyField.register_lookup(MyFieldExact)
|
| 746 |
+
|
| 747 |
+
:mod:`django.contrib.gis`
|
| 748 |
+
-------------------------
|
| 749 |
+
|
| 750 |
+
* Support for SpatiaLite < 3.0 and GEOS < 3.3 is dropped.
|
| 751 |
+
|
| 752 |
+
* The ``add_postgis_srs()`` backwards compatibility alias for
|
| 753 |
+
``django.contrib.gis.utils.add_srs_entry()`` is removed.
|
| 754 |
+
|
| 755 |
+
* On Oracle/GIS, the :class:`~django.contrib.gis.db.models.functions.Area`
|
| 756 |
+
aggregate function now returns a ``float`` instead of ``decimal.Decimal``.
|
| 757 |
+
(It's still wrapped in a measure of square meters.)
|
| 758 |
+
|
| 759 |
+
* The default :class:`~django.contrib.gis.geos.GEOSGeometry` representation (WKT
|
| 760 |
+
output) is trimmed by default. That is, instead of
|
| 761 |
+
``POINT (23.0000000000000000 5.5000000000000000)``, you'll get
|
| 762 |
+
``POINT (23 5.5)``.
|
| 763 |
+
|
| 764 |
+
Maximum size of a request body and the number of GET/POST parameters is limited
|
| 765 |
+
-------------------------------------------------------------------------------
|
| 766 |
+
|
| 767 |
+
Two new settings help mitigate denial-of-service attacks via large requests:
|
| 768 |
+
|
| 769 |
+
* :setting:`DATA_UPLOAD_MAX_MEMORY_SIZE` limits the size that a request body
|
| 770 |
+
may be. File uploads don't count toward this limit.
|
| 771 |
+
* :setting:`DATA_UPLOAD_MAX_NUMBER_FIELDS` limits the number of GET/POST
|
| 772 |
+
parameters that are parsed.
|
| 773 |
+
|
| 774 |
+
Applications that receive unusually large form posts may need to tune these
|
| 775 |
+
settings.
|
| 776 |
+
|
| 777 |
+
Miscellaneous
|
| 778 |
+
-------------
|
| 779 |
+
|
| 780 |
+
* The ``repr()`` of a ``QuerySet`` is wrapped in ``<QuerySet >`` to
|
| 781 |
+
disambiguate it from a plain list when debugging.
|
| 782 |
+
|
| 783 |
+
* ``utils.version.get_version()`` returns :pep:`440` compliant release
|
| 784 |
+
candidate versions (e.g. '1.10rc1' instead of '1.10c1').
|
| 785 |
+
|
| 786 |
+
* CSRF token values are now required to be strings of 64 alphanumerics; values
|
| 787 |
+
of 32 alphanumerics, as set by older versions of Django by default, are
|
| 788 |
+
automatically replaced by strings of 64 characters. Other values are
|
| 789 |
+
considered invalid. This should only affect developers or users who replace
|
| 790 |
+
these tokens.
|
| 791 |
+
|
| 792 |
+
* The ``LOGOUT_URL`` setting is removed as Django hasn't made use of it
|
| 793 |
+
since pre-1.0. If you use it in your project, you can add it to your
|
| 794 |
+
project's settings. The default value was ``'/accounts/logout/'``.
|
| 795 |
+
|
| 796 |
+
* Objects with a ``close()`` method such as files and generators passed to
|
| 797 |
+
:class:`~django.http.HttpResponse` are now closed immediately instead of when
|
| 798 |
+
the WSGI server calls ``close()`` on the response.
|
| 799 |
+
|
| 800 |
+
* A redundant ``transaction.atomic()`` call in ``QuerySet.update_or_create()``
|
| 801 |
+
is removed. This may affect query counts tested by
|
| 802 |
+
``TransactionTestCase.assertNumQueries()``.
|
| 803 |
+
|
| 804 |
+
* Support for ``skip_validation`` in ``BaseCommand.execute(**options)`` is
|
| 805 |
+
removed. Use ``skip_checks`` (added in Django 1.7) instead.
|
| 806 |
+
|
| 807 |
+
* :djadmin:`loaddata` now raises a ``CommandError`` instead of showing a
|
| 808 |
+
warning when the specified fixture file is not found.
|
| 809 |
+
|
| 810 |
+
* Instead of directly accessing the ``LogEntry.change_message`` attribute, it's
|
| 811 |
+
now better to call the ``LogEntry.get_change_message()`` method which will
|
| 812 |
+
provide the message in the current language.
|
| 813 |
+
|
| 814 |
+
* The default error views now raise ``TemplateDoesNotExist`` if a nonexistent
|
| 815 |
+
``template_name`` is specified.
|
| 816 |
+
|
| 817 |
+
* The unused ``choices`` keyword argument of the ``Select`` and
|
| 818 |
+
``SelectMultiple`` widgets' ``render()`` method is removed. The ``choices``
|
| 819 |
+
argument of the ``render_options()`` method is also removed, making
|
| 820 |
+
``selected_choices`` the first argument.
|
| 821 |
+
|
| 822 |
+
* Tests that violate deferrable database constraints will now error when run on
|
| 823 |
+
a database that supports deferrable constraints.
|
| 824 |
+
|
| 825 |
+
* Built-in management commands now use indexing of keys in ``options``, e.g.
|
| 826 |
+
``options['verbosity']``, instead of ``options.get()`` and no longer perform
|
| 827 |
+
any type coercion. This could be a problem if you're calling commands using
|
| 828 |
+
``Command.execute()`` (which bypasses the argument parser that sets a default
|
| 829 |
+
value) instead of :func:`~django.core.management.call_command`. Instead of
|
| 830 |
+
calling ``Command.execute()``, pass the command object as the first argument
|
| 831 |
+
to ``call_command()``.
|
| 832 |
+
|
| 833 |
+
* :class:`~django.contrib.auth.backends.ModelBackend` and
|
| 834 |
+
:class:`~django.contrib.auth.backends.RemoteUserBackend` now reject inactive
|
| 835 |
+
users. This means that inactive users can't login and will be logged
|
| 836 |
+
out if they are switched from ``is_active=True`` to ``False``. If you need
|
| 837 |
+
the previous behavior, use the new
|
| 838 |
+
:class:`~django.contrib.auth.backends.AllowAllUsersModelBackend` or
|
| 839 |
+
:class:`~django.contrib.auth.backends.AllowAllUsersRemoteUserBackend`
|
| 840 |
+
in :setting:`AUTHENTICATION_BACKENDS` instead.
|
| 841 |
+
|
| 842 |
+
* In light of the previous change, the test client's
|
| 843 |
+
:meth:`~django.test.Client.login()` method no longer always rejects inactive
|
| 844 |
+
users but instead delegates this decision to the authentication backend.
|
| 845 |
+
:meth:`~django.test.Client.force_login()` also delegates the decision to the
|
| 846 |
+
authentication backend, so if you're using the default backends, you need to
|
| 847 |
+
use an active user.
|
| 848 |
+
|
| 849 |
+
* :func:`django.views.i18n.set_language` may now return a 204 status code for
|
| 850 |
+
AJAX requests.
|
| 851 |
+
|
| 852 |
+
* The ``base_field`` attribute of
|
| 853 |
+
:class:`~django.contrib.postgres.fields.RangeField` is now a type of field,
|
| 854 |
+
not an instance of a field. If you have created a custom subclass of
|
| 855 |
+
:class:`~django.contrib.postgres.fields.RangeField`, you should change the
|
| 856 |
+
``base_field`` attribute.
|
| 857 |
+
|
| 858 |
+
* Middleware classes are now initialized when the server starts rather than
|
| 859 |
+
during the first request.
|
| 860 |
+
|
| 861 |
+
* If you override ``is_authenticated()`` or ``is_anonymous()`` in a custom user
|
| 862 |
+
model, you must convert them to attributes or properties as described in
|
| 863 |
+
:ref:`the deprecation note <user-is-auth-anon-deprecation>`.
|
| 864 |
+
|
| 865 |
+
* When using :attr:`ModelAdmin.save_as=True
|
| 866 |
+
<django.contrib.admin.ModelAdmin.save_as>`, the "Save as new" button now
|
| 867 |
+
redirects to the change view for the new object instead of to the model's
|
| 868 |
+
changelist. If you need the previous behavior, set the new
|
| 869 |
+
:attr:`ModelAdmin.save_as_continue
|
| 870 |
+
<django.contrib.admin.ModelAdmin.save_as_continue>` attribute to ``False``.
|
| 871 |
+
|
| 872 |
+
* Required form fields now have the ``required`` HTML attribute. Set the
|
| 873 |
+
:attr:`Form.use_required_attribute <django.forms.Form.use_required_attribute>`
|
| 874 |
+
attribute to ``False`` to disable it. You could also add the ``novalidate``
|
| 875 |
+
attribute to ``<form>`` if you don't want browser validation. To disable
|
| 876 |
+
the ``required`` attribute on custom widgets, override the
|
| 877 |
+
:meth:`Widget.use_required_attribute() <django.forms.Widget.use_required_attribute>`
|
| 878 |
+
method.
|
| 879 |
+
|
| 880 |
+
* The WSGI handler no longer removes content of responses from ``HEAD``
|
| 881 |
+
requests or responses with a ``status_code`` of 100-199, 204, or 304. Most
|
| 882 |
+
web servers already implement this behavior. Responses retrieved using the
|
| 883 |
+
Django test client continue to have these "response fixes" applied.
|
| 884 |
+
|
| 885 |
+
* ``Model.__init__()`` now receives ``django.db.models.DEFERRED`` as the value
|
| 886 |
+
of deferred fields.
|
| 887 |
+
|
| 888 |
+
* The ``Model._deferred`` attribute is removed as dynamic model classes when
|
| 889 |
+
using ``QuerySet.defer()`` and ``only()`` is removed.
|
| 890 |
+
|
| 891 |
+
* :meth:`Storage.save() <django.core.files.storage.Storage.save>` no longer
|
| 892 |
+
replaces ``'\'`` with ``'/'``. This behavior is moved to
|
| 893 |
+
:class:`~django.core.files.storage.FileSystemStorage` since this is a storage
|
| 894 |
+
specific implementation detail. Any Windows user with a custom storage
|
| 895 |
+
implementation that relies on this behavior will need to implement it in the
|
| 896 |
+
custom storage's ``save()`` method.
|
| 897 |
+
|
| 898 |
+
* Private :class:`~django.db.models.FileField` methods ``get_directory_name()``
|
| 899 |
+
and ``get_filename()`` are no longer called (and are now deprecated) which is
|
| 900 |
+
a backwards incompatible change for users overriding those methods on custom
|
| 901 |
+
fields. To adapt such code, override ``FileField.generate_filename()`` or
|
| 902 |
+
:meth:`Storage.generate_filename()
|
| 903 |
+
<django.core.files.storage.Storage.generate_filename>` instead. It
|
| 904 |
+
might be possible to use :attr:`~django.db.models.FileField.upload_to` also.
|
| 905 |
+
|
| 906 |
+
* The subject of mail sent by ``AdminEmailHandler`` is no longer truncated at
|
| 907 |
+
989 characters. If you were counting on a limited length, truncate the subject
|
| 908 |
+
yourself.
|
| 909 |
+
|
| 910 |
+
* Private expressions ``django.db.models.expressions.Date`` and ``DateTime``
|
| 911 |
+
are removed. The new :class:`~django.db.models.functions.Trunc` expressions
|
| 912 |
+
provide the same functionality.
|
| 913 |
+
|
| 914 |
+
* The ``_base_manager`` and ``_default_manager`` attributes are removed from
|
| 915 |
+
model instances. They remain accessible on the model class.
|
| 916 |
+
|
| 917 |
+
* Accessing a deleted field on a model instance, e.g. after ``del obj.field``,
|
| 918 |
+
reloads the field's value instead of raising ``AttributeError``.
|
| 919 |
+
|
| 920 |
+
* If you subclass ``AbstractBaseUser`` and override ``clean()``, be sure it
|
| 921 |
+
calls ``super()``. :meth:`.AbstractBaseUser.normalize_username` is called in
|
| 922 |
+
a new :meth:`.AbstractBaseUser.clean` method.
|
| 923 |
+
|
| 924 |
+
* Private API ``django.forms.models.model_to_dict()`` returns a queryset rather
|
| 925 |
+
than a list of primary keys for ``ManyToManyField``\s.
|
| 926 |
+
|
| 927 |
+
* If ``django.contrib.staticfiles`` is
|
| 928 |
+
installed, the :ttag:`static` template tag uses the ``staticfiles`` storage
|
| 929 |
+
to construct the URL rather than simply joining the value with
|
| 930 |
+
``STATIC_ROOT``. The new approach encodes the URL, which could be
|
| 931 |
+
backwards-incompatible in cases such as including a fragment in a path, e.g.
|
| 932 |
+
``{% static 'img.svg#fragment' %}``, since the ``#`` is encoded as ``%23``.
|
| 933 |
+
To adapt, move the fragment outside the template tag:
|
| 934 |
+
``{% static 'img.svg' %}#fragment``.
|
| 935 |
+
|
| 936 |
+
* When ``USE_L10N`` is ``True``, localization is now applied for the
|
| 937 |
+
:tfilter:`date` and :tfilter:`time` filters when no format string is
|
| 938 |
+
specified. The ``DATE_FORMAT`` and ``TIME_FORMAT`` specifiers from the active
|
| 939 |
+
locale are used instead of the settings of the same name.
|
| 940 |
+
|
| 941 |
+
.. _deprecated-features-1.10:
|
| 942 |
+
|
| 943 |
+
Features deprecated in 1.10
|
| 944 |
+
===========================
|
| 945 |
+
|
| 946 |
+
Direct assignment to a reverse foreign key or many-to-many relation
|
| 947 |
+
-------------------------------------------------------------------
|
| 948 |
+
|
| 949 |
+
Instead of assigning related objects using direct assignment:
|
| 950 |
+
|
| 951 |
+
.. code-block:: pycon
|
| 952 |
+
|
| 953 |
+
>>> new_list = [obj1, obj2, obj3]
|
| 954 |
+
>>> e.related_set = new_list
|
| 955 |
+
|
| 956 |
+
Use the :meth:`~django.db.models.fields.related.RelatedManager.set` method
|
| 957 |
+
added in Django 1.9:
|
| 958 |
+
|
| 959 |
+
.. code-block:: pycon
|
| 960 |
+
|
| 961 |
+
>>> e.related_set.set([obj1, obj2, obj3])
|
| 962 |
+
|
| 963 |
+
This prevents confusion about an assignment resulting in an implicit save.
|
| 964 |
+
|
| 965 |
+
Non-timezone-aware :class:`~django.core.files.storage.Storage` API
|
| 966 |
+
------------------------------------------------------------------
|
| 967 |
+
|
| 968 |
+
The old, non-timezone-aware methods ``accessed_time()``, ``created_time()``,
|
| 969 |
+
and ``modified_time()`` are deprecated in favor of the new ``get_*_time()``
|
| 970 |
+
methods.
|
| 971 |
+
|
| 972 |
+
Third-party storage backends should implement the new methods and mark the old
|
| 973 |
+
ones as deprecated. Until then, the new ``get_*_time()`` methods on the base
|
| 974 |
+
:class:`~django.core.files.storage.Storage` class convert ``datetime``\s from
|
| 975 |
+
the old methods as required and emit a deprecation warning as they do so.
|
| 976 |
+
|
| 977 |
+
Third-party storage backends may retain the old methods as long as they
|
| 978 |
+
wish to support earlier versions of Django.
|
| 979 |
+
|
| 980 |
+
:mod:`django.contrib.gis`
|
| 981 |
+
-------------------------
|
| 982 |
+
|
| 983 |
+
* The ``get_srid()`` and ``set_srid()`` methods of
|
| 984 |
+
:class:`~django.contrib.gis.geos.GEOSGeometry` are deprecated in favor
|
| 985 |
+
of the :attr:`~django.contrib.gis.geos.GEOSGeometry.srid` property.
|
| 986 |
+
|
| 987 |
+
* The ``get_x()``, ``set_x()``, ``get_y()``, ``set_y()``, ``get_z()``, and
|
| 988 |
+
``set_z()`` methods of :class:`~django.contrib.gis.geos.Point` are deprecated
|
| 989 |
+
in favor of the ``x``, ``y``, and ``z`` properties.
|
| 990 |
+
|
| 991 |
+
* The ``get_coords()`` and ``set_coords()`` methods of
|
| 992 |
+
:class:`~django.contrib.gis.geos.Point` are deprecated in favor of the
|
| 993 |
+
``tuple`` property.
|
| 994 |
+
|
| 995 |
+
* The ``cascaded_union`` property of
|
| 996 |
+
:class:`~django.contrib.gis.geos.MultiPolygon` is deprecated in favor of the
|
| 997 |
+
:attr:`~django.contrib.gis.geos.GEOSGeometry.unary_union` property.
|
| 998 |
+
|
| 999 |
+
* The ``django.contrib.gis.utils.precision_wkt()`` function is deprecated in
|
| 1000 |
+
favor of :class:`~django.contrib.gis.geos.WKTWriter`.
|
| 1001 |
+
|
| 1002 |
+
``CommaSeparatedIntegerField`` model field
|
| 1003 |
+
------------------------------------------
|
| 1004 |
+
|
| 1005 |
+
``CommaSeparatedIntegerField`` is deprecated in favor of
|
| 1006 |
+
:class:`~django.db.models.CharField` with the
|
| 1007 |
+
:func:`~django.core.validators.validate_comma_separated_integer_list`
|
| 1008 |
+
validator::
|
| 1009 |
+
|
| 1010 |
+
from django.core.validators import validate_comma_separated_integer_list
|
| 1011 |
+
from django.db import models
|
| 1012 |
+
|
| 1013 |
+
|
| 1014 |
+
class MyModel(models.Model):
|
| 1015 |
+
numbers = models.CharField(..., validators=[validate_comma_separated_integer_list])
|
| 1016 |
+
|
| 1017 |
+
If you're using Oracle, ``CharField`` uses a different database field type
|
| 1018 |
+
(``NVARCHAR2``) than ``CommaSeparatedIntegerField`` (``VARCHAR2``). Depending
|
| 1019 |
+
on your database settings, this might imply a different encoding, and thus a
|
| 1020 |
+
different length (in bytes) for the same contents. If your stored values are
|
| 1021 |
+
longer than the 4000 byte limit of ``NVARCHAR2``, you should use ``TextField``
|
| 1022 |
+
(``NCLOB``) instead. In this case, if you have any queries that group by the
|
| 1023 |
+
field (e.g. annotating the model with an aggregation or using ``distinct()``)
|
| 1024 |
+
you'll need to change them (to defer the field).
|
| 1025 |
+
|
| 1026 |
+
Using a model name as a query lookup when ``default_related_name`` is set
|
| 1027 |
+
-------------------------------------------------------------------------
|
| 1028 |
+
|
| 1029 |
+
Assume the following models::
|
| 1030 |
+
|
| 1031 |
+
from django.db import models
|
| 1032 |
+
|
| 1033 |
+
|
| 1034 |
+
class Foo(models.Model):
|
| 1035 |
+
pass
|
| 1036 |
+
|
| 1037 |
+
|
| 1038 |
+
class Bar(models.Model):
|
| 1039 |
+
foo = models.ForeignKey(Foo)
|
| 1040 |
+
|
| 1041 |
+
class Meta:
|
| 1042 |
+
default_related_name = "bars"
|
| 1043 |
+
|
| 1044 |
+
In older versions, :attr:`~django.db.models.Options.default_related_name`
|
| 1045 |
+
couldn't be used as a query lookup. This is fixed and support for the old
|
| 1046 |
+
lookup name is deprecated. For example, since ``default_related_name`` is set
|
| 1047 |
+
in model ``Bar``, instead of using the model name ``bar`` as the lookup:
|
| 1048 |
+
|
| 1049 |
+
.. code-block:: pycon
|
| 1050 |
+
|
| 1051 |
+
>>> bar = Bar.objects.get(pk=1)
|
| 1052 |
+
>>> Foo.objects.get(bar=bar)
|
| 1053 |
+
|
| 1054 |
+
use the default_related_name ``bars``:
|
| 1055 |
+
|
| 1056 |
+
.. code-block:: pycon
|
| 1057 |
+
|
| 1058 |
+
>>> Foo.objects.get(bars=bar)
|
| 1059 |
+
|
| 1060 |
+
.. _search-lookup-replacement:
|
| 1061 |
+
|
| 1062 |
+
``__search`` query lookup
|
| 1063 |
+
-------------------------
|
| 1064 |
+
|
| 1065 |
+
The ``search`` lookup, which supports MySQL only and is extremely limited in
|
| 1066 |
+
features, is deprecated. Replace it with a custom lookup::
|
| 1067 |
+
|
| 1068 |
+
from django.db import models
|
| 1069 |
+
|
| 1070 |
+
|
| 1071 |
+
class Search(models.Lookup):
|
| 1072 |
+
lookup_name = "search"
|
| 1073 |
+
|
| 1074 |
+
def as_mysql(self, compiler, connection):
|
| 1075 |
+
lhs, lhs_params = self.process_lhs(compiler, connection)
|
| 1076 |
+
rhs, rhs_params = self.process_rhs(compiler, connection)
|
| 1077 |
+
params = lhs_params + rhs_params
|
| 1078 |
+
return "MATCH (%s) AGAINST (%s IN BOOLEAN MODE)" % (lhs, rhs), params
|
| 1079 |
+
|
| 1080 |
+
|
| 1081 |
+
models.CharField.register_lookup(Search)
|
| 1082 |
+
models.TextField.register_lookup(Search)
|
| 1083 |
+
|
| 1084 |
+
.. _user-is-auth-anon-deprecation:
|
| 1085 |
+
|
| 1086 |
+
Using ``User.is_authenticated()`` and ``User.is_anonymous()`` as methods
|
| 1087 |
+
------------------------------------------------------------------------
|
| 1088 |
+
|
| 1089 |
+
The ``is_authenticated()`` and ``is_anonymous()`` methods of
|
| 1090 |
+
:class:`~django.contrib.auth.models.AbstractBaseUser` and
|
| 1091 |
+
:class:`~django.contrib.auth.models.AnonymousUser` classes are now
|
| 1092 |
+
properties. They will still work as methods until Django 2.0, but all usage
|
| 1093 |
+
in Django now uses attribute access.
|
| 1094 |
+
|
| 1095 |
+
For example, if you use
|
| 1096 |
+
:class:`~django.contrib.auth.middleware.AuthenticationMiddleware` and want
|
| 1097 |
+
to know whether the user is currently logged-in you would use::
|
| 1098 |
+
|
| 1099 |
+
if request.user.is_authenticated:
|
| 1100 |
+
... # Do something for logged-in users.
|
| 1101 |
+
else:
|
| 1102 |
+
... # Do something for anonymous users.
|
| 1103 |
+
|
| 1104 |
+
instead of ``request.user.is_authenticated()``.
|
| 1105 |
+
|
| 1106 |
+
This change avoids accidental information leakage if you forget to call the
|
| 1107 |
+
method, e.g.::
|
| 1108 |
+
|
| 1109 |
+
if request.user.is_authenticated:
|
| 1110 |
+
return sensitive_information
|
| 1111 |
+
|
| 1112 |
+
If you override these methods in a custom user model, you must change them to
|
| 1113 |
+
properties or attributes.
|
| 1114 |
+
|
| 1115 |
+
Django uses a ``CallableBool`` object to allow these attributes to work as both
|
| 1116 |
+
a property and a method. Thus, until the deprecation period ends, you cannot
|
| 1117 |
+
compare these properties using the ``is`` operator. That is, the following
|
| 1118 |
+
won't work::
|
| 1119 |
+
|
| 1120 |
+
if request.user.is_authenticated is True:
|
| 1121 |
+
...
|
| 1122 |
+
|
| 1123 |
+
Custom manager classes available through ``prefetch_related`` must define a ``_apply_rel_filters()`` method
|
| 1124 |
+
-----------------------------------------------------------------------------------------------------------
|
| 1125 |
+
|
| 1126 |
+
If you defined a custom manager class available through
|
| 1127 |
+
:meth:`~django.db.models.query.QuerySet.prefetch_related` you must make sure
|
| 1128 |
+
it defines a ``_apply_rel_filters()`` method.
|
| 1129 |
+
|
| 1130 |
+
This method must accept a :class:`~django.db.models.query.QuerySet` instance
|
| 1131 |
+
as its single argument and return a filtered version of the queryset for the
|
| 1132 |
+
model instance the manager is bound to.
|
| 1133 |
+
|
| 1134 |
+
The "escape" half of ``django.utils.safestring``
|
| 1135 |
+
------------------------------------------------
|
| 1136 |
+
|
| 1137 |
+
The ``mark_for_escaping()`` function and the classes it uses: ``EscapeData``,
|
| 1138 |
+
``EscapeBytes``, ``EscapeText``, ``EscapeString``, and ``EscapeUnicode`` are
|
| 1139 |
+
deprecated.
|
| 1140 |
+
|
| 1141 |
+
As a result, the "lazy" behavior of the ``escape`` filter (where it would
|
| 1142 |
+
always be applied as the last filter no matter where in the filter chain it
|
| 1143 |
+
appeared) is deprecated. The filter will change to immediately apply
|
| 1144 |
+
:func:`~django.utils.html.conditional_escape` in Django 2.0.
|
| 1145 |
+
|
| 1146 |
+
``Manager.use_for_related_fields`` and inheritance changes
|
| 1147 |
+
----------------------------------------------------------
|
| 1148 |
+
|
| 1149 |
+
``Manager.use_for_related_fields`` is deprecated in favor of setting
|
| 1150 |
+
:attr:`Meta.base_manager_name <django.db.models.Options.base_manager_name>` on
|
| 1151 |
+
the model.
|
| 1152 |
+
|
| 1153 |
+
Model ``Manager`` inheritance will follow MRO inheritance rules in Django 2.0,
|
| 1154 |
+
changing the current behavior where managers defined on non-abstract base
|
| 1155 |
+
classes aren't inherited by child classes. A deprecating warning with
|
| 1156 |
+
instructions on how to adapt your code is raised if you have any affected
|
| 1157 |
+
managers. You'll either redeclare a manager from an abstract model on the child
|
| 1158 |
+
class to override the manager from the concrete model, or you'll set the
|
| 1159 |
+
model's ``Meta.manager_inheritance_from_future=True`` option to opt-in to the
|
| 1160 |
+
new inheritance behavior.
|
| 1161 |
+
|
| 1162 |
+
During the deprecation period, ``use_for_related_fields`` will be honored and
|
| 1163 |
+
raise a warning, even if a ``base_manager_name`` is set. This allows
|
| 1164 |
+
third-party code to preserve legacy behavior while transitioning to the new
|
| 1165 |
+
API. The warning can be silenced by setting
|
| 1166 |
+
``silence_use_for_related_fields_deprecation=True`` on the manager.
|
| 1167 |
+
|
| 1168 |
+
Miscellaneous
|
| 1169 |
+
-------------
|
| 1170 |
+
|
| 1171 |
+
* The ``makemigrations --exit`` option is deprecated in favor of the
|
| 1172 |
+
:option:`makemigrations --check` option.
|
| 1173 |
+
|
| 1174 |
+
* ``django.utils.functional.allow_lazy()`` is deprecated in favor of the new
|
| 1175 |
+
:func:`~django.utils.functional.keep_lazy` function which can be used with a
|
| 1176 |
+
more natural decorator syntax.
|
| 1177 |
+
|
| 1178 |
+
* The ``shell --plain`` option is deprecated in favor of ``-i python`` or
|
| 1179 |
+
``--interface python``.
|
| 1180 |
+
|
| 1181 |
+
* Importing from the ``django.core.urlresolvers`` module is deprecated in
|
| 1182 |
+
favor of its new location, :mod:`django.urls`.
|
| 1183 |
+
|
| 1184 |
+
* The template ``Context.has_key()`` method is deprecated in favor of ``in``.
|
| 1185 |
+
|
| 1186 |
+
* The private attribute ``virtual_fields`` of ``Model._meta`` is
|
| 1187 |
+
deprecated in favor of ``private_fields``.
|
| 1188 |
+
|
| 1189 |
+
* The private keyword arguments ``virtual_only`` in
|
| 1190 |
+
``Field.contribute_to_class()`` and ``virtual`` in
|
| 1191 |
+
``Model._meta.add_field()`` are deprecated in favor of ``private_only``
|
| 1192 |
+
and ``private``, respectively.
|
| 1193 |
+
|
| 1194 |
+
* The ``javascript_catalog()`` and ``json_catalog()`` views are deprecated in
|
| 1195 |
+
favor of class-based views :class:`~django.views.i18n.JavaScriptCatalog`
|
| 1196 |
+
and :class:`~django.views.i18n.JSONCatalog`.
|
| 1197 |
+
|
| 1198 |
+
* In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a
|
| 1199 |
+
``parent_link`` is deprecated. Add ``parent_link=True`` to such fields.
|
| 1200 |
+
|
| 1201 |
+
* The private API ``Widget._format_value()`` is made public and renamed to
|
| 1202 |
+
:meth:`~django.forms.Widget.format_value`. The old name will work
|
| 1203 |
+
through a deprecation period.
|
| 1204 |
+
|
| 1205 |
+
* Private ``FileField`` methods ``get_directory_name()`` and ``get_filename()``
|
| 1206 |
+
are deprecated in favor of performing this work in
|
| 1207 |
+
:meth:`Storage.generate_filename()
|
| 1208 |
+
<django.core.files.storage.Storage.generate_filename>`).
|
| 1209 |
+
|
| 1210 |
+
* Old-style middleware that uses ``settings.MIDDLEWARE_CLASSES`` are
|
| 1211 |
+
deprecated. :ref:`Adapt old, custom middleware <upgrading-middleware>` and
|
| 1212 |
+
use the new :setting:`MIDDLEWARE` setting.
|
| 1213 |
+
|
| 1214 |
+
.. _removed-features-1.10:
|
| 1215 |
+
|
| 1216 |
+
Features removed in 1.10
|
| 1217 |
+
========================
|
| 1218 |
+
|
| 1219 |
+
These features have reached the end of their deprecation cycle and are removed
|
| 1220 |
+
in Django 1.10. See :ref:`deprecated-features-1.8` for details, including how
|
| 1221 |
+
to remove usage of these features.
|
| 1222 |
+
|
| 1223 |
+
* Support for calling a ``SQLCompiler`` directly as an alias for calling its
|
| 1224 |
+
``quote_name_unless_alias`` method is removed.
|
| 1225 |
+
|
| 1226 |
+
* The ``cycle`` and ``firstof`` template tags are removed from the ``future``
|
| 1227 |
+
template tag library.
|
| 1228 |
+
|
| 1229 |
+
* ``django.conf.urls.patterns()`` is removed.
|
| 1230 |
+
|
| 1231 |
+
* Support for the ``prefix`` argument to
|
| 1232 |
+
``django.conf.urls.i18n.i18n_patterns()`` is removed.
|
| 1233 |
+
|
| 1234 |
+
* ``SimpleTestCase.urls`` is removed.
|
| 1235 |
+
|
| 1236 |
+
* Using an incorrect count of unpacked values in the ``for`` template tag
|
| 1237 |
+
raises an exception rather than failing silently.
|
| 1238 |
+
|
| 1239 |
+
* The ability to :func:`~django.urls.reverse` URLs using a dotted Python path
|
| 1240 |
+
is removed.
|
| 1241 |
+
|
| 1242 |
+
* The ability to use a dotted Python path for the ``LOGIN_URL`` and
|
| 1243 |
+
``LOGIN_REDIRECT_URL`` settings is removed.
|
| 1244 |
+
|
| 1245 |
+
* Support for ``optparse`` is dropped for custom management commands.
|
| 1246 |
+
|
| 1247 |
+
* The class ``django.core.management.NoArgsCommand`` is removed.
|
| 1248 |
+
|
| 1249 |
+
* ``django.core.context_processors`` module is removed.
|
| 1250 |
+
|
| 1251 |
+
* ``django.db.models.sql.aggregates`` module is removed.
|
| 1252 |
+
|
| 1253 |
+
* ``django.contrib.gis.db.models.sql.aggregates`` module is removed.
|
| 1254 |
+
|
| 1255 |
+
* The following methods and properties of ``django.db.sql.query.Query`` are
|
| 1256 |
+
removed:
|
| 1257 |
+
|
| 1258 |
+
* Properties: ``aggregates`` and ``aggregate_select``
|
| 1259 |
+
* Methods: ``add_aggregate``, ``set_aggregate_mask``, and
|
| 1260 |
+
``append_aggregate_mask``.
|
| 1261 |
+
|
| 1262 |
+
* ``django.template.resolve_variable`` is removed.
|
| 1263 |
+
|
| 1264 |
+
* The following private APIs are removed from
|
| 1265 |
+
:class:`django.db.models.options.Options` (``Model._meta``):
|
| 1266 |
+
|
| 1267 |
+
* ``get_field_by_name()``
|
| 1268 |
+
* ``get_all_field_names()``
|
| 1269 |
+
* ``get_fields_with_model()``
|
| 1270 |
+
* ``get_concrete_fields_with_model()``
|
| 1271 |
+
* ``get_m2m_with_model()``
|
| 1272 |
+
* ``get_all_related_objects()``
|
| 1273 |
+
* ``get_all_related_objects_with_model()``
|
| 1274 |
+
* ``get_all_related_many_to_many_objects()``
|
| 1275 |
+
* ``get_all_related_m2m_objects_with_model()``
|
| 1276 |
+
|
| 1277 |
+
* The ``error_message`` argument of ``django.forms.RegexField`` is removed.
|
| 1278 |
+
|
| 1279 |
+
* The ``unordered_list`` filter no longer supports old style lists.
|
| 1280 |
+
|
| 1281 |
+
* Support for string ``view`` arguments to ``url()`` is removed.
|
| 1282 |
+
|
| 1283 |
+
* The backward compatible shim to rename ``django.forms.Form._has_changed()``
|
| 1284 |
+
to ``has_changed()`` is removed.
|
| 1285 |
+
|
| 1286 |
+
* The ``removetags`` template filter is removed.
|
| 1287 |
+
|
| 1288 |
+
* The ``remove_tags()`` and ``strip_entities()`` functions in
|
| 1289 |
+
``django.utils.html`` is removed.
|
| 1290 |
+
|
| 1291 |
+
* The ``is_admin_site`` argument to
|
| 1292 |
+
``django.contrib.auth.views.password_reset()`` is removed.
|
| 1293 |
+
|
| 1294 |
+
* ``django.db.models.field.subclassing.SubfieldBase`` is removed.
|
| 1295 |
+
|
| 1296 |
+
* ``django.utils.checksums`` is removed.
|
| 1297 |
+
|
| 1298 |
+
* The ``original_content_type_id`` attribute on
|
| 1299 |
+
``django.contrib.admin.helpers.InlineAdminForm`` is removed.
|
| 1300 |
+
|
| 1301 |
+
* The backwards compatibility shim to allow ``FormMixin.get_form()`` to be
|
| 1302 |
+
defined with no default value for its ``form_class`` argument is removed.
|
| 1303 |
+
|
| 1304 |
+
* The following settings are removed, and you must upgrade to the
|
| 1305 |
+
:setting:`TEMPLATES` setting:
|
| 1306 |
+
|
| 1307 |
+
* ``ALLOWED_INCLUDE_ROOTS``
|
| 1308 |
+
* ``TEMPLATE_CONTEXT_PROCESSORS``
|
| 1309 |
+
* ``TEMPLATE_DEBUG``
|
| 1310 |
+
* ``TEMPLATE_DIRS``
|
| 1311 |
+
* ``TEMPLATE_LOADERS``
|
| 1312 |
+
* ``TEMPLATE_STRING_IF_INVALID``
|
| 1313 |
+
|
| 1314 |
+
* The backwards compatibility alias ``django.template.loader.BaseLoader`` is
|
| 1315 |
+
removed.
|
| 1316 |
+
|
| 1317 |
+
* Django template objects returned by
|
| 1318 |
+
:func:`~django.template.loader.get_template` and
|
| 1319 |
+
:func:`~django.template.loader.select_template` no longer accept a
|
| 1320 |
+
:class:`~django.template.Context` in their
|
| 1321 |
+
:meth:`~django.template.backends.base.Template.render()` method.
|
| 1322 |
+
|
| 1323 |
+
* :doc:`Template response APIs </ref/template-response>` enforce the use of
|
| 1324 |
+
:class:`dict` and backend-dependent template objects instead of
|
| 1325 |
+
:class:`~django.template.Context` and :class:`~django.template.Template`
|
| 1326 |
+
respectively.
|
| 1327 |
+
|
| 1328 |
+
* The ``current_app`` parameter for the following function and classes is
|
| 1329 |
+
removed:
|
| 1330 |
+
|
| 1331 |
+
* ``django.shortcuts.render()``
|
| 1332 |
+
* ``django.template.Context()``
|
| 1333 |
+
* ``django.template.RequestContext()``
|
| 1334 |
+
* ``django.template.response.TemplateResponse()``
|
| 1335 |
+
|
| 1336 |
+
* The ``dictionary`` and ``context_instance`` parameters for the following
|
| 1337 |
+
functions are removed:
|
| 1338 |
+
|
| 1339 |
+
* ``django.shortcuts.render()``
|
| 1340 |
+
* ``django.shortcuts.render_to_response()``
|
| 1341 |
+
* ``django.template.loader.render_to_string()``
|
| 1342 |
+
|
| 1343 |
+
* The ``dirs`` parameter for the following functions is removed:
|
| 1344 |
+
|
| 1345 |
+
* ``django.template.loader.get_template()``
|
| 1346 |
+
* ``django.template.loader.select_template()``
|
| 1347 |
+
* ``django.shortcuts.render()``
|
| 1348 |
+
* ``django.shortcuts.render_to_response()``
|
| 1349 |
+
|
| 1350 |
+
* Session verification is enabled regardless of whether or not
|
| 1351 |
+
``'django.contrib.auth.middleware.SessionAuthenticationMiddleware'`` is in
|
| 1352 |
+
``MIDDLEWARE_CLASSES``. ``SessionAuthenticationMiddleware`` no longer has
|
| 1353 |
+
any purpose and can be removed from ``MIDDLEWARE_CLASSES``. It's kept as
|
| 1354 |
+
a stub until Django 2.0 as a courtesy for users who don't read this note.
|
| 1355 |
+
|
| 1356 |
+
* Private attribute ``django.db.models.Field.related`` is removed.
|
| 1357 |
+
|
| 1358 |
+
* The ``--list`` option of the ``migrate`` management command is removed.
|
| 1359 |
+
|
| 1360 |
+
* The ``ssi`` template tag is removed.
|
| 1361 |
+
|
| 1362 |
+
* Support for the ``=`` comparison operator in the ``if`` template tag is
|
| 1363 |
+
removed.
|
| 1364 |
+
|
| 1365 |
+
* The backwards compatibility shims to allow ``Storage.get_available_name()``
|
| 1366 |
+
and ``Storage.save()`` to be defined without a ``max_length`` argument are
|
| 1367 |
+
removed.
|
| 1368 |
+
|
| 1369 |
+
* Support for the legacy ``%(<foo>)s`` syntax in ``ModelFormMixin.success_url``
|
| 1370 |
+
is removed.
|
| 1371 |
+
|
| 1372 |
+
* ``GeoQuerySet`` aggregate methods ``collect()``, ``extent()``, ``extent3d()``,
|
| 1373 |
+
``make_line()``, and ``unionagg()`` are removed.
|
| 1374 |
+
|
| 1375 |
+
* The ability to specify ``ContentType.name`` when creating a content type
|
| 1376 |
+
instance is removed.
|
| 1377 |
+
|
| 1378 |
+
* Support for the old signature of ``allow_migrate`` is removed.
|
| 1379 |
+
|
| 1380 |
+
* Support for the syntax of ``{% cycle %}`` that uses comma-separated arguments
|
| 1381 |
+
is removed.
|
| 1382 |
+
|
| 1383 |
+
* The warning that :class:`~django.core.signing.Signer` issued when given an
|
| 1384 |
+
invalid separator is now a ``ValueError``.
|
testbed/django__django/docs/releases/1.11.1.txt
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
===========================
|
| 2 |
+
Django 1.11.1 release notes
|
| 3 |
+
===========================
|
| 4 |
+
|
| 5 |
+
*May 6, 2017*
|
| 6 |
+
|
| 7 |
+
Django 1.11.1 adds a minor feature and fixes several bugs in 1.11.
|
| 8 |
+
|
| 9 |
+
Allowed disabling server-side cursors on PostgreSQL
|
| 10 |
+
===================================================
|
| 11 |
+
|
| 12 |
+
The change in Django 1.11 to make :meth:`.QuerySet.iterator()` use server-side
|
| 13 |
+
cursors on PostgreSQL prevents running Django with PgBouncer in transaction
|
| 14 |
+
pooling mode. To reallow that, use the :setting:`DISABLE_SERVER_SIDE_CURSORS
|
| 15 |
+
<DATABASE-DISABLE_SERVER_SIDE_CURSORS>` setting in :setting:`DATABASES`.
|
| 16 |
+
|
| 17 |
+
See :ref:`transaction-pooling-server-side-cursors` for more discussion.
|
| 18 |
+
|
| 19 |
+
Bugfixes
|
| 20 |
+
========
|
| 21 |
+
|
| 22 |
+
* Made migrations respect ``Index``’s ``name`` argument. If you created a
|
| 23 |
+
named index with Django 1.11, ``makemigrations`` will create a migration to
|
| 24 |
+
recreate the index with the correct name (:ticket:`28051`).
|
| 25 |
+
|
| 26 |
+
* Fixed a crash when using a ``__icontains`` lookup on a ``ArrayField``
|
| 27 |
+
(:ticket:`28038`).
|
| 28 |
+
|
| 29 |
+
* Fixed a crash when using a 2-tuple in ``EmailMessage``’s ``attachments``
|
| 30 |
+
argument (:ticket:`28042`).
|
| 31 |
+
|
| 32 |
+
* Fixed ``QuerySet.filter()`` crash when it references the name of a
|
| 33 |
+
``OneToOneField`` primary key (:ticket:`28047`).
|
| 34 |
+
|
| 35 |
+
* Fixed empty POST data table appearing instead of "No POST data" in HTML debug
|
| 36 |
+
page (:ticket:`28079`).
|
| 37 |
+
|
| 38 |
+
* Restored ``BoundField``\s without any ``choices`` evaluating to ``True``
|
| 39 |
+
(:ticket:`28058`).
|
| 40 |
+
|
| 41 |
+
* Prevented ``SessionBase.cycle_key()`` from losing session data if
|
| 42 |
+
``_session_cache`` isn't populated (:ticket:`28066`).
|
| 43 |
+
|
| 44 |
+
* Fixed layout of ``ReadOnlyPasswordHashWidget`` (used in the admin's user
|
| 45 |
+
change page) (:ticket:`28097`).
|
| 46 |
+
|
| 47 |
+
* Allowed prefetch calls on managers with custom ``ModelIterable`` subclasses
|
| 48 |
+
(:ticket:`28096`).
|
| 49 |
+
|
| 50 |
+
* Fixed change password link in the ``contrib.auth`` admin for ``el``,
|
| 51 |
+
``es_MX``, and ``pt`` translations (:ticket:`28100`).
|
| 52 |
+
|
| 53 |
+
* Restored the output of the ``class`` attribute in the ``<ul>`` of widgets
|
| 54 |
+
that use the ``multiple_input.html`` template. This fixes
|
| 55 |
+
``ModelAdmin.radio_fields`` with ``admin.HORIZONTAL`` (:ticket:`28059`).
|
| 56 |
+
|
| 57 |
+
* Fixed crash in ``BaseGeometryWidget.subwidgets()`` (:ticket:`28039`).
|
| 58 |
+
|
| 59 |
+
* Fixed exception reraising in ORM query execution when ``cursor.execute()``
|
| 60 |
+
fails and the subsequent ``cursor.close()`` also fails (:ticket:`28091`).
|
| 61 |
+
|
| 62 |
+
* Fixed a regression where ``CheckboxSelectMultiple``, ``NullBooleanSelect``,
|
| 63 |
+
``RadioSelect``, ``SelectMultiple``, and ``Select`` localized option values
|
| 64 |
+
(:ticket:`28075`).
|
| 65 |
+
|
| 66 |
+
* Corrected the stack level of unordered queryset pagination warnings
|
| 67 |
+
(:ticket:`28109`).
|
| 68 |
+
|
| 69 |
+
* Fixed a regression causing incorrect queries for ``__in`` subquery lookups
|
| 70 |
+
when models use ``ForeignKey.to_field`` (:ticket:`28101`).
|
| 71 |
+
|
| 72 |
+
* Fixed crash when overriding the template of
|
| 73 |
+
``django.views.static.directory_index()`` (:ticket:`28122`).
|
| 74 |
+
|
| 75 |
+
* Fixed a regression in formset ``min_num`` validation with unchanged forms
|
| 76 |
+
that have initial data (:ticket:`28130`).
|
| 77 |
+
|
| 78 |
+
* Prepared for ``cx_Oracle`` 6.0 support (:ticket:`28138`).
|
| 79 |
+
|
| 80 |
+
* Updated the ``contrib.postgres`` ``SplitArrayWidget`` to use template-based
|
| 81 |
+
widget rendering (:ticket:`28040`).
|
| 82 |
+
|
| 83 |
+
* Fixed crash in ``BaseGeometryWidget.get_context()`` when overriding existing
|
| 84 |
+
``attrs`` (:ticket:`28105`).
|
| 85 |
+
|
| 86 |
+
* Prevented ``AddIndex`` and ``RemoveIndex`` from mutating model state
|
| 87 |
+
(:ticket:`28043`).
|
| 88 |
+
|
| 89 |
+
* Prevented migrations from dropping database indexes from ``Meta.indexes``
|
| 90 |
+
when changing ``Field.db_index`` to ``False`` (:ticket:`28052`).
|
| 91 |
+
|
| 92 |
+
* Fixed a regression in choice ordering in form fields with grouped and
|
| 93 |
+
non-grouped options (:ticket:`28157`).
|
| 94 |
+
|
| 95 |
+
* Fixed crash in ``BaseInlineFormSet._construct_form()`` when using
|
| 96 |
+
``save_as_new`` (:ticket:`28159`).
|
| 97 |
+
|
| 98 |
+
* Fixed a regression where ``Model._state.db`` wasn't set correctly on
|
| 99 |
+
multi-table inheritance parent models after saving a child model
|
| 100 |
+
(:ticket:`28166`).
|
| 101 |
+
|
| 102 |
+
* Corrected the return type of ``ArrayField(CITextField())`` values retrieved
|
| 103 |
+
from the database (:ticket:`28161`).
|
| 104 |
+
|
| 105 |
+
* Fixed ``QuerySet.prefetch_related()`` crash when fetching relations in nested
|
| 106 |
+
``Prefetch`` objects (:ticket:`27554`).
|
| 107 |
+
|
| 108 |
+
* Prevented hiding GDAL errors if it's not installed when using ``contrib.gis``
|
| 109 |
+
(:ticket:`28160`). (It's a required dependency as of Django 1.11.)
|
| 110 |
+
|
| 111 |
+
* Fixed a regression causing ``__in`` lookups on a foreign key to fail when
|
| 112 |
+
using the foreign key's parent model as the lookup value (:ticket:`28175`).
|
testbed/django__django/docs/releases/1.11.13.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
============================
|
| 2 |
+
Django 1.11.13 release notes
|
| 3 |
+
============================
|
| 4 |
+
|
| 5 |
+
*May 1, 2018*
|
| 6 |
+
|
| 7 |
+
Django 1.11.13 fixes several bugs in 1.11.12.
|
| 8 |
+
|
| 9 |
+
Bugfixes
|
| 10 |
+
========
|
| 11 |
+
|
| 12 |
+
* Fixed a regression in Django 1.11.8 where altering a field with a unique
|
| 13 |
+
constraint may drop and rebuild more foreign keys than necessary
|
| 14 |
+
(:ticket:`29193`).
|
| 15 |
+
|
| 16 |
+
* Fixed crashes in ``django.contrib.admindocs`` when a view is a callable
|
| 17 |
+
object, such as ``django.contrib.syndication.views.Feed`` (:ticket:`29296`).
|
| 18 |
+
|
| 19 |
+
* Fixed a regression in Django 1.11.12 where ``QuerySet.values()`` or
|
| 20 |
+
``values_list()`` after combining an annotated and unannotated queryset with
|
| 21 |
+
``union()``, ``difference()``, or ``intersection()`` crashed due to mismatching
|
| 22 |
+
columns (:ticket:`29286`).
|
testbed/django__django/docs/releases/1.11.5.txt
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
===========================
|
| 2 |
+
Django 1.11.5 release notes
|
| 3 |
+
===========================
|
| 4 |
+
|
| 5 |
+
*September 5, 2017*
|
| 6 |
+
|
| 7 |
+
Django 1.11.5 fixes a security issue and several bugs in 1.11.4.
|
| 8 |
+
|
| 9 |
+
CVE-2017-12794: Possible XSS in traceback section of technical 500 debug page
|
| 10 |
+
=============================================================================
|
| 11 |
+
|
| 12 |
+
In older versions, HTML autoescaping was disabled in a portion of the template
|
| 13 |
+
for the technical 500 debug page. Given the right circumstances, this allowed
|
| 14 |
+
a cross-site scripting attack. This vulnerability shouldn't affect most
|
| 15 |
+
production sites since you shouldn't run with ``DEBUG = True`` (which makes
|
| 16 |
+
this page accessible) in your production settings.
|
| 17 |
+
|
| 18 |
+
Bugfixes
|
| 19 |
+
========
|
| 20 |
+
|
| 21 |
+
* Fixed GEOS version parsing if the version has a commit hash at the end (new
|
| 22 |
+
in GEOS 3.6.2) (:ticket:`28441`).
|
| 23 |
+
|
| 24 |
+
* Added compatibility for ``cx_Oracle`` 6 (:ticket:`28498`).
|
| 25 |
+
|
| 26 |
+
* Fixed select widget rendering when option values are tuples (:ticket:`28502`).
|
| 27 |
+
|
| 28 |
+
* Django 1.11 inadvertently changed the sequence and trigger naming scheme on
|
| 29 |
+
Oracle. This causes errors on INSERTs for some tables if
|
| 30 |
+
``'use_returning_into': False`` is in the ``OPTIONS`` part of ``DATABASES``.
|
| 31 |
+
The pre-1.11 naming scheme is now restored. Unfortunately, it necessarily
|
| 32 |
+
requires an update to Oracle tables created with Django 1.11.[1-4]. Use the
|
| 33 |
+
upgrade script in :ticket:`28451` comment 8 to update sequence and trigger
|
| 34 |
+
names to use the pre-1.11 naming scheme.
|
| 35 |
+
|
| 36 |
+
* Added POST request support to ``LogoutView``, for equivalence with the
|
| 37 |
+
function-based ``logout()`` view (:ticket:`28513`).
|
| 38 |
+
|
| 39 |
+
* Omitted ``pages_per_range`` from ``BrinIndex.deconstruct()`` if it's ``None``
|
| 40 |
+
(:ticket:`25809`).
|
| 41 |
+
|
| 42 |
+
* Fixed a regression where ``SelectDateWidget`` localized the years in the
|
| 43 |
+
select box (:ticket:`28530`).
|
| 44 |
+
|
| 45 |
+
* Fixed a regression in 1.11.4 where ``runserver`` crashed with non-Unicode
|
| 46 |
+
system encodings on Python 2 + Windows (:ticket:`28487`).
|
| 47 |
+
|
| 48 |
+
* Fixed a regression in Django 1.10 where changes to a ``ManyToManyField``
|
| 49 |
+
weren't logged in the admin change history (:ticket:`27998`) and prevented
|
| 50 |
+
``ManyToManyField`` initial data in model forms from being affected by
|
| 51 |
+
subsequent model changes (:ticket:`28543`).
|
| 52 |
+
|
| 53 |
+
* Fixed non-deterministic results or an ``AssertionError`` crash in some
|
| 54 |
+
queries with multiple joins (:ticket:`26522`).
|
| 55 |
+
|
| 56 |
+
* Fixed a regression in ``contrib.auth``'s ``login()`` and ``logout()`` views
|
| 57 |
+
where they ignored positional arguments (:ticket:`28550`).
|
testbed/django__django/docs/releases/1.11.9.txt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
===========================
|
| 2 |
+
Django 1.11.9 release notes
|
| 3 |
+
===========================
|
| 4 |
+
|
| 5 |
+
*January 1, 2018*
|
| 6 |
+
|
| 7 |
+
Django 1.11.9 fixes several bugs in 1.11.8.
|
| 8 |
+
|
| 9 |
+
Bugfixes
|
| 10 |
+
========
|
| 11 |
+
|
| 12 |
+
* Fixed a regression in Django 1.11 that added newlines between ``MultiWidget``'s
|
| 13 |
+
subwidgets (:ticket:`28890`).
|
| 14 |
+
|
| 15 |
+
* Fixed incorrect class-based model index name generation for models with
|
| 16 |
+
quoted ``db_table`` (:ticket:`28876`).
|
| 17 |
+
|
| 18 |
+
* Fixed incorrect foreign key constraint name for models with quoted
|
| 19 |
+
``db_table`` (:ticket:`28876`).
|
| 20 |
+
|
| 21 |
+
* Fixed a regression in caching of a ``GenericForeignKey`` when the referenced
|
| 22 |
+
model instance uses more than one level of multi-table inheritance
|
| 23 |
+
(:ticket:`28856`).
|
testbed/django__django/docs/releases/1.11.txt
ADDED
|
@@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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
=========================
|
| 2 |
+
Django 1.11 release notes
|
| 3 |
+
=========================
|
| 4 |
+
|
| 5 |
+
*April 4, 2017*
|
| 6 |
+
|
| 7 |
+
Welcome to Django 1.11!
|
| 8 |
+
|
| 9 |
+
These release notes cover the :ref:`new features <whats-new-1.11>`, as well as
|
| 10 |
+
some :ref:`backwards incompatible changes <backwards-incompatible-1.11>` you'll
|
| 11 |
+
want to be aware of when upgrading from Django 1.10 or older versions. We've
|
| 12 |
+
:ref:`begun the deprecation process for some features
|
| 13 |
+
<deprecated-features-1.11>`.
|
| 14 |
+
|
| 15 |
+
See the :doc:`/howto/upgrade-version` guide if you're updating an existing
|
| 16 |
+
project.
|
| 17 |
+
|
| 18 |
+
Django 1.11 is designated as a :term:`long-term support release
|
| 19 |
+
<Long-term support release>`. It will receive security updates for at least
|
| 20 |
+
three years after its release. Support for the previous LTS, Django 1.8, will
|
| 21 |
+
end in April 2018.
|
| 22 |
+
|
| 23 |
+
Python compatibility
|
| 24 |
+
====================
|
| 25 |
+
|
| 26 |
+
Django 1.11 requires Python 2.7, 3.4, 3.5, 3.6, or 3.7 (as of 1.11.17). We
|
| 27 |
+
**highly recommend** and only officially support the latest release of each
|
| 28 |
+
series.
|
| 29 |
+
|
| 30 |
+
The Django 1.11.x series is the last to support Python 2. The next major
|
| 31 |
+
release, Django 2.0, will only support Python 3.4+.
|
| 32 |
+
|
| 33 |
+
Deprecating warnings are no longer loud by default
|
| 34 |
+
==================================================
|
| 35 |
+
|
| 36 |
+
Unlike older versions of Django, Django's own deprecation warnings are no
|
| 37 |
+
longer displayed by default. This is consistent with Python's default behavior.
|
| 38 |
+
|
| 39 |
+
This change allows third-party apps to support both Django 1.11 LTS and Django
|
| 40 |
+
1.8 LTS without having to add code to avoid deprecation warnings.
|
| 41 |
+
|
| 42 |
+
Following the release of Django 2.0, we suggest that third-party app authors
|
| 43 |
+
drop support for all versions of Django prior to 1.11. At that time, you should
|
| 44 |
+
be able run your package's tests using ``python -Wd`` so that deprecation
|
| 45 |
+
warnings do appear. After making the deprecation warning fixes, your app should
|
| 46 |
+
be compatible with Django 2.0.
|
| 47 |
+
|
| 48 |
+
.. _whats-new-1.11:
|
| 49 |
+
|
| 50 |
+
What's new in Django 1.11
|
| 51 |
+
=========================
|
| 52 |
+
|
| 53 |
+
Class-based model indexes
|
| 54 |
+
-------------------------
|
| 55 |
+
|
| 56 |
+
The new :mod:`django.db.models.indexes` module contains classes which ease
|
| 57 |
+
creating database indexes. Indexes are added to models using the
|
| 58 |
+
:attr:`Meta.indexes <django.db.models.Options.indexes>` option.
|
| 59 |
+
|
| 60 |
+
The :class:`~django.db.models.Index` class creates a b-tree index, as if you
|
| 61 |
+
used :attr:`~django.db.models.Field.db_index` on the model field or
|
| 62 |
+
:attr:`~django.db.models.Options.index_together` on the model ``Meta`` class.
|
| 63 |
+
It can be subclassed to support different index types, such as
|
| 64 |
+
:class:`~django.contrib.postgres.indexes.GinIndex`. It also allows defining the
|
| 65 |
+
order (ASC/DESC) for the columns of the index.
|
| 66 |
+
|
| 67 |
+
Template-based widget rendering
|
| 68 |
+
-------------------------------
|
| 69 |
+
|
| 70 |
+
To ease customizing widgets, form widget rendering is now done using the
|
| 71 |
+
template system rather than in Python. See :doc:`/ref/forms/renderers`.
|
| 72 |
+
|
| 73 |
+
You may need to adjust any custom widgets that you've written for a few
|
| 74 |
+
:ref:`backwards incompatible changes <template-widget-incompatibilities-1-11>`.
|
| 75 |
+
|
| 76 |
+
``Subquery`` expressions
|
| 77 |
+
------------------------
|
| 78 |
+
|
| 79 |
+
The new :class:`~django.db.models.Subquery` and
|
| 80 |
+
:class:`~django.db.models.Exists` database expressions allow creating
|
| 81 |
+
explicit subqueries. Subqueries may refer to fields from the outer queryset
|
| 82 |
+
using the :class:`~django.db.models.OuterRef` class.
|
| 83 |
+
|
| 84 |
+
Minor features
|
| 85 |
+
--------------
|
| 86 |
+
|
| 87 |
+
:mod:`django.contrib.admin`
|
| 88 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 89 |
+
|
| 90 |
+
* :attr:`.ModelAdmin.date_hierarchy` can now reference fields across relations.
|
| 91 |
+
|
| 92 |
+
* The new :meth:`ModelAdmin.get_exclude()
|
| 93 |
+
<django.contrib.admin.ModelAdmin.get_exclude>` hook allows specifying the
|
| 94 |
+
exclude fields based on the request or model instance.
|
| 95 |
+
|
| 96 |
+
* The ``popup_response.html`` template can now be overridden per app, per
|
| 97 |
+
model, or by setting the :attr:`.ModelAdmin.popup_response_template`
|
| 98 |
+
attribute.
|
| 99 |
+
|
| 100 |
+
:mod:`django.contrib.auth`
|
| 101 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 102 |
+
|
| 103 |
+
* The default iteration count for the PBKDF2 password hasher is increased by
|
| 104 |
+
20%.
|
| 105 |
+
|
| 106 |
+
* The :class:`~django.contrib.auth.views.LoginView` and
|
| 107 |
+
:class:`~django.contrib.auth.views.LogoutView` class-based views supersede the
|
| 108 |
+
deprecated ``login()`` and ``logout()`` function-based views.
|
| 109 |
+
|
| 110 |
+
* The :class:`~django.contrib.auth.views.PasswordChangeView`,
|
| 111 |
+
:class:`~django.contrib.auth.views.PasswordChangeDoneView`,
|
| 112 |
+
:class:`~django.contrib.auth.views.PasswordResetView`,
|
| 113 |
+
:class:`~django.contrib.auth.views.PasswordResetDoneView`,
|
| 114 |
+
:class:`~django.contrib.auth.views.PasswordResetConfirmView`, and
|
| 115 |
+
:class:`~django.contrib.auth.views.PasswordResetCompleteView` class-based
|
| 116 |
+
views supersede the deprecated ``password_change()``,
|
| 117 |
+
``password_change_done()``, ``password_reset()``, ``password_reset_done()``,
|
| 118 |
+
``password_reset_confirm()``, and ``password_reset_complete()`` function-based
|
| 119 |
+
views.
|
| 120 |
+
|
| 121 |
+
* The new ``post_reset_login`` attribute for
|
| 122 |
+
:class:`~django.contrib.auth.views.PasswordResetConfirmView` allows
|
| 123 |
+
automatically logging in a user after a successful password reset.
|
| 124 |
+
If you have multiple ``AUTHENTICATION_BACKENDS`` configured, use the
|
| 125 |
+
``post_reset_login_backend`` attribute to choose which one to use.
|
| 126 |
+
|
| 127 |
+
* To avoid the possibility of leaking a password reset token via the HTTP
|
| 128 |
+
Referer header (for example, if the reset page includes a reference to CSS or
|
| 129 |
+
JavaScript hosted on another domain), the
|
| 130 |
+
:class:`~django.contrib.auth.views.PasswordResetConfirmView` (but not the
|
| 131 |
+
deprecated ``password_reset_confirm()`` function-based view) stores the token
|
| 132 |
+
in a session and redirects to itself to present the password change form to
|
| 133 |
+
the user without the token in the URL.
|
| 134 |
+
|
| 135 |
+
* :func:`~django.contrib.auth.update_session_auth_hash` now rotates the session
|
| 136 |
+
key to allow a password change to invalidate stolen session cookies.
|
| 137 |
+
|
| 138 |
+
* The new ``success_url_allowed_hosts`` attribute for
|
| 139 |
+
:class:`~django.contrib.auth.views.LoginView` and
|
| 140 |
+
:class:`~django.contrib.auth.views.LogoutView` allows specifying a set of
|
| 141 |
+
hosts that are safe for redirecting after login and logout.
|
| 142 |
+
|
| 143 |
+
* Added password validators ``help_text`` to
|
| 144 |
+
:class:`~django.contrib.auth.forms.UserCreationForm`.
|
| 145 |
+
|
| 146 |
+
* The ``HttpRequest`` is now passed to :func:`~django.contrib.auth.authenticate`
|
| 147 |
+
which in turn passes it to the authentication backend if it accepts a
|
| 148 |
+
``request`` argument.
|
| 149 |
+
|
| 150 |
+
* The :func:`~django.contrib.auth.signals.user_login_failed` signal now
|
| 151 |
+
receives a ``request`` argument.
|
| 152 |
+
|
| 153 |
+
* :class:`~django.contrib.auth.forms.PasswordResetForm` supports custom user
|
| 154 |
+
models that use an email field named something other than ``'email'``.
|
| 155 |
+
Set :attr:`CustomUser.EMAIL_FIELD
|
| 156 |
+
<django.contrib.auth.models.CustomUser.EMAIL_FIELD>` to the name of the field.
|
| 157 |
+
|
| 158 |
+
* :func:`~django.contrib.auth.get_user_model` can now be called at import time,
|
| 159 |
+
even in modules that define models.
|
| 160 |
+
|
| 161 |
+
:mod:`django.contrib.contenttypes`
|
| 162 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 163 |
+
|
| 164 |
+
* When stale content types are detected in the
|
| 165 |
+
:djadmin:`remove_stale_contenttypes` command, there's now a list of related
|
| 166 |
+
objects such as ``auth.Permission``\s that will also be deleted. Previously,
|
| 167 |
+
only the content types were listed (and this prompt was after ``migrate``
|
| 168 |
+
rather than in a separate command).
|
| 169 |
+
|
| 170 |
+
:mod:`django.contrib.gis`
|
| 171 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 172 |
+
|
| 173 |
+
* The new :meth:`.GEOSGeometry.from_gml` and :meth:`.OGRGeometry.from_gml`
|
| 174 |
+
methods allow creating geometries from GML.
|
| 175 |
+
|
| 176 |
+
* Added support for the :lookup:`dwithin` lookup on SpatiaLite.
|
| 177 |
+
|
| 178 |
+
* The :class:`~django.contrib.gis.db.models.functions.Area` function,
|
| 179 |
+
:class:`~django.contrib.gis.db.models.functions.Distance` function, and
|
| 180 |
+
distance lookups now work with geodetic coordinates on SpatiaLite.
|
| 181 |
+
|
| 182 |
+
* The OpenLayers-based form widgets now use ``OpenLayers.js`` from
|
| 183 |
+
``https://cdnjs.cloudflare.com`` which is more suitable for production use
|
| 184 |
+
than the old ``https://openlayers.org/`` source. They are also updated to use
|
| 185 |
+
OpenLayers 3.
|
| 186 |
+
|
| 187 |
+
* PostGIS migrations can now change field dimensions.
|
| 188 |
+
|
| 189 |
+
* Added the ability to pass the ``size``, ``shape``, and ``offset`` parameters
|
| 190 |
+
when creating :class:`~django.contrib.gis.gdal.GDALRaster` objects.
|
| 191 |
+
|
| 192 |
+
* Added SpatiaLite support for the
|
| 193 |
+
:class:`~django.contrib.gis.db.models.functions.IsValid` function,
|
| 194 |
+
:class:`~django.contrib.gis.db.models.functions.MakeValid` function, and
|
| 195 |
+
:lookup:`isvalid` lookup.
|
| 196 |
+
|
| 197 |
+
* Added Oracle support for the
|
| 198 |
+
:class:`~django.contrib.gis.db.models.functions.AsGML` function,
|
| 199 |
+
:class:`~django.contrib.gis.db.models.functions.BoundingCircle` function,
|
| 200 |
+
:class:`~django.contrib.gis.db.models.functions.IsValid` function, and
|
| 201 |
+
:lookup:`isvalid` lookup.
|
| 202 |
+
|
| 203 |
+
:mod:`django.contrib.postgres`
|
| 204 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 205 |
+
|
| 206 |
+
* The new ``distinct`` argument for
|
| 207 |
+
:class:`~django.contrib.postgres.aggregates.StringAgg` determines if
|
| 208 |
+
concatenated values will be distinct.
|
| 209 |
+
|
| 210 |
+
* The new :class:`~django.contrib.postgres.indexes.GinIndex` and
|
| 211 |
+
:class:`~django.contrib.postgres.indexes.BrinIndex` classes allow
|
| 212 |
+
creating ``GIN`` and ``BRIN`` indexes in the database.
|
| 213 |
+
|
| 214 |
+
* ``django.contrib.postgres.fields.JSONField`` accepts a new ``encoder``
|
| 215 |
+
parameter to specify a custom class to encode data types not supported by the
|
| 216 |
+
standard encoder.
|
| 217 |
+
|
| 218 |
+
* The new ``CIText`` mixin and
|
| 219 |
+
:class:`~django.contrib.postgres.operations.CITextExtension` migration
|
| 220 |
+
operation allow using PostgreSQL's ``citext`` extension for case-insensitive
|
| 221 |
+
lookups. Three fields are provided: ``CICharField``, ``CIEmailField``, and
|
| 222 |
+
``CITextField``.
|
| 223 |
+
|
| 224 |
+
* The new :class:`~django.contrib.postgres.aggregates.JSONBAgg` allows
|
| 225 |
+
aggregating values as a JSON array.
|
| 226 |
+
|
| 227 |
+
* The :class:`~django.contrib.postgres.fields.HStoreField` (model field) and
|
| 228 |
+
:class:`~django.contrib.postgres.forms.HStoreField` (form field) allow
|
| 229 |
+
storing null values.
|
| 230 |
+
|
| 231 |
+
Cache
|
| 232 |
+
~~~~~
|
| 233 |
+
|
| 234 |
+
* Memcached backends now pass the contents of :setting:`OPTIONS <CACHES-OPTIONS>`
|
| 235 |
+
as keyword arguments to the client constructors, allowing for more advanced
|
| 236 |
+
control of client behavior. See the :ref:`cache arguments <cache_arguments>`
|
| 237 |
+
documentation for examples.
|
| 238 |
+
|
| 239 |
+
* Memcached backends now allow defining multiple servers as a comma-delimited
|
| 240 |
+
string in :setting:`LOCATION <CACHES-LOCATION>`, for convenience with
|
| 241 |
+
third-party services that use such strings in environment variables.
|
| 242 |
+
|
| 243 |
+
CSRF
|
| 244 |
+
~~~~
|
| 245 |
+
|
| 246 |
+
* Added the :setting:`CSRF_USE_SESSIONS` setting to allow storing the CSRF
|
| 247 |
+
token in the user's session rather than in a cookie.
|
| 248 |
+
|
| 249 |
+
Database backends
|
| 250 |
+
~~~~~~~~~~~~~~~~~
|
| 251 |
+
|
| 252 |
+
* Added the ``skip_locked`` argument to :meth:`.QuerySet.select_for_update()`
|
| 253 |
+
on PostgreSQL 9.5+ and Oracle to execute queries with
|
| 254 |
+
``FOR UPDATE SKIP LOCKED``.
|
| 255 |
+
|
| 256 |
+
* Added the :setting:`TEST['TEMPLATE'] <TEST_TEMPLATE>` setting to let
|
| 257 |
+
PostgreSQL users specify a template for creating the test database.
|
| 258 |
+
|
| 259 |
+
* :meth:`.QuerySet.iterator()` now uses `server-side cursors`_ on PostgreSQL.
|
| 260 |
+
This feature transfers some of the worker memory load (used to hold query
|
| 261 |
+
results) to the database and might increase database memory usage.
|
| 262 |
+
|
| 263 |
+
.. _server-side cursors: https://www.psycopg.org/docs/usage.html#server-side-cursors
|
| 264 |
+
|
| 265 |
+
* Added MySQL support for the ``'isolation_level'`` option in
|
| 266 |
+
:setting:`OPTIONS` to allow specifying the :ref:`transaction isolation level
|
| 267 |
+
<mysql-isolation-level>`. To avoid possible data loss, it's recommended to
|
| 268 |
+
switch from MySQL's default level, repeatable read, to read committed.
|
| 269 |
+
|
| 270 |
+
* Added support for ``cx_Oracle`` 5.3.
|
| 271 |
+
|
| 272 |
+
Email
|
| 273 |
+
~~~~~
|
| 274 |
+
|
| 275 |
+
* Added the :setting:`EMAIL_USE_LOCALTIME` setting to allow sending SMTP date
|
| 276 |
+
headers in the local time zone rather than in UTC.
|
| 277 |
+
|
| 278 |
+
* ``EmailMessage.attach()`` and ``attach_file()`` now fall back to MIME type
|
| 279 |
+
:mimetype:`application/octet-stream` when binary content that can't be
|
| 280 |
+
decoded as UTF-8 is specified for a :mimetype:`text/*` attachment.
|
| 281 |
+
|
| 282 |
+
File Storage
|
| 283 |
+
~~~~~~~~~~~~
|
| 284 |
+
|
| 285 |
+
* To make it wrappable by :class:`io.TextIOWrapper`,
|
| 286 |
+
:class:`~django.core.files.File` now has the ``readable()``, ``writable()``,
|
| 287 |
+
and ``seekable()`` methods.
|
| 288 |
+
|
| 289 |
+
Forms
|
| 290 |
+
~~~~~
|
| 291 |
+
|
| 292 |
+
* The new ``empty_value`` attribute on :class:`~django.forms.CharField`,
|
| 293 |
+
:class:`~django.forms.EmailField`, :class:`~django.forms.RegexField`,
|
| 294 |
+
:class:`~django.forms.SlugField`, and :class:`~django.forms.URLField` allows
|
| 295 |
+
specifying the Python value to use to represent "empty".
|
| 296 |
+
|
| 297 |
+
* The new :meth:`Form.get_initial_for_field()
|
| 298 |
+
<django.forms.Form.get_initial_for_field>` method returns initial data for a
|
| 299 |
+
form field.
|
| 300 |
+
|
| 301 |
+
Internationalization
|
| 302 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 303 |
+
|
| 304 |
+
* Number formatting and the :setting:`NUMBER_GROUPING` setting support
|
| 305 |
+
non-uniform digit grouping.
|
| 306 |
+
|
| 307 |
+
Management Commands
|
| 308 |
+
~~~~~~~~~~~~~~~~~~~
|
| 309 |
+
|
| 310 |
+
* The new :option:`loaddata --exclude` option allows excluding models and apps
|
| 311 |
+
while loading data from fixtures.
|
| 312 |
+
|
| 313 |
+
* The new :option:`diffsettings --default` option allows specifying a settings
|
| 314 |
+
module other than Django's default settings to compare against.
|
| 315 |
+
|
| 316 |
+
* ``app_label``\s arguments now limit the :option:`showmigrations --plan`
|
| 317 |
+
output.
|
| 318 |
+
|
| 319 |
+
Migrations
|
| 320 |
+
~~~~~~~~~~
|
| 321 |
+
|
| 322 |
+
* Added support for serialization of ``uuid.UUID`` objects.
|
| 323 |
+
|
| 324 |
+
Models
|
| 325 |
+
~~~~~~
|
| 326 |
+
|
| 327 |
+
* Added support for callable values in the ``defaults`` argument of
|
| 328 |
+
:meth:`QuerySet.update_or_create()
|
| 329 |
+
<django.db.models.query.QuerySet.update_or_create>` and
|
| 330 |
+
:meth:`~django.db.models.query.QuerySet.get_or_create`.
|
| 331 |
+
|
| 332 |
+
* :class:`~django.db.models.ImageField` now has a default
|
| 333 |
+
:data:`~django.core.validators.validate_image_file_extension` validator.
|
| 334 |
+
(This validator moved to the form field in :doc:`Django 1.11.2 <1.11.2>`.)
|
| 335 |
+
|
| 336 |
+
* Added support for time truncation to
|
| 337 |
+
:class:`~django.db.models.functions.Trunc` functions.
|
| 338 |
+
|
| 339 |
+
* Added the :class:`~django.db.models.functions.ExtractWeek` function to
|
| 340 |
+
extract the week from :class:`~django.db.models.DateField` and
|
| 341 |
+
:class:`~django.db.models.DateTimeField` and exposed it through the
|
| 342 |
+
:lookup:`week` lookup.
|
| 343 |
+
|
| 344 |
+
* Added the :class:`~django.db.models.functions.TruncTime` function to truncate
|
| 345 |
+
:class:`~django.db.models.DateTimeField` to its time component and exposed it
|
| 346 |
+
through the :lookup:`time` lookup.
|
| 347 |
+
|
| 348 |
+
* Added support for expressions in :meth:`.QuerySet.values` and
|
| 349 |
+
:meth:`~.QuerySet.values_list`.
|
| 350 |
+
|
| 351 |
+
* Added support for query expressions on lookups that take multiple arguments,
|
| 352 |
+
such as ``range``.
|
| 353 |
+
|
| 354 |
+
* You can now use the ``unique=True`` option with
|
| 355 |
+
:class:`~django.db.models.FileField`.
|
| 356 |
+
|
| 357 |
+
* Added the ``nulls_first`` and ``nulls_last`` parameters to
|
| 358 |
+
:class:`Expression.asc() <django.db.models.Expression.asc>` and
|
| 359 |
+
:meth:`~django.db.models.Expression.desc` to control
|
| 360 |
+
the ordering of null values.
|
| 361 |
+
|
| 362 |
+
* The new ``F`` expression ``bitleftshift()`` and ``bitrightshift()`` methods
|
| 363 |
+
allow :ref:`bitwise shift operations <using-f-expressions-in-filters>`.
|
| 364 |
+
|
| 365 |
+
* Added :meth:`.QuerySet.union`, :meth:`~.QuerySet.intersection`, and
|
| 366 |
+
:meth:`~.QuerySet.difference`.
|
| 367 |
+
|
| 368 |
+
Requests and Responses
|
| 369 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 370 |
+
|
| 371 |
+
* Added :meth:`QueryDict.fromkeys() <django.http.QueryDict.fromkeys>`.
|
| 372 |
+
|
| 373 |
+
* :class:`~django.middleware.common.CommonMiddleware` now sets the
|
| 374 |
+
``Content-Length`` response header for non-streaming responses.
|
| 375 |
+
|
| 376 |
+
* Added the :setting:`SECURE_HSTS_PRELOAD` setting to allow appending the
|
| 377 |
+
``preload`` directive to the ``Strict-Transport-Security`` header.
|
| 378 |
+
|
| 379 |
+
* :class:`~django.middleware.http.ConditionalGetMiddleware` now adds the
|
| 380 |
+
``ETag`` header to responses.
|
| 381 |
+
|
| 382 |
+
Serialization
|
| 383 |
+
~~~~~~~~~~~~~
|
| 384 |
+
|
| 385 |
+
* The new ``django.core.serializers.base.Serializer.stream_class`` attribute
|
| 386 |
+
allows subclasses to customize the default stream.
|
| 387 |
+
|
| 388 |
+
* The encoder used by the :ref:`JSON serializer <serialization-formats-json>`
|
| 389 |
+
can now be customized by passing a ``cls`` keyword argument to the
|
| 390 |
+
``serializers.serialize()`` function.
|
| 391 |
+
|
| 392 |
+
* :class:`~django.core.serializers.json.DjangoJSONEncoder` now serializes
|
| 393 |
+
:class:`~datetime.timedelta` objects (used by
|
| 394 |
+
:class:`~django.db.models.DurationField`).
|
| 395 |
+
|
| 396 |
+
Templates
|
| 397 |
+
~~~~~~~~~
|
| 398 |
+
|
| 399 |
+
* :meth:`~django.utils.safestring.mark_safe` can now be used as a decorator.
|
| 400 |
+
|
| 401 |
+
* The :class:`~django.template.backends.jinja2.Jinja2` template backend now
|
| 402 |
+
supports context processors by setting the ``'context_processors'`` option in
|
| 403 |
+
:setting:`OPTIONS <TEMPLATES-OPTIONS>`.
|
| 404 |
+
|
| 405 |
+
* The :ttag:`regroup` tag now returns ``namedtuple``\s instead of dictionaries
|
| 406 |
+
so you can unpack the group object directly in a loop, e.g.
|
| 407 |
+
``{% for grouper, list in regrouped %}``.
|
| 408 |
+
|
| 409 |
+
* Added a :ttag:`resetcycle` template tag to allow resetting the sequence of
|
| 410 |
+
the :ttag:`cycle` template tag.
|
| 411 |
+
|
| 412 |
+
* You can now specify specific directories for a particular
|
| 413 |
+
:class:`filesystem.Loader <django.template.loaders.filesystem.Loader>`.
|
| 414 |
+
|
| 415 |
+
Tests
|
| 416 |
+
~~~~~
|
| 417 |
+
|
| 418 |
+
* Added :meth:`.DiscoverRunner.get_test_runner_kwargs` to allow customizing the
|
| 419 |
+
keyword arguments passed to the test runner.
|
| 420 |
+
|
| 421 |
+
* Added the :option:`test --debug-mode` option to help troubleshoot test
|
| 422 |
+
failures by setting the :setting:`DEBUG` setting to ``True``.
|
| 423 |
+
|
| 424 |
+
* The new :func:`django.test.utils.setup_databases` (moved from
|
| 425 |
+
``django.test.runner``) and :func:`~django.test.utils.teardown_databases`
|
| 426 |
+
functions make it easier to build custom test runners.
|
| 427 |
+
|
| 428 |
+
* Added support for :meth:`python:unittest.TestCase.subTest`’s when using the
|
| 429 |
+
:option:`test --parallel` option.
|
| 430 |
+
|
| 431 |
+
* ``DiscoverRunner`` now runs the system checks at the start of a test run.
|
| 432 |
+
Override the :meth:`.DiscoverRunner.run_checks` method if you want to disable
|
| 433 |
+
that.
|
| 434 |
+
|
| 435 |
+
Validators
|
| 436 |
+
~~~~~~~~~~
|
| 437 |
+
|
| 438 |
+
* Added :class:`~django.core.validators.FileExtensionValidator` to validate
|
| 439 |
+
file extensions and
|
| 440 |
+
:data:`~django.core.validators.validate_image_file_extension` to validate
|
| 441 |
+
image files.
|
| 442 |
+
|
| 443 |
+
.. _backwards-incompatible-1.11:
|
| 444 |
+
|
| 445 |
+
Backwards incompatible changes in 1.11
|
| 446 |
+
======================================
|
| 447 |
+
|
| 448 |
+
:mod:`django.contrib.gis`
|
| 449 |
+
-------------------------
|
| 450 |
+
|
| 451 |
+
* To simplify the codebase and because it's easier to install than when
|
| 452 |
+
``contrib.gis`` was first released, :ref:`gdalbuild` is now a required
|
| 453 |
+
dependency for GeoDjango. In older versions, it's only required for SQLite.
|
| 454 |
+
|
| 455 |
+
* ``contrib.gis.maps`` is removed as it interfaces with a retired version of
|
| 456 |
+
the Google Maps API and seems to be unmaintained. If you're using it,
|
| 457 |
+
:ticket:`let us know <14284>`.
|
| 458 |
+
|
| 459 |
+
* The ``GEOSGeometry`` equality operator now also compares SRID.
|
| 460 |
+
|
| 461 |
+
* The OpenLayers-based form widgets now use OpenLayers 3, and the
|
| 462 |
+
``gis/openlayers.html`` and ``gis/openlayers-osm.html`` templates have been
|
| 463 |
+
updated. Check your project if you subclass these widgets or extend the
|
| 464 |
+
templates. Also, the new widgets work a bit differently than the old ones.
|
| 465 |
+
Instead of using a toolbar in the widget, you click to draw, click and drag
|
| 466 |
+
to move the map, and click and drag a point/vertex/corner to move it.
|
| 467 |
+
|
| 468 |
+
* Support for SpatiaLite < 4.0 is dropped.
|
| 469 |
+
|
| 470 |
+
* Support for GDAL 1.7 and 1.8 is dropped.
|
| 471 |
+
|
| 472 |
+
* The widgets in ``contrib.gis.forms.widgets`` and the admin's
|
| 473 |
+
``OpenLayersWidget`` use the :doc:`form rendering API </ref/forms/renderers>`
|
| 474 |
+
rather than ``loader.render_to_string()``. If you're using a custom widget
|
| 475 |
+
template, you'll need to be sure your form renderer can locate it. For
|
| 476 |
+
example, you could use the :class:`~django.forms.renderers.TemplatesSetting`
|
| 477 |
+
renderer.
|
| 478 |
+
|
| 479 |
+
:mod:`django.contrib.staticfiles`
|
| 480 |
+
---------------------------------
|
| 481 |
+
|
| 482 |
+
* ``collectstatic`` may now fail during post-processing when using a hashed
|
| 483 |
+
static files storage if a reference loop exists (e.g. ``'foo.css'``
|
| 484 |
+
references ``'bar.css'`` which itself references ``'foo.css'``) or if the
|
| 485 |
+
chain of files referencing other files is too deep to resolve in several
|
| 486 |
+
passes. In the latter case, increase the number of passes using
|
| 487 |
+
:attr:`.ManifestStaticFilesStorage.max_post_process_passes`.
|
| 488 |
+
|
| 489 |
+
* When using ``ManifestStaticFilesStorage``, static files not found in the
|
| 490 |
+
manifest at runtime now raise a ``ValueError`` instead of returning an
|
| 491 |
+
unchanged path. You can revert to the old behavior by setting
|
| 492 |
+
:attr:`.ManifestStaticFilesStorage.manifest_strict` to ``False``.
|
| 493 |
+
|
| 494 |
+
Database backend API
|
| 495 |
+
--------------------
|
| 496 |
+
|
| 497 |
+
This section describes changes that may be needed in third-party database
|
| 498 |
+
backends.
|
| 499 |
+
|
| 500 |
+
* The ``DatabaseOperations.time_trunc_sql()`` method is added to support
|
| 501 |
+
``TimeField`` truncation. It accepts a ``lookup_type`` and ``field_name``
|
| 502 |
+
arguments and returns the appropriate SQL to truncate the given time field
|
| 503 |
+
``field_name`` to a time object with only the given specificity. The
|
| 504 |
+
``lookup_type`` argument can be either ``'hour'``, ``'minute'``, or
|
| 505 |
+
``'second'``.
|
| 506 |
+
|
| 507 |
+
* The ``DatabaseOperations.datetime_cast_time_sql()`` method is added to
|
| 508 |
+
support the :lookup:`time` lookup. It accepts a ``field_name`` and ``tzname``
|
| 509 |
+
arguments and returns the SQL necessary to cast a datetime value to time value.
|
| 510 |
+
|
| 511 |
+
* To enable ``FOR UPDATE SKIP LOCKED`` support, set
|
| 512 |
+
``DatabaseFeatures.has_select_for_update_skip_locked = True``.
|
| 513 |
+
|
| 514 |
+
* The new ``DatabaseFeatures.supports_index_column_ordering`` attribute
|
| 515 |
+
specifies if a database allows defining ordering for columns in indexes. The
|
| 516 |
+
default value is ``True`` and the ``DatabaseIntrospection.get_constraints()``
|
| 517 |
+
method should include an ``'orders'`` key in each of the returned
|
| 518 |
+
dictionaries with a list of ``'ASC'`` and/or ``'DESC'`` values corresponding
|
| 519 |
+
to the ordering of each column in the index.
|
| 520 |
+
|
| 521 |
+
* :djadmin:`inspectdb` no longer calls ``DatabaseIntrospection.get_indexes()``
|
| 522 |
+
which is deprecated. Custom database backends should ensure all types of
|
| 523 |
+
indexes are returned by ``DatabaseIntrospection.get_constraints()``.
|
| 524 |
+
|
| 525 |
+
* Renamed the ``ignores_quoted_identifier_case`` feature to
|
| 526 |
+
``ignores_table_name_case`` to more accurately reflect how it is used.
|
| 527 |
+
|
| 528 |
+
* The ``name`` keyword argument is added to the
|
| 529 |
+
``DatabaseWrapper.create_cursor(self, name=None)`` method to allow usage of
|
| 530 |
+
server-side cursors on backends that support it.
|
| 531 |
+
|
| 532 |
+
Dropped support for PostgreSQL 9.2 and PostGIS 2.0
|
| 533 |
+
--------------------------------------------------
|
| 534 |
+
|
| 535 |
+
Upstream support for PostgreSQL 9.2 ends in September 2017. As a consequence,
|
| 536 |
+
Django 1.11 sets PostgreSQL 9.3 as the minimum version it officially supports.
|
| 537 |
+
|
| 538 |
+
Support for PostGIS 2.0 is also removed as PostgreSQL 9.2 is the last version
|
| 539 |
+
to support it.
|
| 540 |
+
|
| 541 |
+
Also, the minimum supported version of psycopg2 is increased from 2.4.5 to
|
| 542 |
+
2.5.4.
|
| 543 |
+
|
| 544 |
+
.. _liveservertestcase-port-zero-change:
|
| 545 |
+
|
| 546 |
+
``LiveServerTestCase`` binds to port zero
|
| 547 |
+
-----------------------------------------
|
| 548 |
+
|
| 549 |
+
Rather than taking a port range and iterating to find a free port,
|
| 550 |
+
``LiveServerTestCase`` binds to port zero and relies on the operating system
|
| 551 |
+
to assign a free port. The ``DJANGO_LIVE_TEST_SERVER_ADDRESS`` environment
|
| 552 |
+
variable is no longer used, and as it's also no longer used, the
|
| 553 |
+
``manage.py test --liveserver`` option is removed.
|
| 554 |
+
|
| 555 |
+
If you need to bind ``LiveServerTestCase`` to a specific port, use the ``port``
|
| 556 |
+
attribute added in Django 1.11.2.
|
| 557 |
+
|
| 558 |
+
Protection against insecure redirects in :mod:`django.contrib.auth` and ``i18n`` views
|
| 559 |
+
--------------------------------------------------------------------------------------
|
| 560 |
+
|
| 561 |
+
``LoginView``, ``LogoutView`` (and the deprecated function-based equivalents),
|
| 562 |
+
and :func:`~django.views.i18n.set_language` protect users from being redirected
|
| 563 |
+
to non-HTTPS ``next`` URLs when the app is running over HTTPS.
|
| 564 |
+
|
| 565 |
+
``QuerySet.get_or_create()`` and ``update_or_create()`` validate arguments
|
| 566 |
+
--------------------------------------------------------------------------
|
| 567 |
+
|
| 568 |
+
To prevent typos from passing silently,
|
| 569 |
+
:meth:`~django.db.models.query.QuerySet.get_or_create` and
|
| 570 |
+
:meth:`~django.db.models.query.QuerySet.update_or_create` check that their
|
| 571 |
+
arguments are model fields. This should be backwards-incompatible only in the
|
| 572 |
+
fact that it might expose a bug in your project.
|
| 573 |
+
|
| 574 |
+
``pytz`` is a required dependency and support for ``settings.TIME_ZONE = None`` is removed
|
| 575 |
+
------------------------------------------------------------------------------------------
|
| 576 |
+
|
| 577 |
+
To simplify Django's timezone handling, ``pytz`` is now a required dependency.
|
| 578 |
+
It's automatically installed along with Django.
|
| 579 |
+
|
| 580 |
+
Support for ``settings.TIME_ZONE = None`` is removed as the behavior isn't
|
| 581 |
+
commonly used and is questionably useful. If you want to automatically detect
|
| 582 |
+
the timezone based on the system timezone, you can use :pypi:`tzlocal`::
|
| 583 |
+
|
| 584 |
+
from tzlocal import get_localzone
|
| 585 |
+
|
| 586 |
+
TIME_ZONE = get_localzone().zone
|
| 587 |
+
|
| 588 |
+
This works similar to ``settings.TIME_ZONE = None`` except that it also sets
|
| 589 |
+
``os.environ['TZ']``. `Let us know
|
| 590 |
+
<https://groups.google.com/g/django-developers/c/OAV3FChfuPM/discussion>`__
|
| 591 |
+
if there's a use case where you find you can't adapt your code to set a
|
| 592 |
+
``TIME_ZONE``.
|
| 593 |
+
|
| 594 |
+
HTML changes in admin templates
|
| 595 |
+
-------------------------------
|
| 596 |
+
|
| 597 |
+
``<p class="help">`` is replaced with a ``<div>`` tag to allow including lists
|
| 598 |
+
inside help text.
|
| 599 |
+
|
| 600 |
+
Read-only fields are wrapped in ``<div class="readonly">...</div>`` instead of
|
| 601 |
+
``<p>...</p>`` to allow any kind of HTML as the field's content.
|
| 602 |
+
|
| 603 |
+
.. _template-widget-incompatibilities-1-11:
|
| 604 |
+
|
| 605 |
+
Changes due to the introduction of template-based widget rendering
|
| 606 |
+
------------------------------------------------------------------
|
| 607 |
+
|
| 608 |
+
Some undocumented classes in ``django.forms.widgets`` are removed:
|
| 609 |
+
|
| 610 |
+
* ``SubWidget``
|
| 611 |
+
* ``RendererMixin``, ``ChoiceFieldRenderer``, ``RadioFieldRenderer``,
|
| 612 |
+
``CheckboxFieldRenderer``
|
| 613 |
+
* ``ChoiceInput``, ``RadioChoiceInput``, ``CheckboxChoiceInput``
|
| 614 |
+
|
| 615 |
+
The undocumented ``Select.render_option()`` method is removed.
|
| 616 |
+
|
| 617 |
+
The ``Widget.format_output()`` method is removed. Use a custom widget template
|
| 618 |
+
instead.
|
| 619 |
+
|
| 620 |
+
Some widget values, such as ``<select>`` options, are now localized if
|
| 621 |
+
``settings.USE_L10N=True``. You could revert to the old behavior with custom
|
| 622 |
+
widget templates that uses the :ttag:`localize` template tag to turn off
|
| 623 |
+
localization.
|
| 624 |
+
|
| 625 |
+
``django.template.backends.django.Template.render()`` prohibits non-dict context
|
| 626 |
+
--------------------------------------------------------------------------------
|
| 627 |
+
|
| 628 |
+
For compatibility with multiple template engines,
|
| 629 |
+
``django.template.backends.django.Template.render()`` (returned from high-level
|
| 630 |
+
template loader APIs such as ``loader.get_template()``) must receive a
|
| 631 |
+
dictionary of context rather than ``Context`` or ``RequestContext``. If you
|
| 632 |
+
were passing either of the two classes, pass a dictionary instead -- doing so
|
| 633 |
+
is backwards-compatible with older versions of Django.
|
| 634 |
+
|
| 635 |
+
Model state changes in migration operations
|
| 636 |
+
-------------------------------------------
|
| 637 |
+
|
| 638 |
+
To improve the speed of applying migrations, rendering of related models is
|
| 639 |
+
delayed until an operation that needs them (e.g. ``RunPython``). If you have a
|
| 640 |
+
custom operation that works with model classes or model instances from the
|
| 641 |
+
``from_state`` argument in ``database_forwards()`` or ``database_backwards()``,
|
| 642 |
+
you must render model states using the ``clear_delayed_apps_cache()`` method as
|
| 643 |
+
described in :ref:`writing your own migration operation
|
| 644 |
+
<writing-your-own-migration-operation>`.
|
| 645 |
+
|
| 646 |
+
Server-side cursors on PostgreSQL
|
| 647 |
+
---------------------------------
|
| 648 |
+
|
| 649 |
+
The change to make :meth:`.QuerySet.iterator()` use server-side cursors on
|
| 650 |
+
PostgreSQL prevents running Django with PgBouncer in transaction pooling mode.
|
| 651 |
+
To reallow that, use the :setting:`DISABLE_SERVER_SIDE_CURSORS
|
| 652 |
+
<DATABASE-DISABLE_SERVER_SIDE_CURSORS>` setting (added in Django 1.11.1) in
|
| 653 |
+
:setting:`DATABASES`.
|
| 654 |
+
|
| 655 |
+
See :ref:`transaction-pooling-server-side-cursors` for more discussion.
|
| 656 |
+
|
| 657 |
+
Miscellaneous
|
| 658 |
+
-------------
|
| 659 |
+
|
| 660 |
+
* If no items in the feed have a ``pubdate`` or ``updateddate`` attribute,
|
| 661 |
+
:meth:`SyndicationFeed.latest_post_date()
|
| 662 |
+
<django.utils.feedgenerator.SyndicationFeed.latest_post_date>` now returns
|
| 663 |
+
the current UTC date/time, instead of a datetime without any timezone
|
| 664 |
+
information.
|
| 665 |
+
|
| 666 |
+
* CSRF failures are logged to the ``django.security.csrf`` logger instead of
|
| 667 |
+
``django.request``.
|
| 668 |
+
|
| 669 |
+
* :setting:`ALLOWED_HOSTS` validation is no longer disabled when running tests.
|
| 670 |
+
If your application includes tests with custom host names, you must include
|
| 671 |
+
those host names in :setting:`ALLOWED_HOSTS`. See
|
| 672 |
+
:ref:`topics-testing-advanced-multiple-hosts`.
|
| 673 |
+
|
| 674 |
+
* Using a foreign key's id (e.g. ``'field_id'``) in ``ModelAdmin.list_display``
|
| 675 |
+
displays the related object's ID. Remove the ``_id`` suffix if you want the
|
| 676 |
+
old behavior of the string representation of the object.
|
| 677 |
+
|
| 678 |
+
* In model forms, :class:`~django.db.models.CharField` with ``null=True`` now
|
| 679 |
+
saves ``NULL`` for blank values instead of empty strings.
|
| 680 |
+
|
| 681 |
+
* On Oracle, :meth:`Model.validate_unique()
|
| 682 |
+
<django.db.models.Model.validate_unique>` no longer checks empty strings for
|
| 683 |
+
uniqueness as the database interprets the value as ``NULL``.
|
| 684 |
+
|
| 685 |
+
* If you subclass :class:`.AbstractUser` and override ``clean()``, be sure it
|
| 686 |
+
calls ``super()``. :meth:`.BaseUserManager.normalize_email` is called in a
|
| 687 |
+
new :meth:`.AbstractUser.clean` method so that normalization is applied in
|
| 688 |
+
cases like model form validation.
|
| 689 |
+
|
| 690 |
+
* ``EmailField`` and ``URLField`` no longer accept the ``strip`` keyword
|
| 691 |
+
argument. Remove it because it doesn't have an effect in older versions of
|
| 692 |
+
Django as these fields always strip whitespace.
|
| 693 |
+
|
| 694 |
+
* The ``checked`` and ``selected`` attribute rendered by form widgets now uses
|
| 695 |
+
HTML5 boolean syntax rather than XHTML's ``checked='checked'`` and
|
| 696 |
+
``selected='selected'``.
|
| 697 |
+
|
| 698 |
+
* :meth:`RelatedManager.add()
|
| 699 |
+
<django.db.models.fields.related.RelatedManager.add>`,
|
| 700 |
+
:meth:`~django.db.models.fields.related.RelatedManager.remove`,
|
| 701 |
+
:meth:`~django.db.models.fields.related.RelatedManager.clear`, and
|
| 702 |
+
:meth:`~django.db.models.fields.related.RelatedManager.set` now
|
| 703 |
+
clear the ``prefetch_related()`` cache.
|
| 704 |
+
|
| 705 |
+
* To prevent possible loss of saved settings,
|
| 706 |
+
:func:`~django.test.utils.setup_test_environment` now raises an exception if
|
| 707 |
+
called a second time before calling
|
| 708 |
+
:func:`~django.test.utils.teardown_test_environment`.
|
| 709 |
+
|
| 710 |
+
* The undocumented ``DateTimeAwareJSONEncoder`` alias for
|
| 711 |
+
:class:`~django.core.serializers.json.DjangoJSONEncoder` (renamed in Django
|
| 712 |
+
1.0) is removed.
|
| 713 |
+
|
| 714 |
+
* The :class:`cached template loader <django.template.loaders.cached.Loader>`
|
| 715 |
+
is now enabled if :setting:`OPTIONS['loaders'] <TEMPLATES-OPTIONS>` isn't
|
| 716 |
+
specified and :setting:`OPTIONS['debug'] <TEMPLATES-OPTIONS>` is ``False``
|
| 717 |
+
(the latter option defaults to the value of :setting:`DEBUG`). This could
|
| 718 |
+
be backwards-incompatible if you have some :ref:`template tags that aren't
|
| 719 |
+
thread safe <template_tag_thread_safety>`.
|
| 720 |
+
|
| 721 |
+
* The prompt for stale content type deletion no longer occurs after running the
|
| 722 |
+
``migrate`` command. Use the new :djadmin:`remove_stale_contenttypes` command
|
| 723 |
+
instead.
|
| 724 |
+
|
| 725 |
+
* The admin's widget for ``IntegerField`` uses ``type="number"`` rather than
|
| 726 |
+
``type="text"``.
|
| 727 |
+
|
| 728 |
+
* Conditional HTTP headers are now parsed and compared according to the
|
| 729 |
+
:rfc:`7232` Conditional Requests specification rather than the older
|
| 730 |
+
:rfc:`2616`.
|
| 731 |
+
|
| 732 |
+
* :func:`~django.utils.cache.patch_response_headers` no longer adds a
|
| 733 |
+
``Last-Modified`` header. According to the :rfc:`7234#section-4.2.2`, this
|
| 734 |
+
header is useless alongside other caching headers that provide an explicit
|
| 735 |
+
expiration time, e.g. ``Expires`` or ``Cache-Control``.
|
| 736 |
+
:class:`~django.middleware.cache.UpdateCacheMiddleware` and
|
| 737 |
+
:func:`~django.utils.cache.add_never_cache_headers` call
|
| 738 |
+
``patch_response_headers()`` and therefore are also affected by this change.
|
| 739 |
+
|
| 740 |
+
* In the admin templates, ``<p class="help">`` is replaced with a ``<div>`` tag
|
| 741 |
+
to allow including lists inside help text.
|
| 742 |
+
|
| 743 |
+
* :class:`~django.middleware.http.ConditionalGetMiddleware` no longer sets the
|
| 744 |
+
``Date`` header as web servers set that header. It also no longer sets the
|
| 745 |
+
``Content-Length`` header as this is now done by
|
| 746 |
+
:class:`~django.middleware.common.CommonMiddleware`.
|
| 747 |
+
|
| 748 |
+
If you have a middleware that modifies a response's content and appears
|
| 749 |
+
before ``CommonMiddleware`` in the ``MIDDLEWARE`` or ``MIDDLEWARE_CLASSES``
|
| 750 |
+
settings, you must reorder your middleware so that responses aren't modified
|
| 751 |
+
after ``Content-Length`` is set, or have the response modifying middleware
|
| 752 |
+
reset the ``Content-Length`` header.
|
| 753 |
+
|
| 754 |
+
* :meth:`~django.apps.AppConfig.get_model` and
|
| 755 |
+
:meth:`~django.apps.AppConfig.get_models` now raise
|
| 756 |
+
:exc:`~django.core.exceptions.AppRegistryNotReady` if they're called before
|
| 757 |
+
models of all applications have been loaded. Previously they only required
|
| 758 |
+
the target application's models to be loaded and thus could return models
|
| 759 |
+
without all their relations set up. If you need the old behavior of
|
| 760 |
+
``get_model()``, set the ``require_ready`` argument to ``False``.
|
| 761 |
+
|
| 762 |
+
* The unused ``BaseCommand.can_import_settings`` attribute is removed.
|
| 763 |
+
|
| 764 |
+
* The undocumented ``django.utils.functional.lazy_property`` is removed.
|
| 765 |
+
|
| 766 |
+
* For consistency with non-multipart requests, ``MultiPartParser.parse()`` now
|
| 767 |
+
leaves ``request.POST`` immutable. If you're modifying that ``QueryDict``,
|
| 768 |
+
you must now first copy it, e.g. ``request.POST.copy()``.
|
| 769 |
+
|
| 770 |
+
* Support for ``cx_Oracle`` < 5.2 is removed.
|
| 771 |
+
|
| 772 |
+
* Support for IPython < 1.0 is removed from the ``shell`` command.
|
| 773 |
+
|
| 774 |
+
* The signature of private API ``Widget.build_attrs()`` changed from
|
| 775 |
+
``extra_attrs=None, **kwargs`` to ``base_attrs, extra_attrs=None``.
|
| 776 |
+
|
| 777 |
+
* File-like objects (e.g., :class:`~io.StringIO` and :class:`~io.BytesIO`)
|
| 778 |
+
uploaded to an :class:`~django.db.models.ImageField` using the test client
|
| 779 |
+
now require a ``name`` attribute with a value that passes the
|
| 780 |
+
:data:`~django.core.validators.validate_image_file_extension` validator.
|
| 781 |
+
See the note in :meth:`.Client.post`.
|
| 782 |
+
|
| 783 |
+
* :class:`~django.db.models.FileField` now moves rather than copies the file
|
| 784 |
+
it receives. With the default file upload settings, files larger than
|
| 785 |
+
:setting:`FILE_UPLOAD_MAX_MEMORY_SIZE` now have the same permissions as
|
| 786 |
+
temporary files (often ``0o600``) rather than the system's standard umask
|
| 787 |
+
(often ``0o6644``). Set the :setting:`FILE_UPLOAD_PERMISSIONS` if you need
|
| 788 |
+
the same permission regardless of file size.
|
| 789 |
+
|
| 790 |
+
.. _deprecated-features-1.11:
|
| 791 |
+
|
| 792 |
+
Features deprecated in 1.11
|
| 793 |
+
===========================
|
| 794 |
+
|
| 795 |
+
``models.permalink()`` decorator
|
| 796 |
+
--------------------------------
|
| 797 |
+
|
| 798 |
+
Use :func:`django.urls.reverse` instead. For example::
|
| 799 |
+
|
| 800 |
+
from django.db import models
|
| 801 |
+
|
| 802 |
+
|
| 803 |
+
class MyModel(models.Model):
|
| 804 |
+
...
|
| 805 |
+
|
| 806 |
+
@models.permalink
|
| 807 |
+
def url(self):
|
| 808 |
+
return ("guitarist_detail", [self.slug])
|
| 809 |
+
|
| 810 |
+
becomes::
|
| 811 |
+
|
| 812 |
+
from django.db import models
|
| 813 |
+
from django.urls import reverse
|
| 814 |
+
|
| 815 |
+
|
| 816 |
+
class MyModel(models.Model):
|
| 817 |
+
...
|
| 818 |
+
|
| 819 |
+
def url(self):
|
| 820 |
+
return reverse("guitarist_detail", args=[self.slug])
|
| 821 |
+
|
| 822 |
+
Miscellaneous
|
| 823 |
+
-------------
|
| 824 |
+
|
| 825 |
+
* ``contrib.auth``’s ``login()`` and ``logout()`` function-based views are
|
| 826 |
+
deprecated in favor of new class-based views
|
| 827 |
+
:class:`~django.contrib.auth.views.LoginView` and
|
| 828 |
+
:class:`~django.contrib.auth.views.LogoutView`.
|
| 829 |
+
|
| 830 |
+
* The unused ``extra_context`` parameter of
|
| 831 |
+
``contrib.auth.views.logout_then_login()`` is deprecated.
|
| 832 |
+
|
| 833 |
+
* ``contrib.auth``’s ``password_change()``, ``password_change_done()``,
|
| 834 |
+
``password_reset()``, ``password_reset_done()``, ``password_reset_confirm()``,
|
| 835 |
+
and ``password_reset_complete()`` function-based views are deprecated in favor
|
| 836 |
+
of new class-based views
|
| 837 |
+
:class:`~django.contrib.auth.views.PasswordChangeView`,
|
| 838 |
+
:class:`~django.contrib.auth.views.PasswordChangeDoneView`,
|
| 839 |
+
:class:`~django.contrib.auth.views.PasswordResetView`,
|
| 840 |
+
:class:`~django.contrib.auth.views.PasswordResetDoneView`,
|
| 841 |
+
:class:`~django.contrib.auth.views.PasswordResetConfirmView`, and
|
| 842 |
+
:class:`~django.contrib.auth.views.PasswordResetCompleteView`.
|
| 843 |
+
|
| 844 |
+
* ``django.test.runner.setup_databases()`` is moved to
|
| 845 |
+
:func:`django.test.utils.setup_databases`. The old location is deprecated.
|
| 846 |
+
|
| 847 |
+
* ``django.utils.translation.string_concat()`` is deprecated in
|
| 848 |
+
favor of :func:`django.utils.text.format_lazy`. ``string_concat(*strings)``
|
| 849 |
+
can be replaced by ``format_lazy('{}' * len(strings), *strings)``.
|
| 850 |
+
|
| 851 |
+
* For the ``PyLibMCCache`` cache backend, passing ``pylibmc`` behavior settings
|
| 852 |
+
as top-level attributes of ``OPTIONS`` is deprecated. Set them under a
|
| 853 |
+
``behaviors`` key within ``OPTIONS`` instead.
|
| 854 |
+
|
| 855 |
+
* The ``host`` parameter of ``django.utils.http.is_safe_url()`` is deprecated
|
| 856 |
+
in favor of the new ``allowed_hosts`` parameter.
|
| 857 |
+
|
| 858 |
+
* Silencing exceptions raised while rendering the
|
| 859 |
+
:ttag:`{% include %} <include>` template tag is deprecated as the behavior is
|
| 860 |
+
often more confusing than helpful. In Django 2.1, the exception will be
|
| 861 |
+
raised.
|
| 862 |
+
|
| 863 |
+
* ``DatabaseIntrospection.get_indexes()`` is deprecated in favor of
|
| 864 |
+
``DatabaseIntrospection.get_constraints()``.
|
| 865 |
+
|
| 866 |
+
* :func:`~django.contrib.auth.authenticate` now passes a ``request`` argument
|
| 867 |
+
to the ``authenticate()`` method of authentication backends. Support for
|
| 868 |
+
methods that don't accept ``request`` as the first positional argument will
|
| 869 |
+
be removed in Django 2.1.
|
| 870 |
+
|
| 871 |
+
* The ``USE_ETAGS`` setting is deprecated in favor of
|
| 872 |
+
:class:`~django.middleware.http.ConditionalGetMiddleware` which now adds the
|
| 873 |
+
``ETag`` header to responses regardless of the setting. ``CommonMiddleware``
|
| 874 |
+
and ``django.utils.cache.patch_response_headers()`` will no longer set ETags
|
| 875 |
+
when the deprecation ends.
|
| 876 |
+
|
| 877 |
+
* ``Model._meta.has_auto_field`` is deprecated in favor of checking if
|
| 878 |
+
``Model._meta.auto_field is not None``.
|
| 879 |
+
|
| 880 |
+
* Using regular expression groups with ``iLmsu#`` in ``url()`` is deprecated.
|
| 881 |
+
The only group that's useful is ``(?i)`` for case-insensitive URLs, however,
|
| 882 |
+
case-insensitive URLs aren't a good practice because they create multiple
|
| 883 |
+
entries for search engines, for example. An alternative solution could be to
|
| 884 |
+
create a :data:`~django.conf.urls.handler404` that looks for uppercase
|
| 885 |
+
characters in the URL and redirects to a lowercase equivalent.
|
| 886 |
+
|
| 887 |
+
* The ``renderer`` argument is added to the :meth:`Widget.render()
|
| 888 |
+
<django.forms.Widget.render>` method. Methods that don't accept that argument
|
| 889 |
+
will work through a deprecation period.
|
testbed/django__django/docs/releases/1.2.6.txt
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.2.6 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*September 9, 2011*
|
| 6 |
+
|
| 7 |
+
Welcome to Django 1.2.6!
|
| 8 |
+
|
| 9 |
+
This is the sixth bugfix/security release in the Django 1.2 series, fixing
|
| 10 |
+
several security issues present in Django 1.2.5. Django 1.2.6 is a
|
| 11 |
+
recommended upgrade for all users of any Django release in the 1.2.X series.
|
| 12 |
+
|
| 13 |
+
For a full list of issues addressed in this release, see the `security
|
| 14 |
+
advisory`_.
|
| 15 |
+
|
| 16 |
+
.. _security advisory: https://www.djangoproject.com/weblog/2011/sep/09/security-releases-issued/
|
testbed/django__django/docs/releases/1.2.txt
ADDED
|
@@ -0,0 +1,1200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========================
|
| 2 |
+
Django 1.2 release notes
|
| 3 |
+
========================
|
| 4 |
+
|
| 5 |
+
*May 17, 2010.*
|
| 6 |
+
|
| 7 |
+
Welcome to Django 1.2!
|
| 8 |
+
|
| 9 |
+
Nearly a year in the making, Django 1.2 packs an impressive list of :ref:`new
|
| 10 |
+
features <whats-new-1.2>` and lots of bug fixes. These release notes cover
|
| 11 |
+
the new features, as well as important changes you'll want to be aware of when
|
| 12 |
+
upgrading from Django 1.1 or older versions.
|
| 13 |
+
|
| 14 |
+
Overview
|
| 15 |
+
========
|
| 16 |
+
|
| 17 |
+
Django 1.2 introduces several large, important new features, including:
|
| 18 |
+
|
| 19 |
+
* Support for :ref:`multiple database connections
|
| 20 |
+
<support-for-multiple-databases>` in a single Django instance.
|
| 21 |
+
|
| 22 |
+
* `Model validation`_ inspired by Django's form validation.
|
| 23 |
+
|
| 24 |
+
* Vastly :ref:`improved protection against Cross-Site Request Forgery
|
| 25 |
+
<improved-csrf-protection>` (CSRF).
|
| 26 |
+
|
| 27 |
+
* A new :ref:`user "messages" framework <messages-framework>` with support for
|
| 28 |
+
cookie- and session-based message for both anonymous and authenticated users.
|
| 29 |
+
|
| 30 |
+
* Hooks for `object-level permissions`_, `permissions for anonymous users`_,
|
| 31 |
+
and :ref:`more flexible username requirements
|
| 32 |
+
<relaxed-requirements-for-usernames>`.
|
| 33 |
+
|
| 34 |
+
* Customization of email sending via `email backends`_.
|
| 35 |
+
|
| 36 |
+
* New :ref:`"smart" if template tag <new-in-1.2-smart-if>` which supports
|
| 37 |
+
comparison operators.
|
| 38 |
+
|
| 39 |
+
These are just the highlights; full details and a complete list of features
|
| 40 |
+
:ref:`may be found below <whats-new-1.2>`.
|
| 41 |
+
|
| 42 |
+
.. seealso::
|
| 43 |
+
|
| 44 |
+
`Django Advent`_ covered the release of Django 1.2 with a series of
|
| 45 |
+
articles and tutorials that cover some of the new features in depth.
|
| 46 |
+
|
| 47 |
+
.. _django advent: https://github.com/djangoadvent/djangoadvent-articles
|
| 48 |
+
|
| 49 |
+
Wherever possible these features have been introduced in a backwards-compatible
|
| 50 |
+
manner per :doc:`our API stability policy </misc/api-stability>` policy.
|
| 51 |
+
|
| 52 |
+
However, a handful of features *have* changed in ways that, for some users, will be
|
| 53 |
+
backwards-incompatible. The big changes are:
|
| 54 |
+
|
| 55 |
+
* Support for Python 2.3 has been dropped. See the full notes
|
| 56 |
+
below.
|
| 57 |
+
|
| 58 |
+
* The new CSRF protection framework is not backwards-compatible with
|
| 59 |
+
the old system. Users of the old system will not be affected until
|
| 60 |
+
the old system is removed in Django 1.4.
|
| 61 |
+
|
| 62 |
+
However, upgrading to the new CSRF protection framework requires a few
|
| 63 |
+
important backwards-incompatible changes, detailed in `CSRF Protection`_,
|
| 64 |
+
below.
|
| 65 |
+
|
| 66 |
+
* Authors of custom :class:`~django.db.models.Field` subclasses should be
|
| 67 |
+
aware that a number of methods have had a change in prototype, detailed
|
| 68 |
+
under `get_db_prep_*() methods on Field`_, below.
|
| 69 |
+
|
| 70 |
+
* The internals of template tags have changed somewhat; authors of custom
|
| 71 |
+
template tags that need to store state (e.g. custom control flow tags)
|
| 72 |
+
should ensure that their code follows the new rules for `stateful template
|
| 73 |
+
tags`_
|
| 74 |
+
|
| 75 |
+
* The :func:`~django.contrib.auth.decorators.user_passes_test`,
|
| 76 |
+
:func:`~django.contrib.auth.decorators.login_required`, and
|
| 77 |
+
:func:`~django.contrib.auth.decorators.permission_required`, decorators
|
| 78 |
+
from :mod:`django.contrib.auth` only apply to functions and no longer
|
| 79 |
+
work on methods. There's a simple one-line fix :ref:`detailed below
|
| 80 |
+
<user-passes-test-login-required-permission-required>`.
|
| 81 |
+
|
| 82 |
+
Again, these are just the big features that will affect the most users. Users
|
| 83 |
+
upgrading from previous versions of Django are heavily encouraged to consult
|
| 84 |
+
the complete list of :ref:`backwards-incompatible changes
|
| 85 |
+
<backwards-incompatible-changes-1.2>` and the list of :ref:`deprecated
|
| 86 |
+
features <deprecated-features-1.2>`.
|
| 87 |
+
|
| 88 |
+
Python compatibility
|
| 89 |
+
====================
|
| 90 |
+
|
| 91 |
+
While not a new feature, it's important to note that Django 1.2
|
| 92 |
+
introduces the first shift in our Python compatibility policy since
|
| 93 |
+
Django's initial public debut. Previous Django releases were tested
|
| 94 |
+
and supported on 2.x Python versions from 2.3 up; Django 1.2, however,
|
| 95 |
+
drops official support for Python 2.3. As such, the minimum Python
|
| 96 |
+
version required for Django is now 2.4, and Django is tested and
|
| 97 |
+
supported on Python 2.4, 2.5 and 2.6, and will be supported on the
|
| 98 |
+
as-yet-unreleased Python 2.7.
|
| 99 |
+
|
| 100 |
+
This change should affect only a small number of Django users, as most
|
| 101 |
+
operating-system vendors today are shipping Python 2.4 or newer as
|
| 102 |
+
their default version. If you're still using Python 2.3, however,
|
| 103 |
+
you'll need to stick to Django 1.1 until you can upgrade; per
|
| 104 |
+
:doc:`our support policy </internals/release-process>`, Django 1.1 will
|
| 105 |
+
continue to receive security support until the release of Django 1.3.
|
| 106 |
+
|
| 107 |
+
A roadmap for Django's overall 2.x Python support, and eventual
|
| 108 |
+
transition to Python 3.x, is currently being developed, and will be
|
| 109 |
+
announced prior to the release of Django 1.3.
|
| 110 |
+
|
| 111 |
+
.. _whats-new-1.2:
|
| 112 |
+
|
| 113 |
+
What's new in Django 1.2
|
| 114 |
+
========================
|
| 115 |
+
|
| 116 |
+
.. _support-for-multiple-databases:
|
| 117 |
+
|
| 118 |
+
Support for multiple databases
|
| 119 |
+
------------------------------
|
| 120 |
+
|
| 121 |
+
Django 1.2 adds the ability to use :doc:`more than one database
|
| 122 |
+
</topics/db/multi-db>` in your Django project. Queries can be issued at a
|
| 123 |
+
specific database with the ``using()`` method on ``QuerySet`` objects.
|
| 124 |
+
Individual objects can be saved to a specific database by providing a ``using``
|
| 125 |
+
argument when you call ``save()``.
|
| 126 |
+
|
| 127 |
+
Model validation
|
| 128 |
+
----------------
|
| 129 |
+
|
| 130 |
+
Model instances now have support for :ref:`validating their own data
|
| 131 |
+
<validating-objects>`, and both model and form fields now accept configurable
|
| 132 |
+
lists of :doc:`validators </ref/validators>` specifying reusable, encapsulated
|
| 133 |
+
validation behavior. Note, however, that validation must still be performed
|
| 134 |
+
explicitly. Simply invoking a model instance's ``save()`` method will not
|
| 135 |
+
perform any validation of the instance's data.
|
| 136 |
+
|
| 137 |
+
.. _improved-csrf-protection:
|
| 138 |
+
|
| 139 |
+
Improved CSRF protection
|
| 140 |
+
------------------------
|
| 141 |
+
|
| 142 |
+
Django now has much improved protection against :doc:`Cross-Site Request Forgery
|
| 143 |
+
(CSRF) attacks</ref/csrf>`. This type of attack occurs when a malicious
|
| 144 |
+
website contains a link, a form button or some JavaScript that is intended to
|
| 145 |
+
perform some action on your website, using the credentials of a logged-in user
|
| 146 |
+
who visits the malicious site in their browser. A related type of attack, "login
|
| 147 |
+
CSRF," where an attacking site tricks a user's browser into logging into a site
|
| 148 |
+
with someone else's credentials, is also covered.
|
| 149 |
+
|
| 150 |
+
.. _messages-framework:
|
| 151 |
+
|
| 152 |
+
Messages framework
|
| 153 |
+
------------------
|
| 154 |
+
|
| 155 |
+
Django now includes a robust and configurable :doc:`messages framework
|
| 156 |
+
</ref/contrib/messages>` with built-in support for cookie- and session-based
|
| 157 |
+
messaging, for both anonymous and authenticated clients. The messages framework
|
| 158 |
+
replaces the deprecated user message API and allows you to temporarily store
|
| 159 |
+
messages in one request and retrieve them for display in a subsequent request
|
| 160 |
+
(usually the next one).
|
| 161 |
+
|
| 162 |
+
Object-level permissions
|
| 163 |
+
------------------------
|
| 164 |
+
|
| 165 |
+
A foundation for specifying permissions at the per-object level has been added.
|
| 166 |
+
Although there is no implementation of this in core, a custom authentication
|
| 167 |
+
backend can provide this implementation and it will be used by
|
| 168 |
+
:class:`django.contrib.auth.models.User`. See the :doc:`authentication docs
|
| 169 |
+
</topics/auth/index>` for more information.
|
| 170 |
+
|
| 171 |
+
Permissions for anonymous users
|
| 172 |
+
-------------------------------
|
| 173 |
+
|
| 174 |
+
If you provide a custom auth backend with ``supports_anonymous_user`` set to
|
| 175 |
+
``True``, AnonymousUser will check the backend for permissions, just like
|
| 176 |
+
User already did. This is useful for centralizing permission handling - apps
|
| 177 |
+
can always delegate the question of whether something is allowed or not to
|
| 178 |
+
the authorization/authentication backend. See the :doc:`authentication
|
| 179 |
+
docs </topics/auth/index>` for more details.
|
| 180 |
+
|
| 181 |
+
.. _relaxed-requirements-for-usernames:
|
| 182 |
+
|
| 183 |
+
Relaxed requirements for usernames
|
| 184 |
+
----------------------------------
|
| 185 |
+
|
| 186 |
+
The built-in :class:`~django.contrib.auth.models.User` model's
|
| 187 |
+
:attr:`~django.contrib.auth.models.User.username` field now allows a wider range
|
| 188 |
+
of characters, including ``@``, ``+``, ``.`` and ``-`` characters.
|
| 189 |
+
|
| 190 |
+
Email backends
|
| 191 |
+
--------------
|
| 192 |
+
|
| 193 |
+
You can now :ref:`configure the way that Django sends email
|
| 194 |
+
<topic-email-backends>`. Instead of using SMTP to send all email, you
|
| 195 |
+
can now choose a configurable email backend to send messages. If your
|
| 196 |
+
hosting provider uses a sandbox or some other non-SMTP technique for
|
| 197 |
+
sending mail, you can now construct an email backend that will allow
|
| 198 |
+
Django's standard :doc:`mail sending methods</topics/email>` to use
|
| 199 |
+
those facilities.
|
| 200 |
+
|
| 201 |
+
This also makes it easier to debug mail sending. Django ships with
|
| 202 |
+
backend implementations that allow you to send email to a
|
| 203 |
+
:ref:`file<topic-email-file-backend>`, to the
|
| 204 |
+
:ref:`console<topic-email-console-backend>`, or to
|
| 205 |
+
:ref:`memory<topic-email-memory-backend>`. You can even configure all
|
| 206 |
+
email to be :ref:`thrown away<topic-email-dummy-backend>`.
|
| 207 |
+
|
| 208 |
+
.. _new-in-1.2-smart-if:
|
| 209 |
+
|
| 210 |
+
"Smart" :ttag:`if` tag
|
| 211 |
+
----------------------
|
| 212 |
+
|
| 213 |
+
The :ttag:`if` tag has been upgraded to be much more powerful. First, we've
|
| 214 |
+
added support for comparison operators. No longer will you have to type:
|
| 215 |
+
|
| 216 |
+
.. code-block:: html+django
|
| 217 |
+
|
| 218 |
+
{% ifnotequal a b %}
|
| 219 |
+
...
|
| 220 |
+
{% endifnotequal %}
|
| 221 |
+
|
| 222 |
+
You can now do this:
|
| 223 |
+
|
| 224 |
+
.. code-block:: html+django
|
| 225 |
+
|
| 226 |
+
{% if a != b %}
|
| 227 |
+
...
|
| 228 |
+
{% endif %}
|
| 229 |
+
|
| 230 |
+
There's really no reason to use ``{% ifequal %}`` or ``{% ifnotequal %}``
|
| 231 |
+
anymore, unless you're the nostalgic type.
|
| 232 |
+
|
| 233 |
+
The operators supported are ``==``, ``!=``, ``<``, ``>``, ``<=``, ``>=``,
|
| 234 |
+
``in`` and ``not in``, all of which work like the Python operators, in addition
|
| 235 |
+
to ``and``, ``or`` and ``not``, which were already supported.
|
| 236 |
+
|
| 237 |
+
Also, filters may now be used in the ``if`` expression. For example:
|
| 238 |
+
|
| 239 |
+
.. code-block:: html+django
|
| 240 |
+
|
| 241 |
+
<div
|
| 242 |
+
{% if user.email|lower == message.recipient|lower %}
|
| 243 |
+
class="highlight"
|
| 244 |
+
{% endif %}
|
| 245 |
+
>{{ message }}</div>
|
| 246 |
+
|
| 247 |
+
Template caching
|
| 248 |
+
----------------
|
| 249 |
+
|
| 250 |
+
In previous versions of Django, every time you rendered a template, it
|
| 251 |
+
would be reloaded from disk. In Django 1.2, you can use a :ref:`cached
|
| 252 |
+
template loader <template-loaders>` to load templates once, then
|
| 253 |
+
cache the result for every subsequent render. This can lead to a
|
| 254 |
+
significant performance improvement if your templates are broken into
|
| 255 |
+
lots of smaller subtemplates (using the ``{% extends %}`` or ``{%
|
| 256 |
+
include %}`` tags).
|
| 257 |
+
|
| 258 |
+
As a side effect, it is now much easier to support non-Django template
|
| 259 |
+
languages.
|
| 260 |
+
|
| 261 |
+
Class-based template loaders
|
| 262 |
+
----------------------------
|
| 263 |
+
|
| 264 |
+
As part of the changes made to introduce `Template caching`_ and following
|
| 265 |
+
a general trend in Django, the template loaders API has been modified
|
| 266 |
+
to use template loading mechanisms that are encapsulated in Python classes as
|
| 267 |
+
opposed to functions, the only method available until Django 1.1.
|
| 268 |
+
|
| 269 |
+
All the template loaders :ref:`shipped with Django <template-loaders>` have
|
| 270 |
+
been ported to the new API but they still implement the function-based API and
|
| 271 |
+
the template core machinery still accepts function-based loaders (builtin or
|
| 272 |
+
third party) so there is no immediate need to modify your ``TEMPLATE_LOADERS``
|
| 273 |
+
setting in existing projects, things will keep working if you leave it
|
| 274 |
+
untouched up to and including the Django 1.3 release.
|
| 275 |
+
|
| 276 |
+
If you have developed your own custom template loaders we suggest to consider
|
| 277 |
+
porting them to a class-based implementation because the code for backwards
|
| 278 |
+
compatibility with function-based loaders starts its deprecation process in
|
| 279 |
+
Django 1.2 and will be removed in Django 1.4. There is a description of the
|
| 280 |
+
API these loader classes must implement in the template API reference and you
|
| 281 |
+
can also examine the source code of the loaders shipped with Django.
|
| 282 |
+
|
| 283 |
+
Natural keys in fixtures
|
| 284 |
+
------------------------
|
| 285 |
+
|
| 286 |
+
Fixtures can now refer to remote objects using
|
| 287 |
+
:ref:`topics-serialization-natural-keys`. This lookup scheme is an
|
| 288 |
+
alternative to the normal primary-key based object references in a
|
| 289 |
+
fixture, improving readability and resolving problems referring to
|
| 290 |
+
objects whose primary key value may not be predictable or known.
|
| 291 |
+
|
| 292 |
+
Fast failure for tests
|
| 293 |
+
----------------------
|
| 294 |
+
|
| 295 |
+
Both the :djadmin:`test` subcommand of ``django-admin.py`` and the
|
| 296 |
+
``runtests.py`` script used to run Django's own test suite now support a
|
| 297 |
+
``--failfast`` option. When specified, this option causes the test runner to
|
| 298 |
+
exit after encountering a failure instead of continuing with the test run. In
|
| 299 |
+
addition, the handling of ``Ctrl-C`` during a test run has been improved to
|
| 300 |
+
trigger a graceful exit from the test run that reports details of the tests that
|
| 301 |
+
were run before the interruption.
|
| 302 |
+
|
| 303 |
+
``BigIntegerField``
|
| 304 |
+
-------------------
|
| 305 |
+
|
| 306 |
+
Models can now use a 64-bit :class:`~django.db.models.BigIntegerField` type.
|
| 307 |
+
|
| 308 |
+
Improved localization
|
| 309 |
+
---------------------
|
| 310 |
+
|
| 311 |
+
Django's :doc:`internationalization framework </topics/i18n/index>` has been expanded
|
| 312 |
+
with locale-aware formatting and form processing. That means, if enabled, dates
|
| 313 |
+
and numbers on templates will be displayed using the format specified for the
|
| 314 |
+
current locale. Django will also use localized formats when parsing data in
|
| 315 |
+
forms. See :doc:`/topics/i18n/formatting` for more details.
|
| 316 |
+
|
| 317 |
+
``readonly_fields`` in ``ModelAdmin``
|
| 318 |
+
-------------------------------------
|
| 319 |
+
|
| 320 |
+
:attr:`django.contrib.admin.ModelAdmin.readonly_fields` has been added to
|
| 321 |
+
enable non-editable fields in add/change pages for models and inlines. Field
|
| 322 |
+
and calculated values can be displayed alongside editable fields.
|
| 323 |
+
|
| 324 |
+
Customizable syntax highlighting
|
| 325 |
+
--------------------------------
|
| 326 |
+
|
| 327 |
+
You can now use a :envvar:`DJANGO_COLORS` environment variable to modify or
|
| 328 |
+
disable the colors used by ``django-admin.py`` to provide :ref:`syntax
|
| 329 |
+
highlighting <syntax-coloring>`.
|
| 330 |
+
|
| 331 |
+
Syndication feeds as views
|
| 332 |
+
--------------------------
|
| 333 |
+
|
| 334 |
+
:doc:`Syndication feeds </ref/contrib/syndication>` can now be used directly as
|
| 335 |
+
views in your :doc:`URLconf </topics/http/urls>`. This means that you can
|
| 336 |
+
maintain complete control over the URL structure of your feeds. Like any other
|
| 337 |
+
view, feeds views are passed a ``request`` object, so you can do anything you
|
| 338 |
+
would normally do with a view, like user based access control, or making a feed
|
| 339 |
+
a named URL.
|
| 340 |
+
|
| 341 |
+
GeoDjango
|
| 342 |
+
---------
|
| 343 |
+
|
| 344 |
+
The most significant new feature for :doc:`GeoDjango </ref/contrib/gis/index>`
|
| 345 |
+
in 1.2 is support for multiple spatial databases. As a result,
|
| 346 |
+
the following :ref:`spatial database backends <spatial-backends>`
|
| 347 |
+
are now included:
|
| 348 |
+
|
| 349 |
+
* ``django.contrib.gis.db.backends.postgis``
|
| 350 |
+
* ``django.contrib.gis.db.backends.mysql``
|
| 351 |
+
* ``django.contrib.gis.db.backends.oracle``
|
| 352 |
+
* ``django.contrib.gis.db.backends.spatialite``
|
| 353 |
+
|
| 354 |
+
GeoDjango now supports the rich capabilities added in the PostGIS 1.5 release.
|
| 355 |
+
New features include support for the :ref:`geography type <geography-type>`
|
| 356 |
+
and enabling of :ref:`distance queries <distance-queries>`
|
| 357 |
+
with non-point geometries on geographic coordinate systems.
|
| 358 |
+
|
| 359 |
+
Support for 3D geometry fields was added, and may be enabled
|
| 360 |
+
by setting the :attr:`~django.contrib.gis.db.models.GeometryField.dim`
|
| 361 |
+
keyword to 3 in your :class:`~django.contrib.gis.db.models.GeometryField`.
|
| 362 |
+
The :class:`~django.contrib.gis.db.models.Extent3D` aggregate
|
| 363 |
+
and ``extent3d()`` ``GeoQuerySet`` method were added as a part of this feature.
|
| 364 |
+
|
| 365 |
+
The ``force_rhr()``, ``reverse_geom()``, and ``geohash()`` ``GeoQuerySet``
|
| 366 |
+
methods are new.
|
| 367 |
+
|
| 368 |
+
The GEOS interface was updated to use thread-safe C library functions when
|
| 369 |
+
available on the platform.
|
| 370 |
+
|
| 371 |
+
The GDAL interface now allows the user to set a
|
| 372 |
+
:attr:`~django.contrib.gis.gdal.Layer.spatial_filter` on the features returned
|
| 373 |
+
when iterating over a :class:`~django.contrib.gis.gdal.Layer`.
|
| 374 |
+
|
| 375 |
+
Finally, :doc:`GeoDjango's documentation </ref/contrib/gis/index>` is now
|
| 376 |
+
included with Django's and is no longer hosted separately at ``geodjango.org``.
|
| 377 |
+
|
| 378 |
+
.. _1.2-js-assisted-inlines:
|
| 379 |
+
|
| 380 |
+
JavaScript-assisted handling of inline related objects in the admin
|
| 381 |
+
-------------------------------------------------------------------
|
| 382 |
+
|
| 383 |
+
If a user has JavaScript enabled in their browser, the interface for
|
| 384 |
+
inline objects in the admin now allows inline objects to be
|
| 385 |
+
dynamically added and removed. Users without JavaScript-enabled
|
| 386 |
+
browsers will see no change in the behavior of inline objects.
|
| 387 |
+
|
| 388 |
+
New ``now`` template tag format specifier characters: ``c`` and ``u``
|
| 389 |
+
---------------------------------------------------------------------
|
| 390 |
+
|
| 391 |
+
The argument to the :ttag:`now` has gained two new format characters:
|
| 392 |
+
``c`` to specify that a datetime value should be formatted in ISO 8601
|
| 393 |
+
format, and ``u`` that allows output of the microseconds part of a
|
| 394 |
+
datetime or time value.
|
| 395 |
+
|
| 396 |
+
These are also available in others parts like the :tfilter:`date` and
|
| 397 |
+
:tfilter:`time` template filters, the ``humanize`` template tag library
|
| 398 |
+
and the new `format localization`_ framework.
|
| 399 |
+
|
| 400 |
+
.. _format localization: `Improved localization`_
|
| 401 |
+
|
| 402 |
+
.. _backwards-incompatible-changes-1.2:
|
| 403 |
+
|
| 404 |
+
Backwards-incompatible changes in 1.2
|
| 405 |
+
=====================================
|
| 406 |
+
|
| 407 |
+
Wherever possible the new features above have been introduced in a
|
| 408 |
+
backwards-compatible manner per :doc:`our API stability policy
|
| 409 |
+
</misc/api-stability>` policy. This means that practically all existing
|
| 410 |
+
code which worked with Django 1.1 will continue to work with Django
|
| 411 |
+
1.2; such code will, however, begin issuing warnings (see below for
|
| 412 |
+
details).
|
| 413 |
+
|
| 414 |
+
However, a handful of features *have* changed in ways that, for some
|
| 415 |
+
users, will be immediately backwards-incompatible. Those changes are
|
| 416 |
+
detailed below.
|
| 417 |
+
|
| 418 |
+
CSRF Protection
|
| 419 |
+
---------------
|
| 420 |
+
|
| 421 |
+
We've made large changes to the way CSRF protection works, detailed in
|
| 422 |
+
:doc:`the CSRF documentation </ref/csrf>`. Here are the major changes you
|
| 423 |
+
should be aware of:
|
| 424 |
+
|
| 425 |
+
* ``CsrfResponseMiddleware`` and ``CsrfMiddleware`` have been deprecated and
|
| 426 |
+
will be removed completely in Django 1.4, in favor of a template tag that
|
| 427 |
+
should be inserted into forms.
|
| 428 |
+
|
| 429 |
+
* All contrib apps use a ``csrf_protect`` decorator to protect the view. This
|
| 430 |
+
requires the use of the ``csrf_token`` template tag in the template. If you
|
| 431 |
+
have used custom templates for contrib views, you MUST READ THE UPGRADE
|
| 432 |
+
INSTRUCTIONS to fix those templates.
|
| 433 |
+
|
| 434 |
+
.. admonition:: Documentation removed
|
| 435 |
+
|
| 436 |
+
The upgrade notes have been removed in current Django docs. Please refer
|
| 437 |
+
to the docs for Django 1.3 or older to find these instructions.
|
| 438 |
+
|
| 439 |
+
* ``CsrfViewMiddleware`` is included in ``MIDDLEWARE_CLASSES`` by
|
| 440 |
+
default. This turns on CSRF protection by default, so views that accept
|
| 441 |
+
POST requests need to be written to work with the middleware. Instructions
|
| 442 |
+
on how to do this are found in the CSRF docs.
|
| 443 |
+
|
| 444 |
+
* All of the CSRF has moved from contrib to core (with backwards
|
| 445 |
+
compatible imports in the old locations, which are deprecated and
|
| 446 |
+
will cease to be supported in Django 1.4).
|
| 447 |
+
|
| 448 |
+
``get_db_prep_*()`` methods on ``Field``
|
| 449 |
+
----------------------------------------
|
| 450 |
+
|
| 451 |
+
Prior to Django 1.2, a custom ``Field`` had the option of defining
|
| 452 |
+
several functions to support conversion of Python values into
|
| 453 |
+
database-compatible values. A custom field might look something like::
|
| 454 |
+
|
| 455 |
+
class CustomModelField(models.Field):
|
| 456 |
+
...
|
| 457 |
+
|
| 458 |
+
def db_type(self):
|
| 459 |
+
...
|
| 460 |
+
|
| 461 |
+
def get_db_prep_save(self, value):
|
| 462 |
+
...
|
| 463 |
+
|
| 464 |
+
def get_db_prep_value(self, value):
|
| 465 |
+
...
|
| 466 |
+
|
| 467 |
+
def get_db_prep_lookup(self, lookup_type, value):
|
| 468 |
+
...
|
| 469 |
+
|
| 470 |
+
In 1.2, these three methods have undergone a change in prototype, and
|
| 471 |
+
two extra methods have been introduced::
|
| 472 |
+
|
| 473 |
+
class CustomModelField(models.Field):
|
| 474 |
+
...
|
| 475 |
+
|
| 476 |
+
def db_type(self, connection):
|
| 477 |
+
...
|
| 478 |
+
|
| 479 |
+
def get_prep_value(self, value):
|
| 480 |
+
...
|
| 481 |
+
|
| 482 |
+
def get_prep_lookup(self, lookup_type, value):
|
| 483 |
+
...
|
| 484 |
+
|
| 485 |
+
def get_db_prep_save(self, value, connection):
|
| 486 |
+
...
|
| 487 |
+
|
| 488 |
+
def get_db_prep_value(self, value, connection, prepared=False):
|
| 489 |
+
...
|
| 490 |
+
|
| 491 |
+
def get_db_prep_lookup(self, lookup_type, value, connection, prepared=False):
|
| 492 |
+
...
|
| 493 |
+
|
| 494 |
+
These changes are required to support multiple databases --
|
| 495 |
+
``db_type`` and ``get_db_prep_*`` can no longer make any assumptions
|
| 496 |
+
regarding the database for which it is preparing. The ``connection``
|
| 497 |
+
argument now provides the preparation methods with the specific
|
| 498 |
+
connection for which the value is being prepared.
|
| 499 |
+
|
| 500 |
+
The two new methods exist to differentiate general data-preparation
|
| 501 |
+
requirements from requirements that are database-specific. The
|
| 502 |
+
``prepared`` argument is used to indicate to the database-preparation
|
| 503 |
+
methods whether generic value preparation has been performed. If
|
| 504 |
+
an unprepared (i.e., ``prepared=False``) value is provided to the
|
| 505 |
+
``get_db_prep_*()`` calls, they should invoke the corresponding
|
| 506 |
+
``get_prep_*()`` calls to perform generic data preparation.
|
| 507 |
+
|
| 508 |
+
We've provided conversion functions that will transparently
|
| 509 |
+
convert functions adhering to the old prototype into functions
|
| 510 |
+
compatible with the new prototype. However, these conversion functions
|
| 511 |
+
will be removed in Django 1.4, so you should upgrade your ``Field``
|
| 512 |
+
definitions to use the new prototype as soon as possible.
|
| 513 |
+
|
| 514 |
+
If your ``get_db_prep_*()`` methods made no use of the database
|
| 515 |
+
connection, you should be able to upgrade by renaming
|
| 516 |
+
``get_db_prep_value()`` to ``get_prep_value()`` and
|
| 517 |
+
``get_db_prep_lookup()`` to ``get_prep_lookup()``. If you require
|
| 518 |
+
database specific conversions, then you will need to provide an
|
| 519 |
+
implementation ``get_db_prep_*`` that uses the ``connection``
|
| 520 |
+
argument to resolve database-specific values.
|
| 521 |
+
|
| 522 |
+
Stateful template tags
|
| 523 |
+
----------------------
|
| 524 |
+
|
| 525 |
+
Template tags that store rendering state on their ``Node`` subclass
|
| 526 |
+
have always been vulnerable to thread-safety and other issues; as of
|
| 527 |
+
Django 1.2, however, they may also cause problems when used with the
|
| 528 |
+
new :ref:`cached template loader<template-loaders>`.
|
| 529 |
+
|
| 530 |
+
All of the built-in Django template tags are safe to use with the cached
|
| 531 |
+
loader, but if you're using custom template tags that come from third
|
| 532 |
+
party packages, or from your own code, you should ensure that the
|
| 533 |
+
``Node`` implementation for each tag is thread-safe. For more
|
| 534 |
+
information, see
|
| 535 |
+
:ref:`template tag thread safety considerations<template_tag_thread_safety>`.
|
| 536 |
+
|
| 537 |
+
You may also need to update your templates if you were relying on the
|
| 538 |
+
implementation of Django's template tags *not* being thread safe. The
|
| 539 |
+
:ttag:`cycle` tag is the most likely to be affected in this way,
|
| 540 |
+
especially when used in conjunction with the :ttag:`include` tag.
|
| 541 |
+
Consider the following template fragment:
|
| 542 |
+
|
| 543 |
+
.. code-block:: html+django
|
| 544 |
+
|
| 545 |
+
{% for object in object_list %}
|
| 546 |
+
{% include "subtemplate.html" %}
|
| 547 |
+
{% endfor %}
|
| 548 |
+
|
| 549 |
+
with a ``subtemplate.html`` that reads:
|
| 550 |
+
|
| 551 |
+
.. code-block:: html+django
|
| 552 |
+
|
| 553 |
+
{% cycle 'even' 'odd' %}
|
| 554 |
+
|
| 555 |
+
Using the non-thread-safe, pre-Django 1.2 renderer, this would output:
|
| 556 |
+
|
| 557 |
+
.. code-block:: text
|
| 558 |
+
|
| 559 |
+
even odd even odd ...
|
| 560 |
+
|
| 561 |
+
Using the thread-safe Django 1.2 renderer, you will instead get:
|
| 562 |
+
|
| 563 |
+
.. code-block:: text
|
| 564 |
+
|
| 565 |
+
even even even even ...
|
| 566 |
+
|
| 567 |
+
This is because each rendering of the :ttag:`include` tag is an
|
| 568 |
+
independent rendering. When the :ttag:`cycle` tag was not thread safe,
|
| 569 |
+
the state of the :ttag:`cycle` tag would leak between multiple
|
| 570 |
+
renderings of the same :ttag:`include`. Now that the :ttag:`cycle` tag
|
| 571 |
+
is thread safe, this leakage no longer occurs.
|
| 572 |
+
|
| 573 |
+
.. _user-passes-test-login-required-permission-required:
|
| 574 |
+
|
| 575 |
+
``user_passes_test``, ``login_required`` and ``permission_required``
|
| 576 |
+
--------------------------------------------------------------------
|
| 577 |
+
|
| 578 |
+
``django.contrib.auth.decorators`` provides the decorators
|
| 579 |
+
``login_required``, ``permission_required`` and
|
| 580 |
+
``user_passes_test``. Previously it was possible to use these
|
| 581 |
+
decorators both on functions (where the first argument is 'request')
|
| 582 |
+
and on methods (where the first argument is 'self', and the second
|
| 583 |
+
argument is 'request'). Unfortunately, flaws were discovered in the
|
| 584 |
+
code supporting this: it only works in limited circumstances, and
|
| 585 |
+
produces errors that are very difficult to debug when it does not
|
| 586 |
+
work.
|
| 587 |
+
|
| 588 |
+
For this reason, the 'auto adapt' behavior has been removed, and if
|
| 589 |
+
you are using these decorators on methods, you will need to manually
|
| 590 |
+
apply :func:`django.utils.decorators.method_decorator` to convert the
|
| 591 |
+
decorator to one that works with methods. For example, you would
|
| 592 |
+
change code from this::
|
| 593 |
+
|
| 594 |
+
class MyClass(object):
|
| 595 |
+
@login_required
|
| 596 |
+
def my_view(self, request):
|
| 597 |
+
pass
|
| 598 |
+
|
| 599 |
+
to this::
|
| 600 |
+
|
| 601 |
+
from django.utils.decorators import method_decorator
|
| 602 |
+
|
| 603 |
+
|
| 604 |
+
class MyClass(object):
|
| 605 |
+
@method_decorator(login_required)
|
| 606 |
+
def my_view(self, request):
|
| 607 |
+
pass
|
| 608 |
+
|
| 609 |
+
or::
|
| 610 |
+
|
| 611 |
+
from django.utils.decorators import method_decorator
|
| 612 |
+
|
| 613 |
+
login_required_m = method_decorator(login_required)
|
| 614 |
+
|
| 615 |
+
|
| 616 |
+
class MyClass(object):
|
| 617 |
+
@login_required_m
|
| 618 |
+
def my_view(self, request):
|
| 619 |
+
pass
|
| 620 |
+
|
| 621 |
+
For those of you who've been following the development trunk, this
|
| 622 |
+
change also applies to other decorators introduced since 1.1,
|
| 623 |
+
including ``csrf_protect``, ``cache_control`` and anything created
|
| 624 |
+
using ``decorator_from_middleware``.
|
| 625 |
+
|
| 626 |
+
:ttag:`if` tag changes
|
| 627 |
+
----------------------
|
| 628 |
+
|
| 629 |
+
Due to new features in the :ttag:`if` template tag, it no longer
|
| 630 |
+
accepts 'and', 'or' and 'not' as valid **variable** names. Previously,
|
| 631 |
+
these strings could be used as variable names. Now, the keyword status
|
| 632 |
+
is always enforced, and template code such as ``{% if not %}`` or ``{%
|
| 633 |
+
if and %}`` will throw a ``TemplateSyntaxError``. Also, ``in`` is a
|
| 634 |
+
new keyword and so is not a valid variable name in this tag.
|
| 635 |
+
|
| 636 |
+
``LazyObject``
|
| 637 |
+
--------------
|
| 638 |
+
|
| 639 |
+
``LazyObject`` is an undocumented-but-often-used utility class used for lazily
|
| 640 |
+
wrapping other objects of unknown type.
|
| 641 |
+
|
| 642 |
+
In Django 1.1 and earlier, it handled introspection in a non-standard way,
|
| 643 |
+
depending on wrapped objects implementing a public method named
|
| 644 |
+
``get_all_members()``. Since this could easily lead to name clashes, it has been
|
| 645 |
+
changed to use the standard Python introspection method, involving
|
| 646 |
+
``__members__`` and ``__dir__()``.
|
| 647 |
+
|
| 648 |
+
If you used ``LazyObject`` in your own code
|
| 649 |
+
and implemented the ``get_all_members()`` method for wrapped objects, you'll need
|
| 650 |
+
to make a couple of changes:
|
| 651 |
+
|
| 652 |
+
First, if your class does not have special requirements for introspection (i.e.,
|
| 653 |
+
you have not implemented ``__getattr__()`` or other methods that allow for
|
| 654 |
+
attributes not discoverable by normal mechanisms), you can simply remove the
|
| 655 |
+
``get_all_members()`` method. The default implementation on ``LazyObject`` will
|
| 656 |
+
do the right thing.
|
| 657 |
+
|
| 658 |
+
If you have more complex requirements for introspection, first rename the
|
| 659 |
+
``get_all_members()`` method to ``__dir__()``. This is the standard
|
| 660 |
+
introspection method for Python 2.6 and above. If you require support for Python
|
| 661 |
+
versions earlier than 2.6, add the following code to the class::
|
| 662 |
+
|
| 663 |
+
__members__ = property(lambda self: self.__dir__())
|
| 664 |
+
|
| 665 |
+
``__dict__`` on model instances
|
| 666 |
+
-------------------------------
|
| 667 |
+
|
| 668 |
+
Historically, the ``__dict__`` attribute of a model instance has only contained
|
| 669 |
+
attributes corresponding to the fields on a model.
|
| 670 |
+
|
| 671 |
+
In order to support multiple database configurations, Django 1.2 has
|
| 672 |
+
added a ``_state`` attribute to object instances. This attribute will
|
| 673 |
+
appear in ``__dict__`` for a model instance. If your code relies on
|
| 674 |
+
iterating over ``__dict__`` to obtain a list of fields, you must now
|
| 675 |
+
be prepared to handle or filter out the ``_state`` attribute.
|
| 676 |
+
|
| 677 |
+
Test runner exit status code
|
| 678 |
+
----------------------------
|
| 679 |
+
|
| 680 |
+
The exit status code of the test runners (``tests/runtests.py`` and ``python
|
| 681 |
+
manage.py test``) no longer represents the number of failed tests, because a
|
| 682 |
+
failure of 256 or more tests resulted in a wrong exit status code. The exit
|
| 683 |
+
status code for the test runner is now 0 for success (no failing tests) and 1
|
| 684 |
+
for any number of test failures. If needed, the number of test failures can be
|
| 685 |
+
found at the end of the test runner's output.
|
| 686 |
+
|
| 687 |
+
Cookie encoding
|
| 688 |
+
---------------
|
| 689 |
+
|
| 690 |
+
To fix bugs with cookies in Internet Explorer, Safari, and possibly
|
| 691 |
+
other browsers, our encoding of cookie values was changed so that the
|
| 692 |
+
comma and semicolon are treated as non-safe characters, and are
|
| 693 |
+
therefore encoded as ``\054`` and ``\073`` respectively. This could
|
| 694 |
+
produce backwards incompatibilities, especially if you are storing
|
| 695 |
+
comma or semi-colon in cookies and have JavaScript code that parses
|
| 696 |
+
and manipulates cookie values client-side.
|
| 697 |
+
|
| 698 |
+
``ModelForm.is_valid()`` and ``ModelForm.errors``
|
| 699 |
+
-------------------------------------------------
|
| 700 |
+
|
| 701 |
+
Much of the validation work for ModelForms has been moved down to the model
|
| 702 |
+
level. As a result, the first time you call ``ModelForm.is_valid()``, access
|
| 703 |
+
``ModelForm.errors`` or otherwise trigger form validation, your model will be
|
| 704 |
+
cleaned in-place. This conversion used to happen when the model was saved. If
|
| 705 |
+
you need an unmodified instance of your model, you should pass a copy to the
|
| 706 |
+
``ModelForm`` constructor.
|
| 707 |
+
|
| 708 |
+
``BooleanField`` on MySQL
|
| 709 |
+
--------------------------
|
| 710 |
+
|
| 711 |
+
In previous versions of Django, a model's ``BooleanField`` under MySQL
|
| 712 |
+
would return its value as either ``1`` or ``0``, instead of ``True``
|
| 713 |
+
or ``False``; for most people this wasn't a problem because ``bool``
|
| 714 |
+
is a subclass of ``int`` in Python. In Django 1.2, however,
|
| 715 |
+
``BooleanField`` on MySQL correctly returns a real ``bool``. The only
|
| 716 |
+
time this should ever be an issue is if you were expecting the
|
| 717 |
+
``repr`` of a ``BooleanField`` to print ``1`` or ``0``.
|
| 718 |
+
|
| 719 |
+
Changes to the interpretation of ``max_num`` in FormSets
|
| 720 |
+
--------------------------------------------------------
|
| 721 |
+
|
| 722 |
+
As part of enhancements made to the handling of FormSets, the default
|
| 723 |
+
value and interpretation of the ``max_num`` parameter to the
|
| 724 |
+
:ref:`django.forms.formsets.formset_factory() <formsets-max-num>` and
|
| 725 |
+
:ref:`django.forms.models.modelformset_factory()
|
| 726 |
+
<model-formsets-max-num>` functions has changed slightly. This
|
| 727 |
+
change also affects the way the
|
| 728 |
+
:attr:`~django.contrib.admin.InlineModelAdmin.max_num` argument is used for
|
| 729 |
+
inline admin objects.
|
| 730 |
+
|
| 731 |
+
Previously, the default value for ``max_num`` was ``0`` (zero).
|
| 732 |
+
FormSets then used the boolean value of ``max_num`` to determine if a
|
| 733 |
+
limit was to be imposed on the number of generated forms. The default
|
| 734 |
+
value of ``0`` meant that there was no default limit on the number of
|
| 735 |
+
forms in a FormSet.
|
| 736 |
+
|
| 737 |
+
Starting with 1.2, the default value for ``max_num`` has been changed
|
| 738 |
+
to ``None``, and FormSets will differentiate between a value of
|
| 739 |
+
``None`` and a value of ``0``. A value of ``None`` indicates that no
|
| 740 |
+
limit on the number of forms is to be imposed; a value of ``0``
|
| 741 |
+
indicates that a maximum of 0 forms should be imposed. This doesn't
|
| 742 |
+
necessarily mean that no forms will be displayed -- see the
|
| 743 |
+
:ref:`ModelFormSet documentation <model-formsets-max-num>` for more
|
| 744 |
+
details.
|
| 745 |
+
|
| 746 |
+
If you were manually specifying a value of ``0`` for ``max_num``, you
|
| 747 |
+
will need to update your FormSet and/or admin definitions.
|
| 748 |
+
|
| 749 |
+
.. seealso::
|
| 750 |
+
|
| 751 |
+
:ref:`1.2-js-assisted-inlines`
|
| 752 |
+
|
| 753 |
+
``email_re``
|
| 754 |
+
------------
|
| 755 |
+
|
| 756 |
+
An undocumented regular expression for validating email addresses has been moved
|
| 757 |
+
from ``django.form.fields`` to ``django.core.validators``. You will need to
|
| 758 |
+
update your imports if you are using it.
|
| 759 |
+
|
| 760 |
+
.. _deprecated-features-1.2:
|
| 761 |
+
|
| 762 |
+
Features deprecated in 1.2
|
| 763 |
+
==========================
|
| 764 |
+
|
| 765 |
+
Finally, Django 1.2 deprecates some features from earlier releases.
|
| 766 |
+
These features are still supported, but will be gradually phased out
|
| 767 |
+
over the next few release cycles.
|
| 768 |
+
|
| 769 |
+
Code taking advantage of any of the features below will raise a
|
| 770 |
+
``PendingDeprecationWarning`` in Django 1.2. This warning will be
|
| 771 |
+
silent by default, but may be turned on using Python's :mod:`warnings`
|
| 772 |
+
module, or by running Python with a ``-Wd`` or ``-Wall`` flag.
|
| 773 |
+
|
| 774 |
+
In Django 1.3, these warnings will become a ``DeprecationWarning``,
|
| 775 |
+
which is *not* silent. In Django 1.4 support for these features will
|
| 776 |
+
be removed entirely.
|
| 777 |
+
|
| 778 |
+
.. seealso::
|
| 779 |
+
|
| 780 |
+
For more details, see the documentation :doc:`Django's release process
|
| 781 |
+
</internals/release-process>` and our :doc:`deprecation timeline
|
| 782 |
+
</internals/deprecation>`.`
|
| 783 |
+
|
| 784 |
+
.. _specifying-databases:
|
| 785 |
+
|
| 786 |
+
Specifying databases
|
| 787 |
+
--------------------
|
| 788 |
+
|
| 789 |
+
Prior to Django 1.2, Django used a number of settings to control
|
| 790 |
+
access to a single database. Django 1.2 introduces support for
|
| 791 |
+
multiple databases, and as a result the way you define database
|
| 792 |
+
settings has changed.
|
| 793 |
+
|
| 794 |
+
Any existing Django settings file will continue to work as expected
|
| 795 |
+
until Django 1.4. Until then, old-style database settings will be
|
| 796 |
+
automatically translated to the new-style format.
|
| 797 |
+
|
| 798 |
+
In the old-style (pre 1.2) format, you had a number of ``DATABASE_``
|
| 799 |
+
settings in your settings file. For example::
|
| 800 |
+
|
| 801 |
+
DATABASE_NAME = "test_db"
|
| 802 |
+
DATABASE_ENGINE = "postgresql_psycopg2"
|
| 803 |
+
DATABASE_USER = "myusername"
|
| 804 |
+
DATABASE_PASSWORD = "s3krit"
|
| 805 |
+
|
| 806 |
+
These settings are now in a dictionary named
|
| 807 |
+
:setting:`DATABASES`. Each item in the dictionary corresponds to a
|
| 808 |
+
single database connection, with the name ``'default'`` describing the
|
| 809 |
+
default database connection. The setting names have also been
|
| 810 |
+
shortened. The previous sample settings would now look like this::
|
| 811 |
+
|
| 812 |
+
DATABASES = {
|
| 813 |
+
"default": {
|
| 814 |
+
"NAME": "test_db",
|
| 815 |
+
"ENGINE": "django.db.backends.postgresql_psycopg2",
|
| 816 |
+
"USER": "myusername",
|
| 817 |
+
"PASSWORD": "s3krit",
|
| 818 |
+
}
|
| 819 |
+
}
|
| 820 |
+
|
| 821 |
+
This affects the following settings:
|
| 822 |
+
|
| 823 |
+
========================================= ==========================
|
| 824 |
+
Old setting New Setting
|
| 825 |
+
========================================= ==========================
|
| 826 |
+
``DATABASE_ENGINE`` :setting:`ENGINE <DATABASE-ENGINE>`
|
| 827 |
+
``DATABASE_HOST`` :setting:`HOST`
|
| 828 |
+
``DATABASE_NAME`` :setting:`NAME`
|
| 829 |
+
``DATABASE_OPTIONS`` :setting:`OPTIONS`
|
| 830 |
+
``DATABASE_PASSWORD`` :setting:`PASSWORD`
|
| 831 |
+
``DATABASE_PORT`` :setting:`PORT`
|
| 832 |
+
``DATABASE_USER`` :setting:`USER`
|
| 833 |
+
``TEST_DATABASE_CHARSET`` :setting:`TEST_CHARSET`
|
| 834 |
+
``TEST_DATABASE_COLLATION`` :setting:`TEST_COLLATION`
|
| 835 |
+
``TEST_DATABASE_NAME`` :setting:`TEST_NAME`
|
| 836 |
+
========================================= ==========================
|
| 837 |
+
|
| 838 |
+
These changes are also required if you have manually created a database
|
| 839 |
+
connection using ``DatabaseWrapper()`` from your database backend of choice.
|
| 840 |
+
|
| 841 |
+
In addition to the change in structure, Django 1.2 removes the special
|
| 842 |
+
handling for the built-in database backends. All database backends
|
| 843 |
+
must now be specified by a fully qualified module name (i.e.,
|
| 844 |
+
``django.db.backends.postgresql_psycopg2``, rather than just
|
| 845 |
+
``postgresql_psycopg2``).
|
| 846 |
+
|
| 847 |
+
``postgresql`` database backend
|
| 848 |
+
-------------------------------
|
| 849 |
+
|
| 850 |
+
The ``psycopg1`` library has not been updated since October 2005. As a
|
| 851 |
+
result, the ``postgresql`` database backend, which uses this library,
|
| 852 |
+
has been deprecated.
|
| 853 |
+
|
| 854 |
+
If you are currently using the ``postgresql`` backend, you should
|
| 855 |
+
migrate to using the ``postgresql_psycopg2`` backend. To update your
|
| 856 |
+
code, install the ``psycopg2`` library and change the
|
| 857 |
+
:setting:`ENGINE <DATABASE-ENGINE>` setting to use
|
| 858 |
+
``django.db.backends.postgresql_psycopg2``.
|
| 859 |
+
|
| 860 |
+
CSRF response-rewriting middleware
|
| 861 |
+
----------------------------------
|
| 862 |
+
|
| 863 |
+
``CsrfResponseMiddleware``, the middleware that automatically inserted
|
| 864 |
+
CSRF tokens into ``POST`` forms in outgoing pages, has been deprecated
|
| 865 |
+
in favor of a template tag method (see above), and will be removed
|
| 866 |
+
completely in Django 1.4. ``CsrfMiddleware``, which includes the
|
| 867 |
+
functionality of ``CsrfResponseMiddleware`` and
|
| 868 |
+
``CsrfViewMiddleware``, has likewise been deprecated.
|
| 869 |
+
|
| 870 |
+
Also, the CSRF module has moved from contrib to core, and the old
|
| 871 |
+
imports are deprecated, as described in the upgrading notes.
|
| 872 |
+
|
| 873 |
+
.. admonition:: Documentation removed
|
| 874 |
+
|
| 875 |
+
The upgrade notes have been removed in current Django docs. Please refer
|
| 876 |
+
to the docs for Django 1.3 or older to find these instructions.
|
| 877 |
+
|
| 878 |
+
``SMTPConnection``
|
| 879 |
+
------------------
|
| 880 |
+
|
| 881 |
+
The ``SMTPConnection`` class has been deprecated in favor of a generic
|
| 882 |
+
email backend API. Old code that explicitly instantiated an instance
|
| 883 |
+
of an SMTPConnection::
|
| 884 |
+
|
| 885 |
+
from django.core.mail import SMTPConnection
|
| 886 |
+
|
| 887 |
+
connection = SMTPConnection()
|
| 888 |
+
messages = get_notification_email()
|
| 889 |
+
connection.send_messages(messages)
|
| 890 |
+
|
| 891 |
+
...should now call :meth:`~django.core.mail.get_connection()` to
|
| 892 |
+
instantiate a generic email connection::
|
| 893 |
+
|
| 894 |
+
from django.core.mail import get_connection
|
| 895 |
+
|
| 896 |
+
connection = get_connection()
|
| 897 |
+
messages = get_notification_email()
|
| 898 |
+
connection.send_messages(messages)
|
| 899 |
+
|
| 900 |
+
Depending on the value of the :setting:`EMAIL_BACKEND` setting, this
|
| 901 |
+
may not return an SMTP connection. If you explicitly require an SMTP
|
| 902 |
+
connection with which to send email, you can explicitly request an
|
| 903 |
+
SMTP connection::
|
| 904 |
+
|
| 905 |
+
from django.core.mail import get_connection
|
| 906 |
+
|
| 907 |
+
connection = get_connection("django.core.mail.backends.smtp.EmailBackend")
|
| 908 |
+
messages = get_notification_email()
|
| 909 |
+
connection.send_messages(messages)
|
| 910 |
+
|
| 911 |
+
If your call to construct an instance of ``SMTPConnection`` required
|
| 912 |
+
additional arguments, those arguments can be passed to the
|
| 913 |
+
:meth:`~django.core.mail.get_connection()` call::
|
| 914 |
+
|
| 915 |
+
connection = get_connection(
|
| 916 |
+
"django.core.mail.backends.smtp.EmailBackend", hostname="localhost", port=1234
|
| 917 |
+
)
|
| 918 |
+
|
| 919 |
+
User Messages API
|
| 920 |
+
-----------------
|
| 921 |
+
|
| 922 |
+
The API for storing messages in the user ``Message`` model (via
|
| 923 |
+
``user.message_set.create``) is now deprecated and will be removed in Django
|
| 924 |
+
1.4 according to the standard :doc:`release process </internals/release-process>`.
|
| 925 |
+
|
| 926 |
+
To upgrade your code, you need to replace any instances of this::
|
| 927 |
+
|
| 928 |
+
user.message_set.create("a message")
|
| 929 |
+
|
| 930 |
+
...with the following::
|
| 931 |
+
|
| 932 |
+
from django.contrib import messages
|
| 933 |
+
|
| 934 |
+
messages.add_message(request, messages.INFO, "a message")
|
| 935 |
+
|
| 936 |
+
Additionally, if you make use of the method, you need to replace the
|
| 937 |
+
following::
|
| 938 |
+
|
| 939 |
+
for message in user.get_and_delete_messages():
|
| 940 |
+
...
|
| 941 |
+
|
| 942 |
+
...with::
|
| 943 |
+
|
| 944 |
+
from django.contrib import messages
|
| 945 |
+
|
| 946 |
+
for message in messages.get_messages(request):
|
| 947 |
+
...
|
| 948 |
+
|
| 949 |
+
For more information, see the full
|
| 950 |
+
:doc:`messages documentation </ref/contrib/messages>`. You should begin to
|
| 951 |
+
update your code to use the new API immediately.
|
| 952 |
+
|
| 953 |
+
Date format helper functions
|
| 954 |
+
----------------------------
|
| 955 |
+
|
| 956 |
+
``django.utils.translation.get_date_formats()`` and
|
| 957 |
+
``django.utils.translation.get_partial_date_formats()`` have been deprecated
|
| 958 |
+
in favor of the appropriate calls to ``django.utils.formats.get_format()``,
|
| 959 |
+
which is locale-aware when ``USE_L10N`` is set to ``True``, and falls
|
| 960 |
+
back to default settings if set to ``False``.
|
| 961 |
+
|
| 962 |
+
To get the different date formats, instead of writing this::
|
| 963 |
+
|
| 964 |
+
from django.utils.translation import get_date_formats
|
| 965 |
+
|
| 966 |
+
date_format, datetime_format, time_format = get_date_formats()
|
| 967 |
+
|
| 968 |
+
...use::
|
| 969 |
+
|
| 970 |
+
from django.utils import formats
|
| 971 |
+
|
| 972 |
+
date_format = formats.get_format("DATE_FORMAT")
|
| 973 |
+
datetime_format = formats.get_format("DATETIME_FORMAT")
|
| 974 |
+
time_format = formats.get_format("TIME_FORMAT")
|
| 975 |
+
|
| 976 |
+
Or, when directly formatting a date value::
|
| 977 |
+
|
| 978 |
+
from django.utils import formats
|
| 979 |
+
|
| 980 |
+
value_formatted = formats.date_format(value, "DATETIME_FORMAT")
|
| 981 |
+
|
| 982 |
+
The same applies to the globals found in ``django.forms.fields``:
|
| 983 |
+
|
| 984 |
+
* ``DEFAULT_DATE_INPUT_FORMATS``
|
| 985 |
+
* ``DEFAULT_TIME_INPUT_FORMATS``
|
| 986 |
+
* ``DEFAULT_DATETIME_INPUT_FORMATS``
|
| 987 |
+
|
| 988 |
+
Use ``django.utils.formats.get_format()`` to get the appropriate formats.
|
| 989 |
+
|
| 990 |
+
Function-based test runners
|
| 991 |
+
---------------------------
|
| 992 |
+
|
| 993 |
+
Django 1.2 changes the test runner tools to use a class-based
|
| 994 |
+
approach. Old style function-based test runners will still work, but
|
| 995 |
+
should be updated to use the new :ref:`class-based runners
|
| 996 |
+
<topics-testing-test_runner>`.
|
| 997 |
+
|
| 998 |
+
.. _1.2-updating-feeds:
|
| 999 |
+
|
| 1000 |
+
``Feed`` in ``django.contrib.syndication.feeds``
|
| 1001 |
+
------------------------------------------------
|
| 1002 |
+
|
| 1003 |
+
The ``django.contrib.syndication.feeds.Feed`` class has been
|
| 1004 |
+
replaced by the :class:`django.contrib.syndication.views.Feed` class.
|
| 1005 |
+
The old ``feeds.Feed`` class is deprecated, and will be removed in
|
| 1006 |
+
Django 1.4.
|
| 1007 |
+
|
| 1008 |
+
The new class has an almost identical API, but allows instances to be
|
| 1009 |
+
used as views. For example, consider the use of the old framework in
|
| 1010 |
+
the following :doc:`URLconf </topics/http/urls>`::
|
| 1011 |
+
|
| 1012 |
+
from django.conf.urls.defaults import *
|
| 1013 |
+
from myproject.feeds import LatestEntries, LatestEntriesByCategory
|
| 1014 |
+
|
| 1015 |
+
feeds = {
|
| 1016 |
+
"latest": LatestEntries,
|
| 1017 |
+
"categories": LatestEntriesByCategory,
|
| 1018 |
+
}
|
| 1019 |
+
|
| 1020 |
+
urlpatterns = patterns(
|
| 1021 |
+
"",
|
| 1022 |
+
# ...
|
| 1023 |
+
(
|
| 1024 |
+
r"^feeds/(?P<url>.*)/$",
|
| 1025 |
+
"django.contrib.syndication.views.feed",
|
| 1026 |
+
{"feed_dict": feeds},
|
| 1027 |
+
),
|
| 1028 |
+
# ...
|
| 1029 |
+
)
|
| 1030 |
+
|
| 1031 |
+
Using the new Feed class, these feeds can be deployed directly as views::
|
| 1032 |
+
|
| 1033 |
+
from django.conf.urls.defaults import *
|
| 1034 |
+
from myproject.feeds import LatestEntries, LatestEntriesByCategory
|
| 1035 |
+
|
| 1036 |
+
urlpatterns = patterns(
|
| 1037 |
+
"",
|
| 1038 |
+
# ...
|
| 1039 |
+
(r"^feeds/latest/$", LatestEntries()),
|
| 1040 |
+
(r"^feeds/categories/(?P<category_id>\d+)/$", LatestEntriesByCategory()),
|
| 1041 |
+
# ...
|
| 1042 |
+
)
|
| 1043 |
+
|
| 1044 |
+
If you currently use the ``feed()`` view, the ``LatestEntries`` class would
|
| 1045 |
+
often not need to be modified apart from subclassing the new
|
| 1046 |
+
:class:`~django.contrib.syndication.views.Feed` class. The exception is if
|
| 1047 |
+
Django was automatically working out the name of the template to use to render
|
| 1048 |
+
the feed's description and title elements (if you were not specifying the
|
| 1049 |
+
``title_template`` and ``description_template`` attributes). You should ensure
|
| 1050 |
+
that you always specify ``title_template`` and ``description_template``
|
| 1051 |
+
attributes, or provide ``item_title()`` and ``item_description()`` methods.
|
| 1052 |
+
|
| 1053 |
+
However, ``LatestEntriesByCategory`` uses the ``get_object()`` method
|
| 1054 |
+
with the ``bits`` argument to specify a specific category to show. In
|
| 1055 |
+
the new :class:`~django.contrib.syndication.views.Feed` class,
|
| 1056 |
+
``get_object()`` method takes a ``request`` and arguments from the
|
| 1057 |
+
URL, so it would look like this::
|
| 1058 |
+
|
| 1059 |
+
from django.contrib.syndication.views import Feed
|
| 1060 |
+
from django.shortcuts import get_object_or_404
|
| 1061 |
+
from myproject.models import Category
|
| 1062 |
+
|
| 1063 |
+
|
| 1064 |
+
class LatestEntriesByCategory(Feed):
|
| 1065 |
+
def get_object(self, request, category_id):
|
| 1066 |
+
return get_object_or_404(Category, id=category_id)
|
| 1067 |
+
|
| 1068 |
+
# ...
|
| 1069 |
+
|
| 1070 |
+
Additionally, the ``get_feed()`` method on ``Feed`` classes now take
|
| 1071 |
+
different arguments, which may impact you if you use the ``Feed``
|
| 1072 |
+
classes directly. Instead of just taking an optional ``url`` argument,
|
| 1073 |
+
it now takes two arguments: the object returned by its own
|
| 1074 |
+
``get_object()`` method, and the current ``request`` object.
|
| 1075 |
+
|
| 1076 |
+
To take into account ``Feed`` classes not being initialized for each
|
| 1077 |
+
request, the ``__init__()`` method now takes no arguments by default.
|
| 1078 |
+
Previously it would have taken the ``slug`` from the URL and the
|
| 1079 |
+
``request`` object.
|
| 1080 |
+
|
| 1081 |
+
In accordance with `RSS best practices`_, RSS feeds will now include
|
| 1082 |
+
an ``atom:link`` element. You may need to update your tests to take
|
| 1083 |
+
this into account.
|
| 1084 |
+
|
| 1085 |
+
For more information, see the full :doc:`syndication framework
|
| 1086 |
+
documentation </ref/contrib/syndication>`.
|
| 1087 |
+
|
| 1088 |
+
.. _RSS best practices: https://www.rssboard.org/rss-profile
|
| 1089 |
+
|
| 1090 |
+
Technical message IDs
|
| 1091 |
+
---------------------
|
| 1092 |
+
|
| 1093 |
+
Up to version 1.1 Django used technical message IDs
|
| 1094 |
+
to provide localizers the possibility to translate date and time formats. They
|
| 1095 |
+
were translatable :term:`translation strings <translation string>` that could
|
| 1096 |
+
be recognized because they were all upper case (for example
|
| 1097 |
+
:setting:`DATETIME_FORMAT`, :setting:`DATE_FORMAT`, :setting:`TIME_FORMAT`).
|
| 1098 |
+
They have been deprecated in favor of the new :doc:`/topics/i18n/formatting`
|
| 1099 |
+
infrastructure that allows localizers to specify that information in a
|
| 1100 |
+
``formats.py`` file in the corresponding ``django/conf/locale/<locale name>/``
|
| 1101 |
+
directory.
|
| 1102 |
+
|
| 1103 |
+
GeoDjango
|
| 1104 |
+
---------
|
| 1105 |
+
|
| 1106 |
+
To allow support for multiple databases, the GeoDjango database internals were
|
| 1107 |
+
changed substantially. The largest backwards-incompatible change is that
|
| 1108 |
+
the module ``django.contrib.gis.db.backend`` was renamed to
|
| 1109 |
+
:mod:`django.contrib.gis.db.backends`, where the full-fledged
|
| 1110 |
+
:ref:`spatial database backends <spatial-backends>` now exist. The
|
| 1111 |
+
following sections provide information on the most-popular APIs that
|
| 1112 |
+
were affected by these changes.
|
| 1113 |
+
|
| 1114 |
+
``SpatialBackend``
|
| 1115 |
+
~~~~~~~~~~~~~~~~~~
|
| 1116 |
+
|
| 1117 |
+
Prior to the creation of the separate spatial backends, the
|
| 1118 |
+
``django.contrib.gis.db.backend.SpatialBackend`` object was
|
| 1119 |
+
provided as an abstraction to introspect on the capabilities of
|
| 1120 |
+
the spatial database. All of the attributes and routines provided by
|
| 1121 |
+
``SpatialBackend`` are now a part of the ``ops`` attribute of the
|
| 1122 |
+
database backend.
|
| 1123 |
+
|
| 1124 |
+
The old module ``django.contrib.gis.db.backend`` is still provided
|
| 1125 |
+
for backwards-compatibility access to a ``SpatialBackend`` object,
|
| 1126 |
+
which is just an alias to the ``ops`` module of the
|
| 1127 |
+
*default* spatial database connection.
|
| 1128 |
+
|
| 1129 |
+
Users that were relying on undocumented modules and objects
|
| 1130 |
+
within ``django.contrib.gis.db.backend``, rather the abstractions
|
| 1131 |
+
provided by ``SpatialBackend``, are required to modify their code.
|
| 1132 |
+
For example, the following import which would work in 1.1 and
|
| 1133 |
+
below::
|
| 1134 |
+
|
| 1135 |
+
from django.contrib.gis.db.backend.postgis import PostGISAdaptor
|
| 1136 |
+
|
| 1137 |
+
Would need to be changed::
|
| 1138 |
+
|
| 1139 |
+
from django.db import connection
|
| 1140 |
+
|
| 1141 |
+
PostGISAdaptor = connection.ops.Adapter
|
| 1142 |
+
|
| 1143 |
+
``SpatialRefSys`` and ``GeometryColumns`` models
|
| 1144 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 1145 |
+
|
| 1146 |
+
In previous versions of GeoDjango, :mod:`django.contrib.gis.db.models`
|
| 1147 |
+
had ``SpatialRefSys`` and ``GeometryColumns`` models for querying
|
| 1148 |
+
the OGC spatial metadata tables ``spatial_ref_sys`` and ``geometry_columns``,
|
| 1149 |
+
respectively.
|
| 1150 |
+
|
| 1151 |
+
While these aliases are still provided, they are only for the
|
| 1152 |
+
*default* database connection and exist only if the default connection
|
| 1153 |
+
is using a supported spatial database backend.
|
| 1154 |
+
|
| 1155 |
+
.. note::
|
| 1156 |
+
|
| 1157 |
+
Because the table structure of the OGC spatial metadata tables
|
| 1158 |
+
differs across spatial databases, the ``SpatialRefSys`` and
|
| 1159 |
+
``GeometryColumns`` models can no longer be associated with
|
| 1160 |
+
the ``gis`` application name. Thus, no models will be returned
|
| 1161 |
+
when using the ``get_models`` method in the following example:
|
| 1162 |
+
|
| 1163 |
+
.. code-block:: pycon
|
| 1164 |
+
|
| 1165 |
+
>>> from django.db.models import get_app, get_models
|
| 1166 |
+
>>> get_models(get_app("gis"))
|
| 1167 |
+
[]
|
| 1168 |
+
|
| 1169 |
+
To get the correct ``SpatialRefSys`` and ``GeometryColumns``
|
| 1170 |
+
for your spatial database use the methods provided by the spatial backend:
|
| 1171 |
+
|
| 1172 |
+
.. code-block:: pycon
|
| 1173 |
+
|
| 1174 |
+
>>> from django.db import connections
|
| 1175 |
+
>>> SpatialRefSys = connections["my_spatialite"].ops.spatial_ref_sys()
|
| 1176 |
+
>>> GeometryColumns = connections["my_postgis"].ops.geometry_columns()
|
| 1177 |
+
|
| 1178 |
+
.. note::
|
| 1179 |
+
|
| 1180 |
+
When using the models returned from the ``spatial_ref_sys()`` and
|
| 1181 |
+
``geometry_columns()`` method, you'll still need to use the
|
| 1182 |
+
correct database alias when querying on the non-default connection.
|
| 1183 |
+
In other words, to ensure that the models in the example above
|
| 1184 |
+
use the correct database::
|
| 1185 |
+
|
| 1186 |
+
sr_qs = SpatialRefSys.objects.using("my_spatialite").filter(...)
|
| 1187 |
+
gc_qs = GeometryColumns.objects.using("my_postgis").filter(...)
|
| 1188 |
+
|
| 1189 |
+
Language code ``no``
|
| 1190 |
+
--------------------
|
| 1191 |
+
|
| 1192 |
+
The currently used language code for Norwegian Bokmål ``no`` is being
|
| 1193 |
+
replaced by the more common language code ``nb``.
|
| 1194 |
+
|
| 1195 |
+
Function-based template loaders
|
| 1196 |
+
-------------------------------
|
| 1197 |
+
|
| 1198 |
+
Django 1.2 changes the template loading mechanism to use a class-based
|
| 1199 |
+
approach. Old style function-based template loaders will still work, but should
|
| 1200 |
+
be updated to use the new class-based template loaders.
|
testbed/django__django/docs/releases/1.3.1.txt
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.3.1 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*September 9, 2011*
|
| 6 |
+
|
| 7 |
+
Welcome to Django 1.3.1!
|
| 8 |
+
|
| 9 |
+
This is the first security release in the Django 1.3 series, fixing several
|
| 10 |
+
security issues in Django 1.3. Django 1.3.1 is a recommended upgrade for
|
| 11 |
+
all users of Django 1.3.
|
| 12 |
+
|
| 13 |
+
For a full list of issues addressed in this release, see the `security
|
| 14 |
+
advisory`_.
|
| 15 |
+
|
| 16 |
+
.. _security advisory: https://www.djangoproject.com/weblog/2011/sep/09/security-releases-issued/
|
testbed/django__django/docs/releases/1.3.4.txt
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.3.4 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*October 17, 2012*
|
| 6 |
+
|
| 7 |
+
This is the fourth release in the Django 1.3 series.
|
| 8 |
+
|
| 9 |
+
Host header poisoning
|
| 10 |
+
=====================
|
| 11 |
+
|
| 12 |
+
Some parts of Django -- independent of end-user-written applications -- make
|
| 13 |
+
use of full URLs, including domain name, which are generated from the HTTP Host
|
| 14 |
+
header. Some attacks against this are beyond Django's ability to control, and
|
| 15 |
+
require the web server to be properly configured; Django's documentation has
|
| 16 |
+
for some time contained notes advising users on such configuration.
|
| 17 |
+
|
| 18 |
+
Django's own built-in parsing of the Host header is, however, still vulnerable,
|
| 19 |
+
as was reported to us recently. The Host header parsing in Django 1.3.3 and
|
| 20 |
+
Django 1.4.1 -- specifically, ``django.http.HttpRequest.get_host()`` -- was
|
| 21 |
+
incorrectly handling username/password information in the header. Thus, for
|
| 22 |
+
example, the following Host header would be accepted by Django when running on
|
| 23 |
+
``validsite.com``:
|
| 24 |
+
|
| 25 |
+
.. code-block:: text
|
| 26 |
+
|
| 27 |
+
Host: validsite.com:random@evilsite.com
|
| 28 |
+
|
| 29 |
+
Using this, an attacker can cause parts of Django -- particularly the
|
| 30 |
+
password-reset mechanism -- to generate and display arbitrary URLs to users.
|
| 31 |
+
|
| 32 |
+
To remedy this, the parsing in ``HttpRequest.get_host()`` is being modified;
|
| 33 |
+
Host headers which contain potentially dangerous content (such as
|
| 34 |
+
username/password pairs) now raise the exception
|
| 35 |
+
:exc:`django.core.exceptions.SuspiciousOperation`.
|
| 36 |
+
|
| 37 |
+
Details of this issue were initially posted online as a `security advisory`_.
|
| 38 |
+
|
| 39 |
+
.. _security advisory: https://www.djangoproject.com/weblog/2012/oct/17/security/
|
testbed/django__django/docs/releases/1.3.6.txt
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.3.6 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*February 19, 2013*
|
| 6 |
+
|
| 7 |
+
Django 1.3.6 fixes four security issues present in previous Django releases in
|
| 8 |
+
the 1.3 series.
|
| 9 |
+
|
| 10 |
+
This is the sixth bugfix/security release in the Django 1.3 series.
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
Host header poisoning
|
| 14 |
+
=====================
|
| 15 |
+
|
| 16 |
+
Some parts of Django -- independent of end-user-written applications -- make
|
| 17 |
+
use of full URLs, including domain name, which are generated from the HTTP Host
|
| 18 |
+
header. Django's documentation has for some time contained notes advising users
|
| 19 |
+
on how to configure web servers to ensure that only valid Host headers can reach
|
| 20 |
+
the Django application. However, it has been reported to us that even with the
|
| 21 |
+
recommended web server configurations there are still techniques available for
|
| 22 |
+
tricking many common web servers into supplying the application with an
|
| 23 |
+
incorrect and possibly malicious Host header.
|
| 24 |
+
|
| 25 |
+
For this reason, Django 1.3.6 adds a new setting, ``ALLOWED_HOSTS``, which
|
| 26 |
+
should contain an explicit list of valid host/domain names for this site. A
|
| 27 |
+
request with a Host header not matching an entry in this list will raise
|
| 28 |
+
``SuspiciousOperation`` if ``request.get_host()`` is called. For full details
|
| 29 |
+
see the documentation for the :setting:`ALLOWED_HOSTS` setting.
|
| 30 |
+
|
| 31 |
+
The default value for this setting in Django 1.3.6 is ``['*']`` (matching any
|
| 32 |
+
host), for backwards-compatibility, but we strongly encourage all sites to set
|
| 33 |
+
a more restrictive value.
|
| 34 |
+
|
| 35 |
+
This host validation is disabled when ``DEBUG`` is ``True`` or when running tests.
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
XML deserialization
|
| 39 |
+
===================
|
| 40 |
+
|
| 41 |
+
The XML parser in the Python standard library is vulnerable to a number of
|
| 42 |
+
attacks via external entities and entity expansion. Django uses this parser for
|
| 43 |
+
deserializing XML-formatted database fixtures. The fixture deserializer is not
|
| 44 |
+
intended for use with untrusted data, but in order to err on the side of safety
|
| 45 |
+
in Django 1.3.6 the XML deserializer refuses to parse an XML document with a
|
| 46 |
+
DTD (DOCTYPE definition), which closes off these attack avenues.
|
| 47 |
+
|
| 48 |
+
These issues in the Python standard library are CVE-2013-1664 and
|
| 49 |
+
CVE-2013-1665. More information available `from the Python security team`_.
|
| 50 |
+
|
| 51 |
+
Django's XML serializer does not create documents with a DTD, so this should
|
| 52 |
+
not cause any issues with the typical round-trip from ``dumpdata`` to
|
| 53 |
+
``loaddata``, but if you feed your own XML documents to the ``loaddata``
|
| 54 |
+
management command, you will need to ensure they do not contain a DTD.
|
| 55 |
+
|
| 56 |
+
.. _from the Python security team: https://blog.python.org/2013/02/announcing-defusedxml-fixes-for-xml.html
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
Formset memory exhaustion
|
| 60 |
+
=========================
|
| 61 |
+
|
| 62 |
+
Previous versions of Django did not validate or limit the form-count data
|
| 63 |
+
provided by the client in a formset's management form, making it possible to
|
| 64 |
+
exhaust a server's available memory by forcing it to create very large numbers
|
| 65 |
+
of forms.
|
| 66 |
+
|
| 67 |
+
In Django 1.3.6, all formsets have a strictly-enforced maximum number of forms
|
| 68 |
+
(1000 by default, though it can be set higher via the ``max_num`` formset
|
| 69 |
+
factory argument).
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
Admin history view information leakage
|
| 73 |
+
======================================
|
| 74 |
+
|
| 75 |
+
In previous versions of Django, an admin user without change permission on a
|
| 76 |
+
model could still view the Unicode representation of instances via their admin
|
| 77 |
+
history log. Django 1.3.6 now limits the admin history log view for an object
|
| 78 |
+
to users with change permission for that model.
|
testbed/django__django/docs/releases/1.3.txt
ADDED
|
@@ -0,0 +1,899 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========================
|
| 2 |
+
Django 1.3 release notes
|
| 3 |
+
========================
|
| 4 |
+
|
| 5 |
+
*March 23, 2011*
|
| 6 |
+
|
| 7 |
+
Welcome to Django 1.3!
|
| 8 |
+
|
| 9 |
+
Nearly a year in the making, Django 1.3 includes quite a few :ref:`new features
|
| 10 |
+
<whats-new-1.3>` and plenty of bug fixes and improvements to existing features.
|
| 11 |
+
These release notes cover the new features in 1.3, as well as some
|
| 12 |
+
:ref:`backwards-incompatible changes <backwards-incompatible-changes-1.3>`
|
| 13 |
+
you'll want to be aware of when upgrading from Django 1.2 or older versions.
|
| 14 |
+
|
| 15 |
+
Overview
|
| 16 |
+
========
|
| 17 |
+
|
| 18 |
+
Django 1.3's focus has mostly been on resolving smaller, long-standing
|
| 19 |
+
feature requests, but that hasn't prevented a few fairly significant
|
| 20 |
+
new features from landing, including:
|
| 21 |
+
|
| 22 |
+
* A framework for writing `class-based views`_.
|
| 23 |
+
|
| 24 |
+
* Built-in support for `using Python's logging facilities`_.
|
| 25 |
+
|
| 26 |
+
* Contrib support for `easy handling of static files`_.
|
| 27 |
+
|
| 28 |
+
* Django's testing framework now supports (and ships with a copy of)
|
| 29 |
+
`the unittest2 library`_.
|
| 30 |
+
|
| 31 |
+
Wherever possible, new features are introduced in a backwards-compatible manner
|
| 32 |
+
per :doc:`our API stability policy </misc/api-stability>` policy. As a result
|
| 33 |
+
of this policy, Django 1.3 :ref:`begins the deprecation process for some
|
| 34 |
+
features <deprecated-features-1.3>`.
|
| 35 |
+
|
| 36 |
+
.. _using Python's logging facilities: `Logging`_
|
| 37 |
+
.. _easy handling of static files: `Extended static files handling`_
|
| 38 |
+
.. _the unittest2 library: `unittest2 support`_
|
| 39 |
+
|
| 40 |
+
Python compatibility
|
| 41 |
+
====================
|
| 42 |
+
|
| 43 |
+
The release of Django 1.2 was notable for having the first shift in
|
| 44 |
+
Django's Python compatibility policy; prior to Django 1.2, Django
|
| 45 |
+
supported any 2.x version of Python from 2.3 up. As of Django 1.2, the
|
| 46 |
+
minimum requirement was raised to Python 2.4.
|
| 47 |
+
|
| 48 |
+
Django 1.3 continues to support Python 2.4, but will be the final
|
| 49 |
+
Django release series to do so; beginning with Django 1.4, the minimum
|
| 50 |
+
supported Python version will be 2.5. A document outlining our full
|
| 51 |
+
timeline for deprecating Python 2.x and moving to Python 3.x will be
|
| 52 |
+
published shortly after the release of Django 1.3.
|
| 53 |
+
|
| 54 |
+
.. _whats-new-1.3:
|
| 55 |
+
|
| 56 |
+
What's new in Django 1.3
|
| 57 |
+
========================
|
| 58 |
+
|
| 59 |
+
Class-based views
|
| 60 |
+
-----------------
|
| 61 |
+
|
| 62 |
+
Django 1.3 adds a framework that allows you to use a class as a view.
|
| 63 |
+
This means you can compose a view out of a collection of methods that
|
| 64 |
+
can be subclassed and overridden to provide common views of data without
|
| 65 |
+
having to write too much code.
|
| 66 |
+
|
| 67 |
+
Analogs of all the old function-based generic views have been
|
| 68 |
+
provided, along with a completely generic view base class that can be
|
| 69 |
+
used as the basis for reusable applications that can be easily
|
| 70 |
+
extended.
|
| 71 |
+
|
| 72 |
+
See :doc:`the documentation on class-based generic views</topics/class-based-views/index>`
|
| 73 |
+
for more details. There is also a document to help you `convert
|
| 74 |
+
your function-based generic views to class-based
|
| 75 |
+
views <https://raw.githubusercontent.com/django/django/ea9dc9f4b03ae034c1dc080730422dda7a9c2e47/docs/topics/generic-views-migration.txt>`_.
|
| 76 |
+
|
| 77 |
+
Logging
|
| 78 |
+
-------
|
| 79 |
+
|
| 80 |
+
Django 1.3 adds framework-level support for Python's ``logging``
|
| 81 |
+
module. This means you can now easily configure and control logging
|
| 82 |
+
as part of your Django project. A number of logging handlers and
|
| 83 |
+
logging calls have been added to Django's own code as well -- most
|
| 84 |
+
notably, the error emails sent on an HTTP 500 server error are now
|
| 85 |
+
handled as a logging activity. See :doc:`the documentation on Django's
|
| 86 |
+
logging interface </topics/logging>` for more details.
|
| 87 |
+
|
| 88 |
+
Extended static files handling
|
| 89 |
+
------------------------------
|
| 90 |
+
|
| 91 |
+
Django 1.3 ships with a new contrib app --
|
| 92 |
+
``django.contrib.staticfiles`` -- to help developers handle the static
|
| 93 |
+
media files (images, CSS, JavaScript, etc.) that are needed to render
|
| 94 |
+
a complete web page.
|
| 95 |
+
|
| 96 |
+
In previous versions of Django, it was common to place static assets
|
| 97 |
+
in :setting:`MEDIA_ROOT` along with user-uploaded files, and serve
|
| 98 |
+
them both at :setting:`MEDIA_URL`. Part of the purpose of introducing
|
| 99 |
+
the ``staticfiles`` app is to make it easier to keep static files
|
| 100 |
+
separate from user-uploaded files. Static assets should now go in
|
| 101 |
+
``static/`` subdirectories of your apps or in other static assets
|
| 102 |
+
directories listed in :setting:`STATICFILES_DIRS`, and will be served
|
| 103 |
+
at :setting:`STATIC_URL`.
|
| 104 |
+
|
| 105 |
+
See the :doc:`reference documentation of the app </ref/contrib/staticfiles>`
|
| 106 |
+
for more details or learn how to :doc:`manage static files
|
| 107 |
+
</howto/static-files/index>`.
|
| 108 |
+
|
| 109 |
+
``unittest2`` support
|
| 110 |
+
----------------------
|
| 111 |
+
|
| 112 |
+
Python 2.7 introduced some major changes to the ``unittest`` library,
|
| 113 |
+
adding some extremely useful features. To ensure that every Django
|
| 114 |
+
project can benefit from these new features, Django ships with a copy
|
| 115 |
+
of :pypi:`unittest2`, a copy of the Python 2.7 ``unittest`` library,
|
| 116 |
+
backported for Python 2.4 compatibility.
|
| 117 |
+
|
| 118 |
+
To access this library, Django provides the ``django.utils.unittest``
|
| 119 |
+
module alias. If you are using Python 2.7, or you have installed
|
| 120 |
+
``unittest2`` locally, Django will map the alias to the installed
|
| 121 |
+
version of the ``unittest`` library. Otherwise, Django will use its own
|
| 122 |
+
bundled version of ``unittest2``.
|
| 123 |
+
|
| 124 |
+
To take advantage of this alias, simply use::
|
| 125 |
+
|
| 126 |
+
from django.utils import unittest
|
| 127 |
+
|
| 128 |
+
wherever you would have historically used::
|
| 129 |
+
|
| 130 |
+
import unittest
|
| 131 |
+
|
| 132 |
+
If you want to continue to use the base ``unittest`` library, you can --
|
| 133 |
+
you just won't get any of the nice new ``unittest2`` features.
|
| 134 |
+
|
| 135 |
+
Transaction context managers
|
| 136 |
+
----------------------------
|
| 137 |
+
|
| 138 |
+
Users of Python 2.5 and above may now use transaction management functions as
|
| 139 |
+
context managers. For example::
|
| 140 |
+
|
| 141 |
+
with transaction.autocommit():
|
| 142 |
+
...
|
| 143 |
+
|
| 144 |
+
Configurable delete-cascade
|
| 145 |
+
---------------------------
|
| 146 |
+
|
| 147 |
+
:class:`~django.db.models.ForeignKey` and
|
| 148 |
+
:class:`~django.db.models.OneToOneField` now accept an
|
| 149 |
+
:attr:`~django.db.models.ForeignKey.on_delete` argument to customize behavior
|
| 150 |
+
when the referenced object is deleted. Previously, deletes were always
|
| 151 |
+
cascaded; available alternatives now include set null, set default, set to any
|
| 152 |
+
value, protect, or do nothing.
|
| 153 |
+
|
| 154 |
+
For more information, see the :attr:`~django.db.models.ForeignKey.on_delete`
|
| 155 |
+
documentation.
|
| 156 |
+
|
| 157 |
+
Contextual markers and comments for translatable strings
|
| 158 |
+
--------------------------------------------------------
|
| 159 |
+
|
| 160 |
+
For translation strings with ambiguous meaning, you can now
|
| 161 |
+
use the ``pgettext`` function to specify the context of the string.
|
| 162 |
+
|
| 163 |
+
And if you just want to add some information for translators, you
|
| 164 |
+
can also add special translator comments in the source.
|
| 165 |
+
|
| 166 |
+
For more information, see :ref:`contextual-markers` and
|
| 167 |
+
:ref:`translator-comments`.
|
| 168 |
+
|
| 169 |
+
Improvements to built-in template tags
|
| 170 |
+
--------------------------------------
|
| 171 |
+
|
| 172 |
+
A number of improvements have been made to Django's built-in template tags:
|
| 173 |
+
|
| 174 |
+
* The :ttag:`include` tag now accepts a ``with`` option, allowing
|
| 175 |
+
you to specify context variables to the included template
|
| 176 |
+
|
| 177 |
+
* The :ttag:`include` tag now accepts an ``only`` option, allowing
|
| 178 |
+
you to exclude the current context from the included context
|
| 179 |
+
|
| 180 |
+
* The :ttag:`with` tag now allows you to define multiple context
|
| 181 |
+
variables in a single :ttag:`with` block.
|
| 182 |
+
|
| 183 |
+
* The :ttag:`load` tag now accepts a ``from`` argument, allowing
|
| 184 |
+
you to load a single tag or filter from a library.
|
| 185 |
+
|
| 186 |
+
TemplateResponse
|
| 187 |
+
----------------
|
| 188 |
+
|
| 189 |
+
It can sometimes be beneficial to allow decorators or middleware to
|
| 190 |
+
modify a response *after* it has been constructed by the view. For
|
| 191 |
+
example, you may want to change the template that is used, or put
|
| 192 |
+
additional data into the context.
|
| 193 |
+
|
| 194 |
+
However, you can't (easily) modify the content of a basic
|
| 195 |
+
:class:`~django.http.HttpResponse` after it has been constructed. To
|
| 196 |
+
overcome this limitation, Django 1.3 adds a new
|
| 197 |
+
:class:`~django.template.response.TemplateResponse` class. Unlike basic
|
| 198 |
+
:class:`~django.http.HttpResponse` objects,
|
| 199 |
+
:class:`~django.template.response.TemplateResponse` objects retain the details
|
| 200 |
+
of the template and context that was provided by the view to compute
|
| 201 |
+
the response. The final output of the response is not computed until
|
| 202 |
+
it is needed, later in the response process.
|
| 203 |
+
|
| 204 |
+
For more details, see the :doc:`documentation </ref/template-response>`
|
| 205 |
+
on the :class:`~django.template.response.TemplateResponse` class.
|
| 206 |
+
|
| 207 |
+
Caching changes
|
| 208 |
+
---------------
|
| 209 |
+
|
| 210 |
+
Django 1.3 sees the introduction of several improvements to the
|
| 211 |
+
Django's caching infrastructure.
|
| 212 |
+
|
| 213 |
+
Firstly, Django now supports multiple named caches. In the same way
|
| 214 |
+
that Django 1.2 introduced support for multiple database connections,
|
| 215 |
+
Django 1.3 allows you to use the new :setting:`CACHES` setting to
|
| 216 |
+
define multiple named cache connections.
|
| 217 |
+
|
| 218 |
+
Secondly, :ref:`versioning <cache_versioning>`, :ref:`site-wide
|
| 219 |
+
prefixing <cache_key_prefixing>` and :ref:`transformation
|
| 220 |
+
<cache_key_transformation>` have been added to the cache API.
|
| 221 |
+
|
| 222 |
+
Thirdly, :ref:`cache key creation <using-vary-headers>` has been
|
| 223 |
+
updated to take the request query string into account on ``GET``
|
| 224 |
+
requests.
|
| 225 |
+
|
| 226 |
+
Finally, support for pylibmc_ has been added to the memcached cache
|
| 227 |
+
backend.
|
| 228 |
+
|
| 229 |
+
For more details, see the :doc:`documentation on
|
| 230 |
+
caching in Django</topics/cache>`.
|
| 231 |
+
|
| 232 |
+
.. _pylibmc: http://sendapatch.se/projects/pylibmc/
|
| 233 |
+
|
| 234 |
+
Permissions for inactive users
|
| 235 |
+
------------------------------
|
| 236 |
+
|
| 237 |
+
If you provide a custom auth backend with ``supports_inactive_user``
|
| 238 |
+
set to ``True``, an inactive ``User`` instance will check the backend
|
| 239 |
+
for permissions. This is useful for further centralizing the
|
| 240 |
+
permission handling. See the :doc:`authentication docs </topics/auth/index>`
|
| 241 |
+
for more details.
|
| 242 |
+
|
| 243 |
+
GeoDjango
|
| 244 |
+
---------
|
| 245 |
+
|
| 246 |
+
The GeoDjango test suite is now included when
|
| 247 |
+
:ref:`running the Django test suite <running-unit-tests>` with ``runtests.py``
|
| 248 |
+
when using :ref:`spatial database backends <spatial-backends>`.
|
| 249 |
+
|
| 250 |
+
:setting:`MEDIA_URL` and :setting:`STATIC_URL` must end in a slash
|
| 251 |
+
------------------------------------------------------------------
|
| 252 |
+
|
| 253 |
+
Previously, the :setting:`MEDIA_URL` setting only required a trailing slash if
|
| 254 |
+
it contained a suffix beyond the domain name.
|
| 255 |
+
|
| 256 |
+
A trailing slash is now *required* for :setting:`MEDIA_URL` and the new
|
| 257 |
+
:setting:`STATIC_URL` setting as long as it is not blank. This ensures there is
|
| 258 |
+
a consistent way to combine paths in templates.
|
| 259 |
+
|
| 260 |
+
Project settings which provide either of both settings without a trailing
|
| 261 |
+
slash will now raise a ``PendingDeprecationWarning``.
|
| 262 |
+
|
| 263 |
+
In Django 1.4 this same condition will raise ``DeprecationWarning``,
|
| 264 |
+
and in Django 1.5 will raise an ``ImproperlyConfigured`` exception.
|
| 265 |
+
|
| 266 |
+
Everything else
|
| 267 |
+
---------------
|
| 268 |
+
|
| 269 |
+
Django :doc:`1.1 <1.1>` and :doc:`1.2 <1.2>` added
|
| 270 |
+
lots of big ticket items to Django, like multiple-database support,
|
| 271 |
+
model validation, and a session-based messages framework. However,
|
| 272 |
+
this focus on big features came at the cost of lots of smaller
|
| 273 |
+
features.
|
| 274 |
+
|
| 275 |
+
To compensate for this, the focus of the Django 1.3 development
|
| 276 |
+
process has been on adding lots of smaller, long standing feature
|
| 277 |
+
requests. These include:
|
| 278 |
+
|
| 279 |
+
* Improved tools for accessing and manipulating the current
|
| 280 |
+
:class:`~django.contrib.sites.models.Site` object in
|
| 281 |
+
:doc:`the sites framework </ref/contrib/sites>`.
|
| 282 |
+
|
| 283 |
+
* A :class:`~django.test.RequestFactory` for mocking requests
|
| 284 |
+
in tests.
|
| 285 |
+
|
| 286 |
+
* A new test assertion --
|
| 287 |
+
:meth:`~django.test.TransactionTestCase.assertNumQueries` -- making it
|
| 288 |
+
easier to test the database activity associated with a view.
|
| 289 |
+
|
| 290 |
+
* Support for lookups spanning relations in admin's
|
| 291 |
+
:attr:`~django.contrib.admin.ModelAdmin.list_filter`.
|
| 292 |
+
|
| 293 |
+
* Support for HttpOnly_ cookies.
|
| 294 |
+
|
| 295 |
+
* :meth:`~django.core.mail.mail_admins()` and
|
| 296 |
+
:meth:`~django.core.mail.mail_managers()` now support easily attaching
|
| 297 |
+
HTML content to messages.
|
| 298 |
+
|
| 299 |
+
* :class:`~django.core.mail.EmailMessage` now supports CC's.
|
| 300 |
+
|
| 301 |
+
* Error emails now include more of the detail and formatting of the
|
| 302 |
+
debug server error page.
|
| 303 |
+
|
| 304 |
+
* :meth:`~django.template.Library.simple_tag` now accepts a
|
| 305 |
+
``takes_context`` argument, making it easier to write simple
|
| 306 |
+
template tags that require access to template context.
|
| 307 |
+
|
| 308 |
+
* A new :meth:`~django.shortcuts.render()` shortcut -- an alternative
|
| 309 |
+
to ``django.shortcuts.render_to_response()`` providing a
|
| 310 |
+
:class:`~django.template.RequestContext` by default.
|
| 311 |
+
|
| 312 |
+
* Support for combining :class:`F expressions <django.db.models.F>`
|
| 313 |
+
with ``timedelta`` values when retrieving or updating database values.
|
| 314 |
+
|
| 315 |
+
.. _HttpOnly: https://owasp.org/www-community/HttpOnly
|
| 316 |
+
|
| 317 |
+
.. _backwards-incompatible-changes-1.3:
|
| 318 |
+
|
| 319 |
+
Backwards-incompatible changes in 1.3
|
| 320 |
+
=====================================
|
| 321 |
+
|
| 322 |
+
CSRF validation now applies to AJAX requests
|
| 323 |
+
--------------------------------------------
|
| 324 |
+
|
| 325 |
+
Prior to Django 1.2.5, Django's CSRF-prevention system exempted AJAX
|
| 326 |
+
requests from CSRF verification; due to `security issues`_ reported to
|
| 327 |
+
us, however, *all* requests are now subjected to CSRF
|
| 328 |
+
verification. Consult :doc:`the Django CSRF documentation
|
| 329 |
+
</ref/csrf>` for details on how to handle CSRF verification in
|
| 330 |
+
AJAX requests.
|
| 331 |
+
|
| 332 |
+
.. _security issues: https://www.djangoproject.com/weblog/2011/feb/08/security/
|
| 333 |
+
|
| 334 |
+
Restricted filters in admin interface
|
| 335 |
+
-------------------------------------
|
| 336 |
+
|
| 337 |
+
Prior to Django 1.2.5, the Django administrative interface allowed
|
| 338 |
+
filtering on any model field or relation -- not just those specified
|
| 339 |
+
in ``list_filter`` -- via query string manipulation. Due to security
|
| 340 |
+
issues reported to us, however, query string lookup arguments in the
|
| 341 |
+
admin must be for fields or relations specified in ``list_filter`` or
|
| 342 |
+
``date_hierarchy``.
|
| 343 |
+
|
| 344 |
+
Deleting a model doesn't delete associated files
|
| 345 |
+
------------------------------------------------
|
| 346 |
+
|
| 347 |
+
In earlier Django versions, when a model instance containing a
|
| 348 |
+
:class:`~django.db.models.FileField` was deleted,
|
| 349 |
+
:class:`~django.db.models.FileField` took it upon itself to also delete the
|
| 350 |
+
file from the backend storage. This opened the door to several data-loss
|
| 351 |
+
scenarios, including rolled-back transactions and fields on different models
|
| 352 |
+
referencing the same file. In Django 1.3, when a model is deleted the
|
| 353 |
+
:class:`~django.db.models.FileField`’s ``delete()`` method won't be called. If
|
| 354 |
+
you need cleanup of orphaned files, you'll need to handle it yourself (for
|
| 355 |
+
instance, with a custom management command that can be run manually or
|
| 356 |
+
scheduled to run periodically via e.g. cron).
|
| 357 |
+
|
| 358 |
+
PasswordInput default rendering behavior
|
| 359 |
+
----------------------------------------
|
| 360 |
+
|
| 361 |
+
The :class:`~django.forms.PasswordInput` form widget, intended for use
|
| 362 |
+
with form fields which represent passwords, accepts a boolean keyword
|
| 363 |
+
argument ``render_value`` indicating whether to send its data back to
|
| 364 |
+
the browser when displaying a submitted form with errors. Prior to
|
| 365 |
+
Django 1.3, this argument defaulted to ``True``, meaning that the
|
| 366 |
+
submitted password would be sent back to the browser as part of the
|
| 367 |
+
form. Developers who wished to add a bit of additional security by
|
| 368 |
+
excluding that value from the redisplayed form could instantiate a
|
| 369 |
+
:class:`~django.forms.PasswordInput` passing ``render_value=False`` .
|
| 370 |
+
|
| 371 |
+
Due to the sensitive nature of passwords, however, Django 1.3 takes
|
| 372 |
+
this step automatically; the default value of ``render_value`` is now
|
| 373 |
+
``False``, and developers who want the password value returned to the
|
| 374 |
+
browser on a submission with errors (the previous behavior) must now
|
| 375 |
+
explicitly indicate this. For example::
|
| 376 |
+
|
| 377 |
+
class LoginForm(forms.Form):
|
| 378 |
+
username = forms.CharField(max_length=100)
|
| 379 |
+
password = forms.CharField(widget=forms.PasswordInput(render_value=True))
|
| 380 |
+
|
| 381 |
+
Clearable default widget for FileField
|
| 382 |
+
--------------------------------------
|
| 383 |
+
|
| 384 |
+
Django 1.3 now includes a :class:`~django.forms.ClearableFileInput` form widget
|
| 385 |
+
in addition to :class:`~django.forms.FileInput`. ``ClearableFileInput`` renders
|
| 386 |
+
with a checkbox to clear the field's value (if the field has a value and is not
|
| 387 |
+
required); ``FileInput`` provided no means for clearing an existing file from
|
| 388 |
+
a ``FileField``.
|
| 389 |
+
|
| 390 |
+
``ClearableFileInput`` is now the default widget for a ``FileField``, so
|
| 391 |
+
existing forms including ``FileField`` without assigning a custom widget will
|
| 392 |
+
need to account for the possible extra checkbox in the rendered form output.
|
| 393 |
+
|
| 394 |
+
To return to the previous rendering (without the ability to clear the
|
| 395 |
+
``FileField``), use the ``FileInput`` widget in place of
|
| 396 |
+
``ClearableFileInput``. For instance, in a ``ModelForm`` for a hypothetical
|
| 397 |
+
``Document`` model with a ``FileField`` named ``document``::
|
| 398 |
+
|
| 399 |
+
from django import forms
|
| 400 |
+
from myapp.models import Document
|
| 401 |
+
|
| 402 |
+
|
| 403 |
+
class DocumentForm(forms.ModelForm):
|
| 404 |
+
class Meta:
|
| 405 |
+
model = Document
|
| 406 |
+
widgets = {"document": forms.FileInput}
|
| 407 |
+
|
| 408 |
+
New index on database session table
|
| 409 |
+
-----------------------------------
|
| 410 |
+
|
| 411 |
+
Prior to Django 1.3, the database table used by the database backend
|
| 412 |
+
for the :doc:`sessions </topics/http/sessions>` app had no index on
|
| 413 |
+
the ``expire_date`` column. As a result, date-based queries on the
|
| 414 |
+
session table -- such as the query that is needed to purge old
|
| 415 |
+
sessions -- would be very slow if there were lots of sessions.
|
| 416 |
+
|
| 417 |
+
If you have an existing project that is using the database session
|
| 418 |
+
backend, you don't have to do anything to accommodate this change.
|
| 419 |
+
However, you may get a significant performance boost if you manually
|
| 420 |
+
add the new index to the session table. The SQL that will add the
|
| 421 |
+
index can be found by running the ``sqlindexes`` admin command:
|
| 422 |
+
|
| 423 |
+
.. code-block:: shell
|
| 424 |
+
|
| 425 |
+
python manage.py sqlindexes sessions
|
| 426 |
+
|
| 427 |
+
No more naughty words
|
| 428 |
+
---------------------
|
| 429 |
+
|
| 430 |
+
Django has historically provided (and enforced) a list of profanities.
|
| 431 |
+
The comments app has enforced this list of profanities, preventing people from
|
| 432 |
+
submitting comments that contained one of those profanities.
|
| 433 |
+
|
| 434 |
+
Unfortunately, the technique used to implement this profanities list
|
| 435 |
+
was woefully naive, and prone to the `Scunthorpe problem`_. Improving
|
| 436 |
+
the built-in filter to fix this problem would require significant
|
| 437 |
+
effort, and since natural language processing isn't the normal domain
|
| 438 |
+
of a web framework, we have "fixed" the problem by making the list of
|
| 439 |
+
prohibited words an empty list.
|
| 440 |
+
|
| 441 |
+
If you want to restore the old behavior, simply put a
|
| 442 |
+
``PROFANITIES_LIST`` setting in your settings file that includes the
|
| 443 |
+
words that you want to prohibit (see the :commit:`commit that implemented this
|
| 444 |
+
change <edd767d2612d891a906268cf590571f541dd164f>` if you want to see the list
|
| 445 |
+
of words that was historically prohibited). However, if avoiding profanities is
|
| 446 |
+
important to you, you would be well advised to seek out a better, less naive
|
| 447 |
+
approach to the problem.
|
| 448 |
+
|
| 449 |
+
.. _Scunthorpe problem: https://en.wikipedia.org/wiki/Scunthorpe_problem
|
| 450 |
+
|
| 451 |
+
Localflavor changes
|
| 452 |
+
-------------------
|
| 453 |
+
|
| 454 |
+
Django 1.3 introduces the following backwards-incompatible changes to
|
| 455 |
+
local flavors:
|
| 456 |
+
|
| 457 |
+
* Canada (ca) -- The province "Newfoundland and Labrador" has had its
|
| 458 |
+
province code updated to "NL", rather than the older "NF". In
|
| 459 |
+
addition, the Yukon Territory has had its province code corrected to
|
| 460 |
+
"YT", instead of "YK".
|
| 461 |
+
|
| 462 |
+
* Indonesia (id) -- The province "Nanggroe Aceh Darussalam (NAD)" has
|
| 463 |
+
been removed from the province list in favor of the new official
|
| 464 |
+
designation "Aceh (ACE)".
|
| 465 |
+
|
| 466 |
+
* United States of America (us) -- The list of "states" used by
|
| 467 |
+
``USStateField`` has expanded to include Armed Forces postal
|
| 468 |
+
codes. This is backwards-incompatible if you were relying on
|
| 469 |
+
``USStateField`` not including them.
|
| 470 |
+
|
| 471 |
+
FormSet updates
|
| 472 |
+
---------------
|
| 473 |
+
|
| 474 |
+
In Django 1.3 ``FormSet`` creation behavior is modified slightly. Historically
|
| 475 |
+
the class didn't make a distinction between not being passed data and being
|
| 476 |
+
passed empty dictionary. This was inconsistent with behavior in other parts of
|
| 477 |
+
the framework. Starting with 1.3 if you pass in empty dictionary the
|
| 478 |
+
``FormSet`` will raise a ``ValidationError``.
|
| 479 |
+
|
| 480 |
+
For example with a ``FormSet``:
|
| 481 |
+
|
| 482 |
+
.. code-block:: pycon
|
| 483 |
+
|
| 484 |
+
>>> class ArticleForm(Form):
|
| 485 |
+
... title = CharField()
|
| 486 |
+
... pub_date = DateField()
|
| 487 |
+
...
|
| 488 |
+
>>> ArticleFormSet = formset_factory(ArticleForm)
|
| 489 |
+
|
| 490 |
+
the following code will raise a ``ValidationError``:
|
| 491 |
+
|
| 492 |
+
.. code-block:: pycon
|
| 493 |
+
|
| 494 |
+
>>> ArticleFormSet({})
|
| 495 |
+
Traceback (most recent call last):
|
| 496 |
+
...
|
| 497 |
+
ValidationError: [u'ManagementForm data is missing or has been tampered with']
|
| 498 |
+
|
| 499 |
+
if you need to instantiate an empty ``FormSet``, don't pass in the data or use
|
| 500 |
+
``None``:
|
| 501 |
+
|
| 502 |
+
.. code-block:: pycon
|
| 503 |
+
|
| 504 |
+
>>> formset = ArticleFormSet()
|
| 505 |
+
>>> formset = ArticleFormSet(data=None)
|
| 506 |
+
|
| 507 |
+
Callables in templates
|
| 508 |
+
----------------------
|
| 509 |
+
|
| 510 |
+
Previously, a callable in a template would only be called automatically as part
|
| 511 |
+
of the variable resolution process if it was retrieved via attribute
|
| 512 |
+
lookup. This was an inconsistency that could result in confusing and unhelpful
|
| 513 |
+
behavior:
|
| 514 |
+
|
| 515 |
+
.. code-block:: pycon
|
| 516 |
+
|
| 517 |
+
>>> Template("{{ user.get_full_name }}").render(Context({"user": user}))
|
| 518 |
+
u'Joe Bloggs'
|
| 519 |
+
>>> Template("{{ full_name }}").render(Context({"full_name": user.get_full_name}))
|
| 520 |
+
u'<bound method User.get_full_name of <...
|
| 521 |
+
|
| 522 |
+
This has been resolved in Django 1.3 - the result in both cases will be ``u'Joe
|
| 523 |
+
Bloggs'``. Although the previous behavior was not useful for a template language
|
| 524 |
+
designed for web designers, and was never deliberately supported, it is possible
|
| 525 |
+
that some templates may be broken by this change.
|
| 526 |
+
|
| 527 |
+
Use of custom SQL to load initial data in tests
|
| 528 |
+
-----------------------------------------------
|
| 529 |
+
|
| 530 |
+
Django provides a custom SQL hooks as a way to inject hand-crafted SQL
|
| 531 |
+
into the database synchronization process. One of the possible uses
|
| 532 |
+
for this custom SQL is to insert data into your database. If your
|
| 533 |
+
custom SQL contains ``INSERT`` statements, those insertions will be
|
| 534 |
+
performed every time your database is synchronized. This includes the
|
| 535 |
+
synchronization of any test databases that are created when you run a
|
| 536 |
+
test suite.
|
| 537 |
+
|
| 538 |
+
However, in the process of testing the Django 1.3, it was discovered
|
| 539 |
+
that this feature has never completely worked as advertised. When
|
| 540 |
+
using database backends that don't support transactions, or when using
|
| 541 |
+
a TransactionTestCase, data that has been inserted using custom SQL
|
| 542 |
+
will not be visible during the testing process.
|
| 543 |
+
|
| 544 |
+
Unfortunately, there was no way to rectify this problem without
|
| 545 |
+
introducing a backwards incompatibility. Rather than leave
|
| 546 |
+
SQL-inserted initial data in an uncertain state, Django now enforces
|
| 547 |
+
the policy that data inserted by custom SQL will *not* be visible
|
| 548 |
+
during testing.
|
| 549 |
+
|
| 550 |
+
This change only affects the testing process. You can still use custom
|
| 551 |
+
SQL to load data into your production database as part of the ``syncdb``
|
| 552 |
+
process. If you require data to exist during test conditions, you
|
| 553 |
+
should either insert it using :ref:`test fixtures
|
| 554 |
+
<topics-testing-fixtures>`, or using the ``setUp()`` method of your
|
| 555 |
+
test case.
|
| 556 |
+
|
| 557 |
+
Changed priority of translation loading
|
| 558 |
+
---------------------------------------
|
| 559 |
+
|
| 560 |
+
Work has been done to simplify, rationalize and properly document the algorithm
|
| 561 |
+
used by Django at runtime to build translations from the different translations
|
| 562 |
+
found on disk, namely:
|
| 563 |
+
|
| 564 |
+
For translatable literals found in Python code and templates (``'django'``
|
| 565 |
+
gettext domain):
|
| 566 |
+
|
| 567 |
+
* Priorities of translations included with applications listed in the
|
| 568 |
+
:setting:`INSTALLED_APPS` setting were changed. To provide a behavior
|
| 569 |
+
consistent with other parts of Django that also use such setting (templates,
|
| 570 |
+
etc.) now, when building the translation that will be made available, the
|
| 571 |
+
apps listed first have higher precedence than the ones listed later.
|
| 572 |
+
|
| 573 |
+
* Now it is possible to override the translations shipped with applications by
|
| 574 |
+
using the :setting:`LOCALE_PATHS` setting whose translations have now higher
|
| 575 |
+
precedence than the translations of :setting:`INSTALLED_APPS` applications.
|
| 576 |
+
The relative priority among the values listed in this setting has also been
|
| 577 |
+
modified so the paths listed first have higher precedence than the
|
| 578 |
+
ones listed later.
|
| 579 |
+
|
| 580 |
+
* The ``locale`` subdirectory of the directory containing the settings, that
|
| 581 |
+
usually coincides with and is known as the *project directory* is being
|
| 582 |
+
deprecated in this release as a source of translations. (the precedence of
|
| 583 |
+
these translations is intermediate between applications and :setting:`LOCALE_PATHS`
|
| 584 |
+
translations). See the `corresponding deprecated features section`_
|
| 585 |
+
of this document.
|
| 586 |
+
|
| 587 |
+
For translatable literals found in JavaScript code (``'djangojs'`` gettext
|
| 588 |
+
domain):
|
| 589 |
+
|
| 590 |
+
* Similarly to the ``'django'`` domain translations: Overriding of
|
| 591 |
+
translations shipped with applications by using the :setting:`LOCALE_PATHS`
|
| 592 |
+
setting is now possible for this domain too. These translations have higher
|
| 593 |
+
precedence than the translations of Python packages passed to the
|
| 594 |
+
``javascript_catalog()`` view. Paths listed first have higher precedence than
|
| 595 |
+
the ones listed later.
|
| 596 |
+
|
| 597 |
+
* Translations under the ``locale`` subdirectory of the *project directory*
|
| 598 |
+
have never been taken in account for JavaScript translations and remain in
|
| 599 |
+
the same situation considering the deprecation of such location.
|
| 600 |
+
|
| 601 |
+
.. _corresponding deprecated features section: loading_of_project_level_translations_
|
| 602 |
+
|
| 603 |
+
Transaction management
|
| 604 |
+
----------------------
|
| 605 |
+
|
| 606 |
+
When using managed transactions -- that is, anything but the default
|
| 607 |
+
autocommit mode -- it is important when a transaction is marked as
|
| 608 |
+
"dirty". Dirty transactions are committed by the ``commit_on_success``
|
| 609 |
+
decorator or the ``django.middleware.transaction.TransactionMiddleware``, and
|
| 610 |
+
``commit_manually`` forces them to be closed explicitly; clean transactions
|
| 611 |
+
"get a pass", which means they are usually rolled back at the end of a request
|
| 612 |
+
when the connection is closed.
|
| 613 |
+
|
| 614 |
+
Until Django 1.3, transactions were only marked dirty when Django was
|
| 615 |
+
aware of a modifying operation performed in them; that is, either some
|
| 616 |
+
model was saved, some bulk update or delete was performed, or the user
|
| 617 |
+
explicitly called ``transaction.set_dirty()``. In Django 1.3, a
|
| 618 |
+
transaction is marked dirty when *any* database operation is
|
| 619 |
+
performed.
|
| 620 |
+
|
| 621 |
+
As a result of this change, you no longer need to set a transaction
|
| 622 |
+
dirty explicitly when you execute raw SQL or use a data-modifying
|
| 623 |
+
``SELECT``. However, you *do* need to explicitly close any read-only
|
| 624 |
+
transactions that are being managed using ``commit_manually()``. For example::
|
| 625 |
+
|
| 626 |
+
@transaction.commit_manually
|
| 627 |
+
def my_view(request, name):
|
| 628 |
+
obj = get_object_or_404(MyObject, name__iexact=name)
|
| 629 |
+
return render_to_response("template", {"object": obj})
|
| 630 |
+
|
| 631 |
+
Prior to Django 1.3, this would work without error. However, under
|
| 632 |
+
Django 1.3, this will raise a
|
| 633 |
+
:class:`~django.db.transaction.TransactionManagementError` because
|
| 634 |
+
the read operation that retrieves the ``MyObject`` instance leaves the
|
| 635 |
+
transaction in a dirty state.
|
| 636 |
+
|
| 637 |
+
No password reset for inactive users
|
| 638 |
+
------------------------------------
|
| 639 |
+
|
| 640 |
+
Prior to Django 1.3, inactive users were able to request a password reset email
|
| 641 |
+
and reset their password. In Django 1.3 inactive users will receive the same
|
| 642 |
+
message as a nonexistent account.
|
| 643 |
+
|
| 644 |
+
Password reset view now accepts ``from_email``
|
| 645 |
+
----------------------------------------------
|
| 646 |
+
|
| 647 |
+
The ``django.contrib.auth.views.password_reset()`` view now accepts a
|
| 648 |
+
``from_email`` parameter, which is passed to the ``password_reset_form``’s
|
| 649 |
+
``save()`` method as a keyword argument. If you are using this view with a
|
| 650 |
+
custom password reset form, then you will need to ensure your form's ``save()``
|
| 651 |
+
method accepts this keyword argument.
|
| 652 |
+
|
| 653 |
+
.. _deprecated-features-1.3:
|
| 654 |
+
|
| 655 |
+
Features deprecated in 1.3
|
| 656 |
+
==========================
|
| 657 |
+
|
| 658 |
+
Django 1.3 deprecates some features from earlier releases.
|
| 659 |
+
These features are still supported, but will be gradually phased out
|
| 660 |
+
over the next few release cycles.
|
| 661 |
+
|
| 662 |
+
Code taking advantage of any of the features below will raise a
|
| 663 |
+
``PendingDeprecationWarning`` in Django 1.3. This warning will be
|
| 664 |
+
silent by default, but may be turned on using Python's :mod:`warnings`
|
| 665 |
+
module, or by running Python with a ``-Wd`` or ``-Wall`` flag.
|
| 666 |
+
|
| 667 |
+
In Django 1.4, these warnings will become a ``DeprecationWarning``,
|
| 668 |
+
which is *not* silent. In Django 1.5 support for these features will
|
| 669 |
+
be removed entirely.
|
| 670 |
+
|
| 671 |
+
.. seealso::
|
| 672 |
+
|
| 673 |
+
For more details, see the documentation :doc:`Django's release process
|
| 674 |
+
</internals/release-process>` and our :doc:`deprecation timeline
|
| 675 |
+
</internals/deprecation>`.
|
| 676 |
+
|
| 677 |
+
``mod_python`` support
|
| 678 |
+
----------------------
|
| 679 |
+
|
| 680 |
+
The ``mod_python`` library has not had a release since 2007 or a commit since
|
| 681 |
+
2008. The Apache Foundation board voted to remove ``mod_python`` from the set
|
| 682 |
+
of active projects in its version control repositories, and its lead developer
|
| 683 |
+
has shifted all of his efforts toward the lighter, slimmer, more stable, and
|
| 684 |
+
more flexible ``mod_wsgi`` backend.
|
| 685 |
+
|
| 686 |
+
If you are currently using the ``mod_python`` request handler, you
|
| 687 |
+
should redeploy your Django projects using another request handler.
|
| 688 |
+
:doc:`mod_wsgi </howto/deployment/wsgi/modwsgi>` is the request handler
|
| 689 |
+
recommended by the Django project, but FastCGI is also supported. Support for
|
| 690 |
+
``mod_python`` deployment will be removed in Django 1.5.
|
| 691 |
+
|
| 692 |
+
Function-based generic views
|
| 693 |
+
----------------------------
|
| 694 |
+
|
| 695 |
+
As a result of the introduction of class-based generic views, the
|
| 696 |
+
function-based generic views provided by Django have been deprecated.
|
| 697 |
+
The following modules and the views they contain have been deprecated:
|
| 698 |
+
|
| 699 |
+
* ``django.views.generic.create_update``
|
| 700 |
+
* ``django.views.generic.date_based``
|
| 701 |
+
* ``django.views.generic.list_detail``
|
| 702 |
+
* ``django.views.generic.simple``
|
| 703 |
+
|
| 704 |
+
Test client response ``template`` attribute
|
| 705 |
+
-------------------------------------------
|
| 706 |
+
|
| 707 |
+
Django's :ref:`test client <test-client>` returns
|
| 708 |
+
:class:`~django.test.Response` objects annotated with extra testing
|
| 709 |
+
information. In Django versions prior to 1.3, this included a ``template``
|
| 710 |
+
attribute containing information about templates rendered in generating the
|
| 711 |
+
response: either None, a single :class:`~django.template.Template` object, or a
|
| 712 |
+
list of :class:`~django.template.Template` objects. This inconsistency in
|
| 713 |
+
return values (sometimes a list, sometimes not) made the attribute difficult
|
| 714 |
+
to work with.
|
| 715 |
+
|
| 716 |
+
In Django 1.3 the ``template`` attribute is deprecated in favor of a new
|
| 717 |
+
:attr:`~django.test.Response.templates` attribute, which is always a
|
| 718 |
+
list, even if it has only a single element or no elements.
|
| 719 |
+
|
| 720 |
+
``DjangoTestRunner``
|
| 721 |
+
--------------------
|
| 722 |
+
|
| 723 |
+
As a result of the introduction of support for ``unittest2``, the features
|
| 724 |
+
of ``django.test.simple.DjangoTestRunner`` (including fail-fast
|
| 725 |
+
and Ctrl-C test termination) have been made redundant. In view of this
|
| 726 |
+
redundancy, ``DjangoTestRunner`` has been turned into an empty placeholder
|
| 727 |
+
class, and will be removed entirely in Django 1.5.
|
| 728 |
+
|
| 729 |
+
Changes to ``url`` and ``ssi``
|
| 730 |
+
------------------------------
|
| 731 |
+
|
| 732 |
+
Most template tags will allow you to pass in either constants or
|
| 733 |
+
variables as arguments -- for example:
|
| 734 |
+
|
| 735 |
+
.. code-block:: html+django
|
| 736 |
+
|
| 737 |
+
{% extends "base.html" %}
|
| 738 |
+
|
| 739 |
+
allows you to specify a base template as a constant, but if you have a
|
| 740 |
+
context variable ``templ`` that contains the value ``base.html``:
|
| 741 |
+
|
| 742 |
+
.. code-block:: html+django
|
| 743 |
+
|
| 744 |
+
{% extends templ %}
|
| 745 |
+
|
| 746 |
+
is also legal.
|
| 747 |
+
|
| 748 |
+
However, due to an accident of history, the ``url`` and ``ssi`` are different.
|
| 749 |
+
These tags use the second, quoteless syntax, but interpret the argument as a
|
| 750 |
+
constant. This means it isn't possible to use a context variable as the target
|
| 751 |
+
of a ``url`` and ``ssi`` tag.
|
| 752 |
+
|
| 753 |
+
Django 1.3 marks the start of the process to correct this historical
|
| 754 |
+
accident. Django 1.3 adds a new template library -- ``future`` -- that
|
| 755 |
+
provides alternate implementations of the ``url`` and ``ssi``
|
| 756 |
+
template tags. This ``future`` library implement behavior that makes
|
| 757 |
+
the handling of the first argument consistent with the handling of all
|
| 758 |
+
other variables. So, an existing template that contains:
|
| 759 |
+
|
| 760 |
+
.. code-block:: html+django
|
| 761 |
+
|
| 762 |
+
{% url sample %}
|
| 763 |
+
|
| 764 |
+
should be replaced with:
|
| 765 |
+
|
| 766 |
+
.. code-block:: html+django
|
| 767 |
+
|
| 768 |
+
{% load url from future %}
|
| 769 |
+
{% url 'sample' %}
|
| 770 |
+
|
| 771 |
+
The tags implementing the old behavior have been deprecated, and in
|
| 772 |
+
Django 1.5, the old behavior will be replaced with the new behavior.
|
| 773 |
+
To ensure compatibility with future versions of Django, existing
|
| 774 |
+
templates should be modified to use the new ``future`` libraries and
|
| 775 |
+
syntax.
|
| 776 |
+
|
| 777 |
+
Changes to the login methods of the admin
|
| 778 |
+
-----------------------------------------
|
| 779 |
+
|
| 780 |
+
In previous version the admin app defined login methods in multiple locations
|
| 781 |
+
and ignored the almost identical implementation in the already used auth app.
|
| 782 |
+
A side effect of this duplication was the missing adoption of the changes made
|
| 783 |
+
in :commit:`r12634 <c8015052d935a99a5c8f96434b2d0cd16d8a4e14>` to support a
|
| 784 |
+
broader set of characters for usernames.
|
| 785 |
+
|
| 786 |
+
This release refactors the admin's login mechanism to use a subclass of the
|
| 787 |
+
:class:`~django.contrib.auth.forms.AuthenticationForm` instead of a manual
|
| 788 |
+
form validation. The previously undocumented method
|
| 789 |
+
``'django.contrib.admin.sites.AdminSite.display_login_form'`` has been removed
|
| 790 |
+
in favor of a new :attr:`~django.contrib.admin.AdminSite.login_form`
|
| 791 |
+
attribute.
|
| 792 |
+
|
| 793 |
+
``reset`` and ``sqlreset`` management commands
|
| 794 |
+
----------------------------------------------
|
| 795 |
+
|
| 796 |
+
Those commands have been deprecated. The ``flush`` and ``sqlflush`` commands
|
| 797 |
+
can be used to delete everything. You can also use ALTER TABLE or DROP TABLE
|
| 798 |
+
statements manually.
|
| 799 |
+
|
| 800 |
+
|
| 801 |
+
GeoDjango
|
| 802 |
+
---------
|
| 803 |
+
|
| 804 |
+
* The function-based :setting:`TEST_RUNNER` previously used to execute
|
| 805 |
+
the GeoDjango test suite, ``django.contrib.gis.tests.run_gis_tests``, was
|
| 806 |
+
deprecated for the class-based runner,
|
| 807 |
+
``django.contrib.gis.tests.GeoDjangoTestSuiteRunner``.
|
| 808 |
+
|
| 809 |
+
* Previously, calling
|
| 810 |
+
:meth:`~django.contrib.gis.geos.GEOSGeometry.transform` would
|
| 811 |
+
silently do nothing when GDAL wasn't available. Now, a
|
| 812 |
+
:class:`~django.contrib.gis.geos.GEOSException` is properly raised
|
| 813 |
+
to indicate possible faulty application code. A warning is now
|
| 814 |
+
raised if :meth:`~django.contrib.gis.geos.GEOSGeometry.transform` is
|
| 815 |
+
called when the SRID of the geometry is less than 0 or ``None``.
|
| 816 |
+
|
| 817 |
+
``CZBirthNumberField.clean``
|
| 818 |
+
----------------------------
|
| 819 |
+
|
| 820 |
+
Previously this field's ``clean()`` method accepted a second, gender, argument
|
| 821 |
+
which allowed stronger validation checks to be made, however since this
|
| 822 |
+
argument could never actually be passed from the Django form machinery it is
|
| 823 |
+
now pending deprecation.
|
| 824 |
+
|
| 825 |
+
``CompatCookie``
|
| 826 |
+
----------------
|
| 827 |
+
|
| 828 |
+
Previously, ``django.http`` exposed an undocumented ``CompatCookie`` class,
|
| 829 |
+
which was a bugfix wrapper around the standard library ``SimpleCookie``. As the
|
| 830 |
+
fixes are moving upstream, this is now deprecated - you should use ``from
|
| 831 |
+
django.http import SimpleCookie`` instead.
|
| 832 |
+
|
| 833 |
+
.. _loading_of_project_level_translations:
|
| 834 |
+
|
| 835 |
+
Loading of *project-level* translations
|
| 836 |
+
---------------------------------------
|
| 837 |
+
|
| 838 |
+
This release of Django starts the deprecation process for inclusion of
|
| 839 |
+
translations located under the so-called *project path* in the translation
|
| 840 |
+
building process performed at runtime. The :setting:`LOCALE_PATHS` setting can
|
| 841 |
+
be used for the same task by adding the filesystem path to a ``locale``
|
| 842 |
+
directory containing project-level translations to the value of that setting.
|
| 843 |
+
|
| 844 |
+
Rationale for this decision:
|
| 845 |
+
|
| 846 |
+
* The *project path* has always been a loosely defined concept
|
| 847 |
+
(actually, the directory used for locating project-level
|
| 848 |
+
translations is the directory containing the settings module) and
|
| 849 |
+
there has been a shift in other parts of the framework to stop using
|
| 850 |
+
it as a reference for location of assets at runtime.
|
| 851 |
+
|
| 852 |
+
* Detection of the ``locale`` subdirectory tends to fail when the
|
| 853 |
+
deployment scenario is more complex than the basic one. e.g. it
|
| 854 |
+
fails when the settings module is a directory (ticket #10765).
|
| 855 |
+
|
| 856 |
+
* There are potential strange development- and deployment-time
|
| 857 |
+
problems like the fact that the ``project_dir/locale/`` subdir can
|
| 858 |
+
generate spurious error messages when the project directory is added
|
| 859 |
+
to the Python path (``manage.py runserver`` does this) and then it
|
| 860 |
+
clashes with the equally named standard library module, this is a
|
| 861 |
+
typical warning message:
|
| 862 |
+
|
| 863 |
+
.. code-block:: pytb
|
| 864 |
+
|
| 865 |
+
/usr/lib/python2.6/gettext.py:49: ImportWarning: Not importing directory '/path/to/project/locale': missing __init__.py.
|
| 866 |
+
import locale, copy, os, re, struct, sys
|
| 867 |
+
|
| 868 |
+
* This location wasn't included in the translation building process
|
| 869 |
+
for JavaScript literals. This deprecation removes such
|
| 870 |
+
inconsistency.
|
| 871 |
+
|
| 872 |
+
``PermWrapper`` moved to ``django.contrib.auth.context_processors``
|
| 873 |
+
-------------------------------------------------------------------
|
| 874 |
+
|
| 875 |
+
In Django 1.2, we began the process of changing the location of the
|
| 876 |
+
``auth`` context processor from ``django.core.context_processors`` to
|
| 877 |
+
``django.contrib.auth.context_processors``. However, the
|
| 878 |
+
``PermWrapper`` support class was mistakenly omitted from that
|
| 879 |
+
migration. In Django 1.3, the ``PermWrapper`` class has also been
|
| 880 |
+
moved to ``django.contrib.auth.context_processors``, along with the
|
| 881 |
+
``PermLookupDict`` support class. The new classes are functionally
|
| 882 |
+
identical to their old versions; only the module location has changed.
|
| 883 |
+
|
| 884 |
+
Removal of ``XMLField``
|
| 885 |
+
-----------------------
|
| 886 |
+
|
| 887 |
+
When Django was first released, Django included an ``XMLField`` that performed
|
| 888 |
+
automatic XML validation for any field input. However, this validation function
|
| 889 |
+
hasn't been performed since the introduction of ``newforms``, prior to the 1.0
|
| 890 |
+
release. As a result, ``XMLField`` as currently implemented is functionally
|
| 891 |
+
indistinguishable from a simple :class:`~django.db.models.TextField`.
|
| 892 |
+
|
| 893 |
+
For this reason, Django 1.3 has fast-tracked the deprecation of
|
| 894 |
+
``XMLField`` -- instead of a two-release deprecation, ``XMLField``
|
| 895 |
+
will be removed entirely in Django 1.4.
|
| 896 |
+
|
| 897 |
+
It's easy to update your code to accommodate this change -- just
|
| 898 |
+
replace all uses of ``XMLField`` with ``TextField``, and remove the
|
| 899 |
+
``schema_path`` keyword argument (if it is specified).
|
testbed/django__django/docs/releases/1.4.12.txt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
===========================
|
| 2 |
+
Django 1.4.12 release notes
|
| 3 |
+
===========================
|
| 4 |
+
|
| 5 |
+
*April 28, 2014*
|
| 6 |
+
|
| 7 |
+
Django 1.4.12 fixes a regression in the 1.4.11 security release.
|
| 8 |
+
|
| 9 |
+
Bugfixes
|
| 10 |
+
========
|
| 11 |
+
|
| 12 |
+
* Restored the ability to ``reverse()`` views created using
|
| 13 |
+
:func:`functools.partial()` (:ticket:`22486`).
|
testbed/django__django/docs/releases/1.4.13.txt
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
===========================
|
| 2 |
+
Django 1.4.13 release notes
|
| 3 |
+
===========================
|
| 4 |
+
|
| 5 |
+
*May 14, 2014*
|
| 6 |
+
|
| 7 |
+
Django 1.4.13 fixes two security issues in 1.4.12.
|
| 8 |
+
|
| 9 |
+
Caches may incorrectly be allowed to store and serve private data
|
| 10 |
+
=================================================================
|
| 11 |
+
|
| 12 |
+
In certain situations, Django may allow caches to store private data
|
| 13 |
+
related to a particular session and then serve that data to requests
|
| 14 |
+
with a different session, or no session at all. This can lead to
|
| 15 |
+
information disclosure and can be a vector for cache poisoning.
|
| 16 |
+
|
| 17 |
+
When using Django sessions, Django will set a ``Vary: Cookie`` header to
|
| 18 |
+
ensure caches do not serve cached data to requests from other sessions.
|
| 19 |
+
However, older versions of Internet Explorer (most likely only Internet
|
| 20 |
+
Explorer 6, and Internet Explorer 7 if run on Windows XP or Windows Server
|
| 21 |
+
2003) are unable to handle the ``Vary`` header in combination with many content
|
| 22 |
+
types. Therefore, Django would remove the header if the request was made by
|
| 23 |
+
Internet Explorer.
|
| 24 |
+
|
| 25 |
+
To remedy this, the special behavior for these older Internet Explorer versions
|
| 26 |
+
has been removed, and the ``Vary`` header is no longer stripped from the response.
|
| 27 |
+
In addition, modifications to the ``Cache-Control`` header for all Internet Explorer
|
| 28 |
+
requests with a ``Content-Disposition`` header have also been removed as they
|
| 29 |
+
were found to have similar issues.
|
| 30 |
+
|
| 31 |
+
Malformed redirect URLs from user input not correctly validated
|
| 32 |
+
===============================================================
|
| 33 |
+
|
| 34 |
+
The validation for redirects did not correctly validate some malformed URLs,
|
| 35 |
+
which are accepted by some browsers. This allows a user to be redirected to
|
| 36 |
+
an unsafe URL unexpectedly.
|
| 37 |
+
|
| 38 |
+
Django relies on user input in some cases (e.g.
|
| 39 |
+
``django.contrib.auth.views.login()``, ``django.contrib.comments``, and
|
| 40 |
+
:doc:`i18n </topics/i18n/index>`) to redirect the user to an "on success" URL.
|
| 41 |
+
The security checks for these redirects (namely
|
| 42 |
+
``django.utils.http.is_safe_url()``) did not correctly validate some malformed
|
| 43 |
+
URLs, such as ``http:\\\\\\djangoproject.com``, which are accepted by some
|
| 44 |
+
browsers with more liberal URL parsing.
|
| 45 |
+
|
| 46 |
+
To remedy this, the validation in ``is_safe_url()`` has been tightened to be able
|
| 47 |
+
to handle and correctly validate these malformed URLs.
|
testbed/django__django/docs/releases/1.4.14.txt
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
===========================
|
| 2 |
+
Django 1.4.14 release notes
|
| 3 |
+
===========================
|
| 4 |
+
|
| 5 |
+
*August 20, 2014*
|
| 6 |
+
|
| 7 |
+
Django 1.4.14 fixes several security issues in 1.4.13.
|
| 8 |
+
|
| 9 |
+
``reverse()`` could generate URLs pointing to other hosts
|
| 10 |
+
=========================================================
|
| 11 |
+
|
| 12 |
+
In certain situations, URL reversing could generate scheme-relative URLs (URLs
|
| 13 |
+
starting with two slashes), which could unexpectedly redirect a user to a
|
| 14 |
+
different host. An attacker could exploit this, for example, by redirecting
|
| 15 |
+
users to a phishing site designed to ask for user's passwords.
|
| 16 |
+
|
| 17 |
+
To remedy this, URL reversing now ensures that no URL starts with two slashes
|
| 18 |
+
(//), replacing the second slash with its URL encoded counterpart (%2F). This
|
| 19 |
+
approach ensures that semantics stay the same, while making the URL relative to
|
| 20 |
+
the domain and not to the scheme.
|
| 21 |
+
|
| 22 |
+
File upload denial-of-service
|
| 23 |
+
=============================
|
| 24 |
+
|
| 25 |
+
Before this release, Django's file upload handing in its default configuration
|
| 26 |
+
may degrade to producing a huge number of ``os.stat()`` system calls when a
|
| 27 |
+
duplicate filename is uploaded. Since ``stat()`` may invoke IO, this may produce
|
| 28 |
+
a huge data-dependent slowdown that slowly worsens over time. The net result is
|
| 29 |
+
that given enough time, a user with the ability to upload files can cause poor
|
| 30 |
+
performance in the upload handler, eventually causing it to become very slow
|
| 31 |
+
simply by uploading 0-byte files. At this point, even a slow network connection
|
| 32 |
+
and few HTTP requests would be all that is necessary to make a site unavailable.
|
| 33 |
+
|
| 34 |
+
We've remedied the issue by changing the algorithm for generating file names
|
| 35 |
+
if a file with the uploaded name already exists.
|
| 36 |
+
:meth:`Storage.get_available_name()
|
| 37 |
+
<django.core.files.storage.Storage.get_available_name>` now appends an
|
| 38 |
+
underscore plus a random 7 character alphanumeric string (e.g. ``"_x3a1gho"``),
|
| 39 |
+
rather than iterating through an underscore followed by a number (e.g. ``"_1"``,
|
| 40 |
+
``"_2"``, etc.).
|
| 41 |
+
|
| 42 |
+
``RemoteUserMiddleware`` session hijacking
|
| 43 |
+
==========================================
|
| 44 |
+
|
| 45 |
+
When using the :class:`~django.contrib.auth.middleware.RemoteUserMiddleware`
|
| 46 |
+
and the ``RemoteUserBackend``, a change to the ``REMOTE_USER`` header between
|
| 47 |
+
requests without an intervening logout could result in the prior user's session
|
| 48 |
+
being co-opted by the subsequent user. The middleware now logs the user out on
|
| 49 |
+
a failed login attempt.
|
| 50 |
+
|
| 51 |
+
Data leakage via query string manipulation in ``contrib.admin``
|
| 52 |
+
===============================================================
|
| 53 |
+
|
| 54 |
+
In older versions of Django it was possible to reveal any field's data by
|
| 55 |
+
modifying the "popup" and "to_field" parameters of the query string on an admin
|
| 56 |
+
change form page. For example, requesting a URL like
|
| 57 |
+
``/admin/auth/user/?pop=1&t=password`` and viewing the page's HTML allowed
|
| 58 |
+
viewing the password hash of each user. While the admin requires users to have
|
| 59 |
+
permissions to view the change form pages in the first place, this could leak
|
| 60 |
+
data if you rely on users having access to view only certain fields on a model.
|
| 61 |
+
|
| 62 |
+
To address the issue, an exception will now be raised if a ``to_field`` value
|
| 63 |
+
that isn't a related field to a model that has been registered with the admin
|
| 64 |
+
is specified.
|
testbed/django__django/docs/releases/1.4.2.txt
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.4.2 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*October 17, 2012*
|
| 6 |
+
|
| 7 |
+
This is the second security release in the Django 1.4 series.
|
| 8 |
+
|
| 9 |
+
Host header poisoning
|
| 10 |
+
=====================
|
| 11 |
+
|
| 12 |
+
Some parts of Django -- independent of end-user-written applications -- make
|
| 13 |
+
use of full URLs, including domain name, which are generated from the HTTP Host
|
| 14 |
+
header. Some attacks against this are beyond Django's ability to control, and
|
| 15 |
+
require the web server to be properly configured; Django's documentation has
|
| 16 |
+
for some time contained notes advising users on such configuration.
|
| 17 |
+
|
| 18 |
+
Django's own built-in parsing of the Host header is, however, still vulnerable,
|
| 19 |
+
as was reported to us recently. The Host header parsing in Django 1.3.3 and
|
| 20 |
+
Django 1.4.1 -- specifically, ``django.http.HttpRequest.get_host()`` -- was
|
| 21 |
+
incorrectly handling username/password information in the header. Thus, for
|
| 22 |
+
example, the following Host header would be accepted by Django when running on
|
| 23 |
+
``validsite.com``:
|
| 24 |
+
|
| 25 |
+
.. code-block:: text
|
| 26 |
+
|
| 27 |
+
Host: validsite.com:random@evilsite.com
|
| 28 |
+
|
| 29 |
+
Using this, an attacker can cause parts of Django -- particularly the
|
| 30 |
+
password-reset mechanism -- to generate and display arbitrary URLs to users.
|
| 31 |
+
|
| 32 |
+
To remedy this, the parsing in ``HttpRequest.get_host()`` is being modified;
|
| 33 |
+
Host headers which contain potentially dangerous content (such as
|
| 34 |
+
username/password pairs) now raise the exception
|
| 35 |
+
:exc:`django.core.exceptions.SuspiciousOperation`.
|
| 36 |
+
|
| 37 |
+
Details of this issue were initially posted online as a `security advisory`_.
|
| 38 |
+
|
| 39 |
+
.. _security advisory: https://www.djangoproject.com/weblog/2012/oct/17/security/
|
| 40 |
+
|
| 41 |
+
Backwards incompatible changes
|
| 42 |
+
==============================
|
| 43 |
+
|
| 44 |
+
* The newly introduced :class:`~django.db.models.GenericIPAddressField`
|
| 45 |
+
constructor arguments have been adapted to match those of all other model
|
| 46 |
+
fields. The first two keyword arguments are now verbose_name and name.
|
| 47 |
+
|
| 48 |
+
Other bugfixes and changes
|
| 49 |
+
==========================
|
| 50 |
+
|
| 51 |
+
* Subclass HTMLParser only for appropriate Python versions (#18239).
|
| 52 |
+
* Added batch_size argument to qs.bulk_create() (#17788).
|
| 53 |
+
* Fixed a small regression in the admin filters where wrongly formatted dates passed as url parameters caused an unhandled ValidationError (#18530).
|
| 54 |
+
* Fixed an endless loop bug when accessing permissions in templates (#18979)
|
| 55 |
+
* Fixed some Python 2.5 compatibility issues
|
| 56 |
+
* Fixed an issue with quoted filenames in Content-Disposition header (#19006)
|
| 57 |
+
* Made the context option in ``trans`` and ``blocktrans`` tags accept literals wrapped in single quotes (#18881).
|
| 58 |
+
* Numerous documentation improvements and fixes.
|
testbed/django__django/docs/releases/1.4.4.txt
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.4.4 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*February 19, 2013*
|
| 6 |
+
|
| 7 |
+
Django 1.4.4 fixes four security issues present in previous Django releases in
|
| 8 |
+
the 1.4 series, as well as several other bugs and numerous documentation
|
| 9 |
+
improvements.
|
| 10 |
+
|
| 11 |
+
This is the fourth bugfix/security release in the Django 1.4 series.
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
Host header poisoning
|
| 15 |
+
=====================
|
| 16 |
+
|
| 17 |
+
Some parts of Django -- independent of end-user-written applications -- make
|
| 18 |
+
use of full URLs, including domain name, which are generated from the HTTP Host
|
| 19 |
+
header. Django's documentation has for some time contained notes advising users
|
| 20 |
+
on how to configure web servers to ensure that only valid Host headers can reach
|
| 21 |
+
the Django application. However, it has been reported to us that even with the
|
| 22 |
+
recommended web server configurations there are still techniques available for
|
| 23 |
+
tricking many common web servers into supplying the application with an
|
| 24 |
+
incorrect and possibly malicious Host header.
|
| 25 |
+
|
| 26 |
+
For this reason, Django 1.4.4 adds a new setting, ``ALLOWED_HOSTS``, containing
|
| 27 |
+
an explicit list of valid host/domain names for this site. A request with a
|
| 28 |
+
Host header not matching an entry in this list will raise
|
| 29 |
+
``SuspiciousOperation`` if ``request.get_host()`` is called. For full details
|
| 30 |
+
see the documentation for the :setting:`ALLOWED_HOSTS` setting.
|
| 31 |
+
|
| 32 |
+
The default value for this setting in Django 1.4.4 is ``['*']`` (matching any
|
| 33 |
+
host), for backwards-compatibility, but we strongly encourage all sites to set
|
| 34 |
+
a more restrictive value.
|
| 35 |
+
|
| 36 |
+
This host validation is disabled when ``DEBUG`` is ``True`` or when running tests.
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
XML deserialization
|
| 40 |
+
===================
|
| 41 |
+
|
| 42 |
+
The XML parser in the Python standard library is vulnerable to a number of
|
| 43 |
+
attacks via external entities and entity expansion. Django uses this parser for
|
| 44 |
+
deserializing XML-formatted database fixtures. This deserializer is not
|
| 45 |
+
intended for use with untrusted data, but in order to err on the side of safety
|
| 46 |
+
in Django 1.4.4 the XML deserializer refuses to parse an XML document with a
|
| 47 |
+
DTD (DOCTYPE definition), which closes off these attack avenues.
|
| 48 |
+
|
| 49 |
+
These issues in the Python standard library are CVE-2013-1664 and
|
| 50 |
+
CVE-2013-1665. More information available `from the Python security team`_.
|
| 51 |
+
|
| 52 |
+
Django's XML serializer does not create documents with a DTD, so this should
|
| 53 |
+
not cause any issues with the typical round-trip from ``dumpdata`` to
|
| 54 |
+
``loaddata``, but if you feed your own XML documents to the ``loaddata``
|
| 55 |
+
management command, you will need to ensure they do not contain a DTD.
|
| 56 |
+
|
| 57 |
+
.. _from the Python security team: https://blog.python.org/2013/02/announcing-defusedxml-fixes-for-xml.html
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
Formset memory exhaustion
|
| 61 |
+
=========================
|
| 62 |
+
|
| 63 |
+
Previous versions of Django did not validate or limit the form-count data
|
| 64 |
+
provided by the client in a formset's management form, making it possible to
|
| 65 |
+
exhaust a server's available memory by forcing it to create very large numbers
|
| 66 |
+
of forms.
|
| 67 |
+
|
| 68 |
+
In Django 1.4.4, all formsets have a strictly-enforced maximum number of forms
|
| 69 |
+
(1000 by default, though it can be set higher via the ``max_num`` formset
|
| 70 |
+
factory argument).
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
Admin history view information leakage
|
| 74 |
+
======================================
|
| 75 |
+
|
| 76 |
+
In previous versions of Django, an admin user without change permission on a
|
| 77 |
+
model could still view the Unicode representation of instances via their admin
|
| 78 |
+
history log. Django 1.4.4 now limits the admin history log view for an object
|
| 79 |
+
to users with change permission for that model.
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
Other bugfixes and changes
|
| 83 |
+
==========================
|
| 84 |
+
|
| 85 |
+
* Prevented transaction state from leaking from one request to the next (#19707).
|
| 86 |
+
* Changed an SQL command syntax to be MySQL 4 compatible (#19702).
|
| 87 |
+
* Added backwards-compatibility with old unsalted MD5 passwords (#18144).
|
| 88 |
+
* Numerous documentation improvements and fixes.
|
testbed/django__django/docs/releases/1.4.txt
ADDED
|
@@ -0,0 +1,1363 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
Welcome to Django 1.4!
|
| 8 |
+
|
| 9 |
+
These release notes cover the :ref:`new features <whats-new-1.4>`, as well as
|
| 10 |
+
some :ref:`backwards incompatible changes <backwards-incompatible-1.4>` you'll
|
| 11 |
+
want to be aware of when upgrading from Django 1.3 or older versions. We've
|
| 12 |
+
also dropped some features, which are detailed in :ref:`our deprecation plan
|
| 13 |
+
<deprecation-removed-in-1.4>`, and we've :ref:`begun the deprecation process
|
| 14 |
+
for some features <deprecated-features-1.4>`.
|
| 15 |
+
|
| 16 |
+
Overview
|
| 17 |
+
========
|
| 18 |
+
|
| 19 |
+
The biggest new feature in Django 1.4 is `support for time zones`_ when
|
| 20 |
+
handling date/times. When enabled, this Django will store date/times in UTC,
|
| 21 |
+
use timezone-aware objects internally, and translate them to users' local
|
| 22 |
+
timezones for display.
|
| 23 |
+
|
| 24 |
+
If you're upgrading an existing project to Django 1.4, switching to the timezone
|
| 25 |
+
aware mode may take some care: the new mode disallows some rather sloppy
|
| 26 |
+
behavior that used to be accepted. We encourage anyone who's upgrading to check
|
| 27 |
+
out the :ref:`timezone migration guide <time-zones-migration-guide>` and the
|
| 28 |
+
:ref:`timezone FAQ <time-zones-faq>` for useful pointers.
|
| 29 |
+
|
| 30 |
+
Other notable new features in Django 1.4 include:
|
| 31 |
+
|
| 32 |
+
* A number of ORM improvements, including `SELECT FOR UPDATE support`_,
|
| 33 |
+
the ability to `bulk insert <#model-objects-bulk-create-in-the-orm>`_
|
| 34 |
+
large datasets for improved performance, and
|
| 35 |
+
`QuerySet.prefetch_related`_, a method to batch-load related objects
|
| 36 |
+
in areas where :meth:`~django.db.models.query.QuerySet.select_related`
|
| 37 |
+
doesn't work.
|
| 38 |
+
|
| 39 |
+
* Some nice security additions, including `improved password hashing`_
|
| 40 |
+
(featuring PBKDF2_ and bcrypt_ support), new `tools for cryptographic
|
| 41 |
+
signing`_, several `CSRF improvements`_, and `simple clickjacking
|
| 42 |
+
protection`_.
|
| 43 |
+
|
| 44 |
+
* An `updated default project layout and manage.py`_ that removes the "magic"
|
| 45 |
+
from prior versions. And for those who don't like the new layout, you can
|
| 46 |
+
use `custom project and app templates`_ instead!
|
| 47 |
+
|
| 48 |
+
* `Support for in-browser testing frameworks`_ (like Selenium_).
|
| 49 |
+
|
| 50 |
+
* ... and a whole lot more; `see below <#what-s-new-in-django-1-4>`_!
|
| 51 |
+
|
| 52 |
+
Wherever possible we try to introduce new features in a backwards-compatible
|
| 53 |
+
manner per :doc:`our API stability policy </misc/api-stability>` policy.
|
| 54 |
+
However, as with previous releases, Django 1.4 ships with some minor
|
| 55 |
+
:ref:`backwards incompatible changes <backwards-incompatible-1.4>`; people
|
| 56 |
+
upgrading from previous versions of Django should read that list carefully.
|
| 57 |
+
|
| 58 |
+
Python compatibility
|
| 59 |
+
====================
|
| 60 |
+
|
| 61 |
+
Django 1.4 has dropped support for Python 2.4. Python 2.5 is now the minimum
|
| 62 |
+
required Python version. Django is tested and supported on Python 2.5, 2.6 and
|
| 63 |
+
2.7.
|
| 64 |
+
|
| 65 |
+
This change should affect only a small number of Django users, as most
|
| 66 |
+
operating-system vendors today are shipping Python 2.5 or newer as their default
|
| 67 |
+
version. If you're still using Python 2.4, however, you'll need to stick to
|
| 68 |
+
Django 1.3 until you can upgrade. Per :doc:`our support policy
|
| 69 |
+
</internals/release-process>`, Django 1.3 will continue to receive security
|
| 70 |
+
support until the release of Django 1.5.
|
| 71 |
+
|
| 72 |
+
Django does not support Python 3.x at this time. At some point before the
|
| 73 |
+
release of Django 1.4, we plan to publish a document outlining our full
|
| 74 |
+
timeline for deprecating Python 2.x and moving to Python 3.x.
|
| 75 |
+
|
| 76 |
+
.. _whats-new-1.4:
|
| 77 |
+
|
| 78 |
+
What's new in Django 1.4
|
| 79 |
+
========================
|
| 80 |
+
|
| 81 |
+
Support for time zones
|
| 82 |
+
----------------------
|
| 83 |
+
|
| 84 |
+
In previous versions, Django used "naive" date/times (that is, date/times
|
| 85 |
+
without an associated time zone), leaving it up to each developer to interpret
|
| 86 |
+
what a given date/time "really means". This can cause all sorts of subtle
|
| 87 |
+
timezone-related bugs.
|
| 88 |
+
|
| 89 |
+
In Django 1.4, you can now switch Django into a more correct, time-zone aware
|
| 90 |
+
mode. In this mode, Django stores date and time information in UTC in the
|
| 91 |
+
database, uses time-zone-aware datetime objects internally and translates them
|
| 92 |
+
to the end user's time zone in templates and forms. Reasons for using this
|
| 93 |
+
feature include:
|
| 94 |
+
|
| 95 |
+
- Customizing date and time display for users around the world.
|
| 96 |
+
|
| 97 |
+
- Storing datetimes in UTC for database portability and interoperability.
|
| 98 |
+
(This argument doesn't apply to PostgreSQL, because it already stores
|
| 99 |
+
timestamps with time zone information in Django 1.3.)
|
| 100 |
+
|
| 101 |
+
- Avoiding data corruption problems around DST transitions.
|
| 102 |
+
|
| 103 |
+
Time zone support is enabled by default in new projects created with
|
| 104 |
+
:djadmin:`startproject`. If you want to use this feature in an existing
|
| 105 |
+
project, read the :ref:`migration guide <time-zones-migration-guide>`. If you
|
| 106 |
+
encounter problems, there's a helpful :ref:`FAQ <time-zones-faq>`.
|
| 107 |
+
|
| 108 |
+
Support for in-browser testing frameworks
|
| 109 |
+
-----------------------------------------
|
| 110 |
+
|
| 111 |
+
Django 1.4 supports integration with in-browser testing frameworks like
|
| 112 |
+
Selenium_. The new :class:`django.test.LiveServerTestCase` base class lets you
|
| 113 |
+
test the interactions between your site's front and back ends more
|
| 114 |
+
comprehensively. See the
|
| 115 |
+
:class:`documentation<django.test.LiveServerTestCase>` for more details and
|
| 116 |
+
concrete examples.
|
| 117 |
+
|
| 118 |
+
.. _Selenium: https://www.selenium.dev/
|
| 119 |
+
|
| 120 |
+
Updated default project layout and ``manage.py``
|
| 121 |
+
------------------------------------------------
|
| 122 |
+
|
| 123 |
+
Django 1.4 ships with an updated default project layout and ``manage.py`` file
|
| 124 |
+
for the :djadmin:`startproject` management command. These fix some issues with
|
| 125 |
+
the previous ``manage.py`` handling of Python import paths that caused double
|
| 126 |
+
imports, trouble moving from development to deployment, and other
|
| 127 |
+
difficult-to-debug path issues.
|
| 128 |
+
|
| 129 |
+
The previous ``manage.py`` called functions that are now deprecated, and thus
|
| 130 |
+
projects upgrading to Django 1.4 should update their ``manage.py``. (The
|
| 131 |
+
old-style ``manage.py`` will continue to work as before until Django 1.6. In
|
| 132 |
+
1.5 it will raise ``DeprecationWarning``).
|
| 133 |
+
|
| 134 |
+
The new recommended ``manage.py`` file should look like this::
|
| 135 |
+
|
| 136 |
+
#!/usr/bin/env python
|
| 137 |
+
import os, sys
|
| 138 |
+
|
| 139 |
+
if __name__ == "__main__":
|
| 140 |
+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
|
| 141 |
+
|
| 142 |
+
from django.core.management import execute_from_command_line
|
| 143 |
+
|
| 144 |
+
execute_from_command_line(sys.argv)
|
| 145 |
+
|
| 146 |
+
``{{ project_name }}`` should be replaced with the Python package name of the
|
| 147 |
+
actual project.
|
| 148 |
+
|
| 149 |
+
If settings, URLconfs and apps within the project are imported or referenced
|
| 150 |
+
using the project name prefix (e.g. ``myproject.settings``, ``ROOT_URLCONF =
|
| 151 |
+
"myproject.urls"``, etc.), the new ``manage.py`` will need to be moved one
|
| 152 |
+
directory up, so it is outside the project package rather than adjacent to
|
| 153 |
+
``settings.py`` and ``urls.py``.
|
| 154 |
+
|
| 155 |
+
For instance, with the following layout:
|
| 156 |
+
|
| 157 |
+
.. code-block:: text
|
| 158 |
+
|
| 159 |
+
manage.py
|
| 160 |
+
mysite/
|
| 161 |
+
__init__.py
|
| 162 |
+
settings.py
|
| 163 |
+
urls.py
|
| 164 |
+
myapp/
|
| 165 |
+
__init__.py
|
| 166 |
+
models.py
|
| 167 |
+
|
| 168 |
+
You could import ``mysite.settings``, ``mysite.urls``, and ``mysite.myapp``,
|
| 169 |
+
but not ``settings``, ``urls``, or ``myapp`` as top-level modules.
|
| 170 |
+
|
| 171 |
+
Anything imported as a top-level module can be placed adjacent to the new
|
| 172 |
+
``manage.py``. For instance, to decouple ``myapp`` from the project module and
|
| 173 |
+
import it as just ``myapp``, place it outside the ``mysite/`` directory:
|
| 174 |
+
|
| 175 |
+
.. code-block:: text
|
| 176 |
+
|
| 177 |
+
manage.py
|
| 178 |
+
myapp/
|
| 179 |
+
__init__.py
|
| 180 |
+
models.py
|
| 181 |
+
mysite/
|
| 182 |
+
__init__.py
|
| 183 |
+
settings.py
|
| 184 |
+
urls.py
|
| 185 |
+
|
| 186 |
+
If the same code is imported inconsistently (some places with the project
|
| 187 |
+
prefix, some places without it), the imports will need to be cleaned up when
|
| 188 |
+
switching to the new ``manage.py``.
|
| 189 |
+
|
| 190 |
+
Custom project and app templates
|
| 191 |
+
--------------------------------
|
| 192 |
+
|
| 193 |
+
The :djadmin:`startapp` and :djadmin:`startproject` management commands
|
| 194 |
+
now have a ``--template`` option for specifying a path or URL to a custom app
|
| 195 |
+
or project template.
|
| 196 |
+
|
| 197 |
+
For example, Django will use the ``/path/to/my_project_template`` directory
|
| 198 |
+
when you run the following command:
|
| 199 |
+
|
| 200 |
+
.. code-block:: shell
|
| 201 |
+
|
| 202 |
+
django-admin.py startproject --template=/path/to/my_project_template myproject
|
| 203 |
+
|
| 204 |
+
You can also now provide a destination directory as the second
|
| 205 |
+
argument to both :djadmin:`startapp` and :djadmin:`startproject`:
|
| 206 |
+
|
| 207 |
+
.. code-block:: shell
|
| 208 |
+
|
| 209 |
+
django-admin.py startapp myapp /path/to/new/app
|
| 210 |
+
django-admin.py startproject myproject /path/to/new/project
|
| 211 |
+
|
| 212 |
+
For more information, see the :djadmin:`startapp` and :djadmin:`startproject`
|
| 213 |
+
documentation.
|
| 214 |
+
|
| 215 |
+
Improved WSGI support
|
| 216 |
+
---------------------
|
| 217 |
+
|
| 218 |
+
The :djadmin:`startproject` management command now adds a :file:`wsgi.py`
|
| 219 |
+
module to the initial project layout, containing a simple WSGI application that
|
| 220 |
+
can be used for :doc:`deploying with WSGI app
|
| 221 |
+
servers</howto/deployment/wsgi/index>`.
|
| 222 |
+
|
| 223 |
+
The :djadmin:`built-in development server<runserver>` now supports using an
|
| 224 |
+
externally-defined WSGI callable, which makes it possible to run ``runserver``
|
| 225 |
+
with the same WSGI configuration that is used for deployment. The new
|
| 226 |
+
:setting:`WSGI_APPLICATION` setting lets you configure which WSGI callable
|
| 227 |
+
:djadmin:`runserver` uses.
|
| 228 |
+
|
| 229 |
+
(The ``runfcgi`` management command also internally wraps the WSGI
|
| 230 |
+
callable configured via :setting:`WSGI_APPLICATION`.)
|
| 231 |
+
|
| 232 |
+
``SELECT FOR UPDATE`` support
|
| 233 |
+
-----------------------------
|
| 234 |
+
|
| 235 |
+
Django 1.4 includes a :meth:`QuerySet.select_for_update()
|
| 236 |
+
<django.db.models.query.QuerySet.select_for_update>` method, which generates a
|
| 237 |
+
``SELECT ... FOR UPDATE`` SQL query. This will lock rows until the end of the
|
| 238 |
+
transaction, meaning other transactions cannot modify or delete rows matched by
|
| 239 |
+
a ``FOR UPDATE`` query.
|
| 240 |
+
|
| 241 |
+
For more details, see the documentation for
|
| 242 |
+
:meth:`~django.db.models.query.QuerySet.select_for_update`.
|
| 243 |
+
|
| 244 |
+
``Model.objects.bulk_create`` in the ORM
|
| 245 |
+
----------------------------------------
|
| 246 |
+
|
| 247 |
+
This method lets you create multiple objects more efficiently. It can result in
|
| 248 |
+
significant performance increases if you have many objects.
|
| 249 |
+
|
| 250 |
+
Django makes use of this internally, meaning some operations (such as database
|
| 251 |
+
setup for test suites) have seen a performance benefit as a result.
|
| 252 |
+
|
| 253 |
+
See the :meth:`~django.db.models.query.QuerySet.bulk_create` docs for more
|
| 254 |
+
information.
|
| 255 |
+
|
| 256 |
+
``QuerySet.prefetch_related``
|
| 257 |
+
-----------------------------
|
| 258 |
+
|
| 259 |
+
Similar to :meth:`~django.db.models.query.QuerySet.select_related` but with a
|
| 260 |
+
different strategy and broader scope,
|
| 261 |
+
:meth:`~django.db.models.query.QuerySet.prefetch_related` has been added to
|
| 262 |
+
:class:`~django.db.models.query.QuerySet`. This method returns a new
|
| 263 |
+
``QuerySet`` that will prefetch each of the specified related lookups in a
|
| 264 |
+
single batch as soon as the query begins to be evaluated. Unlike
|
| 265 |
+
``select_related``, it does the joins in Python, not in the database, and
|
| 266 |
+
supports many-to-many relationships, ``GenericForeignKey`` and more. This
|
| 267 |
+
allows you to fix a very common performance problem in which your code ends up
|
| 268 |
+
doing O(n) database queries (or worse) if objects on your primary ``QuerySet``
|
| 269 |
+
each have many related objects that you also need to fetch.
|
| 270 |
+
|
| 271 |
+
Improved password hashing
|
| 272 |
+
-------------------------
|
| 273 |
+
|
| 274 |
+
Django's auth system (``django.contrib.auth``) stores passwords using a one-way
|
| 275 |
+
algorithm. Django 1.3 uses the SHA1_ algorithm, but increasing processor speeds
|
| 276 |
+
and theoretical attacks have revealed that SHA1 isn't as secure as we'd like.
|
| 277 |
+
Thus, Django 1.4 introduces a new password storage system: by default Django now
|
| 278 |
+
uses the PBKDF2_ algorithm (as recommended by NIST_). You can also easily choose
|
| 279 |
+
a different algorithm (including the popular bcrypt_ algorithm). For more
|
| 280 |
+
details, see :ref:`auth_password_storage`.
|
| 281 |
+
|
| 282 |
+
.. _sha1: https://en.wikipedia.org/wiki/SHA1
|
| 283 |
+
.. _pbkdf2: https://en.wikipedia.org/wiki/PBKDF2
|
| 284 |
+
.. _nist: https://csrc.nist.gov/publications/detail/sp/800-132/final
|
| 285 |
+
.. _bcrypt: https://en.wikipedia.org/wiki/Bcrypt
|
| 286 |
+
|
| 287 |
+
HTML5 doctype
|
| 288 |
+
-------------
|
| 289 |
+
|
| 290 |
+
We've switched the admin and other bundled templates to use the HTML5
|
| 291 |
+
doctype. While Django will be careful to maintain compatibility with older
|
| 292 |
+
browsers, this change means that you can use any HTML5 features you need in
|
| 293 |
+
admin pages without having to lose HTML validity or override the provided
|
| 294 |
+
templates to change the doctype.
|
| 295 |
+
|
| 296 |
+
List filters in admin interface
|
| 297 |
+
-------------------------------
|
| 298 |
+
|
| 299 |
+
Prior to Django 1.4, the :mod:`~django.contrib.admin` app let you specify
|
| 300 |
+
change list filters by specifying a field lookup, but it didn't allow you to
|
| 301 |
+
create custom filters. This has been rectified with a simple API (previously
|
| 302 |
+
used internally and known as "FilterSpec"). For more details, see the
|
| 303 |
+
documentation for :attr:`~django.contrib.admin.ModelAdmin.list_filter`.
|
| 304 |
+
|
| 305 |
+
Multiple sort in admin interface
|
| 306 |
+
--------------------------------
|
| 307 |
+
|
| 308 |
+
The admin change list now supports sorting on multiple columns. It respects all
|
| 309 |
+
elements of the :attr:`~django.contrib.admin.ModelAdmin.ordering` attribute, and
|
| 310 |
+
sorting on multiple columns by clicking on headers is designed to mimic the
|
| 311 |
+
behavior of desktop GUIs. We also added a
|
| 312 |
+
:meth:`~django.contrib.admin.ModelAdmin.get_ordering` method for specifying the
|
| 313 |
+
ordering dynamically (i.e., depending on the request).
|
| 314 |
+
|
| 315 |
+
New ``ModelAdmin`` methods
|
| 316 |
+
--------------------------
|
| 317 |
+
|
| 318 |
+
We added a :meth:`~django.contrib.admin.ModelAdmin.save_related` method to
|
| 319 |
+
:mod:`~django.contrib.admin.ModelAdmin` to ease customization of how
|
| 320 |
+
related objects are saved in the admin.
|
| 321 |
+
|
| 322 |
+
Two other new :class:`~django.contrib.admin.ModelAdmin` methods,
|
| 323 |
+
:meth:`~django.contrib.admin.ModelAdmin.get_list_display` and
|
| 324 |
+
:meth:`~django.contrib.admin.ModelAdmin.get_list_display_links`
|
| 325 |
+
enable dynamic customization of fields and links displayed on the admin
|
| 326 |
+
change list.
|
| 327 |
+
|
| 328 |
+
Admin inlines respect user permissions
|
| 329 |
+
--------------------------------------
|
| 330 |
+
|
| 331 |
+
Admin inlines now only allow those actions for which the user has
|
| 332 |
+
permission. For ``ManyToMany`` relationships with an auto-created intermediate
|
| 333 |
+
model (which does not have its own permissions), the change permission for the
|
| 334 |
+
related model determines if the user has the permission to add, change or
|
| 335 |
+
delete relationships.
|
| 336 |
+
|
| 337 |
+
Tools for cryptographic signing
|
| 338 |
+
-------------------------------
|
| 339 |
+
|
| 340 |
+
Django 1.4 adds both a low-level API for signing values and a high-level API
|
| 341 |
+
for setting and reading signed cookies, one of the most common uses of
|
| 342 |
+
signing in web applications.
|
| 343 |
+
|
| 344 |
+
See the :doc:`cryptographic signing </topics/signing>` docs for more
|
| 345 |
+
information.
|
| 346 |
+
|
| 347 |
+
Cookie-based session backend
|
| 348 |
+
----------------------------
|
| 349 |
+
|
| 350 |
+
Django 1.4 introduces a cookie-based session backend that uses the tools for
|
| 351 |
+
:doc:`cryptographic signing </topics/signing>` to store the session data in
|
| 352 |
+
the client's browser.
|
| 353 |
+
|
| 354 |
+
.. warning::
|
| 355 |
+
|
| 356 |
+
Session data is signed and validated by the server, but it's not
|
| 357 |
+
encrypted. This means a user can view any data stored in the
|
| 358 |
+
session but cannot change it. Please read the documentation for
|
| 359 |
+
further clarification before using this backend.
|
| 360 |
+
|
| 361 |
+
See the :ref:`cookie-based session backend <cookie-session-backend>` docs for
|
| 362 |
+
more information.
|
| 363 |
+
|
| 364 |
+
New form wizard
|
| 365 |
+
---------------
|
| 366 |
+
|
| 367 |
+
The previous ``FormWizard`` from ``django.contrib.formtools`` has been
|
| 368 |
+
replaced with a new implementation based on the class-based views
|
| 369 |
+
introduced in Django 1.3. It features a pluggable storage API and doesn't
|
| 370 |
+
require the wizard to pass around hidden fields for every previous step.
|
| 371 |
+
|
| 372 |
+
Django 1.4 ships with a session-based storage backend and a cookie-based
|
| 373 |
+
storage backend. The latter uses the tools for
|
| 374 |
+
:doc:`cryptographic signing </topics/signing>` also introduced in
|
| 375 |
+
Django 1.4 to store the wizard's state in the user's cookies.
|
| 376 |
+
|
| 377 |
+
``reverse_lazy``
|
| 378 |
+
----------------
|
| 379 |
+
|
| 380 |
+
A lazily evaluated version of ``reverse()`` was added to allow using URL
|
| 381 |
+
reversals before the project's URLconf gets loaded.
|
| 382 |
+
|
| 383 |
+
Translating URL patterns
|
| 384 |
+
------------------------
|
| 385 |
+
|
| 386 |
+
Django can now look for a language prefix in the URLpattern when using the new
|
| 387 |
+
:func:`~django.conf.urls.i18n.i18n_patterns` helper function.
|
| 388 |
+
It's also now possible to define translatable URL patterns using
|
| 389 |
+
``django.utils.translation.ugettext_lazy()``. See
|
| 390 |
+
:ref:`url-internationalization` for more information about the language prefix
|
| 391 |
+
and how to internationalize URL patterns.
|
| 392 |
+
|
| 393 |
+
Contextual translation support for ``{% trans %}`` and ``{% blocktrans %}``
|
| 394 |
+
---------------------------------------------------------------------------
|
| 395 |
+
|
| 396 |
+
The :ref:`contextual translation<contextual-markers>` support introduced in
|
| 397 |
+
Django 1.3 via the ``pgettext`` function has been extended to the
|
| 398 |
+
:ttag:`trans` and :ttag:`blocktrans` template tags using the new ``context``
|
| 399 |
+
keyword.
|
| 400 |
+
|
| 401 |
+
Customizable ``SingleObjectMixin`` URLConf kwargs
|
| 402 |
+
-------------------------------------------------
|
| 403 |
+
|
| 404 |
+
Two new attributes,
|
| 405 |
+
:attr:`pk_url_kwarg<django.views.generic.detail.SingleObjectMixin.pk_url_kwarg>`
|
| 406 |
+
and
|
| 407 |
+
:attr:`slug_url_kwarg<django.views.generic.detail.SingleObjectMixin.slug_url_kwarg>`,
|
| 408 |
+
have been added to :class:`~django.views.generic.detail.SingleObjectMixin` to
|
| 409 |
+
enable the customization of URLconf keyword arguments used for single
|
| 410 |
+
object generic views.
|
| 411 |
+
|
| 412 |
+
Assignment template tags
|
| 413 |
+
------------------------
|
| 414 |
+
|
| 415 |
+
A new ``assignment_tag`` helper function was added to ``template.Library`` to
|
| 416 |
+
ease the creation of template tags that store data in a specified context
|
| 417 |
+
variable.
|
| 418 |
+
|
| 419 |
+
``*args`` and ``**kwargs`` support for template tag helper functions
|
| 420 |
+
--------------------------------------------------------------------
|
| 421 |
+
|
| 422 |
+
The :ref:`simple_tag<howto-custom-template-tags-simple-tags>`,
|
| 423 |
+
:ref:`inclusion_tag <howto-custom-template-tags-inclusion-tags>` and newly
|
| 424 |
+
introduced ``assignment_tag`` template helper functions may now accept any
|
| 425 |
+
number of positional or keyword arguments. For example::
|
| 426 |
+
|
| 427 |
+
@register.simple_tag
|
| 428 |
+
def my_tag(a, b, *args, **kwargs):
|
| 429 |
+
warning = kwargs["warning"]
|
| 430 |
+
profile = kwargs["profile"]
|
| 431 |
+
...
|
| 432 |
+
return ...
|
| 433 |
+
|
| 434 |
+
Then, in the template, any number of arguments may be passed to the template tag.
|
| 435 |
+
For example:
|
| 436 |
+
|
| 437 |
+
.. code-block:: html+django
|
| 438 |
+
|
| 439 |
+
{% my_tag 123 "abcd" book.title warning=message|lower profile=user.profile %}
|
| 440 |
+
|
| 441 |
+
No wrapping of exceptions in ``TEMPLATE_DEBUG`` mode
|
| 442 |
+
----------------------------------------------------
|
| 443 |
+
|
| 444 |
+
In previous versions of Django, whenever the ``TEMPLATE_DEBUG`` setting
|
| 445 |
+
was ``True``, any exception raised during template rendering (even exceptions
|
| 446 |
+
unrelated to template syntax) were wrapped in ``TemplateSyntaxError`` and
|
| 447 |
+
re-raised. This was done in order to provide detailed template source location
|
| 448 |
+
information in the debug 500 page.
|
| 449 |
+
|
| 450 |
+
In Django 1.4, exceptions are no longer wrapped. Instead, the original
|
| 451 |
+
exception is annotated with the source information. This means that catching
|
| 452 |
+
exceptions from template rendering is now consistent regardless of the value of
|
| 453 |
+
``TEMPLATE_DEBUG``, and there's no need to catch and unwrap
|
| 454 |
+
``TemplateSyntaxError`` in order to catch other errors.
|
| 455 |
+
|
| 456 |
+
``truncatechars`` template filter
|
| 457 |
+
---------------------------------
|
| 458 |
+
|
| 459 |
+
This new filter truncates a string to be no longer than the specified
|
| 460 |
+
number of characters. Truncated strings end with a translatable ellipsis
|
| 461 |
+
sequence ("..."). See the documentation for :tfilter:`truncatechars` for
|
| 462 |
+
more details.
|
| 463 |
+
|
| 464 |
+
``static`` template tag
|
| 465 |
+
-----------------------
|
| 466 |
+
|
| 467 |
+
The :mod:`staticfiles<django.contrib.staticfiles>` contrib app has a new
|
| 468 |
+
``static`` template tag to refer to files saved with the
|
| 469 |
+
:setting:`STATICFILES_STORAGE` storage backend. It uses the storage backend's
|
| 470 |
+
``url`` method and therefore supports advanced features such as :ref:`serving
|
| 471 |
+
files from a cloud service<staticfiles-from-cdn>`.
|
| 472 |
+
|
| 473 |
+
``CachedStaticFilesStorage`` storage backend
|
| 474 |
+
--------------------------------------------
|
| 475 |
+
|
| 476 |
+
The :mod:`staticfiles<django.contrib.staticfiles>` contrib app now has a
|
| 477 |
+
``django.contrib.staticfiles.storage.CachedStaticFilesStorage`` backend
|
| 478 |
+
that caches the files it saves (when running the :djadmin:`collectstatic`
|
| 479 |
+
management command) by appending the MD5 hash of the file's content to the
|
| 480 |
+
filename. For example, the file ``css/styles.css`` would also be saved as
|
| 481 |
+
``css/styles.55e7cbb9ba48.css``
|
| 482 |
+
|
| 483 |
+
Simple clickjacking protection
|
| 484 |
+
------------------------------
|
| 485 |
+
|
| 486 |
+
We've added a middleware to provide easy protection against `clickjacking
|
| 487 |
+
<https://en.wikipedia.org/wiki/Clickjacking>`_ using the ``X-Frame-Options``
|
| 488 |
+
header. It's not enabled by default for backwards compatibility reasons, but
|
| 489 |
+
you'll almost certainly want to :doc:`enable it </ref/clickjacking/>` to help
|
| 490 |
+
plug that security hole for browsers that support the header.
|
| 491 |
+
|
| 492 |
+
CSRF improvements
|
| 493 |
+
-----------------
|
| 494 |
+
|
| 495 |
+
We've made various improvements to our CSRF features, including the
|
| 496 |
+
:func:`~django.views.decorators.csrf.ensure_csrf_cookie` decorator, which can
|
| 497 |
+
help with AJAX-heavy sites; protection for PUT and DELETE requests; and the
|
| 498 |
+
:setting:`CSRF_COOKIE_SECURE` and :setting:`CSRF_COOKIE_PATH` settings, which can
|
| 499 |
+
improve the security and usefulness of CSRF protection. See the :doc:`CSRF
|
| 500 |
+
docs </ref/csrf>` for more information.
|
| 501 |
+
|
| 502 |
+
Error report filtering
|
| 503 |
+
----------------------
|
| 504 |
+
|
| 505 |
+
We added two function decorators,
|
| 506 |
+
:func:`~django.views.decorators.debug.sensitive_variables` and
|
| 507 |
+
:func:`~django.views.decorators.debug.sensitive_post_parameters`, to allow
|
| 508 |
+
designating the local variables and POST parameters that may contain sensitive
|
| 509 |
+
information and should be filtered out of error reports.
|
| 510 |
+
|
| 511 |
+
All POST parameters are now systematically filtered out of error reports for
|
| 512 |
+
certain views (``login``, ``password_reset_confirm``, ``password_change`` and
|
| 513 |
+
``add_view`` in :mod:`django.contrib.auth.views`, as well as
|
| 514 |
+
``user_change_password`` in the admin app) to prevent the leaking of sensitive
|
| 515 |
+
information such as user passwords.
|
| 516 |
+
|
| 517 |
+
You can override or customize the default filtering by writing a :ref:`custom
|
| 518 |
+
filter<custom-error-reports>`. For more information see the docs on
|
| 519 |
+
:ref:`Filtering error reports<filtering-error-reports>`.
|
| 520 |
+
|
| 521 |
+
Extended IPv6 support
|
| 522 |
+
---------------------
|
| 523 |
+
|
| 524 |
+
Django 1.4 can now better handle IPv6 addresses with the new
|
| 525 |
+
:class:`~django.db.models.GenericIPAddressField` model field,
|
| 526 |
+
:class:`~django.forms.GenericIPAddressField` form field and
|
| 527 |
+
the validators :data:`~django.core.validators.validate_ipv46_address` and
|
| 528 |
+
:data:`~django.core.validators.validate_ipv6_address`.
|
| 529 |
+
|
| 530 |
+
HTML comparisons in tests
|
| 531 |
+
-------------------------
|
| 532 |
+
|
| 533 |
+
The base classes in :mod:`django.test` now have some helpers to
|
| 534 |
+
compare HTML without tripping over irrelevant differences in whitespace,
|
| 535 |
+
argument quoting/ordering and closing of self-closing tags. You can either
|
| 536 |
+
compare HTML directly with the new
|
| 537 |
+
:meth:`~django.test.SimpleTestCase.assertHTMLEqual` and
|
| 538 |
+
:meth:`~django.test.SimpleTestCase.assertHTMLNotEqual` assertions, or use
|
| 539 |
+
the ``html=True`` flag with
|
| 540 |
+
:meth:`~django.test.SimpleTestCase.assertContains` and
|
| 541 |
+
:meth:`~django.test.SimpleTestCase.assertNotContains` to test whether the
|
| 542 |
+
client's response contains a given HTML fragment. See the :ref:`assertions
|
| 543 |
+
documentation <assertions>` for more.
|
| 544 |
+
|
| 545 |
+
Two new date format strings
|
| 546 |
+
---------------------------
|
| 547 |
+
|
| 548 |
+
Two new :tfilter:`date` formats were added for use in template filters,
|
| 549 |
+
template tags and :doc:`/topics/i18n/formatting`:
|
| 550 |
+
|
| 551 |
+
- ``e`` -- the name of the timezone of the given datetime object
|
| 552 |
+
- ``o`` -- the ISO 8601 year number
|
| 553 |
+
|
| 554 |
+
Please make sure to update your :ref:`custom format files
|
| 555 |
+
<custom-format-files>` if they contain either ``e`` or ``o`` in a format
|
| 556 |
+
string. For example a Spanish localization format previously only escaped the
|
| 557 |
+
``d`` format character::
|
| 558 |
+
|
| 559 |
+
DATE_FORMAT = r"j \de F \de Y"
|
| 560 |
+
|
| 561 |
+
But now it needs to also escape ``e`` and ``o``::
|
| 562 |
+
|
| 563 |
+
DATE_FORMAT = r"j \d\e F \d\e Y"
|
| 564 |
+
|
| 565 |
+
For more information, see the :tfilter:`date` documentation.
|
| 566 |
+
|
| 567 |
+
Minor features
|
| 568 |
+
--------------
|
| 569 |
+
|
| 570 |
+
Django 1.4 also includes several smaller improvements worth noting:
|
| 571 |
+
|
| 572 |
+
* A more usable stacktrace in the technical 500 page. Frames in the
|
| 573 |
+
stack trace that reference Django's framework code are dimmed out,
|
| 574 |
+
while frames in application code are slightly emphasized. This change
|
| 575 |
+
makes it easier to scan a stacktrace for issues in application code.
|
| 576 |
+
|
| 577 |
+
* :doc:`Tablespace support </topics/db/tablespaces>` in PostgreSQL.
|
| 578 |
+
|
| 579 |
+
* Customizable names for :meth:`~django.template.Library.simple_tag`.
|
| 580 |
+
|
| 581 |
+
* In the documentation, a helpful :doc:`security overview </topics/security>`
|
| 582 |
+
page.
|
| 583 |
+
|
| 584 |
+
* The ``django.contrib.auth.models.check_password`` function has been moved
|
| 585 |
+
to the :mod:`django.contrib.auth.hashers` module. Importing it from the old
|
| 586 |
+
location will still work, but you should update your imports.
|
| 587 |
+
|
| 588 |
+
* The :djadmin:`collectstatic` management command now has a ``--clear`` option
|
| 589 |
+
to delete all files at the destination before copying or linking the static
|
| 590 |
+
files.
|
| 591 |
+
|
| 592 |
+
* It's now possible to load fixtures containing forward references when using
|
| 593 |
+
MySQL with the InnoDB database engine.
|
| 594 |
+
|
| 595 |
+
* A new 403 response handler has been added as
|
| 596 |
+
``'django.views.defaults.permission_denied'``. You can set your own handler by
|
| 597 |
+
setting the value of :data:`django.conf.urls.handler403`. See the
|
| 598 |
+
documentation about :ref:`the 403 (HTTP Forbidden) view<http_forbidden_view>`
|
| 599 |
+
for more information.
|
| 600 |
+
|
| 601 |
+
* The :djadmin:`makemessages` command uses a new and more accurate lexer,
|
| 602 |
+
:pypi:`JsLex <jslex>`, for extracting translatable strings from JavaScript
|
| 603 |
+
files.
|
| 604 |
+
|
| 605 |
+
* The :ttag:`trans` template tag now takes an optional ``as`` argument to
|
| 606 |
+
be able to retrieve a translation string without displaying it but setting
|
| 607 |
+
a template context variable instead.
|
| 608 |
+
|
| 609 |
+
* The :ttag:`if` template tag now supports ``{% elif %}`` clauses.
|
| 610 |
+
|
| 611 |
+
* If your Django app is behind a proxy, you might find the new
|
| 612 |
+
:setting:`SECURE_PROXY_SSL_HEADER` setting useful. It solves the problem of your
|
| 613 |
+
proxy "eating" the fact that a request came in via HTTPS. But only use this
|
| 614 |
+
setting if you know what you're doing.
|
| 615 |
+
|
| 616 |
+
* A new, plain-text, version of the HTTP 500 status code internal error page
|
| 617 |
+
served when :setting:`DEBUG` is ``True`` is now sent to the client when
|
| 618 |
+
Django detects that the request has originated in JavaScript code.
|
| 619 |
+
(``is_ajax()`` is used for this.)
|
| 620 |
+
|
| 621 |
+
Like its HTML counterpart, it contains a collection of different
|
| 622 |
+
pieces of information about the state of the application.
|
| 623 |
+
|
| 624 |
+
This should make it easier to read when debugging interaction with
|
| 625 |
+
client-side JavaScript.
|
| 626 |
+
|
| 627 |
+
* Added the :option:`makemessages --no-location` option.
|
| 628 |
+
|
| 629 |
+
* Changed the ``locmem`` cache backend to use
|
| 630 |
+
``pickle.HIGHEST_PROTOCOL`` for better compatibility with the other
|
| 631 |
+
cache backends.
|
| 632 |
+
|
| 633 |
+
* Added support in the ORM for generating ``SELECT`` queries containing
|
| 634 |
+
``DISTINCT ON``.
|
| 635 |
+
|
| 636 |
+
The ``distinct()`` ``QuerySet`` method now accepts an optional list of model
|
| 637 |
+
field names. If specified, then the ``DISTINCT`` statement is limited to these
|
| 638 |
+
fields. This is only supported in PostgreSQL.
|
| 639 |
+
|
| 640 |
+
For more details, see the documentation for
|
| 641 |
+
:meth:`~django.db.models.query.QuerySet.distinct`.
|
| 642 |
+
|
| 643 |
+
* The admin login page will add a password reset link if you include a URL with
|
| 644 |
+
the name ``'admin_password_reset'`` in your ``urls.py``, so plugging in the
|
| 645 |
+
built-in password reset mechanism and making it available is now much easier.
|
| 646 |
+
For details, see :ref:`auth_password_reset`.
|
| 647 |
+
|
| 648 |
+
* The MySQL database backend can now make use of the savepoint feature
|
| 649 |
+
implemented by MySQL version 5.0.3 or newer with the InnoDB storage engine.
|
| 650 |
+
|
| 651 |
+
* It's now possible to pass initial values to the model forms that are part of
|
| 652 |
+
both model formsets and inline model formsets as returned from factory
|
| 653 |
+
functions ``modelformset_factory`` and ``inlineformset_factory`` respectively
|
| 654 |
+
just like with regular formsets. However, initial values only apply to extra
|
| 655 |
+
forms, i.e. those which are not bound to an existing model instance.
|
| 656 |
+
|
| 657 |
+
* The sitemaps framework can now handle HTTPS links using the new
|
| 658 |
+
:attr:`Sitemap.protocol <django.contrib.sitemaps.Sitemap.protocol>` class
|
| 659 |
+
attribute.
|
| 660 |
+
|
| 661 |
+
* A new :class:`django.test.SimpleTestCase` subclass of
|
| 662 |
+
:class:`unittest.TestCase`
|
| 663 |
+
that's lighter than :class:`django.test.TestCase` and company. It can be
|
| 664 |
+
useful in tests that don't need to hit a database. See
|
| 665 |
+
:ref:`testcase_hierarchy_diagram`.
|
| 666 |
+
|
| 667 |
+
.. _backwards-incompatible-1.4:
|
| 668 |
+
|
| 669 |
+
Backwards incompatible changes in 1.4
|
| 670 |
+
=====================================
|
| 671 |
+
|
| 672 |
+
SECRET_KEY setting is required
|
| 673 |
+
------------------------------
|
| 674 |
+
|
| 675 |
+
Running Django with an empty or known :setting:`SECRET_KEY` disables many of
|
| 676 |
+
Django's security protections and can lead to remote-code-execution
|
| 677 |
+
vulnerabilities. No Django site should ever be run without a
|
| 678 |
+
:setting:`SECRET_KEY`.
|
| 679 |
+
|
| 680 |
+
In Django 1.4, starting Django with an empty :setting:`SECRET_KEY` will raise a
|
| 681 |
+
``DeprecationWarning``. In Django 1.5, it will raise an exception and Django
|
| 682 |
+
will refuse to start. This is slightly accelerated from the usual deprecation
|
| 683 |
+
path due to the severity of the consequences of running Django with no
|
| 684 |
+
:setting:`SECRET_KEY`.
|
| 685 |
+
|
| 686 |
+
``django.contrib.admin``
|
| 687 |
+
------------------------
|
| 688 |
+
|
| 689 |
+
The included administration app ``django.contrib.admin`` has for a long time
|
| 690 |
+
shipped with a default set of static files such as JavaScript, images and
|
| 691 |
+
stylesheets. Django 1.3 added a new contrib app ``django.contrib.staticfiles``
|
| 692 |
+
to handle such files in a generic way and defined conventions for static
|
| 693 |
+
files included in apps.
|
| 694 |
+
|
| 695 |
+
Starting in Django 1.4, the admin's static files also follow this
|
| 696 |
+
convention, to make the files easier to deploy. In previous versions of Django,
|
| 697 |
+
it was also common to define an ``ADMIN_MEDIA_PREFIX`` setting to point to the
|
| 698 |
+
URL where the admin's static files live on a web server. This setting has now
|
| 699 |
+
been deprecated and replaced by the more general setting :setting:`STATIC_URL`.
|
| 700 |
+
Django will now expect to find the admin static files under the URL
|
| 701 |
+
``<STATIC_URL>/admin/``.
|
| 702 |
+
|
| 703 |
+
If you've previously used a URL path for ``ADMIN_MEDIA_PREFIX`` (e.g.
|
| 704 |
+
``/media/``) simply make sure :setting:`STATIC_URL` and :setting:`STATIC_ROOT`
|
| 705 |
+
are configured and your web server serves those files correctly. The
|
| 706 |
+
development server continues to serve the admin files just like before. Read
|
| 707 |
+
the :doc:`static files howto </howto/static-files/index>` for more details.
|
| 708 |
+
|
| 709 |
+
If your ``ADMIN_MEDIA_PREFIX`` is set to a specific domain (e.g.
|
| 710 |
+
``http://media.example.com/admin/``), make sure to also set your
|
| 711 |
+
:setting:`STATIC_URL` setting to the correct URL -- for example,
|
| 712 |
+
``http://media.example.com/``.
|
| 713 |
+
|
| 714 |
+
.. warning::
|
| 715 |
+
|
| 716 |
+
If you're implicitly relying on the path of the admin static files within
|
| 717 |
+
Django's source code, you'll need to update that path. The files were moved
|
| 718 |
+
from :file:`django/contrib/admin/media/` to
|
| 719 |
+
:file:`django/contrib/admin/static/admin/`.
|
| 720 |
+
|
| 721 |
+
Supported browsers for the admin
|
| 722 |
+
--------------------------------
|
| 723 |
+
|
| 724 |
+
Django hasn't had a clear policy on which browsers are supported by the
|
| 725 |
+
admin app. Our new policy formalizes existing practices: `YUI's A-grade`_
|
| 726 |
+
browsers should provide a fully-functional admin experience, with the notable
|
| 727 |
+
exception of Internet Explorer 6, which is no longer supported.
|
| 728 |
+
|
| 729 |
+
Released over 10 years ago, IE6 imposes many limitations on modern web
|
| 730 |
+
development. The practical implications of this policy are that contributors
|
| 731 |
+
are free to improve the admin without consideration for these limitations.
|
| 732 |
+
|
| 733 |
+
This new policy **has no impact** on sites you develop using Django. It only
|
| 734 |
+
applies to the Django admin. Feel free to develop apps compatible with any
|
| 735 |
+
range of browsers.
|
| 736 |
+
|
| 737 |
+
.. _YUI's A-grade: https://github.com/yui/yui3/wiki/Graded-Browser-Support
|
| 738 |
+
|
| 739 |
+
Removed admin icons
|
| 740 |
+
-------------------
|
| 741 |
+
|
| 742 |
+
As part of an effort to improve the performance and usability of the admin's
|
| 743 |
+
change-list sorting interface and :attr:`horizontal
|
| 744 |
+
<django.contrib.admin.ModelAdmin.filter_horizontal>` and :attr:`vertical
|
| 745 |
+
<django.contrib.admin.ModelAdmin.filter_vertical>` "filter" widgets, some icon
|
| 746 |
+
files were removed and grouped into two sprite files.
|
| 747 |
+
|
| 748 |
+
Specifically: ``selector-add.gif``, ``selector-addall.gif``,
|
| 749 |
+
``selector-remove.gif``, ``selector-removeall.gif``,
|
| 750 |
+
``selector_stacked-add.gif`` and ``selector_stacked-remove.gif`` were
|
| 751 |
+
combined into ``selector-icons.gif``; and ``arrow-up.gif`` and
|
| 752 |
+
``arrow-down.gif`` were combined into ``sorting-icons.gif``.
|
| 753 |
+
|
| 754 |
+
If you used those icons to customize the admin, then you'll need to replace
|
| 755 |
+
them with your own icons or get the files from a previous release.
|
| 756 |
+
|
| 757 |
+
CSS class names in admin forms
|
| 758 |
+
------------------------------
|
| 759 |
+
|
| 760 |
+
To avoid conflicts with other common CSS class names (e.g. "button"), we added
|
| 761 |
+
a prefix ("field-") to all CSS class names automatically generated from the
|
| 762 |
+
form field names in the main admin forms, stacked inline forms and tabular
|
| 763 |
+
inline cells. You'll need to take that prefix into account in your custom
|
| 764 |
+
style sheets or JavaScript files if you previously used plain field names as
|
| 765 |
+
selectors for custom styles or JavaScript transformations.
|
| 766 |
+
|
| 767 |
+
Compatibility with old signed data
|
| 768 |
+
----------------------------------
|
| 769 |
+
|
| 770 |
+
Django 1.3 changed the cryptographic signing mechanisms used in a number of
|
| 771 |
+
places in Django. While Django 1.3 kept fallbacks that would accept hashes
|
| 772 |
+
produced by the previous methods, these fallbacks are removed in Django 1.4.
|
| 773 |
+
|
| 774 |
+
So, if you upgrade to Django 1.4 directly from 1.2 or earlier, you may
|
| 775 |
+
lose/invalidate certain pieces of data that have been cryptographically signed
|
| 776 |
+
using an old method. To avoid this, use Django 1.3 first for a period of time
|
| 777 |
+
to allow the signed data to expire naturally. The affected parts are detailed
|
| 778 |
+
below, with 1) the consequences of ignoring this advice and 2) the amount of
|
| 779 |
+
time you need to run Django 1.3 for the data to expire or become irrelevant.
|
| 780 |
+
|
| 781 |
+
* ``contrib.sessions`` data integrity check
|
| 782 |
+
|
| 783 |
+
* Consequences: The user will be logged out, and session data will be lost.
|
| 784 |
+
|
| 785 |
+
* Time period: Defined by :setting:`SESSION_COOKIE_AGE`.
|
| 786 |
+
|
| 787 |
+
* ``contrib.auth`` password reset hash
|
| 788 |
+
|
| 789 |
+
* Consequences: Password reset links from before the upgrade will not work.
|
| 790 |
+
|
| 791 |
+
* Time period: Defined by ``PASSWORD_RESET_TIMEOUT_DAYS``.
|
| 792 |
+
|
| 793 |
+
Form-related hashes: these have a much shorter lifetime and are relevant
|
| 794 |
+
only for the short window where a user might fill in a form generated by the
|
| 795 |
+
pre-upgrade Django instance and try to submit it to the upgraded Django
|
| 796 |
+
instance:
|
| 797 |
+
|
| 798 |
+
* ``contrib.comments`` form security hash
|
| 799 |
+
|
| 800 |
+
* Consequences: The user will see the validation error "Security hash failed."
|
| 801 |
+
|
| 802 |
+
* Time period: The amount of time you expect users to take filling out comment
|
| 803 |
+
forms.
|
| 804 |
+
|
| 805 |
+
* ``FormWizard`` security hash
|
| 806 |
+
|
| 807 |
+
* Consequences: The user will see an error about the form having expired
|
| 808 |
+
and will be sent back to the first page of the wizard, losing the data
|
| 809 |
+
entered so far.
|
| 810 |
+
|
| 811 |
+
* Time period: The amount of time you expect users to take filling out the
|
| 812 |
+
affected forms.
|
| 813 |
+
|
| 814 |
+
* CSRF check
|
| 815 |
+
|
| 816 |
+
* Note: This is actually a Django 1.1 fallback, not Django 1.2,
|
| 817 |
+
and it applies only if you're upgrading from 1.1.
|
| 818 |
+
|
| 819 |
+
* Consequences: The user will see a 403 error with any CSRF-protected POST
|
| 820 |
+
form.
|
| 821 |
+
|
| 822 |
+
* Time period: The amount of time you expect user to take filling out
|
| 823 |
+
such forms.
|
| 824 |
+
|
| 825 |
+
* ``contrib.auth`` user password hash-upgrade sequence
|
| 826 |
+
|
| 827 |
+
* Consequences: Each user's password will be updated to a stronger password
|
| 828 |
+
hash when it's written to the database in 1.4. This means that if you
|
| 829 |
+
upgrade to 1.4 and then need to downgrade to 1.3, version 1.3 won't be able
|
| 830 |
+
to read the updated passwords.
|
| 831 |
+
|
| 832 |
+
* Remedy: Set :setting:`PASSWORD_HASHERS` to use your original password
|
| 833 |
+
hashing when you initially upgrade to 1.4. After you confirm your app works
|
| 834 |
+
well with Django 1.4 and you won't have to roll back to 1.3, enable the new
|
| 835 |
+
password hashes.
|
| 836 |
+
|
| 837 |
+
``django.contrib.flatpages``
|
| 838 |
+
----------------------------
|
| 839 |
+
|
| 840 |
+
Starting in 1.4, the
|
| 841 |
+
:class:`~django.contrib.flatpages.middleware.FlatpageFallbackMiddleware` only
|
| 842 |
+
adds a trailing slash and redirects if the resulting URL refers to an existing
|
| 843 |
+
flatpage. For example, requesting ``/notaflatpageoravalidurl`` in a previous
|
| 844 |
+
version would redirect to ``/notaflatpageoravalidurl/``, which would
|
| 845 |
+
subsequently raise a 404. Requesting ``/notaflatpageoravalidurl`` now will
|
| 846 |
+
immediately raise a 404.
|
| 847 |
+
|
| 848 |
+
Also, redirects returned by flatpages are now permanent (with 301 status code),
|
| 849 |
+
to match the behavior of :class:`~django.middleware.common.CommonMiddleware`.
|
| 850 |
+
|
| 851 |
+
Serialization of :class:`~datetime.datetime` and :class:`~datetime.time`
|
| 852 |
+
------------------------------------------------------------------------
|
| 853 |
+
|
| 854 |
+
As a consequence of time-zone support, and according to the ECMA-262
|
| 855 |
+
specification, we made changes to the JSON serializer:
|
| 856 |
+
|
| 857 |
+
* It includes the time zone for aware datetime objects. It raises an exception
|
| 858 |
+
for aware time objects.
|
| 859 |
+
* It includes milliseconds for datetime and time objects. There is still
|
| 860 |
+
some precision loss, because Python stores microseconds (6 digits) and JSON
|
| 861 |
+
only supports milliseconds (3 digits). However, it's better than discarding
|
| 862 |
+
microseconds entirely.
|
| 863 |
+
|
| 864 |
+
We changed the XML serializer to use the ISO8601 format for datetimes.
|
| 865 |
+
The letter ``T`` is used to separate the date part from the time part, instead
|
| 866 |
+
of a space. Time zone information is included in the ``[+-]HH:MM`` format.
|
| 867 |
+
|
| 868 |
+
Though the serializers now use these new formats when creating fixtures, they
|
| 869 |
+
can still load fixtures that use the old format.
|
| 870 |
+
|
| 871 |
+
``supports_timezone`` changed to ``False`` for SQLite
|
| 872 |
+
-----------------------------------------------------
|
| 873 |
+
|
| 874 |
+
The database feature ``supports_timezone`` used to be ``True`` for SQLite.
|
| 875 |
+
Indeed, if you saved an aware datetime object, SQLite stored a string that
|
| 876 |
+
included an UTC offset. However, this offset was ignored when loading the value
|
| 877 |
+
back from the database, which could corrupt the data.
|
| 878 |
+
|
| 879 |
+
In the context of time-zone support, this flag was changed to ``False``, and
|
| 880 |
+
datetimes are now stored without time-zone information in SQLite. When
|
| 881 |
+
:setting:`USE_TZ` is ``False``, if you attempt to save an aware datetime
|
| 882 |
+
object, Django raises an exception.
|
| 883 |
+
|
| 884 |
+
``MySQLdb``-specific exceptions
|
| 885 |
+
-------------------------------
|
| 886 |
+
|
| 887 |
+
The MySQL backend historically has raised ``MySQLdb.OperationalError``
|
| 888 |
+
when a query triggered an exception. We've fixed this bug, and we now raise
|
| 889 |
+
:exc:`django.db.DatabaseError` instead. If you were testing for
|
| 890 |
+
``MySQLdb.OperationalError``, you'll need to update your ``except``
|
| 891 |
+
clauses.
|
| 892 |
+
|
| 893 |
+
Database connection's thread-locality
|
| 894 |
+
-------------------------------------
|
| 895 |
+
|
| 896 |
+
``DatabaseWrapper`` objects (i.e. the connection objects referenced by
|
| 897 |
+
``django.db.connection`` and ``django.db.connections["some_alias"]``) used to
|
| 898 |
+
be thread-local. They are now global objects in order to be potentially shared
|
| 899 |
+
between multiple threads. While the individual connection objects are now
|
| 900 |
+
global, the ``django.db.connections`` dictionary referencing those objects is
|
| 901 |
+
still thread-local. Therefore if you just use the ORM or
|
| 902 |
+
``DatabaseWrapper.cursor()`` then the behavior is still the same as before.
|
| 903 |
+
Note, however, that ``django.db.connection`` does not directly reference the
|
| 904 |
+
default ``DatabaseWrapper`` object anymore and is now a proxy to access that
|
| 905 |
+
object's attributes. If you need to access the actual ``DatabaseWrapper``
|
| 906 |
+
object, use ``django.db.connections[DEFAULT_DB_ALIAS]`` instead.
|
| 907 |
+
|
| 908 |
+
As part of this change, all underlying SQLite connections are now enabled for
|
| 909 |
+
potential thread-sharing (by passing the ``check_same_thread=False`` attribute
|
| 910 |
+
to ``pysqlite``). ``DatabaseWrapper`` however preserves the previous behavior
|
| 911 |
+
by disabling thread-sharing by default, so this does not affect any existing
|
| 912 |
+
code that purely relies on the ORM or on ``DatabaseWrapper.cursor()``.
|
| 913 |
+
|
| 914 |
+
Finally, while it's now possible to pass connections between threads, Django
|
| 915 |
+
doesn't make any effort to synchronize access to the underlying backend.
|
| 916 |
+
Concurrency behavior is defined by the underlying backend implementation.
|
| 917 |
+
Check their documentation for details.
|
| 918 |
+
|
| 919 |
+
``COMMENTS_BANNED_USERS_GROUP`` setting
|
| 920 |
+
---------------------------------------
|
| 921 |
+
|
| 922 |
+
Django's comments has historically
|
| 923 |
+
supported excluding the comments of a special user group, but we've never
|
| 924 |
+
documented the feature properly and didn't enforce the exclusion in other parts
|
| 925 |
+
of the app such as the template tags. To fix this problem, we removed the code
|
| 926 |
+
from the feed class.
|
| 927 |
+
|
| 928 |
+
If you rely on the feature and want to restore the old behavior, use a custom
|
| 929 |
+
comment model manager to exclude the user group, like this::
|
| 930 |
+
|
| 931 |
+
from django.conf import settings
|
| 932 |
+
from django.contrib.comments.managers import CommentManager
|
| 933 |
+
|
| 934 |
+
|
| 935 |
+
class BanningCommentManager(CommentManager):
|
| 936 |
+
def get_query_set(self):
|
| 937 |
+
qs = super().get_query_set()
|
| 938 |
+
if getattr(settings, "COMMENTS_BANNED_USERS_GROUP", None):
|
| 939 |
+
where = [
|
| 940 |
+
"user_id NOT IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)"
|
| 941 |
+
]
|
| 942 |
+
params = [settings.COMMENTS_BANNED_USERS_GROUP]
|
| 943 |
+
qs = qs.extra(where=where, params=params)
|
| 944 |
+
return qs
|
| 945 |
+
|
| 946 |
+
Save this model manager in your custom comment app (e.g., in
|
| 947 |
+
``my_comments_app/managers.py``) and add it your custom comment app model::
|
| 948 |
+
|
| 949 |
+
from django.db import models
|
| 950 |
+
from django.contrib.comments.models import Comment
|
| 951 |
+
|
| 952 |
+
from my_comments_app.managers import BanningCommentManager
|
| 953 |
+
|
| 954 |
+
|
| 955 |
+
class CommentWithTitle(Comment):
|
| 956 |
+
title = models.CharField(max_length=300)
|
| 957 |
+
|
| 958 |
+
objects = BanningCommentManager()
|
| 959 |
+
|
| 960 |
+
``IGNORABLE_404_STARTS`` and ``IGNORABLE_404_ENDS`` settings
|
| 961 |
+
------------------------------------------------------------
|
| 962 |
+
|
| 963 |
+
Until Django 1.3, it was possible to exclude some URLs from Django's
|
| 964 |
+
:doc:`404 error reporting</howto/error-reporting>` by adding prefixes to
|
| 965 |
+
``IGNORABLE_404_STARTS`` and suffixes to ``IGNORABLE_404_ENDS``.
|
| 966 |
+
|
| 967 |
+
In Django 1.4, these two settings are superseded by
|
| 968 |
+
:setting:`IGNORABLE_404_URLS`, which is a list of compiled regular
|
| 969 |
+
expressions. Django won't send an email for 404 errors on URLs that match any
|
| 970 |
+
of them.
|
| 971 |
+
|
| 972 |
+
Furthermore, the previous settings had some rather arbitrary default values::
|
| 973 |
+
|
| 974 |
+
IGNORABLE_404_STARTS = ("/cgi-bin/", "/_vti_bin", "/_vti_inf")
|
| 975 |
+
IGNORABLE_404_ENDS = (
|
| 976 |
+
"mail.pl",
|
| 977 |
+
"mailform.pl",
|
| 978 |
+
"mail.cgi",
|
| 979 |
+
"mailform.cgi",
|
| 980 |
+
"favicon.ico",
|
| 981 |
+
".php",
|
| 982 |
+
)
|
| 983 |
+
|
| 984 |
+
It's not Django's role to decide if your website has a legacy ``/cgi-bin/``
|
| 985 |
+
section or a ``favicon.ico``. As a consequence, the default values of
|
| 986 |
+
:setting:`IGNORABLE_404_URLS`, ``IGNORABLE_404_STARTS``, and
|
| 987 |
+
``IGNORABLE_404_ENDS`` are all now empty.
|
| 988 |
+
|
| 989 |
+
If you have customized ``IGNORABLE_404_STARTS`` or ``IGNORABLE_404_ENDS``, or
|
| 990 |
+
if you want to keep the old default value, you should add the following lines
|
| 991 |
+
in your settings file::
|
| 992 |
+
|
| 993 |
+
import re
|
| 994 |
+
|
| 995 |
+
IGNORABLE_404_URLS = (
|
| 996 |
+
# for each <prefix> in IGNORABLE_404_STARTS
|
| 997 |
+
re.compile(r"^<prefix>"),
|
| 998 |
+
# for each <suffix> in IGNORABLE_404_ENDS
|
| 999 |
+
re.compile(r"<suffix>$"),
|
| 1000 |
+
)
|
| 1001 |
+
|
| 1002 |
+
Don't forget to escape characters that have a special meaning in a regular
|
| 1003 |
+
expression, such as periods.
|
| 1004 |
+
|
| 1005 |
+
CSRF protection extended to PUT and DELETE
|
| 1006 |
+
------------------------------------------
|
| 1007 |
+
|
| 1008 |
+
Previously, Django's :doc:`CSRF protection </ref/csrf/>` provided
|
| 1009 |
+
protection only against POST requests. Since use of PUT and DELETE methods in
|
| 1010 |
+
AJAX applications is becoming more common, we now protect all methods not
|
| 1011 |
+
defined as safe by :rfc:`2616` -- i.e., we exempt GET, HEAD, OPTIONS and TRACE,
|
| 1012 |
+
and we enforce protection on everything else.
|
| 1013 |
+
|
| 1014 |
+
If you're using PUT or DELETE methods in AJAX applications, please see the
|
| 1015 |
+
:ref:`instructions about using AJAX and CSRF <csrf-ajax>`.
|
| 1016 |
+
|
| 1017 |
+
Password reset view now accepts ``subject_template_name``
|
| 1018 |
+
---------------------------------------------------------
|
| 1019 |
+
|
| 1020 |
+
The ``password_reset`` view in ``django.contrib.auth`` now accepts a
|
| 1021 |
+
``subject_template_name`` parameter, which is passed to the password save form
|
| 1022 |
+
as a keyword argument. If you are using this view with a custom password reset
|
| 1023 |
+
form, then you will need to ensure your form's ``save()`` method accepts this
|
| 1024 |
+
keyword argument.
|
| 1025 |
+
|
| 1026 |
+
``django.core.template_loaders``
|
| 1027 |
+
--------------------------------
|
| 1028 |
+
|
| 1029 |
+
This was an alias to ``django.template.loader`` since 2005, and we've removed it
|
| 1030 |
+
without emitting a warning due to the length of the deprecation. If your code
|
| 1031 |
+
still referenced this, please use ``django.template.loader`` instead.
|
| 1032 |
+
|
| 1033 |
+
``django.db.models.fields.URLField.verify_exists``
|
| 1034 |
+
--------------------------------------------------
|
| 1035 |
+
|
| 1036 |
+
This functionality has been removed due to intractable performance and
|
| 1037 |
+
security issues. Any existing usage of ``verify_exists`` should be
|
| 1038 |
+
removed.
|
| 1039 |
+
|
| 1040 |
+
``django.core.files.storage.Storage.open``
|
| 1041 |
+
------------------------------------------
|
| 1042 |
+
|
| 1043 |
+
The ``open`` method of the base Storage class used to take an obscure parameter
|
| 1044 |
+
``mixin`` that allowed you to dynamically change the base classes of the
|
| 1045 |
+
returned file object. This has been removed. In the rare case you relied on the
|
| 1046 |
+
``mixin`` parameter, you can easily achieve the same by overriding the ``open``
|
| 1047 |
+
method, like this::
|
| 1048 |
+
|
| 1049 |
+
from django.core.files import File
|
| 1050 |
+
from django.core.files.storage import FileSystemStorage
|
| 1051 |
+
|
| 1052 |
+
|
| 1053 |
+
class Spam(File):
|
| 1054 |
+
"""
|
| 1055 |
+
Spam, spam, spam, spam and spam.
|
| 1056 |
+
"""
|
| 1057 |
+
|
| 1058 |
+
def ham(self):
|
| 1059 |
+
return "eggs"
|
| 1060 |
+
|
| 1061 |
+
|
| 1062 |
+
class SpamStorage(FileSystemStorage):
|
| 1063 |
+
"""
|
| 1064 |
+
A custom file storage backend.
|
| 1065 |
+
"""
|
| 1066 |
+
|
| 1067 |
+
def open(self, name, mode="rb"):
|
| 1068 |
+
return Spam(open(self.path(name), mode))
|
| 1069 |
+
|
| 1070 |
+
YAML deserializer now uses ``yaml.safe_load``
|
| 1071 |
+
---------------------------------------------
|
| 1072 |
+
|
| 1073 |
+
``yaml.load`` is able to construct any Python object, which may trigger
|
| 1074 |
+
arbitrary code execution if you process a YAML document that comes from an
|
| 1075 |
+
untrusted source. This feature isn't necessary for Django's YAML deserializer,
|
| 1076 |
+
whose primary use is to load fixtures consisting of simple objects. Even though
|
| 1077 |
+
fixtures are trusted data, the YAML deserializer now uses ``yaml.safe_load``
|
| 1078 |
+
for additional security.
|
| 1079 |
+
|
| 1080 |
+
Session cookies now have the ``httponly`` flag by default
|
| 1081 |
+
---------------------------------------------------------
|
| 1082 |
+
|
| 1083 |
+
Session cookies now include the ``httponly`` attribute by default to
|
| 1084 |
+
help reduce the impact of potential XSS attacks. As a consequence of
|
| 1085 |
+
this change, session cookie data, including ``sessionid``, is no longer
|
| 1086 |
+
accessible from JavaScript in many browsers. For strict backwards
|
| 1087 |
+
compatibility, use ``SESSION_COOKIE_HTTPONLY = False`` in your
|
| 1088 |
+
settings file.
|
| 1089 |
+
|
| 1090 |
+
The :tfilter:`urlize` filter no longer escapes every URL
|
| 1091 |
+
--------------------------------------------------------
|
| 1092 |
+
|
| 1093 |
+
When a URL contains a ``%xx`` sequence, where ``xx`` are two hexadecimal
|
| 1094 |
+
digits, :tfilter:`urlize` now assumes that the URL is already escaped and
|
| 1095 |
+
doesn't apply URL escaping again. This is wrong for URLs whose unquoted form
|
| 1096 |
+
contains a ``%xx`` sequence, but such URLs are very unlikely to happen in the
|
| 1097 |
+
wild, because they would confuse browsers too.
|
| 1098 |
+
|
| 1099 |
+
``assertTemplateUsed`` and ``assertTemplateNotUsed`` as context manager
|
| 1100 |
+
-----------------------------------------------------------------------
|
| 1101 |
+
|
| 1102 |
+
It's now possible to check whether a template was used within a block of
|
| 1103 |
+
code with :meth:`~django.test.SimpleTestCase.assertTemplateUsed` and
|
| 1104 |
+
:meth:`~django.test.SimpleTestCase.assertTemplateNotUsed`. And they
|
| 1105 |
+
can be used as a context manager::
|
| 1106 |
+
|
| 1107 |
+
with self.assertTemplateUsed("index.html"):
|
| 1108 |
+
render_to_string("index.html")
|
| 1109 |
+
with self.assertTemplateNotUsed("base.html"):
|
| 1110 |
+
render_to_string("index.html")
|
| 1111 |
+
|
| 1112 |
+
See the :ref:`assertion documentation<assertions>` for more.
|
| 1113 |
+
|
| 1114 |
+
Database connections after running the test suite
|
| 1115 |
+
-------------------------------------------------
|
| 1116 |
+
|
| 1117 |
+
The default test runner no longer restores the database connections after
|
| 1118 |
+
tests' execution. This prevents the production database from being exposed to
|
| 1119 |
+
potential threads that would still be running and attempting to create new
|
| 1120 |
+
connections.
|
| 1121 |
+
|
| 1122 |
+
If your code relied on connections to the production database being created
|
| 1123 |
+
after tests' execution, then you can restore the previous behavior by
|
| 1124 |
+
subclassing ``DjangoTestRunner`` and overriding its ``teardown_databases()``
|
| 1125 |
+
method.
|
| 1126 |
+
|
| 1127 |
+
Output of :djadmin:`manage.py help <help>`
|
| 1128 |
+
------------------------------------------
|
| 1129 |
+
|
| 1130 |
+
:djadmin:`manage.py help <help>` now groups available commands by application.
|
| 1131 |
+
If you depended on the output of this command -- if you parsed it, for example
|
| 1132 |
+
-- then you'll need to update your code. To get a list of all available
|
| 1133 |
+
management commands in a script, use
|
| 1134 |
+
:djadmin:`manage.py help --commands <help>` instead.
|
| 1135 |
+
|
| 1136 |
+
``extends`` template tag
|
| 1137 |
+
------------------------
|
| 1138 |
+
|
| 1139 |
+
Previously, the :ttag:`extends` tag used a buggy method of parsing arguments,
|
| 1140 |
+
which could lead to it erroneously considering an argument as a string literal
|
| 1141 |
+
when it wasn't. It now uses ``parser.compile_filter``, like other tags.
|
| 1142 |
+
|
| 1143 |
+
The internals of the tag aren't part of the official stable API, but in the
|
| 1144 |
+
interests of full disclosure, the ``ExtendsNode.__init__`` definition has
|
| 1145 |
+
changed, which may break any custom tags that use this class.
|
| 1146 |
+
|
| 1147 |
+
Loading some incomplete fixtures no longer works
|
| 1148 |
+
------------------------------------------------
|
| 1149 |
+
|
| 1150 |
+
Prior to 1.4, a default value was inserted for fixture objects that were missing
|
| 1151 |
+
a specific date or datetime value when auto_now or auto_now_add was set for the
|
| 1152 |
+
field. This was something that should not have worked, and in 1.4 loading such
|
| 1153 |
+
incomplete fixtures will fail. Because fixtures are a raw import, they should
|
| 1154 |
+
explicitly specify all field values, regardless of field options on the model.
|
| 1155 |
+
|
| 1156 |
+
Development Server Multithreading
|
| 1157 |
+
---------------------------------
|
| 1158 |
+
|
| 1159 |
+
The development server is now is multithreaded by default. Use the
|
| 1160 |
+
:option:`runserver --nothreading` option to disable the use of threading in the
|
| 1161 |
+
development server:
|
| 1162 |
+
|
| 1163 |
+
.. code-block:: shell
|
| 1164 |
+
|
| 1165 |
+
django-admin.py runserver --nothreading
|
| 1166 |
+
|
| 1167 |
+
Attributes disabled in markdown when safe mode set
|
| 1168 |
+
--------------------------------------------------
|
| 1169 |
+
|
| 1170 |
+
Prior to Django 1.4, attributes were included in any markdown output regardless
|
| 1171 |
+
of safe mode setting of the filter. With version > 2.1 of the Python-Markdown
|
| 1172 |
+
library, an enable_attributes option was added. When the safe argument is
|
| 1173 |
+
passed to the markdown filter, both the ``safe_mode=True`` and
|
| 1174 |
+
``enable_attributes=False`` options are set. If using a version of the
|
| 1175 |
+
Python-Markdown library less than 2.1, a warning is issued that the output is
|
| 1176 |
+
insecure.
|
| 1177 |
+
|
| 1178 |
+
FormMixin get_initial returns an instance-specific dictionary
|
| 1179 |
+
-------------------------------------------------------------
|
| 1180 |
+
|
| 1181 |
+
In Django 1.3, the ``get_initial`` method of the
|
| 1182 |
+
:class:`django.views.generic.edit.FormMixin` class was returning the
|
| 1183 |
+
class ``initial`` dictionary. This has been fixed to return a copy of this
|
| 1184 |
+
dictionary, so form instances can modify their initial data without messing
|
| 1185 |
+
with the class variable.
|
| 1186 |
+
|
| 1187 |
+
.. _deprecated-features-1.4:
|
| 1188 |
+
|
| 1189 |
+
Features deprecated in 1.4
|
| 1190 |
+
==========================
|
| 1191 |
+
|
| 1192 |
+
Old styles of calling ``cache_page`` decorator
|
| 1193 |
+
----------------------------------------------
|
| 1194 |
+
|
| 1195 |
+
Some legacy ways of calling :func:`~django.views.decorators.cache.cache_page`
|
| 1196 |
+
have been deprecated. Please see the documentation for the correct way to use
|
| 1197 |
+
this decorator.
|
| 1198 |
+
|
| 1199 |
+
Support for PostgreSQL versions older than 8.2
|
| 1200 |
+
----------------------------------------------
|
| 1201 |
+
|
| 1202 |
+
Django 1.3 dropped support for PostgreSQL versions older than 8.0, and we
|
| 1203 |
+
suggested using a more recent version because of performance improvements
|
| 1204 |
+
and, more importantly, the end of upstream support periods for 8.0 and 8.1
|
| 1205 |
+
was near (November 2010).
|
| 1206 |
+
|
| 1207 |
+
Django 1.4 takes that policy further and sets 8.2 as the minimum PostgreSQL
|
| 1208 |
+
version it officially supports.
|
| 1209 |
+
|
| 1210 |
+
Request exceptions are now always logged
|
| 1211 |
+
----------------------------------------
|
| 1212 |
+
|
| 1213 |
+
When we added :doc:`logging support </topics/logging/>` in Django in 1.3, the
|
| 1214 |
+
admin error email support was moved into the
|
| 1215 |
+
:class:`django.utils.log.AdminEmailHandler`, attached to the
|
| 1216 |
+
``'django.request'`` logger. In order to maintain the established behavior of
|
| 1217 |
+
error emails, the ``'django.request'`` logger was called only when
|
| 1218 |
+
:setting:`DEBUG` was ``False``.
|
| 1219 |
+
|
| 1220 |
+
To increase the flexibility of error logging for requests, the
|
| 1221 |
+
``'django.request'`` logger is now called regardless of the value of
|
| 1222 |
+
:setting:`DEBUG`, and the default settings file for new projects now includes a
|
| 1223 |
+
separate filter attached to :class:`django.utils.log.AdminEmailHandler` to
|
| 1224 |
+
prevent admin error emails in ``DEBUG`` mode::
|
| 1225 |
+
|
| 1226 |
+
LOGGING = {
|
| 1227 |
+
# ...
|
| 1228 |
+
"filters": {
|
| 1229 |
+
"require_debug_false": {
|
| 1230 |
+
"()": "django.utils.log.RequireDebugFalse",
|
| 1231 |
+
}
|
| 1232 |
+
},
|
| 1233 |
+
"handlers": {
|
| 1234 |
+
"mail_admins": {
|
| 1235 |
+
"level": "ERROR",
|
| 1236 |
+
"filters": ["require_debug_false"],
|
| 1237 |
+
"class": "django.utils.log.AdminEmailHandler",
|
| 1238 |
+
}
|
| 1239 |
+
},
|
| 1240 |
+
}
|
| 1241 |
+
|
| 1242 |
+
If your project was created prior to this change, your :setting:`LOGGING`
|
| 1243 |
+
setting will not include this new filter. In order to maintain
|
| 1244 |
+
backwards-compatibility, Django will detect that your ``'mail_admins'`` handler
|
| 1245 |
+
configuration includes no ``'filters'`` section and will automatically add
|
| 1246 |
+
this filter for you and issue a pending-deprecation warning. This will become a
|
| 1247 |
+
deprecation warning in Django 1.5, and in Django 1.6 the
|
| 1248 |
+
backwards-compatibility shim will be removed entirely.
|
| 1249 |
+
|
| 1250 |
+
The existence of any ``'filters'`` key under the ``'mail_admins'`` handler will
|
| 1251 |
+
disable this backward-compatibility shim and deprecation warning.
|
| 1252 |
+
|
| 1253 |
+
``django.conf.urls.defaults``
|
| 1254 |
+
-----------------------------
|
| 1255 |
+
|
| 1256 |
+
Until Django 1.3, the ``include()``, ``patterns()``, and ``url()`` functions,
|
| 1257 |
+
plus :data:`~django.conf.urls.handler404` and :data:`~django.conf.urls.handler500`
|
| 1258 |
+
were located in a ``django.conf.urls.defaults`` module.
|
| 1259 |
+
|
| 1260 |
+
In Django 1.4, they live in :mod:`django.conf.urls`.
|
| 1261 |
+
|
| 1262 |
+
``django.contrib.databrowse``
|
| 1263 |
+
-----------------------------
|
| 1264 |
+
|
| 1265 |
+
Databrowse has not seen active development for some time, and this does not show
|
| 1266 |
+
any sign of changing. There had been a suggestion for a `GSOC project`_ to
|
| 1267 |
+
integrate the functionality of databrowse into the admin, but no progress was
|
| 1268 |
+
made. While Databrowse has been deprecated, an enhancement of
|
| 1269 |
+
``django.contrib.admin`` providing a similar feature set is still possible.
|
| 1270 |
+
|
| 1271 |
+
.. _GSOC project: https://code.djangoproject.com/wiki/SummerOfCode2011#Integratedatabrowseintotheadmin
|
| 1272 |
+
|
| 1273 |
+
The code that powers Databrowse is licensed under the same terms as Django
|
| 1274 |
+
itself, so it's available to be adopted by an individual or group as
|
| 1275 |
+
a third-party project.
|
| 1276 |
+
|
| 1277 |
+
``django.core.management.setup_environ``
|
| 1278 |
+
----------------------------------------
|
| 1279 |
+
|
| 1280 |
+
This function temporarily modified ``sys.path`` in order to make the parent
|
| 1281 |
+
"project" directory importable under the old flat :djadmin:`startproject`
|
| 1282 |
+
layout. This function is now deprecated, as its path workarounds are no longer
|
| 1283 |
+
needed with the new ``manage.py`` and default project layout.
|
| 1284 |
+
|
| 1285 |
+
This function was never documented or part of the public API, but it was widely
|
| 1286 |
+
recommended for use in setting up a "Django environment" for a user script.
|
| 1287 |
+
These uses should be replaced by setting the :envvar:`DJANGO_SETTINGS_MODULE`
|
| 1288 |
+
environment variable or using :func:`django.conf.settings.configure`.
|
| 1289 |
+
|
| 1290 |
+
``django.core.management.execute_manager``
|
| 1291 |
+
------------------------------------------
|
| 1292 |
+
|
| 1293 |
+
This function was previously used by ``manage.py`` to execute a management
|
| 1294 |
+
command. It is identical to
|
| 1295 |
+
``django.core.management.execute_from_command_line``, except that it first
|
| 1296 |
+
calls ``setup_environ``, which is now deprecated. As such, ``execute_manager``
|
| 1297 |
+
is also deprecated; ``execute_from_command_line`` can be used instead. Neither
|
| 1298 |
+
of these functions is documented as part of the public API, but a deprecation
|
| 1299 |
+
path is needed due to use in existing ``manage.py`` files.
|
| 1300 |
+
|
| 1301 |
+
``is_safe`` and ``needs_autoescape`` attributes of template filters
|
| 1302 |
+
-------------------------------------------------------------------
|
| 1303 |
+
|
| 1304 |
+
Two flags, ``is_safe`` and ``needs_autoescape``, define how each template filter
|
| 1305 |
+
interacts with Django's auto-escaping behavior. They used to be attributes of
|
| 1306 |
+
the filter function::
|
| 1307 |
+
|
| 1308 |
+
@register.filter
|
| 1309 |
+
def noop(value):
|
| 1310 |
+
return value
|
| 1311 |
+
|
| 1312 |
+
|
| 1313 |
+
noop.is_safe = True
|
| 1314 |
+
|
| 1315 |
+
However, this technique caused some problems in combination with decorators,
|
| 1316 |
+
especially :func:`@stringfilter <django.template.defaultfilters.stringfilter>`.
|
| 1317 |
+
Now, the flags are keyword arguments of :meth:`@register.filter
|
| 1318 |
+
<django.template.Library.filter>`::
|
| 1319 |
+
|
| 1320 |
+
@register.filter(is_safe=True)
|
| 1321 |
+
def noop(value):
|
| 1322 |
+
return value
|
| 1323 |
+
|
| 1324 |
+
See :ref:`filters and auto-escaping <filters-auto-escaping>` for more information.
|
| 1325 |
+
|
| 1326 |
+
Wildcard expansion of application names in ``INSTALLED_APPS``
|
| 1327 |
+
-------------------------------------------------------------
|
| 1328 |
+
|
| 1329 |
+
Until Django 1.3, :setting:`INSTALLED_APPS` accepted wildcards in application
|
| 1330 |
+
names, like ``django.contrib.*``. The expansion was performed by a
|
| 1331 |
+
filesystem-based implementation of ``from <package> import *``. Unfortunately,
|
| 1332 |
+
this can't be done reliably.
|
| 1333 |
+
|
| 1334 |
+
This behavior was never documented. Since it is unpythonic, it was removed in
|
| 1335 |
+
Django 1.4. If you relied on it, you must edit your settings file to list all
|
| 1336 |
+
your applications explicitly.
|
| 1337 |
+
|
| 1338 |
+
``HttpRequest.raw_post_data`` renamed to ``HttpRequest.body``
|
| 1339 |
+
-------------------------------------------------------------
|
| 1340 |
+
|
| 1341 |
+
This attribute was confusingly named ``HttpRequest.raw_post_data``, but it
|
| 1342 |
+
actually provided the body of the HTTP request. It's been renamed to
|
| 1343 |
+
``HttpRequest.body``, and ``HttpRequest.raw_post_data`` has been deprecated.
|
| 1344 |
+
|
| 1345 |
+
``django.contrib.sitemaps`` bug fix with potential performance implications
|
| 1346 |
+
---------------------------------------------------------------------------
|
| 1347 |
+
|
| 1348 |
+
In previous versions, ``Paginator`` objects used in sitemap classes were
|
| 1349 |
+
cached, which could result in stale site maps. We've removed the caching, so
|
| 1350 |
+
each request to a site map now creates a new Paginator object and calls the
|
| 1351 |
+
:attr:`~django.contrib.sitemaps.Sitemap.items()` method of the
|
| 1352 |
+
:class:`~django.contrib.sitemaps.Sitemap` subclass. Depending on what your
|
| 1353 |
+
``items()`` method is doing, this may have a negative performance impact.
|
| 1354 |
+
To mitigate the performance impact, consider using the :doc:`caching
|
| 1355 |
+
framework </topics/cache>` within your ``Sitemap`` subclass.
|
| 1356 |
+
|
| 1357 |
+
Versions of Python-Markdown earlier than 2.1
|
| 1358 |
+
--------------------------------------------
|
| 1359 |
+
|
| 1360 |
+
Versions of Python-Markdown earlier than 2.1 do not support the option to
|
| 1361 |
+
disable attributes. As a security issue, earlier versions of this library will
|
| 1362 |
+
not be supported by the markup contrib app in 1.5 under an accelerated
|
| 1363 |
+
deprecation timeline.
|
testbed/django__django/docs/releases/1.5.1.txt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.5.1 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*March 28, 2013*
|
| 6 |
+
|
| 7 |
+
This is Django 1.5.1, a bugfix release for Django 1.5. It's completely backwards
|
| 8 |
+
compatible with Django 1.5, but includes a handful of fixes.
|
| 9 |
+
|
| 10 |
+
The biggest fix is for a memory leak introduced in Django 1.5. Under certain
|
| 11 |
+
circumstances, repeated iteration over querysets could leak memory - sometimes
|
| 12 |
+
quite a bit of it. If you'd like more information, the details are in
|
| 13 |
+
:ticket:`our ticket tracker <19895>` (and in :bpo:`a related issue <17468>` in
|
| 14 |
+
Python itself).
|
| 15 |
+
|
| 16 |
+
If you've noticed memory problems under Django 1.5, upgrading to 1.5.1 should
|
| 17 |
+
fix those issues.
|
| 18 |
+
|
| 19 |
+
Django 1.5.1 also includes a couple smaller fixes:
|
| 20 |
+
|
| 21 |
+
* Module-level warnings emitted during tests are no longer silently hidden
|
| 22 |
+
(:ticket:`18985`).
|
| 23 |
+
* Prevented filtering on password hashes in the user admin (:ticket:`20078`).
|
testbed/django__django/docs/releases/1.5.7.txt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.5.7 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*April 28, 2014*
|
| 6 |
+
|
| 7 |
+
Django 1.5.7 fixes a regression in the 1.5.6 security release.
|
| 8 |
+
|
| 9 |
+
Bugfixes
|
| 10 |
+
========
|
| 11 |
+
|
| 12 |
+
* Restored the ability to ``reverse()`` views created using
|
| 13 |
+
:func:`functools.partial()` (:ticket:`22486`).
|
testbed/django__django/docs/releases/1.5.8.txt
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.5.8 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*May 14, 2014*
|
| 6 |
+
|
| 7 |
+
Django 1.5.8 fixes two security issues in 1.5.8.
|
| 8 |
+
|
| 9 |
+
Caches may incorrectly be allowed to store and serve private data
|
| 10 |
+
=================================================================
|
| 11 |
+
|
| 12 |
+
In certain situations, Django may allow caches to store private data
|
| 13 |
+
related to a particular session and then serve that data to requests
|
| 14 |
+
with a different session, or no session at all. This can lead to
|
| 15 |
+
information disclosure and can be a vector for cache poisoning.
|
| 16 |
+
|
| 17 |
+
When using Django sessions, Django will set a ``Vary: Cookie`` header to
|
| 18 |
+
ensure caches do not serve cached data to requests from other sessions.
|
| 19 |
+
However, older versions of Internet Explorer (most likely only Internet
|
| 20 |
+
Explorer 6, and Internet Explorer 7 if run on Windows XP or Windows Server
|
| 21 |
+
2003) are unable to handle the ``Vary`` header in combination with many content
|
| 22 |
+
types. Therefore, Django would remove the header if the request was made by
|
| 23 |
+
Internet Explorer.
|
| 24 |
+
|
| 25 |
+
To remedy this, the special behavior for these older Internet Explorer versions
|
| 26 |
+
has been removed, and the ``Vary`` header is no longer stripped from the response.
|
| 27 |
+
In addition, modifications to the ``Cache-Control`` header for all Internet Explorer
|
| 28 |
+
requests with a ``Content-Disposition`` header have also been removed as they
|
| 29 |
+
were found to have similar issues.
|
| 30 |
+
|
| 31 |
+
Malformed redirect URLs from user input not correctly validated
|
| 32 |
+
===============================================================
|
| 33 |
+
|
| 34 |
+
The validation for redirects did not correctly validate some malformed URLs,
|
| 35 |
+
which are accepted by some browsers. This allows a user to be redirected to
|
| 36 |
+
an unsafe URL unexpectedly.
|
| 37 |
+
|
| 38 |
+
Django relies on user input in some cases (e.g.
|
| 39 |
+
``django.contrib.auth.views.login()``, ``django.contrib.comments``, and
|
| 40 |
+
:doc:`i18n </topics/i18n/index>`) to redirect the user to an "on success" URL.
|
| 41 |
+
The security checks for these redirects (namely
|
| 42 |
+
``django.utils.http.is_safe_url()``) did not correctly validate some malformed
|
| 43 |
+
URLs, such as ``http:\\\\\\djangoproject.com``, which are accepted by some
|
| 44 |
+
browsers with more liberal URL parsing.
|
| 45 |
+
|
| 46 |
+
To remedy this, the validation in ``is_safe_url()`` has been tightened to be able
|
| 47 |
+
to handle and correctly validate these malformed URLs.
|
testbed/django__django/docs/releases/1.5.9.txt
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.5.9 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*August 20, 2014*
|
| 6 |
+
|
| 7 |
+
Django 1.5.9 fixes several security issues in 1.5.8.
|
| 8 |
+
|
| 9 |
+
``reverse()`` could generate URLs pointing to other hosts
|
| 10 |
+
=========================================================
|
| 11 |
+
|
| 12 |
+
In certain situations, URL reversing could generate scheme-relative URLs (URLs
|
| 13 |
+
starting with two slashes), which could unexpectedly redirect a user to a
|
| 14 |
+
different host. An attacker could exploit this, for example, by redirecting
|
| 15 |
+
users to a phishing site designed to ask for user's passwords.
|
| 16 |
+
|
| 17 |
+
To remedy this, URL reversing now ensures that no URL starts with two slashes
|
| 18 |
+
(//), replacing the second slash with its URL encoded counterpart (%2F). This
|
| 19 |
+
approach ensures that semantics stay the same, while making the URL relative to
|
| 20 |
+
the domain and not to the scheme.
|
| 21 |
+
|
| 22 |
+
File upload denial-of-service
|
| 23 |
+
=============================
|
| 24 |
+
|
| 25 |
+
Before this release, Django's file upload handing in its default configuration
|
| 26 |
+
may degrade to producing a huge number of ``os.stat()`` system calls when a
|
| 27 |
+
duplicate filename is uploaded. Since ``stat()`` may invoke IO, this may produce
|
| 28 |
+
a huge data-dependent slowdown that slowly worsens over time. The net result is
|
| 29 |
+
that given enough time, a user with the ability to upload files can cause poor
|
| 30 |
+
performance in the upload handler, eventually causing it to become very slow
|
| 31 |
+
simply by uploading 0-byte files. At this point, even a slow network connection
|
| 32 |
+
and few HTTP requests would be all that is necessary to make a site unavailable.
|
| 33 |
+
|
| 34 |
+
We've remedied the issue by changing the algorithm for generating file names
|
| 35 |
+
if a file with the uploaded name already exists.
|
| 36 |
+
:meth:`Storage.get_available_name()
|
| 37 |
+
<django.core.files.storage.Storage.get_available_name>` now appends an
|
| 38 |
+
underscore plus a random 7 character alphanumeric string (e.g. ``"_x3a1gho"``),
|
| 39 |
+
rather than iterating through an underscore followed by a number (e.g. ``"_1"``,
|
| 40 |
+
``"_2"``, etc.).
|
| 41 |
+
|
| 42 |
+
``RemoteUserMiddleware`` session hijacking
|
| 43 |
+
==========================================
|
| 44 |
+
|
| 45 |
+
When using the :class:`~django.contrib.auth.middleware.RemoteUserMiddleware`
|
| 46 |
+
and the ``RemoteUserBackend``, a change to the ``REMOTE_USER`` header between
|
| 47 |
+
requests without an intervening logout could result in the prior user's session
|
| 48 |
+
being co-opted by the subsequent user. The middleware now logs the user out on
|
| 49 |
+
a failed login attempt.
|
| 50 |
+
|
| 51 |
+
Data leakage via query string manipulation in ``contrib.admin``
|
| 52 |
+
===============================================================
|
| 53 |
+
|
| 54 |
+
In older versions of Django it was possible to reveal any field's data by
|
| 55 |
+
modifying the "popup" and "to_field" parameters of the query string on an admin
|
| 56 |
+
change form page. For example, requesting a URL like
|
| 57 |
+
``/admin/auth/user/?pop=1&t=password`` and viewing the page's HTML allowed
|
| 58 |
+
viewing the password hash of each user. While the admin requires users to have
|
| 59 |
+
permissions to view the change form pages in the first place, this could leak
|
| 60 |
+
data if you rely on users having access to view only certain fields on a model.
|
| 61 |
+
|
| 62 |
+
To address the issue, an exception will now be raised if a ``to_field`` value
|
| 63 |
+
that isn't a related field to a model that has been registered with the admin
|
| 64 |
+
is specified.
|
testbed/django__django/docs/releases/1.5.txt
ADDED
|
@@ -0,0 +1,814 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========================
|
| 2 |
+
Django 1.5 release notes
|
| 3 |
+
========================
|
| 4 |
+
|
| 5 |
+
*February 26, 2013*
|
| 6 |
+
|
| 7 |
+
Welcome to Django 1.5!
|
| 8 |
+
|
| 9 |
+
These release notes cover the :ref:`new features <whats-new-1.5>`, as well as
|
| 10 |
+
some :ref:`backwards incompatible changes <backwards-incompatible-1.5>` you'll
|
| 11 |
+
want to be aware of when upgrading from Django 1.4 or older versions. We've
|
| 12 |
+
also dropped some features, which are detailed in :ref:`our deprecation plan
|
| 13 |
+
<deprecation-removed-in-1.5>`, and we've :ref:`begun the deprecation process
|
| 14 |
+
for some features <deprecated-features-1.5>`.
|
| 15 |
+
|
| 16 |
+
Overview
|
| 17 |
+
========
|
| 18 |
+
|
| 19 |
+
The biggest new feature in Django 1.5 is the `configurable User model`_. Before
|
| 20 |
+
Django 1.5, applications that wanted to use Django's auth framework
|
| 21 |
+
(:mod:`django.contrib.auth`) were forced to use Django's definition of a "user".
|
| 22 |
+
In Django 1.5, you can now swap out the ``User`` model for one that you write
|
| 23 |
+
yourself. This could be a simple extension to the existing ``User`` model -- for
|
| 24 |
+
example, you could add a Twitter or Facebook ID field -- or you could completely
|
| 25 |
+
replace the ``User`` with one totally customized for your site.
|
| 26 |
+
|
| 27 |
+
Django 1.5 is also the first release with `Python 3 support`_! We're labeling
|
| 28 |
+
this support "experimental" because we don't yet consider it production-ready,
|
| 29 |
+
but everything's in place for you to start porting your apps to Python 3.
|
| 30 |
+
Our next release, Django 1.6, will support Python 3 without reservations.
|
| 31 |
+
|
| 32 |
+
Other notable new features in Django 1.5 include:
|
| 33 |
+
|
| 34 |
+
* `Support for saving a subset of model's fields`_ -
|
| 35 |
+
:meth:`Model.save() <django.db.models.Model.save()>` now accepts an
|
| 36 |
+
``update_fields`` argument, letting you specify which fields are
|
| 37 |
+
written back to the database when you call ``save()``. This can help
|
| 38 |
+
in high-concurrency operations, and can improve performance.
|
| 39 |
+
|
| 40 |
+
* Better `support for streaming responses <#explicit-streaming-responses>`_ via
|
| 41 |
+
the new :class:`~django.http.StreamingHttpResponse` response class.
|
| 42 |
+
|
| 43 |
+
* `GeoDjango`_ now supports PostGIS 2.0.
|
| 44 |
+
|
| 45 |
+
* ... and more; `see below <#what-s-new-in-django-1-5>`_.
|
| 46 |
+
|
| 47 |
+
Wherever possible we try to introduce new features in a backwards-compatible
|
| 48 |
+
manner per :doc:`our API stability policy </misc/api-stability>`.
|
| 49 |
+
However, as with previous releases, Django 1.5 ships with some minor
|
| 50 |
+
:ref:`backwards incompatible changes <backwards-incompatible-1.5>`; people
|
| 51 |
+
upgrading from previous versions of Django should read that list carefully.
|
| 52 |
+
|
| 53 |
+
One deprecated feature worth noting is the shift to "new-style" :ttag:`url` tag.
|
| 54 |
+
Prior to Django 1.3, syntax like ``{% url myview %}`` was interpreted
|
| 55 |
+
incorrectly (Django considered ``"myview"`` to be a literal name of a view, not
|
| 56 |
+
a template variable named ``myview``). Django 1.3 and above introduced the
|
| 57 |
+
``{% load url from future %}`` syntax to bring in the corrected behavior where
|
| 58 |
+
``myview`` was seen as a variable.
|
| 59 |
+
|
| 60 |
+
The upshot of this is that if you are not using ``{% load url from future %}``
|
| 61 |
+
in your templates, you'll need to change tags like ``{% url myview %}`` to
|
| 62 |
+
``{% url "myview" %}``. If you *were* using ``{% load url from future %}`` you
|
| 63 |
+
can simply remove that line under Django 1.5
|
| 64 |
+
|
| 65 |
+
Python compatibility
|
| 66 |
+
====================
|
| 67 |
+
|
| 68 |
+
Django 1.5 requires Python 2.6.5 or above, though we **highly recommend**
|
| 69 |
+
Python 2.7.3 or above. Support for Python 2.5 and below has been dropped.
|
| 70 |
+
|
| 71 |
+
This change should affect only a small number of Django users, as most
|
| 72 |
+
operating-system vendors today are shipping Python 2.6 or newer as their default
|
| 73 |
+
version. If you're still using Python 2.5, however, you'll need to stick to
|
| 74 |
+
Django 1.4 until you can upgrade your Python version. Per :doc:`our support
|
| 75 |
+
policy </internals/release-process>`, Django 1.4 will continue to receive
|
| 76 |
+
security support until the release of Django 1.6.
|
| 77 |
+
|
| 78 |
+
Django 1.5 does not run on a Jython final release, because Jython's latest
|
| 79 |
+
release doesn't currently support Python 2.6. However, Jython currently does
|
| 80 |
+
offer an alpha release featuring 2.7 support, and Django 1.5 supports that alpha
|
| 81 |
+
release.
|
| 82 |
+
|
| 83 |
+
Python 3 support
|
| 84 |
+
----------------
|
| 85 |
+
|
| 86 |
+
Django 1.5 introduces support for Python 3 - specifically, Python
|
| 87 |
+
3.2 and above. This comes in the form of a **single** codebase; you don't
|
| 88 |
+
need to install a different version of Django on Python 3. This means that
|
| 89 |
+
you can write applications targeted for just Python 2, just Python 3, or single
|
| 90 |
+
applications that support both platforms.
|
| 91 |
+
|
| 92 |
+
However, we're labeling this support "experimental" for now: although it's
|
| 93 |
+
received extensive testing via our automated test suite, it's received very
|
| 94 |
+
little real-world testing. We've done our best to eliminate bugs, but we can't
|
| 95 |
+
be sure we covered all possible uses of Django.
|
| 96 |
+
|
| 97 |
+
Some features of Django aren't available because they depend on third-party
|
| 98 |
+
software that hasn't been ported to Python 3 yet, including:
|
| 99 |
+
|
| 100 |
+
- the MySQL database backend (depends on MySQLdb)
|
| 101 |
+
- :class:`~django.db.models.ImageField` (depends on PIL)
|
| 102 |
+
- :class:`~django.test.LiveServerTestCase` (depends on Selenium WebDriver)
|
| 103 |
+
|
| 104 |
+
Further, Django's more than a web framework; it's an ecosystem of pluggable
|
| 105 |
+
components. At this point, very few third-party applications have been ported
|
| 106 |
+
to Python 3, so it's unlikely that a real-world application will have all its
|
| 107 |
+
dependencies satisfied under Python 3.
|
| 108 |
+
|
| 109 |
+
Thus, we're recommending that Django 1.5 not be used in production under Python
|
| 110 |
+
3. Instead, use this opportunity to begin porting applications to Python 3. If
|
| 111 |
+
you're an author of a pluggable component, we encourage you to start porting
|
| 112 |
+
now.
|
| 113 |
+
|
| 114 |
+
We plan to offer first-class, production-ready support for Python 3 in our next
|
| 115 |
+
release, Django 1.6.
|
| 116 |
+
|
| 117 |
+
.. _whats-new-1.5:
|
| 118 |
+
|
| 119 |
+
What's new in Django 1.5
|
| 120 |
+
========================
|
| 121 |
+
|
| 122 |
+
Configurable User model
|
| 123 |
+
-----------------------
|
| 124 |
+
|
| 125 |
+
In Django 1.5, you can now use your own model as the store for user-related
|
| 126 |
+
data. If your project needs a username with more than 30 characters, or if
|
| 127 |
+
you want to store user's names in a format other than first name/last name,
|
| 128 |
+
or you want to put custom profile information onto your User object, you can
|
| 129 |
+
now do so.
|
| 130 |
+
|
| 131 |
+
If you have a third-party reusable application that references the User model,
|
| 132 |
+
you may need to make some changes to the way you reference User instances. You
|
| 133 |
+
should also document any specific features of the User model that your
|
| 134 |
+
application relies upon.
|
| 135 |
+
|
| 136 |
+
See the :ref:`documentation on custom user models <auth-custom-user>` for
|
| 137 |
+
more details.
|
| 138 |
+
|
| 139 |
+
Support for saving a subset of model's fields
|
| 140 |
+
---------------------------------------------
|
| 141 |
+
|
| 142 |
+
The method :meth:`Model.save() <django.db.models.Model.save()>` has a new
|
| 143 |
+
keyword argument ``update_fields``. By using this argument it is possible to
|
| 144 |
+
save only a select list of model's fields. This can be useful for performance
|
| 145 |
+
reasons or when trying to avoid overwriting concurrent changes.
|
| 146 |
+
|
| 147 |
+
Deferred instances (those loaded by ``.only()`` or ``.defer()``) will
|
| 148 |
+
automatically save just the loaded fields. If any field is set manually after
|
| 149 |
+
load, that field will also get updated on save.
|
| 150 |
+
|
| 151 |
+
See the :meth:`Model.save() <django.db.models.Model.save()>` documentation for
|
| 152 |
+
more details.
|
| 153 |
+
|
| 154 |
+
Caching of related model instances
|
| 155 |
+
----------------------------------
|
| 156 |
+
|
| 157 |
+
When traversing relations, the ORM will avoid re-fetching objects that were
|
| 158 |
+
previously loaded. For example, with the tutorial's models:
|
| 159 |
+
|
| 160 |
+
.. code-block:: pycon
|
| 161 |
+
|
| 162 |
+
>>> first_poll = Poll.objects.all()[0]
|
| 163 |
+
>>> first_choice = first_poll.choice_set.all()[0]
|
| 164 |
+
>>> first_choice.poll is first_poll
|
| 165 |
+
True
|
| 166 |
+
|
| 167 |
+
In Django 1.5, the third line no longer triggers a new SQL query to fetch
|
| 168 |
+
``first_choice.poll``; it was set by the second line.
|
| 169 |
+
|
| 170 |
+
For one-to-one relationships, both sides can be cached. For many-to-one
|
| 171 |
+
relationships, only the single side of the relationship can be cached. This
|
| 172 |
+
is particularly helpful in combination with ``prefetch_related``.
|
| 173 |
+
|
| 174 |
+
.. _explicit-streaming-responses:
|
| 175 |
+
|
| 176 |
+
Explicit support for streaming responses
|
| 177 |
+
----------------------------------------
|
| 178 |
+
|
| 179 |
+
Before Django 1.5, it was possible to create a streaming response by passing
|
| 180 |
+
an iterator to :class:`~django.http.HttpResponse`. But this was unreliable:
|
| 181 |
+
any middleware that accessed the :attr:`~django.http.HttpResponse.content`
|
| 182 |
+
attribute would consume the iterator prematurely.
|
| 183 |
+
|
| 184 |
+
You can now explicitly generate a streaming response with the new
|
| 185 |
+
:class:`~django.http.StreamingHttpResponse` class. This class exposes a
|
| 186 |
+
:class:`~django.http.StreamingHttpResponse.streaming_content` attribute which
|
| 187 |
+
is an iterator.
|
| 188 |
+
|
| 189 |
+
Since :class:`~django.http.StreamingHttpResponse` does not have a ``content``
|
| 190 |
+
attribute, middleware that needs access to the response content must test for
|
| 191 |
+
streaming responses and behave accordingly.
|
| 192 |
+
|
| 193 |
+
``{% verbatim %}`` template tag
|
| 194 |
+
-------------------------------
|
| 195 |
+
|
| 196 |
+
To make it easier to deal with JavaScript templates which collide with Django's
|
| 197 |
+
syntax, you can now use the :ttag:`verbatim` block tag to avoid parsing the
|
| 198 |
+
tag's content.
|
| 199 |
+
|
| 200 |
+
Retrieval of ``ContentType`` instances associated with proxy models
|
| 201 |
+
-------------------------------------------------------------------
|
| 202 |
+
|
| 203 |
+
The methods :meth:`ContentTypeManager.get_for_model() <django.contrib.contenttypes.models.ContentTypeManager.get_for_model()>`
|
| 204 |
+
and :meth:`ContentTypeManager.get_for_models() <django.contrib.contenttypes.models.ContentTypeManager.get_for_models()>`
|
| 205 |
+
have a new keyword argument – respectively ``for_concrete_model`` and ``for_concrete_models``.
|
| 206 |
+
By passing ``False`` using this argument it is now possible to retrieve the
|
| 207 |
+
:class:`ContentType <django.contrib.contenttypes.models.ContentType>`
|
| 208 |
+
associated with proxy models.
|
| 209 |
+
|
| 210 |
+
New ``view`` variable in class-based views context
|
| 211 |
+
--------------------------------------------------
|
| 212 |
+
|
| 213 |
+
In all :doc:`generic class-based views </topics/class-based-views/index>`
|
| 214 |
+
(or any class-based view inheriting from ``ContextMixin``), the context dictionary
|
| 215 |
+
contains a ``view`` variable that points to the ``View`` instance.
|
| 216 |
+
|
| 217 |
+
GeoDjango
|
| 218 |
+
---------
|
| 219 |
+
|
| 220 |
+
* :class:`~django.contrib.gis.geos.LineString` and
|
| 221 |
+
:class:`~django.contrib.gis.geos.MultiLineString` GEOS objects now support the
|
| 222 |
+
:meth:`~django.contrib.gis.geos.GEOSGeometry.interpolate()` and
|
| 223 |
+
:meth:`~django.contrib.gis.geos.GEOSGeometry.project()` methods
|
| 224 |
+
(so-called linear referencing).
|
| 225 |
+
|
| 226 |
+
* The ``wkb`` and ``hex`` properties of
|
| 227 |
+
:class:`~django.contrib.gis.geos.GEOSGeometry` objects preserve the Z
|
| 228 |
+
dimension.
|
| 229 |
+
|
| 230 |
+
* Support for PostGIS 2.0 has been added and support for GDAL < 1.5 has been
|
| 231 |
+
dropped.
|
| 232 |
+
|
| 233 |
+
New tutorials
|
| 234 |
+
-------------
|
| 235 |
+
|
| 236 |
+
Additions to the docs include a revamped :doc:`Tutorial 3</intro/tutorial03>`
|
| 237 |
+
and a new :doc:`tutorial on testing</intro/tutorial05>`. A new section,
|
| 238 |
+
"Advanced Tutorials", offers :doc:`How to write reusable apps
|
| 239 |
+
</intro/reusable-apps>` as well as a step-by-step guide for new contributors in
|
| 240 |
+
:doc:`Writing your first patch for Django </intro/contributing>`.
|
| 241 |
+
|
| 242 |
+
Minor features
|
| 243 |
+
--------------
|
| 244 |
+
|
| 245 |
+
Django 1.5 also includes several smaller improvements worth noting:
|
| 246 |
+
|
| 247 |
+
* The template engine now interprets ``True``, ``False`` and ``None`` as the
|
| 248 |
+
corresponding Python objects.
|
| 249 |
+
|
| 250 |
+
* :mod:`django.utils.timezone` provides a helper for converting aware
|
| 251 |
+
datetimes between time zones. See :func:`~django.utils.timezone.localtime`.
|
| 252 |
+
|
| 253 |
+
* The generic views support OPTIONS requests.
|
| 254 |
+
|
| 255 |
+
* Management commands do not raise ``SystemExit`` any more when called by code
|
| 256 |
+
from :func:`~django.core.management.call_command`. Any exception raised by
|
| 257 |
+
the command (mostly :exc:`~django.core.management.CommandError`) is
|
| 258 |
+
propagated.
|
| 259 |
+
|
| 260 |
+
Moreover, when you output errors or messages in your custom commands, you
|
| 261 |
+
should now use ``self.stdout.write('message')`` and
|
| 262 |
+
``self.stderr.write('error')`` (see the note on
|
| 263 |
+
:ref:`management commands output <management-commands-output>`).
|
| 264 |
+
|
| 265 |
+
* The :djadmin:`dumpdata` management command outputs one row at a time,
|
| 266 |
+
preventing out-of-memory errors when dumping large datasets.
|
| 267 |
+
|
| 268 |
+
* In the localflavor for Canada, ``pq`` was added to the acceptable codes for
|
| 269 |
+
Quebec. It's an old abbreviation.
|
| 270 |
+
|
| 271 |
+
* The :ref:`receiver <connecting-receiver-functions>` decorator is now able to
|
| 272 |
+
connect to more than one signal by supplying a list of signals.
|
| 273 |
+
|
| 274 |
+
* In the admin, you can now filter users by groups which they are members of.
|
| 275 |
+
|
| 276 |
+
* :meth:`QuerySet.bulk_create()
|
| 277 |
+
<django.db.models.query.QuerySet.bulk_create>` now has a batch_size
|
| 278 |
+
argument. By default the batch_size is unlimited except for SQLite where
|
| 279 |
+
single batch is limited so that 999 parameters per query isn't exceeded.
|
| 280 |
+
|
| 281 |
+
* The :setting:`LOGIN_URL` and :setting:`LOGIN_REDIRECT_URL` settings now also
|
| 282 |
+
accept view function names and
|
| 283 |
+
:ref:`named URL patterns <naming-url-patterns>`. This allows you to reduce
|
| 284 |
+
configuration duplication. More information can be found in the
|
| 285 |
+
:func:`~django.contrib.auth.decorators.login_required` documentation.
|
| 286 |
+
|
| 287 |
+
* Django now provides a mod_wsgi :doc:`auth handler
|
| 288 |
+
</howto/deployment/wsgi/apache-auth>`.
|
| 289 |
+
|
| 290 |
+
* The :meth:`QuerySet.delete() <django.db.models.query.QuerySet.delete>`
|
| 291 |
+
and :meth:`Model.delete() <django.db.models.Model.delete()>` can now take
|
| 292 |
+
fast-path in some cases. The fast-path allows for less queries and less
|
| 293 |
+
objects fetched into memory. See :meth:`QuerySet.delete()
|
| 294 |
+
<django.db.models.query.QuerySet.delete>` for details.
|
| 295 |
+
|
| 296 |
+
* An instance of ``ResolverMatch`` is stored on the request as
|
| 297 |
+
``resolver_match``.
|
| 298 |
+
|
| 299 |
+
* By default, all logging messages reaching the ``django`` logger when
|
| 300 |
+
:setting:`DEBUG` is ``True`` are sent to the console (unless you redefine the
|
| 301 |
+
logger in your :setting:`LOGGING` setting).
|
| 302 |
+
|
| 303 |
+
* When using :class:`~django.template.RequestContext`, it is now possible to
|
| 304 |
+
look up permissions by using ``{% if 'someapp.someperm' in perms %}``
|
| 305 |
+
in templates.
|
| 306 |
+
|
| 307 |
+
* It's not required any more to have ``404.html`` and ``500.html`` templates in
|
| 308 |
+
the root templates directory. Django will output some basic error messages for
|
| 309 |
+
both situations when those templates are not found. It's still recommended as
|
| 310 |
+
good practice to provide those templates in order to present pretty error
|
| 311 |
+
pages to the user.
|
| 312 |
+
|
| 313 |
+
* :mod:`django.contrib.auth` provides a new signal that is emitted
|
| 314 |
+
whenever a user fails to login successfully. See
|
| 315 |
+
:data:`~django.contrib.auth.signals.user_login_failed`
|
| 316 |
+
|
| 317 |
+
* The new :option:`loaddata --ignorenonexistent` option ignore data for fields
|
| 318 |
+
that no longer exist.
|
| 319 |
+
|
| 320 |
+
* :meth:`~django.test.SimpleTestCase.assertXMLEqual` and
|
| 321 |
+
:meth:`~django.test.SimpleTestCase.assertXMLNotEqual` new assertions allow
|
| 322 |
+
you to test equality for XML content at a semantic level, without caring for
|
| 323 |
+
syntax differences (spaces, attribute order, etc.).
|
| 324 |
+
|
| 325 |
+
* RemoteUserMiddleware now forces logout when the REMOTE_USER header
|
| 326 |
+
disappears during the same browser session.
|
| 327 |
+
|
| 328 |
+
* The :ref:`cache-based session backend <cached-sessions-backend>` can store
|
| 329 |
+
session data in a non-default cache.
|
| 330 |
+
|
| 331 |
+
* Multi-column indexes can now be created on models. Read the
|
| 332 |
+
:attr:`~django.db.models.Options.index_together` documentation for more
|
| 333 |
+
information.
|
| 334 |
+
|
| 335 |
+
* During Django's logging configuration verbose Deprecation warnings are
|
| 336 |
+
enabled and warnings are captured into the logging system. Logged warnings
|
| 337 |
+
are routed through the ``console`` logging handler, which by default requires
|
| 338 |
+
:setting:`DEBUG` to be True for output to be generated. The result is that
|
| 339 |
+
DeprecationWarnings should be printed to the console in development
|
| 340 |
+
environments the way they have been in Python versions < 2.7.
|
| 341 |
+
|
| 342 |
+
* The API for :meth:`django.contrib.admin.ModelAdmin.message_user` method has
|
| 343 |
+
been modified to accept additional arguments adding capabilities similar to
|
| 344 |
+
:func:`django.contrib.messages.add_message`. This is useful for generating
|
| 345 |
+
error messages from admin actions.
|
| 346 |
+
|
| 347 |
+
* The admin's list filters can now be customized per-request thanks to the new
|
| 348 |
+
:meth:`django.contrib.admin.ModelAdmin.get_list_filter` method.
|
| 349 |
+
|
| 350 |
+
.. _backwards-incompatible-1.5:
|
| 351 |
+
|
| 352 |
+
Backwards incompatible changes in 1.5
|
| 353 |
+
=====================================
|
| 354 |
+
|
| 355 |
+
.. warning::
|
| 356 |
+
|
| 357 |
+
In addition to the changes outlined in this section, be sure to review the
|
| 358 |
+
:ref:`deprecation plan <deprecation-removed-in-1.5>` for any features that
|
| 359 |
+
have been removed. If you haven't updated your code within the
|
| 360 |
+
deprecation timeline for a given feature, its removal may appear as a
|
| 361 |
+
backwards incompatible change.
|
| 362 |
+
|
| 363 |
+
``ALLOWED_HOSTS`` required in production
|
| 364 |
+
----------------------------------------
|
| 365 |
+
|
| 366 |
+
The new :setting:`ALLOWED_HOSTS` setting validates the request's ``Host``
|
| 367 |
+
header and protects against host-poisoning attacks. This setting is now
|
| 368 |
+
required whenever :setting:`DEBUG` is ``False``, or else
|
| 369 |
+
:meth:`django.http.HttpRequest.get_host()` will raise
|
| 370 |
+
:exc:`~django.core.exceptions.SuspiciousOperation`. For more details see the
|
| 371 |
+
:setting:`full documentation<ALLOWED_HOSTS>` for the new setting.
|
| 372 |
+
|
| 373 |
+
Managers on abstract models
|
| 374 |
+
---------------------------
|
| 375 |
+
|
| 376 |
+
Abstract models are able to define a custom manager, and that manager
|
| 377 |
+
:ref:`will be inherited by any concrete models extending the abstract model
|
| 378 |
+
<custom-managers-and-inheritance>`. However, if you try to use the abstract
|
| 379 |
+
model to call a method on the manager, an exception will now be raised.
|
| 380 |
+
Previously, the call would have been permitted, but would have failed as soon
|
| 381 |
+
as any database operation was attempted (usually with a "table does not exist"
|
| 382 |
+
error from the database).
|
| 383 |
+
|
| 384 |
+
If you have functionality on a manager that you have been invoking using
|
| 385 |
+
the abstract class, you should migrate that logic to a Python
|
| 386 |
+
``staticmethod`` or ``classmethod`` on the abstract class.
|
| 387 |
+
|
| 388 |
+
Context in year archive class-based views
|
| 389 |
+
-----------------------------------------
|
| 390 |
+
|
| 391 |
+
For consistency with the other date-based generic views,
|
| 392 |
+
:class:`~django.views.generic.dates.YearArchiveView` now passes ``year`` in
|
| 393 |
+
the context as a :class:`datetime.date` rather than a string. If you are
|
| 394 |
+
using ``{{ year }}`` in your templates, you must replace it with ``{{
|
| 395 |
+
year|date:"Y" }}``.
|
| 396 |
+
|
| 397 |
+
``next_year`` and ``previous_year`` were also added in the context. They are
|
| 398 |
+
calculated according to ``allow_empty`` and ``allow_future``.
|
| 399 |
+
|
| 400 |
+
Context in year and month archive class-based views
|
| 401 |
+
---------------------------------------------------
|
| 402 |
+
|
| 403 |
+
:class:`~django.views.generic.dates.YearArchiveView` and
|
| 404 |
+
:class:`~django.views.generic.dates.MonthArchiveView` were documented to
|
| 405 |
+
provide a ``date_list`` sorted in ascending order in the context, like their
|
| 406 |
+
function-based predecessors, but it actually was in descending order. In 1.5,
|
| 407 |
+
the documented order was restored. You may want to add (or remove) the
|
| 408 |
+
``reversed`` keyword when you're iterating on ``date_list`` in a template:
|
| 409 |
+
|
| 410 |
+
.. code-block:: html+django
|
| 411 |
+
|
| 412 |
+
{% for date in date_list reversed %}
|
| 413 |
+
|
| 414 |
+
:class:`~django.views.generic.dates.ArchiveIndexView` still provides a
|
| 415 |
+
``date_list`` in descending order.
|
| 416 |
+
|
| 417 |
+
Context in TemplateView
|
| 418 |
+
-----------------------
|
| 419 |
+
|
| 420 |
+
For consistency with the design of the other generic views,
|
| 421 |
+
:class:`~django.views.generic.base.TemplateView` no longer passes a ``params``
|
| 422 |
+
dictionary into the context, instead passing the variables from the URLconf
|
| 423 |
+
directly into the context.
|
| 424 |
+
|
| 425 |
+
Non-form data in HTTP requests
|
| 426 |
+
------------------------------
|
| 427 |
+
|
| 428 |
+
:attr:`request.POST <django.http.HttpRequest.POST>` will no longer include data
|
| 429 |
+
posted via HTTP requests with non form-specific content-types in the header.
|
| 430 |
+
In prior versions, data posted with content-types other than
|
| 431 |
+
:mimetype:`multipart/form-data` or
|
| 432 |
+
:mimetype:`application/x-www-form-urlencoded` would still end up represented in
|
| 433 |
+
the :attr:`request.POST <django.http.HttpRequest.POST>` attribute. Developers
|
| 434 |
+
wishing to access the raw POST data for these cases, should use the
|
| 435 |
+
:attr:`request.body <django.http.HttpRequest.body>` attribute instead.
|
| 436 |
+
|
| 437 |
+
:data:`~django.core.signals.request_finished` signal
|
| 438 |
+
----------------------------------------------------
|
| 439 |
+
|
| 440 |
+
Django used to send the :data:`~django.core.signals.request_finished` signal
|
| 441 |
+
as soon as the view function returned a response. This interacted badly with
|
| 442 |
+
:ref:`streaming responses <httpresponse-streaming>` that delay content
|
| 443 |
+
generation.
|
| 444 |
+
|
| 445 |
+
This signal is now sent after the content is fully consumed by the WSGI
|
| 446 |
+
gateway. This might be backwards incompatible if you rely on the signal being
|
| 447 |
+
fired before sending the response content to the client. If you do, you should
|
| 448 |
+
consider using :doc:`middleware </topics/http/middleware>` instead.
|
| 449 |
+
|
| 450 |
+
.. note::
|
| 451 |
+
|
| 452 |
+
Some WSGI servers and middleware do not always call ``close`` on the
|
| 453 |
+
response object after handling a request, most notably uWSGI prior to 1.2.6
|
| 454 |
+
and Sentry's error reporting middleware up to 2.0.7. In those cases the
|
| 455 |
+
``request_finished`` signal isn't sent at all. This can result in idle
|
| 456 |
+
connections to database and memcache servers.
|
| 457 |
+
|
| 458 |
+
OPTIONS, PUT and DELETE requests in the test client
|
| 459 |
+
---------------------------------------------------
|
| 460 |
+
|
| 461 |
+
Unlike GET and POST, these HTTP methods aren't implemented by web browsers.
|
| 462 |
+
Rather, they're used in APIs, which transfer data in various formats such as
|
| 463 |
+
JSON or XML. Since such requests may contain arbitrary data, Django doesn't
|
| 464 |
+
attempt to decode their body.
|
| 465 |
+
|
| 466 |
+
However, the test client used to build a query string for OPTIONS and DELETE
|
| 467 |
+
requests like for GET, and a request body for PUT requests like for POST. This
|
| 468 |
+
encoding was arbitrary and inconsistent with Django's behavior when it
|
| 469 |
+
receives the requests, so it was removed in Django 1.5.
|
| 470 |
+
|
| 471 |
+
If you were using the ``data`` parameter in an OPTIONS or a DELETE request,
|
| 472 |
+
you must convert it to a query string and append it to the ``path`` parameter.
|
| 473 |
+
|
| 474 |
+
If you were using the ``data`` parameter in a PUT request without a
|
| 475 |
+
``content_type``, you must encode your data before passing it to the test
|
| 476 |
+
client and set the ``content_type`` argument.
|
| 477 |
+
|
| 478 |
+
.. _simplejson-incompatibilities:
|
| 479 |
+
|
| 480 |
+
System version of ``simplejson`` no longer used
|
| 481 |
+
-----------------------------------------------
|
| 482 |
+
|
| 483 |
+
:ref:`As explained below <simplejson-deprecation>`, Django 1.5 deprecates
|
| 484 |
+
``django.utils.simplejson`` in favor of Python 2.6's built-in :mod:`json`
|
| 485 |
+
module. In theory, this change is harmless. Unfortunately, because of
|
| 486 |
+
incompatibilities between versions of ``simplejson``, it may trigger errors
|
| 487 |
+
in some circumstances.
|
| 488 |
+
|
| 489 |
+
JSON-related features in Django 1.4 always used ``django.utils.simplejson``.
|
| 490 |
+
This module was actually:
|
| 491 |
+
|
| 492 |
+
- A system version of ``simplejson``, if one was available (i.e. ``import
|
| 493 |
+
simplejson`` works), if it was more recent than Django's built-in copy or it
|
| 494 |
+
had the C speedups, or
|
| 495 |
+
- The :mod:`json` module from the standard library, if it was available (i.e.
|
| 496 |
+
Python 2.6 or greater), or
|
| 497 |
+
- A built-in copy of version 2.0.7 of ``simplejson``.
|
| 498 |
+
|
| 499 |
+
In Django 1.5, those features use Python's :mod:`json` module, which is based
|
| 500 |
+
on version 2.0.9 of ``simplejson``.
|
| 501 |
+
|
| 502 |
+
There are no known incompatibilities between Django's copy of version 2.0.7 and
|
| 503 |
+
Python's copy of version 2.0.9. However, there are some incompatibilities
|
| 504 |
+
between other versions of ``simplejson``:
|
| 505 |
+
|
| 506 |
+
- While the ``simplejson`` API is documented as always returning Unicode
|
| 507 |
+
strings, the optional C implementation can return a bytestring. This was
|
| 508 |
+
fixed in Python 2.7.
|
| 509 |
+
- ``simplejson.JSONEncoder`` gained a ``namedtuple_as_object`` keyword
|
| 510 |
+
argument in version 2.2.
|
| 511 |
+
|
| 512 |
+
More information on these incompatibilities is available in
|
| 513 |
+
:ticket:`ticket #18023 <18023#comment:10>`.
|
| 514 |
+
|
| 515 |
+
The net result is that, if you have installed ``simplejson`` and your code
|
| 516 |
+
uses Django's serialization internals directly -- for instance
|
| 517 |
+
``django.core.serializers.json.DjangoJSONEncoder``, the switch from
|
| 518 |
+
``simplejson`` to :mod:`json` could break your code. (In general, changes to
|
| 519 |
+
internals aren't documented; we're making an exception here.)
|
| 520 |
+
|
| 521 |
+
At this point, the maintainers of Django believe that using :mod:`json` from
|
| 522 |
+
the standard library offers the strongest guarantee of backwards-compatibility.
|
| 523 |
+
They recommend to use it from now on.
|
| 524 |
+
|
| 525 |
+
String types of hasher method parameters
|
| 526 |
+
----------------------------------------
|
| 527 |
+
|
| 528 |
+
If you have written a :ref:`custom password hasher <auth_password_storage>`,
|
| 529 |
+
your ``encode()``, ``verify()`` or ``safe_summary()`` methods should accept
|
| 530 |
+
Unicode parameters (``password``, ``salt`` or ``encoded``). If any of the
|
| 531 |
+
hashing methods need bytestrings, you can use the
|
| 532 |
+
:func:`~django.utils.encoding.force_bytes` utility to encode the strings.
|
| 533 |
+
|
| 534 |
+
Validation of previous_page_number and next_page_number
|
| 535 |
+
-------------------------------------------------------
|
| 536 |
+
|
| 537 |
+
When using :doc:`object pagination </topics/pagination>`,
|
| 538 |
+
the ``previous_page_number()`` and ``next_page_number()`` methods of the
|
| 539 |
+
:class:`~django.core.paginator.Page` object did not check if the returned
|
| 540 |
+
number was inside the existing page range.
|
| 541 |
+
It does check it now and raises an :exc:`~django.core.paginator.InvalidPage`
|
| 542 |
+
exception when the number is either too low or too high.
|
| 543 |
+
|
| 544 |
+
Behavior of autocommit database option on PostgreSQL changed
|
| 545 |
+
------------------------------------------------------------
|
| 546 |
+
|
| 547 |
+
PostgreSQL's autocommit option didn't work as advertised previously. It did
|
| 548 |
+
work for single transaction block, but after the first block was left the
|
| 549 |
+
autocommit behavior was never restored. This bug is now fixed in 1.5. While
|
| 550 |
+
this is only a bug fix, it is worth checking your applications behavior if
|
| 551 |
+
you are using PostgreSQL together with the autocommit option.
|
| 552 |
+
|
| 553 |
+
Session not saved on 500 responses
|
| 554 |
+
----------------------------------
|
| 555 |
+
|
| 556 |
+
Django's session middleware will skip saving the session data if the
|
| 557 |
+
response's status code is 500.
|
| 558 |
+
|
| 559 |
+
Email checks on failed admin login
|
| 560 |
+
----------------------------------
|
| 561 |
+
|
| 562 |
+
Prior to Django 1.5, if you attempted to log into the admin interface and
|
| 563 |
+
mistakenly used your email address instead of your username, the admin
|
| 564 |
+
interface would provide a warning advising that your email address was
|
| 565 |
+
not your username. In Django 1.5, the introduction of
|
| 566 |
+
:ref:`custom user models <auth-custom-user>` has required the removal of this
|
| 567 |
+
warning. This doesn't change the login behavior of the admin site; it only
|
| 568 |
+
affects the warning message that is displayed under one particular mode of
|
| 569 |
+
login failure.
|
| 570 |
+
|
| 571 |
+
Changes in tests execution
|
| 572 |
+
--------------------------
|
| 573 |
+
|
| 574 |
+
Some changes have been introduced in the execution of tests that might be
|
| 575 |
+
backward-incompatible for some testing setups:
|
| 576 |
+
|
| 577 |
+
Database flushing in ``django.test.TransactionTestCase``
|
| 578 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 579 |
+
|
| 580 |
+
Previously, the test database was truncated *before* each test run in a
|
| 581 |
+
:class:`~django.test.TransactionTestCase`.
|
| 582 |
+
|
| 583 |
+
In order to be able to run unit tests in any order and to make sure they are
|
| 584 |
+
always isolated from each other, :class:`~django.test.TransactionTestCase` will
|
| 585 |
+
now reset the database *after* each test run instead.
|
| 586 |
+
|
| 587 |
+
No more implicit DB sequences reset
|
| 588 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 589 |
+
|
| 590 |
+
:class:`~django.test.TransactionTestCase` tests used to reset primary key
|
| 591 |
+
sequences automatically together with the database flushing actions described
|
| 592 |
+
above.
|
| 593 |
+
|
| 594 |
+
This has been changed so no sequences are implicitly reset. This can cause
|
| 595 |
+
:class:`~django.test.TransactionTestCase` tests that depend on hard-coded
|
| 596 |
+
primary key values to break.
|
| 597 |
+
|
| 598 |
+
The new :attr:`~django.test.TransactionTestCase.reset_sequences` attribute can
|
| 599 |
+
be used to force the old behavior for :class:`~django.test.TransactionTestCase`
|
| 600 |
+
that might need it.
|
| 601 |
+
|
| 602 |
+
Ordering of tests
|
| 603 |
+
~~~~~~~~~~~~~~~~~
|
| 604 |
+
|
| 605 |
+
In order to make sure all ``TestCase`` code starts with a clean database,
|
| 606 |
+
tests are now executed in the following order:
|
| 607 |
+
|
| 608 |
+
* First, all unit tests (including :class:`unittest.TestCase`,
|
| 609 |
+
:class:`~django.test.SimpleTestCase`, :class:`~django.test.TestCase` and
|
| 610 |
+
:class:`~django.test.TransactionTestCase`) are run with no particular ordering
|
| 611 |
+
guaranteed nor enforced among them.
|
| 612 |
+
|
| 613 |
+
* Then any other tests (e.g. doctests) that may alter the database without
|
| 614 |
+
restoring it to its original state are run.
|
| 615 |
+
|
| 616 |
+
This should not cause any problems unless you have existing doctests which
|
| 617 |
+
assume a :class:`~django.test.TransactionTestCase` executed earlier left some
|
| 618 |
+
database state behind or unit tests that rely on some form of state being
|
| 619 |
+
preserved after the execution of other tests. Such tests are already very
|
| 620 |
+
fragile, and must now be changed to be able to run independently.
|
| 621 |
+
|
| 622 |
+
``cleaned_data`` dictionary kept for invalid forms
|
| 623 |
+
--------------------------------------------------
|
| 624 |
+
|
| 625 |
+
The :attr:`~django.forms.Form.cleaned_data` dictionary is now always present
|
| 626 |
+
after form validation. When the form doesn't validate, it contains only the
|
| 627 |
+
fields that passed validation. You should test the success of the validation
|
| 628 |
+
with the :meth:`~django.forms.Form.is_valid()` method and not with the
|
| 629 |
+
presence or absence of the :attr:`~django.forms.Form.cleaned_data` attribute
|
| 630 |
+
on the form.
|
| 631 |
+
|
| 632 |
+
Behavior of ``syncdb`` with multiple databases
|
| 633 |
+
----------------------------------------------
|
| 634 |
+
|
| 635 |
+
``syncdb`` now queries the database routers to determine if content
|
| 636 |
+
types (when :mod:`~django.contrib.contenttypes` is enabled) and permissions
|
| 637 |
+
(when :mod:`~django.contrib.auth` is enabled) should be created in the target
|
| 638 |
+
database. Previously, it created them in the default database, even when
|
| 639 |
+
another database was specified with the ``--database`` option.
|
| 640 |
+
|
| 641 |
+
If you use ``syncdb`` on multiple databases, you should ensure that
|
| 642 |
+
your routers allow synchronizing content types and permissions to only one of
|
| 643 |
+
them. See the docs on the :ref:`behavior of contrib apps with multiple
|
| 644 |
+
databases <contrib_app_multiple_databases>` for more information.
|
| 645 |
+
|
| 646 |
+
XML deserializer will not parse documents with a DTD
|
| 647 |
+
----------------------------------------------------
|
| 648 |
+
|
| 649 |
+
In order to prevent exposure to denial-of-service attacks related to external
|
| 650 |
+
entity references and entity expansion, the XML model deserializer now refuses
|
| 651 |
+
to parse XML documents containing a DTD (DOCTYPE definition). Since the XML
|
| 652 |
+
serializer does not output a DTD, this will not impact typical usage, only
|
| 653 |
+
cases where custom-created XML documents are passed to Django's model
|
| 654 |
+
deserializer.
|
| 655 |
+
|
| 656 |
+
Formsets default ``max_num``
|
| 657 |
+
----------------------------
|
| 658 |
+
|
| 659 |
+
A (default) value of ``None`` for the ``max_num`` argument to a formset factory
|
| 660 |
+
no longer defaults to allowing any number of forms in the formset. Instead, in
|
| 661 |
+
order to prevent memory-exhaustion attacks, it now defaults to a limit of 1000
|
| 662 |
+
forms. This limit can be raised by explicitly setting a higher value for
|
| 663 |
+
``max_num``.
|
| 664 |
+
|
| 665 |
+
Miscellaneous
|
| 666 |
+
-------------
|
| 667 |
+
|
| 668 |
+
* :class:`django.forms.ModelMultipleChoiceField` now returns an empty
|
| 669 |
+
``QuerySet`` as the empty value instead of an empty list.
|
| 670 |
+
|
| 671 |
+
* :func:`~django.utils.http.int_to_base36` properly raises a
|
| 672 |
+
:exc:`TypeError` instead of :exc:`ValueError` for non-integer inputs.
|
| 673 |
+
|
| 674 |
+
* The ``slugify`` template filter is now available as a standard Python
|
| 675 |
+
function at :func:`django.utils.text.slugify`. Similarly, ``remove_tags`` is
|
| 676 |
+
available at ``django.utils.html.remove_tags()``.
|
| 677 |
+
|
| 678 |
+
* Uploaded files are no longer created as executable by default. If you need
|
| 679 |
+
them to be executable change :setting:`FILE_UPLOAD_PERMISSIONS` to your
|
| 680 |
+
needs. The new default value is ``0o666`` (octal) and the current umask value
|
| 681 |
+
is first masked out.
|
| 682 |
+
|
| 683 |
+
* The :class:`F expressions <django.db.models.F>` supported bitwise operators by
|
| 684 |
+
``&`` and ``|``. These operators are now available using ``.bitand()`` and
|
| 685 |
+
``.bitor()`` instead. The removal of ``&`` and ``|`` was done to be
|
| 686 |
+
consistent with :ref:`Q() expressions <complex-lookups-with-q>` and
|
| 687 |
+
``QuerySet`` combining where the operators are used as boolean AND and OR
|
| 688 |
+
operators.
|
| 689 |
+
|
| 690 |
+
* In a ``filter()`` call, when :class:`F expressions <django.db.models.F>`
|
| 691 |
+
contained lookups spanning multi-valued relations, they didn't always reuse
|
| 692 |
+
the same relations as other lookups along the same chain. This was changed,
|
| 693 |
+
and now F() expressions will always use the same relations as other lookups
|
| 694 |
+
within the same ``filter()`` call.
|
| 695 |
+
|
| 696 |
+
* The :ttag:`csrf_token` template tag is no longer enclosed in a div. If you need
|
| 697 |
+
HTML validation against pre-HTML5 Strict DTDs, you should add a div around it
|
| 698 |
+
in your pages.
|
| 699 |
+
|
| 700 |
+
* The template tags library ``adminmedia``, which only contained the
|
| 701 |
+
deprecated template tag ``{% admin_media_prefix %}``, was removed.
|
| 702 |
+
Attempting to load it with ``{% load adminmedia %}`` will fail. If your
|
| 703 |
+
templates still contain that line you must remove it.
|
| 704 |
+
|
| 705 |
+
* Because of an implementation oversight, it was possible to use
|
| 706 |
+
:doc:`django.contrib.redirects </ref/contrib/redirects>` without enabling
|
| 707 |
+
:doc:`django.contrib.sites </ref/contrib/sites>`. This isn't allowed any
|
| 708 |
+
longer. If you're using ``django.contrib.redirects``, make sure
|
| 709 |
+
:setting:`INSTALLED_APPS` contains ``django.contrib.sites``.
|
| 710 |
+
|
| 711 |
+
* :meth:`BoundField.label_tag <django.forms.BoundField.label_tag>` now
|
| 712 |
+
escapes its ``contents`` argument. To avoid the HTML escaping, use
|
| 713 |
+
:func:`django.utils.safestring.mark_safe` on the argument before passing it.
|
| 714 |
+
|
| 715 |
+
* Accessing reverse one-to-one relations fetched via
|
| 716 |
+
:meth:`~django.db.models.query.QuerySet.select_related` now raises
|
| 717 |
+
:exc:`~django.db.models.Model.DoesNotExist` instead of returning ``None``.
|
| 718 |
+
|
| 719 |
+
.. _deprecated-features-1.5:
|
| 720 |
+
|
| 721 |
+
Features deprecated in 1.5
|
| 722 |
+
==========================
|
| 723 |
+
|
| 724 |
+
``django.contrib.localflavor``
|
| 725 |
+
------------------------------
|
| 726 |
+
|
| 727 |
+
The localflavor contrib app has been split into separate packages.
|
| 728 |
+
``django.contrib.localflavor`` itself will be removed in Django 1.6,
|
| 729 |
+
after an accelerated deprecation.
|
| 730 |
+
|
| 731 |
+
The new packages are available on GitHub. The core team cannot
|
| 732 |
+
efficiently maintain these packages in the long term — it spans just a
|
| 733 |
+
dozen countries at this time; similar to translations, maintenance
|
| 734 |
+
will be handed over to interested members of the community.
|
| 735 |
+
|
| 736 |
+
``django.contrib.markup``
|
| 737 |
+
-------------------------
|
| 738 |
+
|
| 739 |
+
The markup contrib module has been deprecated and will follow an accelerated
|
| 740 |
+
deprecation schedule. Direct use of Python markup libraries or 3rd party tag
|
| 741 |
+
libraries is preferred to Django maintaining this functionality in the
|
| 742 |
+
framework.
|
| 743 |
+
|
| 744 |
+
``AUTH_PROFILE_MODULE``
|
| 745 |
+
-----------------------
|
| 746 |
+
|
| 747 |
+
With the introduction of :ref:`custom user models <auth-custom-user>`, there is
|
| 748 |
+
no longer any need for a built-in mechanism to store user profile data.
|
| 749 |
+
|
| 750 |
+
You can still define user profiles models that have a one-to-one relation with
|
| 751 |
+
the User model - in fact, for many applications needing to associate data with
|
| 752 |
+
a User account, this will be an appropriate design pattern to follow. However,
|
| 753 |
+
the ``AUTH_PROFILE_MODULE`` setting, and the
|
| 754 |
+
``django.contrib.auth.models.User.get_profile()`` method for accessing
|
| 755 |
+
the user profile model, should not be used any longer.
|
| 756 |
+
|
| 757 |
+
Streaming behavior of :class:`~django.http.HttpResponse`
|
| 758 |
+
--------------------------------------------------------
|
| 759 |
+
|
| 760 |
+
Django 1.5 deprecates the ability to stream a response by passing an iterator
|
| 761 |
+
to :class:`~django.http.HttpResponse`. If you rely on this behavior, switch to
|
| 762 |
+
:class:`~django.http.StreamingHttpResponse`. See
|
| 763 |
+
:ref:`explicit-streaming-responses` above.
|
| 764 |
+
|
| 765 |
+
In Django 1.7 and above, the iterator will be consumed immediately by
|
| 766 |
+
:class:`~django.http.HttpResponse`.
|
| 767 |
+
|
| 768 |
+
.. _simplejson-deprecation:
|
| 769 |
+
|
| 770 |
+
``django.utils.simplejson``
|
| 771 |
+
---------------------------
|
| 772 |
+
|
| 773 |
+
Since Django 1.5 drops support for Python 2.5, we can now rely on the
|
| 774 |
+
:mod:`json` module being available in Python's standard library, so we've
|
| 775 |
+
removed our own copy of ``simplejson``. You should now import :mod:`json`
|
| 776 |
+
instead of ``django.utils.simplejson``.
|
| 777 |
+
|
| 778 |
+
Unfortunately, this change might have unwanted side-effects, because of
|
| 779 |
+
incompatibilities between versions of ``simplejson`` -- see the
|
| 780 |
+
:ref:`backwards-incompatible changes <simplejson-incompatibilities>` section.
|
| 781 |
+
If you rely on features added to ``simplejson`` after it became Python's
|
| 782 |
+
:mod:`json`, you should import ``simplejson`` explicitly.
|
| 783 |
+
|
| 784 |
+
``django.utils.encoding.StrAndUnicode``
|
| 785 |
+
---------------------------------------
|
| 786 |
+
|
| 787 |
+
The ``django.utils.encoding.StrAndUnicode`` mix-in has been deprecated.
|
| 788 |
+
Define a ``__str__`` method and apply the
|
| 789 |
+
``django.utils.encoding.python_2_unicode_compatible`` decorator instead.
|
| 790 |
+
|
| 791 |
+
``django.utils.itercompat.product``
|
| 792 |
+
-----------------------------------
|
| 793 |
+
|
| 794 |
+
The ``django.utils.itercompat.product`` function has been deprecated. Use
|
| 795 |
+
the built-in :func:`itertools.product` instead.
|
| 796 |
+
|
| 797 |
+
``cleanup`` management command
|
| 798 |
+
------------------------------
|
| 799 |
+
|
| 800 |
+
The ``cleanup`` management command has been deprecated and replaced by
|
| 801 |
+
:djadmin:`clearsessions`.
|
| 802 |
+
|
| 803 |
+
``daily_cleanup.py`` script
|
| 804 |
+
---------------------------
|
| 805 |
+
|
| 806 |
+
The undocumented ``daily_cleanup.py`` script has been deprecated. Use the
|
| 807 |
+
:djadmin:`clearsessions` management command instead.
|
| 808 |
+
|
| 809 |
+
``depth`` keyword argument in ``select_related``
|
| 810 |
+
------------------------------------------------
|
| 811 |
+
|
| 812 |
+
The ``depth`` keyword argument in
|
| 813 |
+
:meth:`~django.db.models.query.QuerySet.select_related` has been deprecated.
|
| 814 |
+
You should use field names instead.
|
testbed/django__django/docs/releases/1.6.1.txt
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.6.1 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*December 12, 2013*
|
| 6 |
+
|
| 7 |
+
This is Django 1.6.1, a bugfix release for Django 1.6. In addition to the bug
|
| 8 |
+
fixes listed below, translations submitted since the 1.6 release are also
|
| 9 |
+
included.
|
| 10 |
+
|
| 11 |
+
Bug fixes
|
| 12 |
+
=========
|
| 13 |
+
|
| 14 |
+
* Fixed ``BCryptSHA256PasswordHasher`` with ``py-bcrypt`` and Python 3
|
| 15 |
+
(#21398).
|
| 16 |
+
* Fixed a regression that prevented a ``ForeignKey`` with a hidden reverse
|
| 17 |
+
manager (``related_name`` ending with '+') from being used as a lookup for
|
| 18 |
+
``prefetch_related`` (#21410).
|
| 19 |
+
* Fixed :meth:`Queryset.datetimes<django.db.models.query.QuerySet.datetimes>`
|
| 20 |
+
raising ``AttributeError`` in some situations (#21432).
|
| 21 |
+
* Fixed :class:`~django.contrib.auth.backends.ModelBackend` raising
|
| 22 |
+
``UnboundLocalError`` if :func:`~django.contrib.auth.get_user_model`
|
| 23 |
+
raised an error (#21439).
|
| 24 |
+
* Fixed a regression that prevented editable ``GenericRelation`` subclasses
|
| 25 |
+
from working in ``ModelForms`` (#21428).
|
| 26 |
+
* Added missing ``to_python`` method for ``ModelMultipleChoiceField`` which
|
| 27 |
+
is required in Django 1.6 to properly detect changes from initial values
|
| 28 |
+
(#21568).
|
| 29 |
+
* Fixed ``django.contrib.humanize`` translations where the Unicode sequence
|
| 30 |
+
for the non-breaking space was returned verbatim (#21415).
|
| 31 |
+
* Fixed :djadmin:`loaddata` error when fixture file name contained any dots
|
| 32 |
+
not related to file extensions (#21457) or when fixture path was relative
|
| 33 |
+
but located in a subdirectory (#21551).
|
| 34 |
+
* Fixed display of inline instances in formsets when parent has 0 for primary
|
| 35 |
+
key (#21472).
|
| 36 |
+
* Fixed a regression where custom querysets for foreign keys were overwritten
|
| 37 |
+
if ``ModelAdmin`` had ordering set (#21405).
|
| 38 |
+
* Removed mention of a feature in the ``--locale``/``-l`` option of the
|
| 39 |
+
``makemessages`` and ``compilemessages`` commands that never worked as
|
| 40 |
+
promised: Support of multiple locale names separated by commas. It's still
|
| 41 |
+
possible to specify multiple locales in one run by using the option
|
| 42 |
+
multiple times (#21488, #17181).
|
| 43 |
+
* Fixed a regression that unnecessarily triggered settings configuration when
|
| 44 |
+
importing ``get_wsgi_application`` (#21486).
|
| 45 |
+
* Fixed test client ``logout()`` method when using the cookie-based session
|
| 46 |
+
backend (#21448).
|
| 47 |
+
* Fixed a crash when a ``GeometryField`` uses a non-geometric widget (#21496).
|
| 48 |
+
* Fixed password hash upgrade when changing the iteration count (#21535).
|
| 49 |
+
* Fixed a bug in the debug view when the URLconf only contains one element
|
| 50 |
+
(#21530).
|
| 51 |
+
* Re-added missing search result count and reset link in changelist admin view
|
| 52 |
+
(#21510).
|
| 53 |
+
* The current language is no longer saved to the session by ``LocaleMiddleware``
|
| 54 |
+
on every response, but rather only after a logout (#21473).
|
| 55 |
+
* Fixed a crash when executing ``runserver`` on non-English systems and when the
|
| 56 |
+
formatted date in its output contained non-ASCII characters (#21358).
|
| 57 |
+
* Fixed a crash in the debug view after an exception occurred on Python ≥ 3.3
|
| 58 |
+
(#21443).
|
| 59 |
+
* Fixed a crash in :class:`~django.db.models.ImageField` on some platforms
|
| 60 |
+
(Homebrew and RHEL6 reported) (#21355).
|
| 61 |
+
* Fixed a regression when using generic relations in ``ModelAdmin.list_filter``
|
| 62 |
+
(#21431).
|
testbed/django__django/docs/releases/1.6.4.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.6.4 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*April 28, 2014*
|
| 6 |
+
|
| 7 |
+
Django 1.6.4 fixes several bugs in 1.6.3.
|
| 8 |
+
|
| 9 |
+
Bugfixes
|
| 10 |
+
========
|
| 11 |
+
|
| 12 |
+
* Added backwards compatibility support for the :mod:`django.contrib.messages`
|
| 13 |
+
cookie format of Django 1.4 and earlier to facilitate upgrading to 1.6 from
|
| 14 |
+
1.4 (:ticket:`22426`).
|
| 15 |
+
|
| 16 |
+
* Restored the ability to ``reverse()`` views created using
|
| 17 |
+
:func:`functools.partial()` (:ticket:`22486`).
|
| 18 |
+
|
| 19 |
+
* Fixed the ``object_id`` of the ``LogEntry`` that's created after a user
|
| 20 |
+
password change in the admin (:ticket:`22515`).
|
testbed/django__django/docs/releases/1.6.5.txt
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.6.5 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*May 14, 2014*
|
| 6 |
+
|
| 7 |
+
Django 1.6.5 fixes two security issues and several bugs in 1.6.4.
|
| 8 |
+
|
| 9 |
+
Issue: Caches may incorrectly be allowed to store and serve private data
|
| 10 |
+
========================================================================
|
| 11 |
+
|
| 12 |
+
In certain situations, Django may allow caches to store private data
|
| 13 |
+
related to a particular session and then serve that data to requests
|
| 14 |
+
with a different session, or no session at all. This can lead to
|
| 15 |
+
information disclosure and can be a vector for cache poisoning.
|
| 16 |
+
|
| 17 |
+
When using Django sessions, Django will set a ``Vary: Cookie`` header to
|
| 18 |
+
ensure caches do not serve cached data to requests from other sessions.
|
| 19 |
+
However, older versions of Internet Explorer (most likely only Internet
|
| 20 |
+
Explorer 6, and Internet Explorer 7 if run on Windows XP or Windows Server
|
| 21 |
+
2003) are unable to handle the ``Vary`` header in combination with many content
|
| 22 |
+
types. Therefore, Django would remove the header if the request was made by
|
| 23 |
+
Internet Explorer.
|
| 24 |
+
|
| 25 |
+
To remedy this, the special behavior for these older Internet Explorer versions
|
| 26 |
+
has been removed, and the ``Vary`` header is no longer stripped from the response.
|
| 27 |
+
In addition, modifications to the ``Cache-Control`` header for all Internet Explorer
|
| 28 |
+
requests with a ``Content-Disposition`` header have also been removed as they
|
| 29 |
+
were found to have similar issues.
|
| 30 |
+
|
| 31 |
+
Issue: Malformed redirect URLs from user input not correctly validated
|
| 32 |
+
======================================================================
|
| 33 |
+
|
| 34 |
+
The validation for redirects did not correctly validate some malformed URLs,
|
| 35 |
+
which are accepted by some browsers. This allows a user to be redirected to
|
| 36 |
+
an unsafe URL unexpectedly.
|
| 37 |
+
|
| 38 |
+
Django relies on user input in some cases (e.g.
|
| 39 |
+
``django.contrib.auth.views.login()``, ``django.contrib.comments``, and
|
| 40 |
+
:doc:`i18n </topics/i18n/index>`) to redirect the user to an "on success" URL.
|
| 41 |
+
The security checks for these redirects (namely
|
| 42 |
+
``django.utils.http.is_safe_url()``) did not correctly validate some malformed
|
| 43 |
+
URLs, such as ``http:\\\\\\djangoproject.com``, which are accepted by some
|
| 44 |
+
browsers with more liberal URL parsing.
|
| 45 |
+
|
| 46 |
+
To remedy this, the validation in ``is_safe_url()`` has been tightened to be able
|
| 47 |
+
to handle and correctly validate these malformed URLs.
|
| 48 |
+
|
| 49 |
+
Bugfixes
|
| 50 |
+
========
|
| 51 |
+
|
| 52 |
+
* Made the ``year_lookup_bounds_for_datetime_field`` Oracle backend method
|
| 53 |
+
Python 3 compatible (:ticket:`22551`).
|
| 54 |
+
|
| 55 |
+
* Fixed ``pgettext_lazy`` crash when receiving bytestring content on Python 2
|
| 56 |
+
(:ticket:`22565`).
|
| 57 |
+
|
| 58 |
+
* Fixed the SQL generated when filtering by a negated ``Q`` object that contains
|
| 59 |
+
a ``F`` object. (:ticket:`22429`).
|
| 60 |
+
|
| 61 |
+
* Avoided overwriting data fetched by ``select_related()`` in certain cases
|
| 62 |
+
which could cause minor performance regressions
|
| 63 |
+
(:ticket:`22508`).
|
testbed/django__django/docs/releases/1.6.6.txt
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.6.6 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*August 20, 2014*
|
| 6 |
+
|
| 7 |
+
Django 1.6.6 fixes several security issues and bugs in 1.6.5.
|
| 8 |
+
|
| 9 |
+
``reverse()`` could generate URLs pointing to other hosts
|
| 10 |
+
=========================================================
|
| 11 |
+
|
| 12 |
+
In certain situations, URL reversing could generate scheme-relative URLs (URLs
|
| 13 |
+
starting with two slashes), which could unexpectedly redirect a user to a
|
| 14 |
+
different host. An attacker could exploit this, for example, by redirecting
|
| 15 |
+
users to a phishing site designed to ask for user's passwords.
|
| 16 |
+
|
| 17 |
+
To remedy this, URL reversing now ensures that no URL starts with two slashes
|
| 18 |
+
(//), replacing the second slash with its URL encoded counterpart (%2F). This
|
| 19 |
+
approach ensures that semantics stay the same, while making the URL relative to
|
| 20 |
+
the domain and not to the scheme.
|
| 21 |
+
|
| 22 |
+
File upload denial-of-service
|
| 23 |
+
=============================
|
| 24 |
+
|
| 25 |
+
Before this release, Django's file upload handing in its default configuration
|
| 26 |
+
may degrade to producing a huge number of ``os.stat()`` system calls when a
|
| 27 |
+
duplicate filename is uploaded. Since ``stat()`` may invoke IO, this may produce
|
| 28 |
+
a huge data-dependent slowdown that slowly worsens over time. The net result is
|
| 29 |
+
that given enough time, a user with the ability to upload files can cause poor
|
| 30 |
+
performance in the upload handler, eventually causing it to become very slow
|
| 31 |
+
simply by uploading 0-byte files. At this point, even a slow network connection
|
| 32 |
+
and few HTTP requests would be all that is necessary to make a site unavailable.
|
| 33 |
+
|
| 34 |
+
We've remedied the issue by changing the algorithm for generating file names
|
| 35 |
+
if a file with the uploaded name already exists.
|
| 36 |
+
:meth:`Storage.get_available_name()
|
| 37 |
+
<django.core.files.storage.Storage.get_available_name>` now appends an
|
| 38 |
+
underscore plus a random 7 character alphanumeric string (e.g. ``"_x3a1gho"``),
|
| 39 |
+
rather than iterating through an underscore followed by a number (e.g. ``"_1"``,
|
| 40 |
+
``"_2"``, etc.).
|
| 41 |
+
|
| 42 |
+
``RemoteUserMiddleware`` session hijacking
|
| 43 |
+
==========================================
|
| 44 |
+
|
| 45 |
+
When using the :class:`~django.contrib.auth.middleware.RemoteUserMiddleware`
|
| 46 |
+
and the ``RemoteUserBackend``, a change to the ``REMOTE_USER`` header between
|
| 47 |
+
requests without an intervening logout could result in the prior user's session
|
| 48 |
+
being co-opted by the subsequent user. The middleware now logs the user out on
|
| 49 |
+
a failed login attempt.
|
| 50 |
+
|
| 51 |
+
Data leakage via query string manipulation in ``contrib.admin``
|
| 52 |
+
===============================================================
|
| 53 |
+
|
| 54 |
+
In older versions of Django it was possible to reveal any field's data by
|
| 55 |
+
modifying the "popup" and "to_field" parameters of the query string on an admin
|
| 56 |
+
change form page. For example, requesting a URL like
|
| 57 |
+
``/admin/auth/user/?_popup=1&t=password`` and viewing the page's HTML allowed
|
| 58 |
+
viewing the password hash of each user. While the admin requires users to have
|
| 59 |
+
permissions to view the change form pages in the first place, this could leak
|
| 60 |
+
data if you rely on users having access to view only certain fields on a model.
|
| 61 |
+
|
| 62 |
+
To address the issue, an exception will now be raised if a ``to_field`` value
|
| 63 |
+
that isn't a related field to a model that has been registered with the admin
|
| 64 |
+
is specified.
|
| 65 |
+
|
| 66 |
+
Bugfixes
|
| 67 |
+
========
|
| 68 |
+
|
| 69 |
+
* Corrected email and URL validation to reject a trailing dash
|
| 70 |
+
(:ticket:`22579`).
|
| 71 |
+
|
| 72 |
+
* Prevented indexes on PostgreSQL virtual fields (:ticket:`22514`).
|
| 73 |
+
|
| 74 |
+
* Prevented edge case where values of FK fields could be initialized with a
|
| 75 |
+
wrong value when an inline model formset is created for a relationship
|
| 76 |
+
defined to point to a field other than the PK (:ticket:`13794`).
|
| 77 |
+
|
| 78 |
+
* Restored ``pre_delete`` signals for ``GenericRelation`` cascade deletion
|
| 79 |
+
(:ticket:`22998`).
|
| 80 |
+
|
| 81 |
+
* Fixed transaction handling when specifying non-default database in
|
| 82 |
+
``createcachetable`` and ``flush`` (:ticket:`23089`).
|
| 83 |
+
|
| 84 |
+
* Fixed the "ORA-01843: not a valid month" errors when using Unicode
|
| 85 |
+
with older versions of Oracle server (:ticket:`20292`).
|
| 86 |
+
|
| 87 |
+
* Restored bug fix for sending Unicode email with Python 2.6.5 and below
|
| 88 |
+
(:ticket:`19107`).
|
| 89 |
+
|
| 90 |
+
* Prevented ``UnicodeDecodeError`` in ``runserver`` with non-UTF-8 and
|
| 91 |
+
non-English locale (:ticket:`23265`).
|
| 92 |
+
|
| 93 |
+
* Fixed JavaScript errors while editing multi-geometry objects in the OpenLayers
|
| 94 |
+
widget (:ticket:`23137`, :ticket:`23293`).
|
| 95 |
+
|
| 96 |
+
* Prevented a crash on Python 3 with query strings containing unencoded
|
| 97 |
+
non-ASCII characters (:ticket:`22996`).
|
testbed/django__django/docs/releases/1.6.txt
ADDED
|
@@ -0,0 +1,1242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
=========================
|
| 2 |
+
Django 1.6 release notes
|
| 3 |
+
=========================
|
| 4 |
+
|
| 5 |
+
.. note::
|
| 6 |
+
|
| 7 |
+
Dedicated to Malcolm Tredinnick
|
| 8 |
+
|
| 9 |
+
On March 17, 2013, the Django project and the free software community lost
|
| 10 |
+
a very dear friend and developer.
|
| 11 |
+
|
| 12 |
+
Malcolm was a long-time contributor to Django, a model community member, a
|
| 13 |
+
brilliant mind, and a friend. His contributions to Django — and to many other
|
| 14 |
+
open source projects — are nearly impossible to enumerate. Many on the core
|
| 15 |
+
Django team had their first patches reviewed by him; his mentorship enriched
|
| 16 |
+
us. His consideration, patience, and dedication will always be an inspiration
|
| 17 |
+
to us.
|
| 18 |
+
|
| 19 |
+
This release of Django is for Malcolm.
|
| 20 |
+
|
| 21 |
+
-- The Django Developers
|
| 22 |
+
|
| 23 |
+
*November 6, 2013*
|
| 24 |
+
|
| 25 |
+
Welcome to Django 1.6!
|
| 26 |
+
|
| 27 |
+
These release notes cover the :ref:`new features <whats-new-1.6>`, as well as
|
| 28 |
+
some :ref:`backwards incompatible changes <backwards-incompatible-1.6>` you'll
|
| 29 |
+
want to be aware of when upgrading from Django 1.5 or older versions. We've
|
| 30 |
+
also dropped some features, which are detailed in :ref:`our deprecation plan
|
| 31 |
+
<deprecation-removed-in-1.6>`, and we've :ref:`begun the deprecation process
|
| 32 |
+
for some features <deprecated-features-1.6>`.
|
| 33 |
+
|
| 34 |
+
Python compatibility
|
| 35 |
+
====================
|
| 36 |
+
|
| 37 |
+
Django 1.6, like Django 1.5, requires Python 2.6.5 or above. Python 3 is also
|
| 38 |
+
officially supported. We **highly recommend** the latest minor release for each
|
| 39 |
+
supported Python series (2.6.X, 2.7.X, 3.2.X, and 3.3.X).
|
| 40 |
+
|
| 41 |
+
Django 1.6 will be the final release series to support Python 2.6; beginning
|
| 42 |
+
with Django 1.7, the minimum supported Python version will be 2.7.
|
| 43 |
+
|
| 44 |
+
Python 3.4 is not supported, but support will be added in Django 1.7.
|
| 45 |
+
|
| 46 |
+
.. _whats-new-1.6:
|
| 47 |
+
|
| 48 |
+
What's new in Django 1.6
|
| 49 |
+
========================
|
| 50 |
+
|
| 51 |
+
Simplified default project and app templates
|
| 52 |
+
--------------------------------------------
|
| 53 |
+
|
| 54 |
+
The default templates used by :djadmin:`startproject` and :djadmin:`startapp`
|
| 55 |
+
have been simplified and modernized. The :doc:`admin
|
| 56 |
+
</ref/contrib/admin/index>` is now enabled by default in new projects; the
|
| 57 |
+
:doc:`sites </ref/contrib/sites>` framework no longer is. :ref:`clickjacking
|
| 58 |
+
prevention <clickjacking-prevention>` is now on and the database defaults to
|
| 59 |
+
SQLite.
|
| 60 |
+
|
| 61 |
+
If the default templates don't suit your tastes, you can use :ref:`custom
|
| 62 |
+
project and app templates <custom-app-and-project-templates>`.
|
| 63 |
+
|
| 64 |
+
Improved transaction management
|
| 65 |
+
-------------------------------
|
| 66 |
+
|
| 67 |
+
Django's transaction management was overhauled. Database-level autocommit is
|
| 68 |
+
now turned on by default. This makes transaction handling more explicit and
|
| 69 |
+
should improve performance. The existing APIs were deprecated, and new APIs
|
| 70 |
+
were introduced, as described in the :doc:`transaction management docs
|
| 71 |
+
</topics/db/transactions>`.
|
| 72 |
+
|
| 73 |
+
Persistent database connections
|
| 74 |
+
-------------------------------
|
| 75 |
+
|
| 76 |
+
Django now supports reusing the same database connection for several requests.
|
| 77 |
+
This avoids the overhead of reestablishing a connection at the beginning of
|
| 78 |
+
each request. For backwards compatibility, this feature is disabled by
|
| 79 |
+
default. See :ref:`persistent-database-connections` for details.
|
| 80 |
+
|
| 81 |
+
Discovery of tests in any test module
|
| 82 |
+
-------------------------------------
|
| 83 |
+
|
| 84 |
+
Django 1.6 ships with a new test runner that allows more flexibility in the
|
| 85 |
+
location of tests. The previous runner
|
| 86 |
+
(``django.test.simple.DjangoTestSuiteRunner``) found tests only in the
|
| 87 |
+
``models.py`` and ``tests.py`` modules of a Python package in
|
| 88 |
+
:setting:`INSTALLED_APPS`.
|
| 89 |
+
|
| 90 |
+
The new runner (``django.test.runner.DiscoverRunner``) uses the test discovery
|
| 91 |
+
features built into ``unittest2`` (the version of ``unittest`` in the
|
| 92 |
+
Python 2.7+ standard library, and bundled with Django). With test discovery,
|
| 93 |
+
tests can be located in any module whose name matches the pattern ``test*.py``.
|
| 94 |
+
|
| 95 |
+
In addition, the test labels provided to ``./manage.py test`` to nominate
|
| 96 |
+
specific tests to run must now be full Python dotted paths (or directory
|
| 97 |
+
paths), rather than ``applabel.TestCase.test_method_name`` pseudo-paths. This
|
| 98 |
+
allows running tests located anywhere in your codebase, rather than only in
|
| 99 |
+
:setting:`INSTALLED_APPS`. For more details, see :doc:`/topics/testing/index`.
|
| 100 |
+
|
| 101 |
+
This change is backwards-incompatible; see the :ref:`backwards-incompatibility
|
| 102 |
+
notes<new-test-runner>`.
|
| 103 |
+
|
| 104 |
+
Time zone aware aggregation
|
| 105 |
+
---------------------------
|
| 106 |
+
|
| 107 |
+
The support for :doc:`time zones </topics/i18n/timezones>` introduced in
|
| 108 |
+
Django 1.4 didn't work well with :meth:`QuerySet.dates()
|
| 109 |
+
<django.db.models.query.QuerySet.dates>`: aggregation was always performed in
|
| 110 |
+
UTC. This limitation was lifted in Django 1.6. Use :meth:`QuerySet.datetimes()
|
| 111 |
+
<django.db.models.query.QuerySet.datetimes>` to perform time zone aware
|
| 112 |
+
aggregation on a :class:`~django.db.models.DateTimeField`.
|
| 113 |
+
|
| 114 |
+
Support for savepoints in SQLite
|
| 115 |
+
--------------------------------
|
| 116 |
+
|
| 117 |
+
Django 1.6 adds support for savepoints in SQLite, with some :ref:`limitations
|
| 118 |
+
<savepoints-in-sqlite>`.
|
| 119 |
+
|
| 120 |
+
``BinaryField`` model field
|
| 121 |
+
---------------------------
|
| 122 |
+
|
| 123 |
+
A new :class:`django.db.models.BinaryField` model field allows storage of raw
|
| 124 |
+
binary data in the database.
|
| 125 |
+
|
| 126 |
+
GeoDjango form widgets
|
| 127 |
+
----------------------
|
| 128 |
+
|
| 129 |
+
GeoDjango now provides :doc:`form fields and widgets </ref/contrib/gis/forms-api>`
|
| 130 |
+
for its geo-specialized fields. They are OpenLayers-based by default, but they
|
| 131 |
+
can be customized to use any other JS framework.
|
| 132 |
+
|
| 133 |
+
``check`` management command added for verifying compatibility
|
| 134 |
+
--------------------------------------------------------------
|
| 135 |
+
|
| 136 |
+
A :djadmin:`check` management command was added, enabling you to verify if your
|
| 137 |
+
current configuration (currently oriented at settings) is compatible with the
|
| 138 |
+
current version of Django.
|
| 139 |
+
|
| 140 |
+
:meth:`Model.save() <django.db.models.Model.save()>` algorithm changed
|
| 141 |
+
----------------------------------------------------------------------
|
| 142 |
+
|
| 143 |
+
The :meth:`Model.save() <django.db.models.Model.save()>` method now
|
| 144 |
+
tries to directly ``UPDATE`` the database if the instance has a primary
|
| 145 |
+
key value. Previously ``SELECT`` was performed to determine if ``UPDATE``
|
| 146 |
+
or ``INSERT`` were needed. The new algorithm needs only one query for
|
| 147 |
+
updating an existing row while the old algorithm needed two. See
|
| 148 |
+
:meth:`Model.save() <django.db.models.Model.save()>` for more details.
|
| 149 |
+
|
| 150 |
+
In some rare cases the database doesn't report that a matching row was
|
| 151 |
+
found when doing an ``UPDATE``. An example is the PostgreSQL ``ON UPDATE``
|
| 152 |
+
trigger which returns ``NULL``. In such cases it is possible to set
|
| 153 |
+
:attr:`django.db.models.Options.select_on_save` flag to force saving to
|
| 154 |
+
use the old algorithm.
|
| 155 |
+
|
| 156 |
+
Minor features
|
| 157 |
+
--------------
|
| 158 |
+
|
| 159 |
+
* Authentication backends can raise ``PermissionDenied`` to immediately fail
|
| 160 |
+
the authentication chain.
|
| 161 |
+
|
| 162 |
+
* The ``HttpOnly`` flag can be set on the CSRF cookie with
|
| 163 |
+
:setting:`CSRF_COOKIE_HTTPONLY`.
|
| 164 |
+
|
| 165 |
+
* The ``assertQuerysetEqual()`` now checks
|
| 166 |
+
for undefined order and raises :exc:`ValueError` if undefined
|
| 167 |
+
order is spotted. The order is seen as undefined if the given ``QuerySet``
|
| 168 |
+
isn't ordered and there is more than one ordered value to compare against.
|
| 169 |
+
|
| 170 |
+
* Added :meth:`~django.db.models.query.QuerySet.earliest` for symmetry with
|
| 171 |
+
:meth:`~django.db.models.query.QuerySet.latest`.
|
| 172 |
+
|
| 173 |
+
* In addition to :lookup:`year`, :lookup:`month` and :lookup:`day`, the ORM
|
| 174 |
+
now supports :lookup:`hour`, :lookup:`minute` and :lookup:`second` lookups.
|
| 175 |
+
|
| 176 |
+
* Django now wraps all :pep:`249` exceptions.
|
| 177 |
+
|
| 178 |
+
* The default widgets for :class:`~django.forms.EmailField`,
|
| 179 |
+
:class:`~django.forms.URLField`, :class:`~django.forms.IntegerField`,
|
| 180 |
+
:class:`~django.forms.FloatField` and :class:`~django.forms.DecimalField` use
|
| 181 |
+
the new type attributes available in HTML5 (``type='email'``, ``type='url'``,
|
| 182 |
+
``type='number'``). Note that due to erratic support of the ``number``
|
| 183 |
+
input type with localized numbers in current browsers, Django only uses it
|
| 184 |
+
when numeric fields are not localized.
|
| 185 |
+
|
| 186 |
+
* The ``number`` argument for :ref:`lazy plural translations
|
| 187 |
+
<lazy-plural-translations>` can be provided at translation time rather than
|
| 188 |
+
at definition time.
|
| 189 |
+
|
| 190 |
+
* For custom management commands: Verification of the presence of valid
|
| 191 |
+
settings in commands that ask for it by using the
|
| 192 |
+
``BaseCommand.can_import_settings`` internal
|
| 193 |
+
option is now performed independently from handling of the locale that
|
| 194 |
+
should be active during the execution of the command. The latter can now be
|
| 195 |
+
influenced by the new
|
| 196 |
+
``BaseCommand.leave_locale_alone`` internal
|
| 197 |
+
option. See :ref:`management-commands-and-locales` for more details.
|
| 198 |
+
|
| 199 |
+
* The :attr:`~django.views.generic.edit.DeletionMixin.success_url` of
|
| 200 |
+
:class:`~django.views.generic.edit.DeletionMixin` is now interpolated with
|
| 201 |
+
its ``object``’s ``__dict__``.
|
| 202 |
+
|
| 203 |
+
* :class:`~django.http.HttpResponseRedirect` and
|
| 204 |
+
:class:`~django.http.HttpResponsePermanentRedirect` now provide an ``url``
|
| 205 |
+
attribute (equivalent to the URL the response will redirect to).
|
| 206 |
+
|
| 207 |
+
* The ``MemcachedCache`` cache backend now uses the latest :mod:`pickle`
|
| 208 |
+
protocol available.
|
| 209 |
+
|
| 210 |
+
* Added :class:`~django.contrib.messages.views.SuccessMessageMixin` which
|
| 211 |
+
provides a ``success_message`` attribute for
|
| 212 |
+
:class:`~django.views.generic.edit.FormView` based classes.
|
| 213 |
+
|
| 214 |
+
* Added the :attr:`django.db.models.ForeignKey.db_constraint` and
|
| 215 |
+
:attr:`django.db.models.ManyToManyField.db_constraint` options.
|
| 216 |
+
|
| 217 |
+
* The jQuery library embedded in the admin has been upgraded to version 1.9.1.
|
| 218 |
+
|
| 219 |
+
* Syndication feeds (:mod:`django.contrib.syndication`) can now pass extra
|
| 220 |
+
context through to feed templates using a new
|
| 221 |
+
:meth:`Feed.get_context_data()
|
| 222 |
+
<django.contrib.syndication.Feed.get_context_data>` callback.
|
| 223 |
+
|
| 224 |
+
* The admin list columns have a ``column-<field_name>`` class in the HTML
|
| 225 |
+
so the columns header can be styled with CSS, e.g. to set a column width.
|
| 226 |
+
|
| 227 |
+
* The :ref:`isolation level<database-isolation-level>` can be customized under
|
| 228 |
+
PostgreSQL.
|
| 229 |
+
|
| 230 |
+
* The :ttag:`blocktrans` template tag now respects
|
| 231 |
+
``TEMPLATE_STRING_IF_INVALID`` for variables not present in the
|
| 232 |
+
context, just like other template constructs.
|
| 233 |
+
|
| 234 |
+
* ``SimpleLazyObject``\s will now present more helpful representations in shell
|
| 235 |
+
debugging situations.
|
| 236 |
+
|
| 237 |
+
* Generic :class:`~django.contrib.gis.db.models.GeometryField` is now editable
|
| 238 |
+
with the OpenLayers widget in the admin.
|
| 239 |
+
|
| 240 |
+
* The documentation contains a :doc:`deployment checklist
|
| 241 |
+
</howto/deployment/checklist>`.
|
| 242 |
+
|
| 243 |
+
* The :djadmin:`diffsettings` command gained a ``--all`` option.
|
| 244 |
+
|
| 245 |
+
* ``django.forms.fields.Field.__init__`` now calls ``super()``, allowing
|
| 246 |
+
field mixins to implement ``__init__()`` methods that will reliably be
|
| 247 |
+
called.
|
| 248 |
+
|
| 249 |
+
* The ``validate_max`` parameter was added to ``BaseFormSet`` and
|
| 250 |
+
:func:`~django.forms.formsets.formset_factory`, and ``ModelForm`` and inline
|
| 251 |
+
versions of the same. The behavior of validation for formsets with
|
| 252 |
+
``max_num`` was clarified. The previously undocumented behavior that
|
| 253 |
+
hardened formsets against memory exhaustion attacks was documented,
|
| 254 |
+
and the undocumented limit of the higher of 1000 or ``max_num`` forms
|
| 255 |
+
was changed so it is always 1000 more than ``max_num``.
|
| 256 |
+
|
| 257 |
+
* Added ``BCryptSHA256PasswordHasher`` to resolve the password truncation issue
|
| 258 |
+
with bcrypt.
|
| 259 |
+
|
| 260 |
+
* :pypi:`Pillow` is now the preferred image manipulation library to use with
|
| 261 |
+
Django. :pypi:`PIL` is pending deprecation (support to be removed in Django
|
| 262 |
+
1.8). To upgrade, you should **first** uninstall PIL, **then** install
|
| 263 |
+
Pillow.
|
| 264 |
+
|
| 265 |
+
* :class:`~django.forms.ModelForm` accepts several new ``Meta``
|
| 266 |
+
options.
|
| 267 |
+
|
| 268 |
+
* Fields included in the ``localized_fields`` list will be localized
|
| 269 |
+
(by setting ``localize`` on the form field).
|
| 270 |
+
* The ``labels``, ``help_texts`` and ``error_messages`` options may be used
|
| 271 |
+
to customize the default fields, see
|
| 272 |
+
:ref:`modelforms-overriding-default-fields` for details.
|
| 273 |
+
|
| 274 |
+
* The ``choices`` argument to model fields now accepts an iterable of iterables
|
| 275 |
+
instead of requiring an iterable of lists or tuples.
|
| 276 |
+
|
| 277 |
+
* The reason phrase can be customized in HTTP responses using
|
| 278 |
+
:attr:`~django.http.HttpResponse.reason_phrase`.
|
| 279 |
+
|
| 280 |
+
* When giving the URL of the next page for
|
| 281 |
+
``django.contrib.auth.views.logout()``,
|
| 282 |
+
``django.contrib.auth.views.password_reset()``,
|
| 283 |
+
``django.contrib.auth.views.password_reset_confirm()``,
|
| 284 |
+
and ``django.contrib.auth.views.password_change()``, you can now pass
|
| 285 |
+
URL names and they will be resolved.
|
| 286 |
+
|
| 287 |
+
* The new :option:`dumpdata --pks` option specifies the primary keys of objects
|
| 288 |
+
to dump. This option can only be used with one model.
|
| 289 |
+
|
| 290 |
+
* Added ``QuerySet`` methods :meth:`~django.db.models.query.QuerySet.first`
|
| 291 |
+
and :meth:`~django.db.models.query.QuerySet.last` which are convenience
|
| 292 |
+
methods returning the first or last object matching the filters. Returns
|
| 293 |
+
``None`` if there are no objects matching.
|
| 294 |
+
|
| 295 |
+
* :class:`~django.views.generic.base.View` and
|
| 296 |
+
:class:`~django.views.generic.base.RedirectView` now support HTTP ``PATCH``
|
| 297 |
+
method.
|
| 298 |
+
|
| 299 |
+
* ``GenericForeignKey`` now takes an optional ``for_concrete_model`` argument,
|
| 300 |
+
which when set to ``False`` allows the field to reference proxy models. The
|
| 301 |
+
default is ``True`` to retain the old behavior.
|
| 302 |
+
|
| 303 |
+
* The :class:`~django.middleware.locale.LocaleMiddleware` now stores the active
|
| 304 |
+
language in session if it is not present there. This prevents loss of
|
| 305 |
+
language settings after session flush, e.g. logout.
|
| 306 |
+
|
| 307 |
+
* :exc:`~django.core.exceptions.SuspiciousOperation` has been differentiated
|
| 308 |
+
into a number of subclasses, and each will log to a matching named logger
|
| 309 |
+
under the ``django.security`` logging hierarchy. Along with this change,
|
| 310 |
+
a ``handler400`` mechanism and default view are used whenever
|
| 311 |
+
a ``SuspiciousOperation`` reaches the WSGI handler to return an
|
| 312 |
+
``HttpResponseBadRequest``.
|
| 313 |
+
|
| 314 |
+
* The :exc:`~django.db.models.Model.DoesNotExist` exception now includes a
|
| 315 |
+
message indicating the name of the attribute used for the lookup.
|
| 316 |
+
|
| 317 |
+
* The :meth:`~django.db.models.query.QuerySet.get_or_create` method no longer
|
| 318 |
+
requires at least one keyword argument.
|
| 319 |
+
|
| 320 |
+
* The :class:`~django.test.SimpleTestCase` class includes a new assertion
|
| 321 |
+
helper for testing formset errors:
|
| 322 |
+
``django.test.SimpleTestCase.assertFormsetError()``.
|
| 323 |
+
|
| 324 |
+
* The list of related fields added to a
|
| 325 |
+
:class:`~django.db.models.query.QuerySet` by
|
| 326 |
+
:meth:`~django.db.models.query.QuerySet.select_related` can be cleared using
|
| 327 |
+
``select_related(None)``.
|
| 328 |
+
|
| 329 |
+
* The :meth:`~django.contrib.admin.InlineModelAdmin.get_extra` and
|
| 330 |
+
:meth:`~django.contrib.admin.InlineModelAdmin.get_max_num` methods on
|
| 331 |
+
:class:`~django.contrib.admin.InlineModelAdmin` may be overridden to
|
| 332 |
+
customize the extra and maximum number of inline forms.
|
| 333 |
+
|
| 334 |
+
* Formsets now have a
|
| 335 |
+
:meth:`~django.forms.formsets.BaseFormSet.total_error_count` method.
|
| 336 |
+
|
| 337 |
+
* :class:`~django.forms.ModelForm` fields can now override error messages
|
| 338 |
+
defined in model fields by using the
|
| 339 |
+
:attr:`~django.forms.Field.error_messages` argument of a ``Field``’s
|
| 340 |
+
constructor. To take advantage of this new feature with your custom fields,
|
| 341 |
+
:ref:`see the updated recommendation <raising-validation-error>` for raising
|
| 342 |
+
a ``ValidationError``.
|
| 343 |
+
|
| 344 |
+
* :class:`~django.contrib.admin.ModelAdmin` now preserves filters on the list view
|
| 345 |
+
after creating, editing or deleting an object. It's possible to restore the previous
|
| 346 |
+
behavior of clearing filters by setting the
|
| 347 |
+
:attr:`~django.contrib.admin.ModelAdmin.preserve_filters` attribute to ``False``.
|
| 348 |
+
|
| 349 |
+
* Added
|
| 350 |
+
:meth:`FormMixin.get_prefix<django.views.generic.edit.FormMixin.get_prefix>`
|
| 351 |
+
(which returns
|
| 352 |
+
:attr:`FormMixin.prefix<django.views.generic.edit.FormMixin.prefix>` by
|
| 353 |
+
default) to allow customizing the :attr:`~django.forms.Form.prefix` of the
|
| 354 |
+
form.
|
| 355 |
+
|
| 356 |
+
* Raw queries (``Manager.raw()`` or ``cursor.execute()``) can now use the
|
| 357 |
+
"pyformat" parameter style, where placeholders in the query are given as
|
| 358 |
+
``'%(name)s'`` and the parameters are passed as a dictionary rather than
|
| 359 |
+
a list (except on SQLite). This has long been possible (but not officially
|
| 360 |
+
supported) on MySQL and PostgreSQL, and is now also available on Oracle.
|
| 361 |
+
|
| 362 |
+
* The default iteration count for the PBKDF2 password hasher has been
|
| 363 |
+
increased by 20%. This backwards compatible change will not affect
|
| 364 |
+
existing passwords or users who have subclassed
|
| 365 |
+
``django.contrib.auth.hashers.PBKDF2PasswordHasher`` to change the
|
| 366 |
+
default value. Passwords :ref:`will be upgraded <password-upgrades>` to use
|
| 367 |
+
the new iteration count as necessary.
|
| 368 |
+
|
| 369 |
+
.. _backwards-incompatible-1.6:
|
| 370 |
+
|
| 371 |
+
Backwards incompatible changes in 1.6
|
| 372 |
+
=====================================
|
| 373 |
+
|
| 374 |
+
.. warning::
|
| 375 |
+
|
| 376 |
+
In addition to the changes outlined in this section, be sure to review the
|
| 377 |
+
:ref:`deprecation plan <deprecation-removed-in-1.6>` for any features that
|
| 378 |
+
have been removed. If you haven't updated your code within the
|
| 379 |
+
deprecation timeline for a given feature, its removal may appear as a
|
| 380 |
+
backwards incompatible change.
|
| 381 |
+
|
| 382 |
+
New transaction management model
|
| 383 |
+
--------------------------------
|
| 384 |
+
|
| 385 |
+
Behavior changes
|
| 386 |
+
~~~~~~~~~~~~~~~~
|
| 387 |
+
|
| 388 |
+
Database-level autocommit is enabled by default in Django 1.6. While this
|
| 389 |
+
doesn't change the general spirit of Django's transaction management, there
|
| 390 |
+
are a few backwards-incompatibilities.
|
| 391 |
+
|
| 392 |
+
Savepoints and ``assertNumQueries``
|
| 393 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 394 |
+
|
| 395 |
+
The changes in transaction management may result in additional statements to
|
| 396 |
+
create, release or rollback savepoints. This is more likely to happen with
|
| 397 |
+
SQLite, since it didn't support savepoints until this release.
|
| 398 |
+
|
| 399 |
+
If tests using :meth:`~django.test.TransactionTestCase.assertNumQueries` fail
|
| 400 |
+
because of a higher number of queries than expected, check that the extra
|
| 401 |
+
queries are related to savepoints, and adjust the expected number of queries
|
| 402 |
+
accordingly.
|
| 403 |
+
|
| 404 |
+
Autocommit option for PostgreSQL
|
| 405 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 406 |
+
|
| 407 |
+
In previous versions, database-level autocommit was only an option for
|
| 408 |
+
PostgreSQL, and it was disabled by default. This option is now ignored and can
|
| 409 |
+
be removed.
|
| 410 |
+
|
| 411 |
+
.. _new-test-runner:
|
| 412 |
+
|
| 413 |
+
New test runner
|
| 414 |
+
---------------
|
| 415 |
+
|
| 416 |
+
In order to maintain greater consistency with Python's ``unittest`` module, the
|
| 417 |
+
new test runner (``django.test.runner.DiscoverRunner``) does not automatically
|
| 418 |
+
support some types of tests that were supported by the previous runner:
|
| 419 |
+
|
| 420 |
+
* Tests in ``models.py`` and ``tests/__init__.py`` files will no longer be
|
| 421 |
+
found and run. Move them to a file whose name begins with ``test``.
|
| 422 |
+
|
| 423 |
+
* Doctests will no longer be automatically discovered. To integrate doctests in
|
| 424 |
+
your test suite, follow the :ref:`recommendations in the Python documentation
|
| 425 |
+
<doctest-unittest-api>`.
|
| 426 |
+
|
| 427 |
+
Django bundles a modified version of the :mod:`doctest` module from the Python
|
| 428 |
+
standard library (in ``django.test._doctest``) and includes some additional
|
| 429 |
+
doctest utilities. These utilities are deprecated and will be removed in Django
|
| 430 |
+
1.8; doctest suites should be updated to work with the standard library's
|
| 431 |
+
doctest module (or converted to ``unittest``-compatible tests).
|
| 432 |
+
|
| 433 |
+
If you wish to delay updates to your test suite, you can set your
|
| 434 |
+
:setting:`TEST_RUNNER` setting to ``django.test.simple.DjangoTestSuiteRunner``
|
| 435 |
+
to fully restore the old test behavior. ``DjangoTestSuiteRunner`` is deprecated
|
| 436 |
+
but will not be removed from Django until version 1.8.
|
| 437 |
+
|
| 438 |
+
Removal of ``django.contrib.gis.tests.GeoDjangoTestSuiteRunner`` GeoDjango custom test runner
|
| 439 |
+
---------------------------------------------------------------------------------------------
|
| 440 |
+
|
| 441 |
+
This is for developers working on the GeoDjango application itself and related
|
| 442 |
+
to the item above about changes in the test runners:
|
| 443 |
+
|
| 444 |
+
The ``django.contrib.gis.tests.GeoDjangoTestSuiteRunner`` test runner has been
|
| 445 |
+
removed and the standalone GeoDjango tests execution setup it implemented isn't
|
| 446 |
+
supported anymore. To run the GeoDjango tests simply use the new
|
| 447 |
+
``DiscoverRunner`` and specify the ``django.contrib.gis`` app.
|
| 448 |
+
|
| 449 |
+
Custom user models in tests
|
| 450 |
+
---------------------------
|
| 451 |
+
|
| 452 |
+
The introduction of the new test runner has also slightly changed the way that
|
| 453 |
+
test models are imported. As a result, any test that overrides ``AUTH_USER_MODEL``
|
| 454 |
+
to test behavior with one of Django's test user models (
|
| 455 |
+
``django.contrib.auth.tests.custom_user.CustomUser`` and
|
| 456 |
+
``django.contrib.auth.tests.custom_user.ExtensionUser``) must now
|
| 457 |
+
explicitly import the User model in your test module::
|
| 458 |
+
|
| 459 |
+
from django.contrib.auth.tests.custom_user import CustomUser
|
| 460 |
+
|
| 461 |
+
|
| 462 |
+
@override_settings(AUTH_USER_MODEL="auth.CustomUser")
|
| 463 |
+
class CustomUserFeatureTests(TestCase):
|
| 464 |
+
def test_something(self):
|
| 465 |
+
# Test code here
|
| 466 |
+
...
|
| 467 |
+
|
| 468 |
+
This import forces the custom user model to be registered. Without this import,
|
| 469 |
+
the test will be unable to swap in the custom user model, and you will get an
|
| 470 |
+
error reporting:
|
| 471 |
+
|
| 472 |
+
.. code-block:: pytb
|
| 473 |
+
|
| 474 |
+
ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.CustomUser' that has not been installed
|
| 475 |
+
|
| 476 |
+
Time zone-aware ``day``, ``month``, and ``week_day`` lookups
|
| 477 |
+
------------------------------------------------------------
|
| 478 |
+
|
| 479 |
+
Django 1.6 introduces time zone support for :lookup:`day`, :lookup:`month`,
|
| 480 |
+
and :lookup:`week_day` lookups when :setting:`USE_TZ` is ``True``. These
|
| 481 |
+
lookups were previously performed in UTC regardless of the current time zone.
|
| 482 |
+
|
| 483 |
+
This requires :ref:`time zone definitions in the database
|
| 484 |
+
<database-time-zone-definitions>`. If you're using SQLite, you must install
|
| 485 |
+
pytz_. If you're using MySQL, you must install pytz_ and load the time zone
|
| 486 |
+
tables with `mysql_tzinfo_to_sql`_.
|
| 487 |
+
|
| 488 |
+
.. _pytz: http://pytz.sourceforge.net/
|
| 489 |
+
.. _mysql_tzinfo_to_sql: https://dev.mysql.com/doc/refman/en/mysql-tzinfo-to-sql.html
|
| 490 |
+
|
| 491 |
+
Addition of ``QuerySet.datetimes()``
|
| 492 |
+
------------------------------------
|
| 493 |
+
|
| 494 |
+
When the :doc:`time zone support </topics/i18n/timezones>` added in Django 1.4
|
| 495 |
+
was active, :meth:`QuerySet.dates() <django.db.models.query.QuerySet.dates>`
|
| 496 |
+
lookups returned unexpected results, because the aggregation was performed in
|
| 497 |
+
UTC. To fix this, Django 1.6 introduces a new API, :meth:`QuerySet.datetimes()
|
| 498 |
+
<django.db.models.query.QuerySet.datetimes>`. This requires a few changes in
|
| 499 |
+
your code.
|
| 500 |
+
|
| 501 |
+
``QuerySet.dates()`` returns ``date`` objects
|
| 502 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 503 |
+
|
| 504 |
+
:meth:`QuerySet.dates() <django.db.models.query.QuerySet.dates>` now returns a
|
| 505 |
+
list of :class:`~datetime.date`. It used to return a list of
|
| 506 |
+
:class:`~datetime.datetime`.
|
| 507 |
+
|
| 508 |
+
:meth:`QuerySet.datetimes() <django.db.models.query.QuerySet.datetimes>`
|
| 509 |
+
returns a list of :class:`~datetime.datetime`.
|
| 510 |
+
|
| 511 |
+
``QuerySet.dates()`` no longer usable on ``DateTimeField``
|
| 512 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 513 |
+
|
| 514 |
+
:meth:`QuerySet.dates() <django.db.models.query.QuerySet.dates>` raises an
|
| 515 |
+
error if it's used on :class:`~django.db.models.DateTimeField` when time
|
| 516 |
+
zone support is active. Use :meth:`QuerySet.datetimes()
|
| 517 |
+
<django.db.models.query.QuerySet.datetimes>` instead.
|
| 518 |
+
|
| 519 |
+
``date_hierarchy`` requires time zone definitions
|
| 520 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 521 |
+
|
| 522 |
+
The :attr:`~django.contrib.admin.ModelAdmin.date_hierarchy` feature of the
|
| 523 |
+
admin now relies on :meth:`QuerySet.datetimes()
|
| 524 |
+
<django.db.models.query.QuerySet.datetimes>` when it's used on a
|
| 525 |
+
:class:`~django.db.models.DateTimeField`.
|
| 526 |
+
|
| 527 |
+
This requires time zone definitions in the database when :setting:`USE_TZ` is
|
| 528 |
+
``True``. :ref:`Learn more <database-time-zone-definitions>`.
|
| 529 |
+
|
| 530 |
+
``date_list`` in generic views requires time zone definitions
|
| 531 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 532 |
+
|
| 533 |
+
For the same reason, accessing ``date_list`` in the context of a date-based
|
| 534 |
+
generic view requires time zone definitions in the database when the view is
|
| 535 |
+
based on a :class:`~django.db.models.DateTimeField` and :setting:`USE_TZ` is
|
| 536 |
+
``True``. :ref:`Learn more <database-time-zone-definitions>`.
|
| 537 |
+
|
| 538 |
+
New lookups may clash with model fields
|
| 539 |
+
---------------------------------------
|
| 540 |
+
|
| 541 |
+
Django 1.6 introduces ``hour``, ``minute``, and ``second`` lookups on
|
| 542 |
+
:class:`~django.db.models.DateTimeField`. If you had model fields called
|
| 543 |
+
``hour``, ``minute``, or ``second``, the new lookups will clash with you field
|
| 544 |
+
names. Append an explicit :lookup:`exact` lookup if this is an issue.
|
| 545 |
+
|
| 546 |
+
``BooleanField`` no longer defaults to ``False``
|
| 547 |
+
------------------------------------------------
|
| 548 |
+
|
| 549 |
+
When a :class:`~django.db.models.BooleanField` doesn't have an explicit
|
| 550 |
+
:attr:`~django.db.models.Field.default`, the implicit default value is
|
| 551 |
+
``None``. In previous version of Django, it was ``False``, but that didn't
|
| 552 |
+
represent accurately the lack of a value.
|
| 553 |
+
|
| 554 |
+
Code that relies on the default value being ``False`` may raise an exception
|
| 555 |
+
when saving new model instances to the database, because ``None`` isn't an
|
| 556 |
+
acceptable value for a :class:`~django.db.models.BooleanField`. You should
|
| 557 |
+
either specify ``default=False`` in the field definition, or ensure the field
|
| 558 |
+
is set to ``True`` or ``False`` before saving the object.
|
| 559 |
+
|
| 560 |
+
Translations and comments in templates
|
| 561 |
+
--------------------------------------
|
| 562 |
+
|
| 563 |
+
Extraction of translations after comments
|
| 564 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 565 |
+
|
| 566 |
+
Extraction of translatable literals from templates with the
|
| 567 |
+
:djadmin:`makemessages` command now correctly detects i18n constructs when
|
| 568 |
+
they are located after a ``{#`` / ``#}``-type comment on the same line. E.g.:
|
| 569 |
+
|
| 570 |
+
.. code-block:: html+django
|
| 571 |
+
|
| 572 |
+
{# A comment #}{% trans "This literal was incorrectly ignored. Not anymore" %}
|
| 573 |
+
|
| 574 |
+
Location of translator comments
|
| 575 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 576 |
+
|
| 577 |
+
:ref:`translator-comments-in-templates` specified using ``{#`` / ``#}`` need to
|
| 578 |
+
be at the end of a line. If they are not, the comments are ignored and
|
| 579 |
+
:djadmin:`makemessages` will generate a warning. For example:
|
| 580 |
+
|
| 581 |
+
.. code-block:: html+django
|
| 582 |
+
|
| 583 |
+
{# Translators: This is ignored #}{% trans "Translate me" %}
|
| 584 |
+
{{ title }}{# Translators: Extracted and associated with 'Welcome' below #}
|
| 585 |
+
<h1>{% trans "Welcome" %}</h1>
|
| 586 |
+
|
| 587 |
+
Quoting in ``reverse()``
|
| 588 |
+
------------------------
|
| 589 |
+
|
| 590 |
+
When reversing URLs, Django didn't apply ``django.utils.http.urlquote``
|
| 591 |
+
to arguments before interpolating them in URL patterns. This bug is fixed in
|
| 592 |
+
Django 1.6. If you worked around this bug by applying URL quoting before
|
| 593 |
+
passing arguments to ``reverse()``, this may result in double-quoting. If this
|
| 594 |
+
happens, simply remove the URL quoting from your code. You will also have to
|
| 595 |
+
replace special characters in URLs used in
|
| 596 |
+
:func:`~django.test.SimpleTestCase.assertRedirects` with their encoded
|
| 597 |
+
versions.
|
| 598 |
+
|
| 599 |
+
Storage of IP addresses in the comments app
|
| 600 |
+
-------------------------------------------
|
| 601 |
+
|
| 602 |
+
The comments app now uses a
|
| 603 |
+
``GenericIPAddressField`` for storing commenters' IP addresses, to support
|
| 604 |
+
comments submitted from IPv6 addresses. Until now, it stored them in an
|
| 605 |
+
``IPAddressField``, which is only meant to support IPv4. When saving a comment
|
| 606 |
+
made from an IPv6 address, the address would be silently truncated on MySQL
|
| 607 |
+
databases, and raise an exception on Oracle. You will need to change the
|
| 608 |
+
column type in your database to benefit from this change.
|
| 609 |
+
|
| 610 |
+
For MySQL, execute this query on your project's database:
|
| 611 |
+
|
| 612 |
+
.. code-block:: sql
|
| 613 |
+
|
| 614 |
+
ALTER TABLE django_comments MODIFY ip_address VARCHAR(39);
|
| 615 |
+
|
| 616 |
+
For Oracle, execute this query:
|
| 617 |
+
|
| 618 |
+
.. code-block:: sql
|
| 619 |
+
|
| 620 |
+
ALTER TABLE DJANGO_COMMENTS MODIFY (ip_address VARCHAR2(39));
|
| 621 |
+
|
| 622 |
+
If you do not apply this change, the behavior is unchanged: on MySQL, IPv6
|
| 623 |
+
addresses are silently truncated; on Oracle, an exception is generated. No
|
| 624 |
+
database change is needed for SQLite or PostgreSQL databases.
|
| 625 |
+
|
| 626 |
+
Percent literals in ``cursor.execute`` queries
|
| 627 |
+
----------------------------------------------
|
| 628 |
+
|
| 629 |
+
When you are running raw SQL queries through the
|
| 630 |
+
:ref:`cursor.execute <executing-custom-sql>` method, the rule about doubling
|
| 631 |
+
percent literals (``%``) inside the query has been unified. Past behavior
|
| 632 |
+
depended on the database backend. Now, across all backends, you only need to
|
| 633 |
+
double literal percent characters if you are also providing replacement
|
| 634 |
+
parameters. For example::
|
| 635 |
+
|
| 636 |
+
# No parameters, no percent doubling
|
| 637 |
+
cursor.execute("SELECT foo FROM bar WHERE baz = '30%'")
|
| 638 |
+
|
| 639 |
+
# Parameters passed, non-placeholders have to be doubled
|
| 640 |
+
cursor.execute("SELECT foo FROM bar WHERE baz = '30%%' and id = %s", [self.id])
|
| 641 |
+
|
| 642 |
+
``SQLite`` users need to check and update such queries.
|
| 643 |
+
|
| 644 |
+
.. _m2m-help_text:
|
| 645 |
+
|
| 646 |
+
Help text of model form fields for ManyToManyField fields
|
| 647 |
+
---------------------------------------------------------
|
| 648 |
+
|
| 649 |
+
HTML rendering of model form fields corresponding to
|
| 650 |
+
:class:`~django.db.models.ManyToManyField` model fields used to get the
|
| 651 |
+
hard-coded sentence:
|
| 652 |
+
|
| 653 |
+
*Hold down "Control", or "Command" on a Mac, to select more than one.*
|
| 654 |
+
|
| 655 |
+
(or its translation to the active locale) imposed as the help legend shown along
|
| 656 |
+
them if neither :attr:`model <django.db.models.Field.help_text>` nor :attr:`form
|
| 657 |
+
<django.forms.Field.help_text>` ``help_text`` attributes were specified by the
|
| 658 |
+
user (or this string was appended to any ``help_text`` that was provided).
|
| 659 |
+
|
| 660 |
+
Since this happened at the model layer, there was no way to prevent the text
|
| 661 |
+
from appearing in cases where it wasn't applicable such as form fields that
|
| 662 |
+
implement user interactions that don't involve a keyboard and/or a mouse.
|
| 663 |
+
|
| 664 |
+
Starting with Django 1.6, as an ad-hoc temporary backward-compatibility
|
| 665 |
+
provision, the logic to add the "Hold down..." sentence has been moved to the
|
| 666 |
+
model form field layer and modified to add the text only when the associated
|
| 667 |
+
widget is :class:`~django.forms.SelectMultiple` or selected subclasses.
|
| 668 |
+
|
| 669 |
+
The change can affect you in a backward incompatible way if you employ custom
|
| 670 |
+
model form fields and/or widgets for ``ManyToManyField`` model fields whose UIs
|
| 671 |
+
do rely on the automatic provision of the mentioned hard-coded sentence. These
|
| 672 |
+
form field implementations need to adapt to the new scenario by providing their
|
| 673 |
+
own handling of the ``help_text`` attribute.
|
| 674 |
+
|
| 675 |
+
Applications that use Django :doc:`model form </topics/forms/modelforms>`
|
| 676 |
+
facilities together with Django built-in form :doc:`fields </ref/forms/fields>`
|
| 677 |
+
and :doc:`widgets </ref/forms/widgets>` aren't affected but need to be aware of
|
| 678 |
+
what's described in :ref:`m2m-help_text-deprecation` below.
|
| 679 |
+
|
| 680 |
+
QuerySet iteration
|
| 681 |
+
------------------
|
| 682 |
+
|
| 683 |
+
The ``QuerySet`` iteration was changed to immediately convert all fetched
|
| 684 |
+
rows to ``Model`` objects. In Django 1.5 and earlier the fetched rows were
|
| 685 |
+
converted to ``Model`` objects in chunks of 100.
|
| 686 |
+
|
| 687 |
+
Existing code will work, but the amount of rows converted to objects
|
| 688 |
+
might change in certain use cases. Such usages include partially looping
|
| 689 |
+
over a queryset or any usage which ends up doing ``__bool__`` or
|
| 690 |
+
``__contains__``.
|
| 691 |
+
|
| 692 |
+
Notably most database backends did fetch all the rows in one go already in
|
| 693 |
+
1.5.
|
| 694 |
+
|
| 695 |
+
It is still possible to convert the fetched rows to ``Model`` objects
|
| 696 |
+
lazily by using the :meth:`~django.db.models.query.QuerySet.iterator()`
|
| 697 |
+
method.
|
| 698 |
+
|
| 699 |
+
:meth:`BoundField.label_tag<django.forms.BoundField.label_tag>` now includes the form's :attr:`~django.forms.Form.label_suffix`
|
| 700 |
+
-------------------------------------------------------------------------------------------------------------------------------
|
| 701 |
+
|
| 702 |
+
This is consistent with how methods like
|
| 703 |
+
:meth:`Form.as_p<django.forms.Form.as_p>` and
|
| 704 |
+
:meth:`Form.as_ul<django.forms.Form.as_ul>` render labels.
|
| 705 |
+
|
| 706 |
+
If you manually render ``label_tag`` in your templates:
|
| 707 |
+
|
| 708 |
+
.. code-block:: html+django
|
| 709 |
+
|
| 710 |
+
{{ form.my_field.label_tag }}: {{ form.my_field }}
|
| 711 |
+
|
| 712 |
+
you'll want to remove the colon (or whatever other separator you may be
|
| 713 |
+
using) to avoid duplicating it when upgrading to Django 1.6. The following
|
| 714 |
+
template in Django 1.6 will render identically to the above template in Django
|
| 715 |
+
1.5, except that the colon will appear inside the ``<label>`` element.
|
| 716 |
+
|
| 717 |
+
.. code-block:: html+django
|
| 718 |
+
|
| 719 |
+
{{ form.my_field.label_tag }} {{ form.my_field }}
|
| 720 |
+
|
| 721 |
+
will render something like:
|
| 722 |
+
|
| 723 |
+
.. code-block:: html
|
| 724 |
+
|
| 725 |
+
<label for="id_my_field">My Field:</label> <input id="id_my_field" type="text" name="my_field" />
|
| 726 |
+
|
| 727 |
+
If you want to keep the current behavior of rendering ``label_tag`` without
|
| 728 |
+
the ``label_suffix``, instantiate the form ``label_suffix=''``. You can also
|
| 729 |
+
customize the ``label_suffix`` on a per-field basis using the new
|
| 730 |
+
``label_suffix`` parameter on :meth:`~django.forms.BoundField.label_tag`.
|
| 731 |
+
|
| 732 |
+
Admin views ``_changelist_filters`` GET parameter
|
| 733 |
+
-------------------------------------------------
|
| 734 |
+
|
| 735 |
+
To achieve preserving and restoring list view filters, admin views now
|
| 736 |
+
pass around the ``_changelist_filters`` GET parameter. It's important that you
|
| 737 |
+
account for that change if you have custom admin templates or if your tests
|
| 738 |
+
rely on the previous URLs. If you want to revert to the original behavior you
|
| 739 |
+
can set the
|
| 740 |
+
:attr:`~django.contrib.admin.ModelAdmin.preserve_filters` attribute to ``False``.
|
| 741 |
+
|
| 742 |
+
``django.contrib.auth`` password reset uses base 64 encoding of ``User`` PK
|
| 743 |
+
---------------------------------------------------------------------------
|
| 744 |
+
|
| 745 |
+
Past versions of Django used base 36 encoding of the ``User`` primary key in
|
| 746 |
+
the password reset views and URLs
|
| 747 |
+
(``django.contrib.auth.views.password_reset_confirm()``). Base 36 encoding is
|
| 748 |
+
sufficient if the user primary key is an integer, however, with the
|
| 749 |
+
introduction of custom user models in Django 1.5, that assumption may no longer
|
| 750 |
+
be true.
|
| 751 |
+
|
| 752 |
+
``django.contrib.auth.views.password_reset_confirm()`` has been modified to
|
| 753 |
+
take a ``uidb64`` parameter instead of ``uidb36``. If you are reversing this
|
| 754 |
+
view, for example in a custom ``password_reset_email.html`` template, be sure
|
| 755 |
+
to update your code.
|
| 756 |
+
|
| 757 |
+
A temporary shim for ``django.contrib.auth.views.password_reset_confirm()``
|
| 758 |
+
that will allow password reset links generated prior to Django 1.6 to continue
|
| 759 |
+
to work has been added to provide backwards compatibility; this will be removed
|
| 760 |
+
in Django 1.7. Thus, as long as your site has been running Django 1.6 for more
|
| 761 |
+
than ``PASSWORD_RESET_TIMEOUT_DAYS``, this change will have no effect.
|
| 762 |
+
If not (for example, if you upgrade directly from Django 1.5 to Django 1.7),
|
| 763 |
+
then any password reset links generated before you upgrade to Django 1.7 or
|
| 764 |
+
later won't work after the upgrade.
|
| 765 |
+
|
| 766 |
+
In addition, if you have any custom password reset URLs, you will need to
|
| 767 |
+
update them by replacing ``uidb36`` with ``uidb64`` and the dash that follows
|
| 768 |
+
that pattern with a slash. Also add ``_\-`` to the list of characters that may
|
| 769 |
+
match the ``uidb64`` pattern.
|
| 770 |
+
|
| 771 |
+
For example::
|
| 772 |
+
|
| 773 |
+
url(
|
| 774 |
+
r"^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$",
|
| 775 |
+
"django.contrib.auth.views.password_reset_confirm",
|
| 776 |
+
name="password_reset_confirm",
|
| 777 |
+
),
|
| 778 |
+
|
| 779 |
+
becomes::
|
| 780 |
+
|
| 781 |
+
url(
|
| 782 |
+
r"^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$",
|
| 783 |
+
"django.contrib.auth.views.password_reset_confirm",
|
| 784 |
+
name="password_reset_confirm",
|
| 785 |
+
),
|
| 786 |
+
|
| 787 |
+
You may also want to add the shim to support the old style reset links. Using
|
| 788 |
+
the example above, you would modify the existing url by replacing
|
| 789 |
+
``django.contrib.auth.views.password_reset_confirm`` with
|
| 790 |
+
``django.contrib.auth.views.password_reset_confirm_uidb36`` and also remove
|
| 791 |
+
the ``name`` argument so it doesn't conflict with the new url::
|
| 792 |
+
|
| 793 |
+
url(
|
| 794 |
+
r"^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$",
|
| 795 |
+
"django.contrib.auth.views.password_reset_confirm_uidb36",
|
| 796 |
+
),
|
| 797 |
+
|
| 798 |
+
You can remove this URL pattern after your app has been deployed with Django
|
| 799 |
+
1.6 for ``PASSWORD_RESET_TIMEOUT_DAYS``.
|
| 800 |
+
|
| 801 |
+
Default session serialization switched to JSON
|
| 802 |
+
----------------------------------------------
|
| 803 |
+
|
| 804 |
+
Historically, :mod:`django.contrib.sessions` used :mod:`pickle` to serialize
|
| 805 |
+
session data before storing it in the backend. If you're using the :ref:`signed
|
| 806 |
+
cookie session backend<cookie-session-backend>` and :setting:`SECRET_KEY` is
|
| 807 |
+
known by an attacker (there isn't an inherent vulnerability in Django that
|
| 808 |
+
would cause it to leak), the attacker could insert a string into their session
|
| 809 |
+
which, when unpickled, executes arbitrary code on the server. The technique for
|
| 810 |
+
doing so is simple and easily available on the internet. Although the cookie
|
| 811 |
+
session storage signs the cookie-stored data to prevent tampering, a
|
| 812 |
+
:setting:`SECRET_KEY` leak immediately escalates to a remote code execution
|
| 813 |
+
vulnerability.
|
| 814 |
+
|
| 815 |
+
This attack can be mitigated by serializing session data using JSON rather
|
| 816 |
+
than :mod:`pickle`. To facilitate this, Django 1.5.3 introduced a new setting,
|
| 817 |
+
:setting:`SESSION_SERIALIZER`, to customize the session serialization format.
|
| 818 |
+
For backwards compatibility, this setting defaulted to using :mod:`pickle`
|
| 819 |
+
in Django 1.5.3, but we've changed the default to JSON in 1.6. If you upgrade
|
| 820 |
+
and switch from pickle to JSON, sessions created before the upgrade will be
|
| 821 |
+
lost. While JSON serialization does not support all Python objects like
|
| 822 |
+
:mod:`pickle` does, we highly recommend using JSON-serialized sessions. Be
|
| 823 |
+
aware of the following when checking your code to determine if JSON
|
| 824 |
+
serialization will work for your application:
|
| 825 |
+
|
| 826 |
+
* JSON requires string keys, so you will likely run into problems if you are
|
| 827 |
+
using non-string keys in ``request.session``.
|
| 828 |
+
* Setting session expiration by passing ``datetime`` values to
|
| 829 |
+
:meth:`~django.contrib.sessions.backends.base.SessionBase.set_expiry` will
|
| 830 |
+
not work as ``datetime`` values are not serializable in JSON. You can use
|
| 831 |
+
integer values instead.
|
| 832 |
+
|
| 833 |
+
See the :ref:`session_serialization` documentation for more details.
|
| 834 |
+
|
| 835 |
+
Object Relational Mapper changes
|
| 836 |
+
--------------------------------
|
| 837 |
+
|
| 838 |
+
Django 1.6 contains many changes to the ORM. These changes fall mostly in
|
| 839 |
+
three categories:
|
| 840 |
+
|
| 841 |
+
1. Bug fixes (e.g. proper join clauses for generic relations, query combining,
|
| 842 |
+
join promotion, and join trimming fixes)
|
| 843 |
+
2. Preparation for new features. For example the ORM is now internally ready
|
| 844 |
+
for multicolumn foreign keys.
|
| 845 |
+
3. General cleanup.
|
| 846 |
+
|
| 847 |
+
These changes can result in some compatibility problems. For example, some
|
| 848 |
+
queries will now generate different table aliases. This can affect
|
| 849 |
+
:meth:`QuerySet.extra() <django.db.models.query.QuerySet.extra>`. In addition
|
| 850 |
+
some queries will now produce different results. An example is
|
| 851 |
+
:meth:`exclude(condition) <django.db.models.query.QuerySet.exclude>`
|
| 852 |
+
where the condition is a complex one (referencing multijoins inside
|
| 853 |
+
:class:`Q objects <django.db.models.Q>`). In many cases the affected
|
| 854 |
+
queries didn't produce correct results in Django 1.5 but do now.
|
| 855 |
+
Unfortunately there are also cases that produce different results, but
|
| 856 |
+
neither Django 1.5 nor 1.6 produce correct results.
|
| 857 |
+
|
| 858 |
+
Finally, there have been many changes to the ORM internal APIs.
|
| 859 |
+
|
| 860 |
+
Miscellaneous
|
| 861 |
+
-------------
|
| 862 |
+
|
| 863 |
+
* The ``django.db.models.query.EmptyQuerySet`` can't be instantiated any more -
|
| 864 |
+
it is only usable as a marker class for checking if
|
| 865 |
+
:meth:`~django.db.models.query.QuerySet.none` has been called:
|
| 866 |
+
``isinstance(qs.none(), EmptyQuerySet)``
|
| 867 |
+
|
| 868 |
+
* If your CSS/JavaScript code used to access HTML input widgets by type, you
|
| 869 |
+
should review it as ``type='text'`` widgets might be now output as
|
| 870 |
+
``type='email'``, ``type='url'`` or ``type='number'`` depending on their
|
| 871 |
+
corresponding field type.
|
| 872 |
+
|
| 873 |
+
* Form field's :attr:`~django.forms.Field.error_messages` that contain a
|
| 874 |
+
placeholder should now always use a named placeholder (``"Value '%(value)s' is
|
| 875 |
+
too big"`` instead of ``"Value '%s' is too big"``). See the corresponding
|
| 876 |
+
field documentation for details about the names of the placeholders. The
|
| 877 |
+
changes in 1.6 particularly affect :class:`~django.forms.DecimalField` and
|
| 878 |
+
:class:`~django.forms.ModelMultipleChoiceField`.
|
| 879 |
+
|
| 880 |
+
* Some :attr:`~django.forms.Field.error_messages` for
|
| 881 |
+
:class:`~django.forms.IntegerField`, :class:`~django.forms.EmailField`,
|
| 882 |
+
``IPAddressField``, :class:`~django.forms.GenericIPAddressField`, and
|
| 883 |
+
:class:`~django.forms.SlugField` have been suppressed because they
|
| 884 |
+
duplicated error messages already provided by validators tied to the fields.
|
| 885 |
+
|
| 886 |
+
* Due to a change in the form validation workflow,
|
| 887 |
+
:class:`~django.forms.TypedChoiceField` ``coerce`` method should always
|
| 888 |
+
return a value present in the ``choices`` field attribute. That limitation
|
| 889 |
+
should be lift again in Django 1.7.
|
| 890 |
+
|
| 891 |
+
* There have been changes in the way timeouts are handled in cache backends.
|
| 892 |
+
Explicitly passing in ``timeout=None`` no longer results in using the
|
| 893 |
+
default timeout. It will now set a non-expiring timeout. Passing 0 into the
|
| 894 |
+
memcache backend no longer uses the default timeout, and now will
|
| 895 |
+
set-and-expire-immediately the value.
|
| 896 |
+
|
| 897 |
+
* The ``django.contrib.flatpages`` app used to set custom HTTP headers for
|
| 898 |
+
debugging purposes. This functionality was not documented and made caching
|
| 899 |
+
ineffective so it has been removed, along with its generic implementation,
|
| 900 |
+
previously available in ``django.core.xheaders``.
|
| 901 |
+
|
| 902 |
+
* The ``XViewMiddleware`` has been moved from ``django.middleware.doc`` to
|
| 903 |
+
``django.contrib.admindocs.middleware`` because it is an implementation
|
| 904 |
+
detail of admindocs, proven not to be reusable in general.
|
| 905 |
+
|
| 906 |
+
* :class:`~django.db.models.GenericIPAddressField` will now only allow
|
| 907 |
+
``blank`` values if ``null`` values are also allowed. Creating a
|
| 908 |
+
``GenericIPAddressField`` where ``blank`` is allowed but ``null`` is not
|
| 909 |
+
will trigger a model validation error because ``blank`` values are always
|
| 910 |
+
stored as ``null``. Previously, storing a ``blank`` value in a field which
|
| 911 |
+
did not allow ``null`` would cause a database exception at runtime.
|
| 912 |
+
|
| 913 |
+
* If a ``NoReverseMatch`` exception is raised from a method when rendering a
|
| 914 |
+
template, it is not silenced. For example, ``{{ obj.view_href }}`` will
|
| 915 |
+
cause template rendering to fail if ``view_href()`` raises
|
| 916 |
+
``NoReverseMatch``. There is no change to the :ttag:`{% url %}<url>` tag, it
|
| 917 |
+
causes template rendering to fail like always when ``NoReverseMatch`` is
|
| 918 |
+
raised.
|
| 919 |
+
|
| 920 |
+
* :meth:`django.test.Client.logout` now calls
|
| 921 |
+
:meth:`django.contrib.auth.logout` which will send the
|
| 922 |
+
:func:`~django.contrib.auth.signals.user_logged_out` signal.
|
| 923 |
+
|
| 924 |
+
* :ref:`Authentication views <built-in-auth-views>` are now reversed by name,
|
| 925 |
+
not their locations in ``django.contrib.auth.views``. If you are using the
|
| 926 |
+
views without a ``name``, you should update your ``urlpatterns`` to use
|
| 927 |
+
``django.conf.urls.url()`` with the ``name`` parameter. For example::
|
| 928 |
+
|
| 929 |
+
(r"^reset/done/$", "django.contrib.auth.views.password_reset_complete")
|
| 930 |
+
|
| 931 |
+
becomes::
|
| 932 |
+
|
| 933 |
+
url(
|
| 934 |
+
r"^reset/done/$",
|
| 935 |
+
"django.contrib.auth.views.password_reset_complete",
|
| 936 |
+
name="password_reset_complete",
|
| 937 |
+
)
|
| 938 |
+
|
| 939 |
+
* :class:`~django.views.generic.base.RedirectView` now has a ``pattern_name``
|
| 940 |
+
attribute which allows it to choose the target by reversing the URL.
|
| 941 |
+
|
| 942 |
+
* In Django 1.4 and 1.5, a blank string was unintentionally not considered to
|
| 943 |
+
be a valid password. This meant
|
| 944 |
+
:meth:`~django.contrib.auth.models.User.set_password()` would save a blank
|
| 945 |
+
password as an unusable password like
|
| 946 |
+
:meth:`~django.contrib.auth.models.User.set_unusable_password()` does, and
|
| 947 |
+
thus :meth:`~django.contrib.auth.models.User.check_password()` always
|
| 948 |
+
returned ``False`` for blank passwords. This has been corrected in this
|
| 949 |
+
release: blank passwords are now valid.
|
| 950 |
+
|
| 951 |
+
* The admin :attr:`~django.contrib.admin.ModelAdmin.changelist_view` previously
|
| 952 |
+
accepted a ``pop`` GET parameter to signify it was to be displayed in a popup.
|
| 953 |
+
This parameter has been renamed to ``_popup`` to be consistent with the rest
|
| 954 |
+
of the admin views. You should update your custom templates if they use the
|
| 955 |
+
previous parameter name.
|
| 956 |
+
|
| 957 |
+
* :meth:`~django.core.validators.validate_email` now accepts email addresses
|
| 958 |
+
with ``localhost`` as the domain.
|
| 959 |
+
|
| 960 |
+
* The new :option:`makemessages --keep-pot` option prevents deleting the
|
| 961 |
+
temporary ``.pot`` file generated before creating the ``.po`` file.
|
| 962 |
+
|
| 963 |
+
* The undocumented ``django.core.servers.basehttp.WSGIServerException`` has
|
| 964 |
+
been removed. Use ``socket.error`` provided by the standard library instead.
|
| 965 |
+
This change was also released in Django 1.5.5.
|
| 966 |
+
|
| 967 |
+
* The signature of :meth:`django.views.generic.base.RedirectView.get_redirect_url`
|
| 968 |
+
has changed and now accepts positional arguments as well (``*args, **kwargs``).
|
| 969 |
+
Any unnamed captured group will now be passed to ``get_redirect_url()``
|
| 970 |
+
which may result in a ``TypeError`` if you don't update the signature of your
|
| 971 |
+
custom method.
|
| 972 |
+
|
| 973 |
+
.. _deprecated-features-1.6:
|
| 974 |
+
|
| 975 |
+
Features deprecated in 1.6
|
| 976 |
+
==========================
|
| 977 |
+
|
| 978 |
+
Transaction management APIs
|
| 979 |
+
---------------------------
|
| 980 |
+
|
| 981 |
+
Transaction management was completely overhauled in Django 1.6, and the
|
| 982 |
+
current APIs are deprecated:
|
| 983 |
+
|
| 984 |
+
- ``django.middleware.transaction.TransactionMiddleware``
|
| 985 |
+
- ``django.db.transaction.autocommit``
|
| 986 |
+
- ``django.db.transaction.commit_on_success``
|
| 987 |
+
- ``django.db.transaction.commit_manually``
|
| 988 |
+
- the ``TRANSACTIONS_MANAGED`` setting
|
| 989 |
+
|
| 990 |
+
``django.contrib.comments``
|
| 991 |
+
---------------------------
|
| 992 |
+
|
| 993 |
+
Django's comment framework has been deprecated and is no longer supported. It
|
| 994 |
+
will be available in Django 1.6 and 1.7, and removed in Django 1.8. Most users
|
| 995 |
+
will be better served with a custom solution, or a hosted product like Disqus__.
|
| 996 |
+
|
| 997 |
+
The code formerly known as ``django.contrib.comments`` is `still available
|
| 998 |
+
in an external repository`__.
|
| 999 |
+
|
| 1000 |
+
__ https://disqus.com/
|
| 1001 |
+
__ https://github.com/django/django-contrib-comments
|
| 1002 |
+
|
| 1003 |
+
Support for PostgreSQL versions older than 8.4
|
| 1004 |
+
----------------------------------------------
|
| 1005 |
+
|
| 1006 |
+
The end of upstream support periods was reached in December 2011 for
|
| 1007 |
+
PostgreSQL 8.2 and in February 2013 for 8.3. As a consequence, Django 1.6 sets
|
| 1008 |
+
8.4 as the minimum PostgreSQL version it officially supports.
|
| 1009 |
+
|
| 1010 |
+
You're strongly encouraged to use the most recent version of PostgreSQL
|
| 1011 |
+
available, because of performance improvements and to take advantage of the
|
| 1012 |
+
native streaming replication available in PostgreSQL 9.x.
|
| 1013 |
+
|
| 1014 |
+
Changes to :ttag:`cycle` and :ttag:`firstof`
|
| 1015 |
+
--------------------------------------------
|
| 1016 |
+
|
| 1017 |
+
The template system generally escapes all variables to avoid XSS attacks.
|
| 1018 |
+
However, due to an accident of history, the :ttag:`cycle` and :ttag:`firstof`
|
| 1019 |
+
tags render their arguments as-is.
|
| 1020 |
+
|
| 1021 |
+
Django 1.6 starts a process to correct this inconsistency. The ``future``
|
| 1022 |
+
template library provides alternate implementations of :ttag:`cycle` and
|
| 1023 |
+
:ttag:`firstof` that autoescape their inputs. If you're using these tags,
|
| 1024 |
+
you're encouraged to include the following line at the top of your templates to
|
| 1025 |
+
enable the new behavior:
|
| 1026 |
+
|
| 1027 |
+
.. code-block:: html+django
|
| 1028 |
+
|
| 1029 |
+
{% load cycle from future %}
|
| 1030 |
+
|
| 1031 |
+
or:
|
| 1032 |
+
|
| 1033 |
+
.. code-block:: html+django
|
| 1034 |
+
|
| 1035 |
+
{% load firstof from future %}
|
| 1036 |
+
|
| 1037 |
+
The tags implementing the old behavior have been deprecated, and in Django
|
| 1038 |
+
1.8, the old behavior will be replaced with the new behavior. To ensure
|
| 1039 |
+
compatibility with future versions of Django, existing templates should be
|
| 1040 |
+
modified to use the ``future`` versions.
|
| 1041 |
+
|
| 1042 |
+
If necessary, you can temporarily disable auto-escaping with
|
| 1043 |
+
:func:`~django.utils.safestring.mark_safe` or :ttag:`{% autoescape off %}
|
| 1044 |
+
<autoescape>`.
|
| 1045 |
+
|
| 1046 |
+
``CACHE_MIDDLEWARE_ANONYMOUS_ONLY`` setting
|
| 1047 |
+
-------------------------------------------
|
| 1048 |
+
|
| 1049 |
+
``CacheMiddleware`` and ``UpdateCacheMiddleware`` used to provide a way to
|
| 1050 |
+
cache requests only if they weren't made by a logged-in user. This mechanism
|
| 1051 |
+
was largely ineffective because the middleware correctly takes into account the
|
| 1052 |
+
``Vary: Cookie`` HTTP header, and this header is being set on a variety of
|
| 1053 |
+
occasions, such as:
|
| 1054 |
+
|
| 1055 |
+
* accessing the session, or
|
| 1056 |
+
* using CSRF protection, which is turned on by default, or
|
| 1057 |
+
* using a client-side library which sets cookies, like `Google Analytics`__.
|
| 1058 |
+
|
| 1059 |
+
This makes the cache effectively work on a per-session basis regardless of the
|
| 1060 |
+
``CACHE_MIDDLEWARE_ANONYMOUS_ONLY`` setting.
|
| 1061 |
+
|
| 1062 |
+
__ https://marketingplatform.google.com/about/analytics/
|
| 1063 |
+
|
| 1064 |
+
``SEND_BROKEN_LINK_EMAILS`` setting
|
| 1065 |
+
-----------------------------------
|
| 1066 |
+
|
| 1067 |
+
:class:`~django.middleware.common.CommonMiddleware` used to provide basic
|
| 1068 |
+
reporting of broken links by email when ``SEND_BROKEN_LINK_EMAILS`` is set to
|
| 1069 |
+
``True``.
|
| 1070 |
+
|
| 1071 |
+
Because of intractable ordering problems between
|
| 1072 |
+
:class:`~django.middleware.common.CommonMiddleware` and
|
| 1073 |
+
:class:`~django.middleware.locale.LocaleMiddleware`, this feature was split
|
| 1074 |
+
out into a new middleware:
|
| 1075 |
+
:class:`~django.middleware.common.BrokenLinkEmailsMiddleware`.
|
| 1076 |
+
|
| 1077 |
+
If you're relying on this feature, you should add
|
| 1078 |
+
``'django.middleware.common.BrokenLinkEmailsMiddleware'`` to your
|
| 1079 |
+
``MIDDLEWARE_CLASSES`` setting and remove ``SEND_BROKEN_LINK_EMAILS``
|
| 1080 |
+
from your settings.
|
| 1081 |
+
|
| 1082 |
+
``_has_changed`` method on widgets
|
| 1083 |
+
----------------------------------
|
| 1084 |
+
|
| 1085 |
+
If you defined your own form widgets and defined the ``_has_changed`` method
|
| 1086 |
+
on a widget, you should now define this method on the form field itself.
|
| 1087 |
+
|
| 1088 |
+
``module_name`` model _meta attribute
|
| 1089 |
+
-------------------------------------
|
| 1090 |
+
|
| 1091 |
+
``Model._meta.module_name`` was renamed to ``model_name``. Despite being a
|
| 1092 |
+
private API, it will go through a regular deprecation path.
|
| 1093 |
+
|
| 1094 |
+
``get_(add|change|delete)_permission`` model _meta methods
|
| 1095 |
+
----------------------------------------------------------
|
| 1096 |
+
|
| 1097 |
+
``Model._meta.get_(add|change|delete)_permission`` methods were deprecated.
|
| 1098 |
+
Even if they were not part of the public API they'll also go through
|
| 1099 |
+
a regular deprecation path. You can replace them with
|
| 1100 |
+
``django.contrib.auth.get_permission_codename('action', Model._meta)`` where
|
| 1101 |
+
``'action'`` is ``'add'``, ``'change'``, or ``'delete'``.
|
| 1102 |
+
|
| 1103 |
+
``get_query_set`` and similar methods renamed to ``get_queryset``
|
| 1104 |
+
-----------------------------------------------------------------
|
| 1105 |
+
|
| 1106 |
+
Methods that return a ``QuerySet`` such as ``Manager.get_query_set`` or
|
| 1107 |
+
``ModelAdmin.queryset`` have been renamed to ``get_queryset``.
|
| 1108 |
+
|
| 1109 |
+
If you are writing a library that implements, for example, a
|
| 1110 |
+
``Manager.get_query_set`` method, and you need to support old Django versions,
|
| 1111 |
+
you should rename the method and conditionally add an alias with the old name::
|
| 1112 |
+
|
| 1113 |
+
class CustomManager(models.Manager):
|
| 1114 |
+
def get_queryset(self):
|
| 1115 |
+
pass # ...
|
| 1116 |
+
|
| 1117 |
+
if django.VERSION < (1, 6):
|
| 1118 |
+
get_query_set = get_queryset
|
| 1119 |
+
|
| 1120 |
+
# For Django >= 1.6, models.Manager provides a get_query_set fallback
|
| 1121 |
+
# that emits a warning when used.
|
| 1122 |
+
|
| 1123 |
+
If you are writing a library that needs to call the ``get_queryset`` method and
|
| 1124 |
+
must support old Django versions, you should write::
|
| 1125 |
+
|
| 1126 |
+
get_queryset = (
|
| 1127 |
+
some_manager.get_query_set
|
| 1128 |
+
if hasattr(some_manager, "get_query_set")
|
| 1129 |
+
else some_manager.get_queryset
|
| 1130 |
+
)
|
| 1131 |
+
return get_queryset() # etc
|
| 1132 |
+
|
| 1133 |
+
In the general case of a custom manager that both implements its own
|
| 1134 |
+
``get_queryset`` method and calls that method, and needs to work with older Django
|
| 1135 |
+
versions, and libraries that have not been updated yet, it is useful to define
|
| 1136 |
+
a ``get_queryset_compat`` method as below and use it internally to your manager::
|
| 1137 |
+
|
| 1138 |
+
class YourCustomManager(models.Manager):
|
| 1139 |
+
def get_queryset(self):
|
| 1140 |
+
return YourCustomQuerySet() # for example
|
| 1141 |
+
|
| 1142 |
+
if django.VERSION < (1, 6):
|
| 1143 |
+
get_query_set = get_queryset
|
| 1144 |
+
|
| 1145 |
+
def active(self): # for example
|
| 1146 |
+
return self.get_queryset_compat().filter(active=True)
|
| 1147 |
+
|
| 1148 |
+
def get_queryset_compat(self):
|
| 1149 |
+
get_queryset = (
|
| 1150 |
+
self.get_query_set if hasattr(self, "get_query_set") else self.get_queryset
|
| 1151 |
+
)
|
| 1152 |
+
return get_queryset()
|
| 1153 |
+
|
| 1154 |
+
This helps to minimize the changes that are needed, but also works correctly in
|
| 1155 |
+
the case of subclasses (such as ``RelatedManagers`` from Django 1.5) which might
|
| 1156 |
+
override either ``get_query_set`` or ``get_queryset``.
|
| 1157 |
+
|
| 1158 |
+
|
| 1159 |
+
``shortcut`` view and URLconf
|
| 1160 |
+
-----------------------------
|
| 1161 |
+
|
| 1162 |
+
The ``shortcut`` view was moved from ``django.views.defaults`` to
|
| 1163 |
+
``django.contrib.contenttypes.views`` shortly after the 1.0 release, but the
|
| 1164 |
+
old location was never deprecated. This oversight was corrected in Django 1.6
|
| 1165 |
+
and you should now use the new location.
|
| 1166 |
+
|
| 1167 |
+
The URLconf ``django.conf.urls.shortcut`` was also deprecated. If you're
|
| 1168 |
+
including it in an URLconf, simply replace::
|
| 1169 |
+
|
| 1170 |
+
(r"^prefix/", include("django.conf.urls.shortcut")),
|
| 1171 |
+
|
| 1172 |
+
with::
|
| 1173 |
+
|
| 1174 |
+
(
|
| 1175 |
+
r"^prefix/(?P<content_type_id>\d+)/(?P<object_id>.*)/$",
|
| 1176 |
+
"django.contrib.contenttypes.views.shortcut",
|
| 1177 |
+
),
|
| 1178 |
+
|
| 1179 |
+
``ModelForm`` without ``fields`` or ``exclude``
|
| 1180 |
+
-----------------------------------------------
|
| 1181 |
+
|
| 1182 |
+
Previously, if you wanted a :class:`~django.forms.ModelForm` to use all fields on
|
| 1183 |
+
the model, you could simply omit the ``Meta.fields`` attribute, and all fields
|
| 1184 |
+
would be used.
|
| 1185 |
+
|
| 1186 |
+
This can lead to security problems where fields are added to the model and,
|
| 1187 |
+
unintentionally, automatically become editable by end users. In some cases,
|
| 1188 |
+
particular with boolean fields, it is possible for this problem to be completely
|
| 1189 |
+
invisible. This is a form of `Mass assignment vulnerability
|
| 1190 |
+
<https://en.wikipedia.org/wiki/Mass_assignment_vulnerability>`_.
|
| 1191 |
+
|
| 1192 |
+
For this reason, this behavior is deprecated, and using the ``Meta.exclude``
|
| 1193 |
+
option is strongly discouraged. Instead, all fields that are intended for
|
| 1194 |
+
inclusion in the form should be listed explicitly in the ``fields`` attribute.
|
| 1195 |
+
|
| 1196 |
+
If this security concern really does not apply in your case, there is a shortcut
|
| 1197 |
+
to explicitly indicate that all fields should be used - use the special value
|
| 1198 |
+
``"__all__"`` for the fields attribute::
|
| 1199 |
+
|
| 1200 |
+
class MyModelForm(ModelForm):
|
| 1201 |
+
class Meta:
|
| 1202 |
+
fields = "__all__"
|
| 1203 |
+
model = MyModel
|
| 1204 |
+
|
| 1205 |
+
If you have custom ``ModelForms`` that only need to be used in the admin, there
|
| 1206 |
+
is another option. The admin has its own methods for defining fields
|
| 1207 |
+
(``fieldsets`` etc.), and so adding a list of fields to the ``ModelForm`` is
|
| 1208 |
+
redundant. Instead, simply omit the ``Meta`` inner class of the ``ModelForm``,
|
| 1209 |
+
or omit the ``Meta.model`` attribute. Since the ``ModelAdmin`` subclass knows
|
| 1210 |
+
which model it is for, it can add the necessary attributes to derive a
|
| 1211 |
+
functioning ``ModelForm``. This behavior also works for earlier Django
|
| 1212 |
+
versions.
|
| 1213 |
+
|
| 1214 |
+
``UpdateView`` and ``CreateView`` without explicit fields
|
| 1215 |
+
---------------------------------------------------------
|
| 1216 |
+
|
| 1217 |
+
The generic views :class:`~django.views.generic.edit.CreateView` and
|
| 1218 |
+
:class:`~django.views.generic.edit.UpdateView`, and anything else derived from
|
| 1219 |
+
:class:`~django.views.generic.edit.ModelFormMixin`, are vulnerable to the
|
| 1220 |
+
security problem described in the section above, because they can automatically
|
| 1221 |
+
create a ``ModelForm`` that uses all fields for a model.
|
| 1222 |
+
|
| 1223 |
+
For this reason, if you use these views for editing models, you must also supply
|
| 1224 |
+
the ``fields`` attribute (new in Django 1.6), which is a list of model fields
|
| 1225 |
+
and works in the same way as the :class:`~django.forms.ModelForm`
|
| 1226 |
+
``Meta.fields`` attribute. Alternatively, you can set the ``form_class``
|
| 1227 |
+
attribute to a ``ModelForm`` that explicitly defines the fields to be used.
|
| 1228 |
+
Defining an ``UpdateView`` or ``CreateView`` subclass to be used with a model
|
| 1229 |
+
but without an explicit list of fields is deprecated.
|
| 1230 |
+
|
| 1231 |
+
.. _m2m-help_text-deprecation:
|
| 1232 |
+
|
| 1233 |
+
Munging of help text of model form fields for ``ManyToManyField`` fields
|
| 1234 |
+
------------------------------------------------------------------------
|
| 1235 |
+
|
| 1236 |
+
All special handling of the ``help_text`` attribute of ``ManyToManyField`` model
|
| 1237 |
+
fields performed by standard model or model form fields as described in
|
| 1238 |
+
:ref:`m2m-help_text` above is deprecated and will be removed in Django 1.8.
|
| 1239 |
+
|
| 1240 |
+
Help text of these fields will need to be handled either by applications, custom
|
| 1241 |
+
form fields or widgets, just like happens with the rest of the model field
|
| 1242 |
+
types.
|
testbed/django__django/docs/releases/1.7.1.txt
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.7.1 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*October 22, 2014*
|
| 6 |
+
|
| 7 |
+
Django 1.7.1 fixes several bugs in 1.7.
|
| 8 |
+
|
| 9 |
+
Bugfixes
|
| 10 |
+
========
|
| 11 |
+
|
| 12 |
+
* Allowed related many-to-many fields to be referenced in the admin
|
| 13 |
+
(:ticket:`23604`).
|
| 14 |
+
|
| 15 |
+
* Added a more helpful error message if you try to migrate an app without first
|
| 16 |
+
creating the ``contenttypes`` table (:ticket:`22411`).
|
| 17 |
+
|
| 18 |
+
* Modified migrations dependency algorithm to avoid possible infinite recursion.
|
| 19 |
+
|
| 20 |
+
* Fixed a ``UnicodeDecodeError`` when the ``flush`` error message contained
|
| 21 |
+
Unicode characters (:ticket:`22882`).
|
| 22 |
+
|
| 23 |
+
* Reinstated missing ``CHECK`` SQL clauses which were omitted on some backends
|
| 24 |
+
when not using migrations (:ticket:`23416`).
|
| 25 |
+
|
| 26 |
+
* Fixed serialization of ``type`` objects in migrations (:ticket:`22951`).
|
| 27 |
+
|
| 28 |
+
* Allowed inline and hidden references to admin fields (:ticket:`23431`).
|
| 29 |
+
|
| 30 |
+
* The ``@deconstructible`` decorator now fails with a ``ValueError`` if the
|
| 31 |
+
decorated object cannot automatically be imported (:ticket:`23418`).
|
| 32 |
+
|
| 33 |
+
* Fixed a typo in an ``inlineformset_factory()`` error message that caused a
|
| 34 |
+
crash (:ticket:`23451`).
|
| 35 |
+
|
| 36 |
+
* Restored the ability to use :setting:`ABSOLUTE_URL_OVERRIDES` with the
|
| 37 |
+
``'auth.User'`` model (:ticket:`11775`). As a side effect, the setting now
|
| 38 |
+
adds a ``get_absolute_url()`` method to any model that appears in
|
| 39 |
+
``ABSOLUTE_URL_OVERRIDES`` but doesn't define ``get_absolute_url()``.
|
| 40 |
+
|
| 41 |
+
* Avoided masking some ``ImportError`` exceptions during application loading
|
| 42 |
+
(:ticket:`22920`).
|
| 43 |
+
|
| 44 |
+
* Empty ``index_together`` or ``unique_together`` model options no longer
|
| 45 |
+
results in infinite migrations (:ticket:`23452`).
|
| 46 |
+
|
| 47 |
+
* Fixed crash in ``contrib.sitemaps`` if ``lastmod`` returned a ``date`` rather
|
| 48 |
+
than a ``datetime`` (:ticket:`23403`).
|
| 49 |
+
|
| 50 |
+
* Allowed migrations to work with ``app_label``\s that have the same last
|
| 51 |
+
part (e.g. ``django.contrib.auth`` and ``vendor.auth``) (:ticket:`23483`).
|
| 52 |
+
|
| 53 |
+
* Restored the ability to deepcopy ``F`` objects (:ticket:`23492`).
|
| 54 |
+
|
| 55 |
+
* Formats for Welsh (``cy``) and several Chinese locales (``zh_CN``,
|
| 56 |
+
``zh_Hans``, ``zh_Hant`` and ``zh_TW``) have been added. Formats for
|
| 57 |
+
Macedonian have been fixed (trailing dot removed, :ticket:`23532`).
|
| 58 |
+
|
| 59 |
+
* Added quoting of constraint names in the SQL generated by migrations to
|
| 60 |
+
prevent crash with uppercase characters in the name (:ticket:`23065`).
|
| 61 |
+
|
| 62 |
+
* Fixed renaming of models with a self-referential many-to-many field
|
| 63 |
+
(``ManyToManyField('self')``) (:ticket:`23503`).
|
| 64 |
+
|
| 65 |
+
* Added the :meth:`~django.contrib.admin.InlineModelAdmin.get_extra()`,
|
| 66 |
+
:meth:`~django.contrib.admin.InlineModelAdmin.get_max_num()`, and
|
| 67 |
+
:meth:`~django.contrib.admin.InlineModelAdmin.get_min_num()` hooks to
|
| 68 |
+
:class:`~django.contrib.contenttypes.admin.GenericInlineModelAdmin`
|
| 69 |
+
(:ticket:`23539`).
|
| 70 |
+
|
| 71 |
+
* Made ``migrations.RunSQL`` no longer require percent sign escaping. This is
|
| 72 |
+
now consistent with ``cursor.execute()`` (:ticket:`23426`).
|
| 73 |
+
|
| 74 |
+
* Made the ``SERIALIZE`` entry in the :setting:`TEST <DATABASE-TEST>`
|
| 75 |
+
dictionary usable (:ticket:`23421`).
|
| 76 |
+
|
| 77 |
+
* Fixed bug in migrations that prevented foreign key constraints to unmanaged
|
| 78 |
+
models with a custom primary key (:ticket:`23415`).
|
| 79 |
+
|
| 80 |
+
* Added ``SchemaEditor`` for MySQL GIS backend so that spatial indexes will be
|
| 81 |
+
created for apps with migrations (:ticket:`23538`).
|
| 82 |
+
|
| 83 |
+
* Added ``SchemaEditor`` for Oracle GIS backend so that spatial metadata and
|
| 84 |
+
indexes will be created for apps with migrations (:ticket:`23537`).
|
| 85 |
+
|
| 86 |
+
* Coerced the ``related_name`` model field option to Unicode during migration
|
| 87 |
+
generation to generate migrations that work with both Python 2 and 3
|
| 88 |
+
(:ticket:`23455`).
|
| 89 |
+
|
| 90 |
+
* Fixed ``MigrationWriter`` to handle builtin types without imports
|
| 91 |
+
(:ticket:`23560`).
|
| 92 |
+
|
| 93 |
+
* Fixed ``deepcopy`` on ``ErrorList`` (:ticket:`23594`).
|
| 94 |
+
|
| 95 |
+
* Made the :mod:`~django.contrib.admindocs` view to browse view details check
|
| 96 |
+
if the view specified in the URL exists in the URLconf. Previously it was
|
| 97 |
+
possible to import arbitrary packages from the Python path. This was not
|
| 98 |
+
considered a security issue because ``admindocs`` is only accessible to staff
|
| 99 |
+
users (:ticket:`23601`).
|
| 100 |
+
|
| 101 |
+
* Fixed ``UnicodeDecodeError`` crash in ``AdminEmailHandler`` with non-ASCII
|
| 102 |
+
characters in the request (:ticket:`23593`).
|
| 103 |
+
|
| 104 |
+
* Fixed missing ``get_or_create`` and ``update_or_create`` on related managers
|
| 105 |
+
causing ``IntegrityError`` (:ticket:`23611`).
|
| 106 |
+
|
| 107 |
+
* Made :func:`~django.utils.http.urlsafe_base64_decode` return the proper
|
| 108 |
+
type (bytestring) on Python 3 (:ticket:`23333`).
|
| 109 |
+
|
| 110 |
+
* :djadmin:`makemigrations` can now serialize timezone-aware values
|
| 111 |
+
(:ticket:`23365`).
|
| 112 |
+
|
| 113 |
+
* Added a prompt to the migrations questioner when removing the null constraint
|
| 114 |
+
from a field to prevent an IntegrityError on existing NULL rows
|
| 115 |
+
(:ticket:`23609`).
|
| 116 |
+
|
| 117 |
+
* Fixed generic relations in ``ModelAdmin.list_filter`` (:ticket:`23616`).
|
| 118 |
+
|
| 119 |
+
* Restored RFC compliance for the SMTP backend on Python 3 (:ticket:`23063`).
|
| 120 |
+
|
| 121 |
+
* Fixed a crash while parsing cookies containing invalid content
|
| 122 |
+
(:ticket:`23638`).
|
| 123 |
+
|
| 124 |
+
* The system check framework now raises error **models.E020** when the
|
| 125 |
+
class method ``Model.check()`` is unreachable (:ticket:`23615`).
|
| 126 |
+
|
| 127 |
+
* Made the Oracle test database creation drop the test user in the event of an
|
| 128 |
+
unclean exit of a previous test run (:ticket:`23649`).
|
| 129 |
+
|
| 130 |
+
* Fixed :djadmin:`makemigrations` to detect changes to
|
| 131 |
+
:attr:`Meta.db_table <django.db.models.Options.db_table>` (:ticket:`23629`).
|
| 132 |
+
|
| 133 |
+
* Fixed a regression when feeding the Django test client with an empty data
|
| 134 |
+
string (:ticket:`21740`).
|
| 135 |
+
|
| 136 |
+
* Fixed a regression in :djadmin:`makemessages` where static files were
|
| 137 |
+
unexpectedly ignored (:ticket:`23583`).
|
testbed/django__django/docs/releases/1.7.2.txt
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.7.2 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*January 2, 2015*
|
| 6 |
+
|
| 7 |
+
Django 1.7.2 fixes several bugs in 1.7.1.
|
| 8 |
+
|
| 9 |
+
Additionally, Django's vendored version of six, ``django.utils.six``, has
|
| 10 |
+
been upgraded to the latest release (1.9.0).
|
| 11 |
+
|
| 12 |
+
Bugfixes
|
| 13 |
+
========
|
| 14 |
+
|
| 15 |
+
* Fixed migration's renaming of auto-created many-to-many tables when changing
|
| 16 |
+
:attr:`Meta.db_table <django.db.models.Options.db_table>` (:ticket:`23630`).
|
| 17 |
+
|
| 18 |
+
* Fixed a migration crash when adding an explicit ``id`` field to a model on
|
| 19 |
+
SQLite (:ticket:`23702`).
|
| 20 |
+
|
| 21 |
+
* Added a warning for duplicate models when a module is reloaded. Previously a
|
| 22 |
+
``RuntimeError`` was raised every time two models clashed in the app registry.
|
| 23 |
+
(:ticket:`23621`).
|
| 24 |
+
|
| 25 |
+
* Prevented :djadmin:`flush` from loading initial data for migrated apps
|
| 26 |
+
(:ticket:`23699`).
|
| 27 |
+
|
| 28 |
+
* Fixed a :djadmin:`makemessages` regression in 1.7.1 when
|
| 29 |
+
:setting:`STATIC_ROOT` has the default ``None`` value (:ticket:`23717`).
|
| 30 |
+
|
| 31 |
+
* Added GeoDjango compatibility with mysqlclient database driver.
|
| 32 |
+
|
| 33 |
+
* Fixed MySQL 5.6+ crash with ``GeometryField``\s in migrations
|
| 34 |
+
(:ticket:`23719`).
|
| 35 |
+
|
| 36 |
+
* Fixed a migration crash when removing a field that is referenced in
|
| 37 |
+
``AlterIndexTogether`` or ``AlterUniqueTogether`` (:ticket:`23614`).
|
| 38 |
+
|
| 39 |
+
* Updated the first day of the week in the Ukrainian locale to Monday.
|
| 40 |
+
|
| 41 |
+
* Added support for transactional spatial metadata initialization on
|
| 42 |
+
SpatiaLite 4.1+ (:ticket:`23152`).
|
| 43 |
+
|
| 44 |
+
* Fixed a migration crash that prevented changing a nullable field with a
|
| 45 |
+
default to non-nullable with the same default (:ticket:`23738`).
|
| 46 |
+
|
| 47 |
+
* Fixed a migration crash when adding ``GeometryField``\s with ``blank=True``
|
| 48 |
+
on PostGIS (:ticket:`23731`).
|
| 49 |
+
|
| 50 |
+
* Allowed usage of ``DateTimeField()`` as ``Transform.output_field``
|
| 51 |
+
(:ticket:`23420`).
|
| 52 |
+
|
| 53 |
+
* Fixed a migration serializing bug involving ``float("nan")`` and
|
| 54 |
+
``float("inf")`` (:ticket:`23770`).
|
| 55 |
+
|
| 56 |
+
* Fixed a regression where custom form fields having a ``queryset`` attribute
|
| 57 |
+
but no ``limit_choices_to`` could not be used in a
|
| 58 |
+
:class:`~django.forms.ModelForm` (:ticket:`23795`).
|
| 59 |
+
|
| 60 |
+
* Fixed a custom field type validation error with MySQL backend when
|
| 61 |
+
``db_type`` returned ``None`` (:ticket:`23761`).
|
| 62 |
+
|
| 63 |
+
* Fixed a migration crash when a field is renamed that is part of an
|
| 64 |
+
``index_together`` (:ticket:`23859`).
|
| 65 |
+
|
| 66 |
+
* Fixed :djadmin:`squashmigrations` to respect the ``--no-optimize`` parameter
|
| 67 |
+
(:ticket:`23799`).
|
| 68 |
+
|
| 69 |
+
* Made :class:`~django.db.migrations.operations.RenameModel` reversible
|
| 70 |
+
(:ticket:`22248`)
|
| 71 |
+
|
| 72 |
+
* Avoided unnecessary rollbacks of migrations from other apps when migrating
|
| 73 |
+
backwards (:ticket:`23410`).
|
| 74 |
+
|
| 75 |
+
* Fixed a rare query error when using deeply nested subqueries
|
| 76 |
+
(:ticket:`23605`).
|
| 77 |
+
|
| 78 |
+
* Fixed a crash in migrations when deleting a field that is part of a
|
| 79 |
+
``index/unique_together`` constraint (:ticket:`23794`).
|
| 80 |
+
|
| 81 |
+
* Fixed ``django.core.files.File.__repr__()`` when the file's ``name`` contains
|
| 82 |
+
Unicode characters (:ticket:`23888`).
|
| 83 |
+
|
| 84 |
+
* Added missing context to the admin's ``delete_selected`` view that prevented
|
| 85 |
+
custom site header, etc. from appearing (:ticket:`23898`).
|
| 86 |
+
|
| 87 |
+
* Fixed a regression with dynamically generated inlines and allowed field
|
| 88 |
+
references in the admin (:ticket:`23754`).
|
| 89 |
+
|
| 90 |
+
* Fixed an infinite loop bug for certain cyclic migration dependencies, and made
|
| 91 |
+
the error message for cyclic dependencies much more helpful.
|
| 92 |
+
|
| 93 |
+
* Added missing ``index_together`` handling for SQLite (:ticket:`23880`).
|
| 94 |
+
|
| 95 |
+
* Fixed a crash when ``RunSQL`` SQL content was collected by the schema editor,
|
| 96 |
+
typically when using ``sqlmigrate`` (:ticket:`23909`).
|
| 97 |
+
|
| 98 |
+
* Fixed a regression in ``contrib.admin`` add/change views which caused some
|
| 99 |
+
``ModelAdmin`` methods to receive the incorrect ``obj`` value
|
| 100 |
+
(:ticket:`23934`).
|
| 101 |
+
|
| 102 |
+
* Fixed ``runserver`` crash when socket error message contained Unicode
|
| 103 |
+
characters (:ticket:`23946`).
|
| 104 |
+
|
| 105 |
+
* Fixed serialization of ``type`` when adding a ``deconstruct()`` method
|
| 106 |
+
(:ticket:`23950`).
|
| 107 |
+
|
| 108 |
+
* Prevented the
|
| 109 |
+
``django.contrib.auth.middleware.SessionAuthenticationMiddleware`` from
|
| 110 |
+
setting a ``"Vary: Cookie"`` header on all responses (:ticket:`23939`).
|
| 111 |
+
|
| 112 |
+
* Fixed a crash when adding ``blank=True`` to ``TextField()`` on MySQL
|
| 113 |
+
(:ticket:`23920`).
|
| 114 |
+
|
| 115 |
+
* Fixed index creation by the migration infrastructure, particularly when
|
| 116 |
+
dealing with PostgreSQL specific ``{text|varchar}_pattern_ops`` indexes
|
| 117 |
+
(:ticket:`23954`).
|
| 118 |
+
|
| 119 |
+
* Fixed bug in ``makemigrations`` that created broken migration files when
|
| 120 |
+
dealing with multiple table inheritance and inheriting from more than one
|
| 121 |
+
model (:ticket:`23956`).
|
| 122 |
+
|
| 123 |
+
* Fixed a crash when a ``MultiValueField`` has invalid data (:ticket:`23674`).
|
| 124 |
+
|
| 125 |
+
* Fixed a crash in the admin when using "Save as new" and also deleting a
|
| 126 |
+
related inline (:ticket:`23857`).
|
| 127 |
+
|
| 128 |
+
* Always converted ``related_name`` to text (Unicode), since that is required
|
| 129 |
+
on Python 3 for interpolation. Removed conversion of ``related_name`` to text
|
| 130 |
+
in migration deconstruction (:ticket:`23455` and :ticket:`23982`).
|
| 131 |
+
|
| 132 |
+
* Enlarged the sizes of tablespaces which are created by default for testing
|
| 133 |
+
on Oracle (the main tablespace was increased from 200M to 300M and the
|
| 134 |
+
temporary tablespace from 100M to 150M). This was required to accommodate
|
| 135 |
+
growth in Django's own test suite (:ticket:`23969`).
|
| 136 |
+
|
| 137 |
+
* Fixed ``timesince`` filter translations in Korean (:ticket:`23989`).
|
| 138 |
+
|
| 139 |
+
* Fixed the SQLite ``SchemaEditor`` to properly add defaults in the absence of
|
| 140 |
+
a user specified ``default``. For example, a ``CharField`` with ``blank=True``
|
| 141 |
+
didn't set existing rows to an empty string which resulted in a crash when
|
| 142 |
+
adding the ``NOT NULL`` constraint (:ticket:`23987`).
|
| 143 |
+
|
| 144 |
+
* ``makemigrations`` no longer prompts for a default value when adding
|
| 145 |
+
``TextField()`` or ``CharField()`` without a ``default`` (:ticket:`23405`).
|
| 146 |
+
|
| 147 |
+
* Fixed a migration crash when adding ``order_with_respect_to`` to a table
|
| 148 |
+
with existing rows (:ticket:`23983`).
|
| 149 |
+
|
| 150 |
+
* Restored the ``pre_migrate`` signal if all apps have migrations
|
| 151 |
+
(:ticket:`23975`).
|
| 152 |
+
|
| 153 |
+
* Made admin system checks run for custom ``AdminSite``\s (:ticket:`23497`).
|
| 154 |
+
|
| 155 |
+
* Ensured the app registry is fully populated when unpickling models. When an
|
| 156 |
+
external script (like a queueing infrastructure) reloads pickled models, it
|
| 157 |
+
could crash with an ``AppRegistryNotReady`` exception (:ticket:`24007`).
|
| 158 |
+
|
| 159 |
+
* Added quoting to field indexes in the SQL generated by migrations to prevent
|
| 160 |
+
a crash when the index name requires it (:ticket:`24015`).
|
| 161 |
+
|
| 162 |
+
* Added ``datetime.time`` support to migrations questioner (:ticket:`23998`).
|
| 163 |
+
|
| 164 |
+
* Fixed admindocs crash on apps installed as eggs (:ticket:`23525`).
|
| 165 |
+
|
| 166 |
+
* Changed migrations autodetector to generate an ``AlterModelOptions`` operation
|
| 167 |
+
instead of ``DeleteModel`` and ``CreateModel`` operations when changing
|
| 168 |
+
``Meta.managed``. This prevents data loss when changing ``managed`` from
|
| 169 |
+
``False`` to ``True`` and vice versa (:ticket:`24037`).
|
| 170 |
+
|
| 171 |
+
* Enabled the ``sqlsequencereset`` command on apps with migrations
|
| 172 |
+
(:ticket:`24054`).
|
| 173 |
+
|
| 174 |
+
* Added tablespace SQL to apps with migrations (:ticket:`24051`).
|
| 175 |
+
|
| 176 |
+
* Corrected ``contrib.sites`` default site creation in a multiple database
|
| 177 |
+
setup (:ticket:`24000`).
|
| 178 |
+
|
| 179 |
+
* Restored support for objects that aren't :class:`str` or :class:`bytes` in
|
| 180 |
+
``django.utils.safestring.mark_for_escaping()`` on Python 3.
|
| 181 |
+
|
| 182 |
+
* Supported strings escaped by third-party libraries with the ``__html__``
|
| 183 |
+
convention in the template engine (:ticket:`23831`).
|
| 184 |
+
|
| 185 |
+
* Prevented extraneous ``DROP DEFAULT`` SQL in migrations (:ticket:`23581`).
|
| 186 |
+
|
| 187 |
+
* Restored the ability to use more than five levels of subqueries
|
| 188 |
+
(:ticket:`23758`).
|
| 189 |
+
|
| 190 |
+
* Fixed crash when ``ValidationError`` is initialized with a ``ValidationError``
|
| 191 |
+
that is initialized with a dictionary (:ticket:`24008`).
|
| 192 |
+
|
| 193 |
+
* Prevented a crash on apps without migrations when running ``migrate --list``
|
| 194 |
+
(:ticket:`23366`).
|
testbed/django__django/docs/releases/1.7.9.txt
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.7.9 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*July 8, 2015*
|
| 6 |
+
|
| 7 |
+
Django 1.7.9 fixes several security issues and bugs in 1.7.8.
|
| 8 |
+
|
| 9 |
+
Denial-of-service possibility by filling session store
|
| 10 |
+
======================================================
|
| 11 |
+
|
| 12 |
+
In previous versions of Django, the session backends created a new empty record
|
| 13 |
+
in the session storage anytime ``request.session`` was accessed and there was a
|
| 14 |
+
session key provided in the request cookies that didn't already have a session
|
| 15 |
+
record. This could allow an attacker to easily create many new session records
|
| 16 |
+
simply by sending repeated requests with unknown session keys, potentially
|
| 17 |
+
filling up the session store or causing other users' session records to be
|
| 18 |
+
evicted.
|
| 19 |
+
|
| 20 |
+
The built-in session backends now create a session record only if the session
|
| 21 |
+
is actually modified; empty session records are not created. Thus this
|
| 22 |
+
potential DoS is now only possible if the site chooses to expose a
|
| 23 |
+
session-modifying view to anonymous users.
|
| 24 |
+
|
| 25 |
+
As each built-in session backend was fixed separately (rather than a fix in the
|
| 26 |
+
core sessions framework), maintainers of third-party session backends should
|
| 27 |
+
check whether the same vulnerability is present in their backend and correct
|
| 28 |
+
it if so.
|
| 29 |
+
|
| 30 |
+
Header injection possibility since validators accept newlines in input
|
| 31 |
+
======================================================================
|
| 32 |
+
|
| 33 |
+
Some of Django's built-in validators
|
| 34 |
+
(:class:`~django.core.validators.EmailValidator`, most seriously) didn't
|
| 35 |
+
prohibit newline characters (due to the usage of ``$`` instead of ``\Z`` in the
|
| 36 |
+
regular expressions). If you use values with newlines in HTTP response or email
|
| 37 |
+
headers, you can suffer from header injection attacks. Django itself isn't
|
| 38 |
+
vulnerable because :class:`~django.http.HttpResponse` and the mail sending
|
| 39 |
+
utilities in :mod:`django.core.mail` prohibit newlines in HTTP and SMTP
|
| 40 |
+
headers, respectively. While the validators have been fixed in Django, if
|
| 41 |
+
you're creating HTTP responses or email messages in other ways, it's a good
|
| 42 |
+
idea to ensure that those methods prohibit newlines as well. You might also
|
| 43 |
+
want to validate that any existing data in your application doesn't contain
|
| 44 |
+
unexpected newlines.
|
| 45 |
+
|
| 46 |
+
:func:`~django.core.validators.validate_ipv4_address`,
|
| 47 |
+
:func:`~django.core.validators.validate_slug`, and
|
| 48 |
+
:class:`~django.core.validators.URLValidator` are also affected, however, as
|
| 49 |
+
of Django 1.6 the ``GenericIPAddresseField``, ``IPAddressField``, ``SlugField``,
|
| 50 |
+
and ``URLField`` form fields which use these validators all strip the input, so
|
| 51 |
+
the possibility of newlines entering your data only exists if you are using
|
| 52 |
+
these validators outside of the form fields.
|
| 53 |
+
|
| 54 |
+
The undocumented, internally unused ``validate_integer()`` function is now
|
| 55 |
+
stricter as it validates using a regular expression instead of simply casting
|
| 56 |
+
the value using ``int()`` and checking if an exception was raised.
|
| 57 |
+
|
| 58 |
+
Bugfixes
|
| 59 |
+
========
|
| 60 |
+
|
| 61 |
+
* Prevented the loss of ``null``/``not null`` column properties during field
|
| 62 |
+
renaming of MySQL databases (:ticket:`24817`).
|
| 63 |
+
|
| 64 |
+
* Fixed ``SimpleTestCase.assertRaisesMessage()`` on Python 2.7.10
|
| 65 |
+
(:ticket:`24903`).
|
testbed/django__django/docs/releases/1.7.txt
ADDED
|
@@ -0,0 +1,1856 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========================
|
| 2 |
+
Django 1.7 release notes
|
| 3 |
+
========================
|
| 4 |
+
|
| 5 |
+
*September 2, 2014*
|
| 6 |
+
|
| 7 |
+
Welcome to Django 1.7!
|
| 8 |
+
|
| 9 |
+
These release notes cover the :ref:`new features <whats-new-1.7>`, as well as
|
| 10 |
+
some :ref:`backwards incompatible changes <backwards-incompatible-1.7>` you'll
|
| 11 |
+
want to be aware of when upgrading from Django 1.6 or older versions. We've
|
| 12 |
+
:ref:`begun the deprecation process for some features
|
| 13 |
+
<deprecated-features-1.7>`, and some features have reached the end of their
|
| 14 |
+
deprecation process and :ref:`have been removed <removed-features-1.7>`.
|
| 15 |
+
|
| 16 |
+
Python compatibility
|
| 17 |
+
====================
|
| 18 |
+
|
| 19 |
+
Django 1.7 requires Python 2.7, 3.2, 3.3, or 3.4. We **highly recommend** and
|
| 20 |
+
only officially support the latest release of each series.
|
| 21 |
+
|
| 22 |
+
The Django 1.6 series is the last to support Python 2.6. Django 1.7 is the
|
| 23 |
+
first release to support Python 3.4.
|
| 24 |
+
|
| 25 |
+
This change should affect only a small number of Django users, as most
|
| 26 |
+
operating-system vendors today are shipping Python 2.7 or newer as their default
|
| 27 |
+
version. If you're still using Python 2.6, however, you'll need to stick to
|
| 28 |
+
Django 1.6 until you can upgrade your Python version. Per :doc:`our support
|
| 29 |
+
policy </internals/release-process>`, Django 1.6 will continue to receive
|
| 30 |
+
security support until the release of Django 1.8.
|
| 31 |
+
|
| 32 |
+
.. _whats-new-1.7:
|
| 33 |
+
|
| 34 |
+
What's new in Django 1.7
|
| 35 |
+
========================
|
| 36 |
+
|
| 37 |
+
Schema migrations
|
| 38 |
+
-----------------
|
| 39 |
+
|
| 40 |
+
Django now has built-in support for schema migrations. It allows models
|
| 41 |
+
to be updated, changed, and deleted by creating migration files that represent
|
| 42 |
+
the model changes and which can be run on any development, staging or production
|
| 43 |
+
database.
|
| 44 |
+
|
| 45 |
+
Migrations are covered in :doc:`their own documentation</topics/migrations>`,
|
| 46 |
+
but a few of the key features are:
|
| 47 |
+
|
| 48 |
+
* ``syncdb`` has been deprecated and replaced by ``migrate``. Don't worry -
|
| 49 |
+
calls to ``syncdb`` will still work as before.
|
| 50 |
+
|
| 51 |
+
* A new ``makemigrations`` command provides an easy way to autodetect changes
|
| 52 |
+
to your models and make migrations for them.
|
| 53 |
+
|
| 54 |
+
``django.db.models.signals.pre_syncdb`` and
|
| 55 |
+
``django.db.models.signals.post_syncdb`` have been deprecated,
|
| 56 |
+
to be replaced by :data:`~django.db.models.signals.pre_migrate` and
|
| 57 |
+
:data:`~django.db.models.signals.post_migrate` respectively. These
|
| 58 |
+
new signals have slightly different arguments. Check the
|
| 59 |
+
documentation for details.
|
| 60 |
+
|
| 61 |
+
* The ``allow_syncdb`` method on database routers is now called ``allow_migrate``,
|
| 62 |
+
but still performs the same function. Routers with ``allow_syncdb`` methods
|
| 63 |
+
will still work, but that method name is deprecated and you should change
|
| 64 |
+
it as soon as possible (nothing more than renaming is required).
|
| 65 |
+
|
| 66 |
+
* ``initial_data`` fixtures are no longer loaded for apps with migrations; if
|
| 67 |
+
you want to load initial data for an app, we suggest you create a migration for
|
| 68 |
+
your application and define a :class:`~django.db.migrations.operations.RunPython`
|
| 69 |
+
or :class:`~django.db.migrations.operations.RunSQL` operation in the ``operations`` section of the migration.
|
| 70 |
+
|
| 71 |
+
* Test rollback behavior is different for apps with migrations; in particular,
|
| 72 |
+
Django will no longer emulate rollbacks on non-transactional databases or
|
| 73 |
+
inside ``TransactionTestCase`` :ref:`unless specifically requested
|
| 74 |
+
<test-case-serialized-rollback>`.
|
| 75 |
+
|
| 76 |
+
* It is not advised to have apps without migrations depend on (have a
|
| 77 |
+
:class:`~django.db.models.ForeignKey` or
|
| 78 |
+
:class:`~django.db.models.ManyToManyField` to) apps with migrations.
|
| 79 |
+
|
| 80 |
+
.. _app-loading-refactor-17-release-note:
|
| 81 |
+
|
| 82 |
+
App-loading refactor
|
| 83 |
+
--------------------
|
| 84 |
+
|
| 85 |
+
Historically, Django applications were tightly linked to models. A singleton
|
| 86 |
+
known as the "app cache" dealt with both installed applications and models.
|
| 87 |
+
The models module was used as an identifier for applications in many APIs.
|
| 88 |
+
|
| 89 |
+
As the concept of :doc:`Django applications </ref/applications>` matured, this
|
| 90 |
+
code showed some shortcomings. It has been refactored into an "app registry"
|
| 91 |
+
where models modules no longer have a central role and where it's possible to
|
| 92 |
+
attach configuration data to applications.
|
| 93 |
+
|
| 94 |
+
Improvements thus far include:
|
| 95 |
+
|
| 96 |
+
* Applications can run code at startup, before Django does anything else, with
|
| 97 |
+
the :meth:`~django.apps.AppConfig.ready` method of their configuration.
|
| 98 |
+
|
| 99 |
+
* Application labels are assigned correctly to models even when they're
|
| 100 |
+
defined outside of ``models.py``. You don't have to set
|
| 101 |
+
:attr:`~django.db.models.Options.app_label` explicitly any more.
|
| 102 |
+
|
| 103 |
+
* It is possible to omit ``models.py`` entirely if an application doesn't
|
| 104 |
+
have any models.
|
| 105 |
+
|
| 106 |
+
* Applications can be relabeled with the :attr:`~django.apps.AppConfig.label`
|
| 107 |
+
attribute of application configurations, to work around label conflicts.
|
| 108 |
+
|
| 109 |
+
* The name of applications can be customized in the admin with the
|
| 110 |
+
:attr:`~django.apps.AppConfig.verbose_name` of application configurations.
|
| 111 |
+
|
| 112 |
+
* The admin automatically calls :func:`~django.contrib.admin.autodiscover()`
|
| 113 |
+
when Django starts. You can consequently remove this line from your
|
| 114 |
+
URLconf.
|
| 115 |
+
|
| 116 |
+
* Django imports all application configurations and models as soon as it
|
| 117 |
+
starts, through a deterministic and straightforward process. This should
|
| 118 |
+
make it easier to diagnose import issues such as import loops.
|
| 119 |
+
|
| 120 |
+
New method on Field subclasses
|
| 121 |
+
------------------------------
|
| 122 |
+
|
| 123 |
+
To help power both schema migrations and to enable easier addition of
|
| 124 |
+
composite keys in future releases of Django, the
|
| 125 |
+
:class:`~django.db.models.Field` API now has a new required method:
|
| 126 |
+
``deconstruct()``.
|
| 127 |
+
|
| 128 |
+
This method takes no arguments, and returns a tuple of four items:
|
| 129 |
+
|
| 130 |
+
* ``name``: The field's attribute name on its parent model, or ``None`` if it
|
| 131 |
+
is not part of a model
|
| 132 |
+
* ``path``: A dotted, Python path to the class of this field, including the class name.
|
| 133 |
+
* ``args``: Positional arguments, as a list
|
| 134 |
+
* ``kwargs``: Keyword arguments, as a dict
|
| 135 |
+
|
| 136 |
+
These four values allow any field to be serialized into a file, as well as
|
| 137 |
+
allowing the field to be copied safely, both essential parts of these new features.
|
| 138 |
+
|
| 139 |
+
This change should not affect you unless you write custom Field subclasses;
|
| 140 |
+
if you do, you may need to reimplement the ``deconstruct()`` method if your
|
| 141 |
+
subclass changes the method signature of ``__init__`` in any way. If your
|
| 142 |
+
field just inherits from a built-in Django field and doesn't override ``__init__``,
|
| 143 |
+
no changes are necessary.
|
| 144 |
+
|
| 145 |
+
If you do need to override ``deconstruct()``, a good place to start is the
|
| 146 |
+
built-in Django fields (``django/db/models/fields/__init__.py``) as several
|
| 147 |
+
fields, including ``DecimalField`` and ``DateField``, override it and show how
|
| 148 |
+
to call the method on the superclass and simply add or remove extra arguments.
|
| 149 |
+
|
| 150 |
+
This also means that all arguments to fields must themselves be serializable;
|
| 151 |
+
to see what we consider serializable, and to find out how to make your own
|
| 152 |
+
classes serializable, read the
|
| 153 |
+
:ref:`migration serialization documentation <migration-serializing>`.
|
| 154 |
+
|
| 155 |
+
Calling custom ``QuerySet`` methods from the ``Manager``
|
| 156 |
+
--------------------------------------------------------
|
| 157 |
+
|
| 158 |
+
Historically, the recommended way to make reusable model queries was to create
|
| 159 |
+
methods on a custom ``Manager`` class. The problem with this approach was that
|
| 160 |
+
after the first method call, you'd get back a ``QuerySet`` instance and
|
| 161 |
+
couldn't call additional custom manager methods.
|
| 162 |
+
|
| 163 |
+
Though not documented, it was common to work around this issue by creating a
|
| 164 |
+
custom ``QuerySet`` so that custom methods could be chained; but the solution
|
| 165 |
+
had a number of drawbacks:
|
| 166 |
+
|
| 167 |
+
* The custom ``QuerySet`` and its custom methods were lost after the first
|
| 168 |
+
call to ``values()`` or ``values_list()``.
|
| 169 |
+
|
| 170 |
+
* Writing a custom ``Manager`` was still necessary to return the custom
|
| 171 |
+
``QuerySet`` class and all methods that were desired on the ``Manager``
|
| 172 |
+
had to be proxied to the ``QuerySet``. The whole process went against
|
| 173 |
+
the DRY principle.
|
| 174 |
+
|
| 175 |
+
The :meth:`QuerySet.as_manager() <django.db.models.query.QuerySet.as_manager>`
|
| 176 |
+
class method can now directly :ref:`create Manager with QuerySet methods
|
| 177 |
+
<create-manager-with-queryset-methods>`::
|
| 178 |
+
|
| 179 |
+
class FoodQuerySet(models.QuerySet):
|
| 180 |
+
def pizzas(self):
|
| 181 |
+
return self.filter(kind="pizza")
|
| 182 |
+
|
| 183 |
+
def vegetarian(self):
|
| 184 |
+
return self.filter(vegetarian=True)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
class Food(models.Model):
|
| 188 |
+
kind = models.CharField(max_length=50)
|
| 189 |
+
vegetarian = models.BooleanField(default=False)
|
| 190 |
+
objects = FoodQuerySet.as_manager()
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
Food.objects.pizzas().vegetarian()
|
| 194 |
+
|
| 195 |
+
Using a custom manager when traversing reverse relations
|
| 196 |
+
--------------------------------------------------------
|
| 197 |
+
|
| 198 |
+
It is now possible to :ref:`specify a custom manager
|
| 199 |
+
<using-custom-reverse-manager>` when traversing a reverse relationship::
|
| 200 |
+
|
| 201 |
+
class Blog(models.Model):
|
| 202 |
+
pass
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
class Entry(models.Model):
|
| 206 |
+
blog = models.ForeignKey(Blog)
|
| 207 |
+
|
| 208 |
+
objects = models.Manager() # Default Manager
|
| 209 |
+
entries = EntryManager() # Custom Manager
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
b = Blog.objects.get(id=1)
|
| 213 |
+
b.entry_set(manager="entries").all()
|
| 214 |
+
|
| 215 |
+
New system check framework
|
| 216 |
+
--------------------------
|
| 217 |
+
|
| 218 |
+
We've added a new :doc:`System check framework </ref/checks>` for
|
| 219 |
+
detecting common problems (like invalid models) and providing hints for
|
| 220 |
+
resolving those problems. The framework is extensible so you can add your
|
| 221 |
+
own checks for your own apps and libraries.
|
| 222 |
+
|
| 223 |
+
To perform system checks, you use the :djadmin:`check` management command.
|
| 224 |
+
This command replaces the older ``validate`` management command.
|
| 225 |
+
|
| 226 |
+
New ``Prefetch`` object for advanced ``prefetch_related`` operations.
|
| 227 |
+
---------------------------------------------------------------------
|
| 228 |
+
|
| 229 |
+
The new :class:`~django.db.models.Prefetch` object allows customizing
|
| 230 |
+
prefetch operations.
|
| 231 |
+
|
| 232 |
+
You can specify the ``QuerySet`` used to traverse a given relation
|
| 233 |
+
or customize the storage location of prefetch results.
|
| 234 |
+
|
| 235 |
+
This enables things like filtering prefetched relations, calling
|
| 236 |
+
:meth:`~django.db.models.query.QuerySet.select_related()` from a prefetched
|
| 237 |
+
relation, or prefetching the same relation multiple times with different
|
| 238 |
+
querysets. See :meth:`~django.db.models.query.QuerySet.prefetch_related()`
|
| 239 |
+
for more details.
|
| 240 |
+
|
| 241 |
+
Admin shortcuts support time zones
|
| 242 |
+
----------------------------------
|
| 243 |
+
|
| 244 |
+
The "today" and "now" shortcuts next to date and time input widgets in the
|
| 245 |
+
admin are now operating in the :ref:`current time zone
|
| 246 |
+
<default-current-time-zone>`. Previously, they used the browser time zone,
|
| 247 |
+
which could result in saving the wrong value when it didn't match the current
|
| 248 |
+
time zone on the server.
|
| 249 |
+
|
| 250 |
+
In addition, the widgets now display a help message when the browser and
|
| 251 |
+
server time zone are different, to clarify how the value inserted in the field
|
| 252 |
+
will be interpreted.
|
| 253 |
+
|
| 254 |
+
Using database cursors as context managers
|
| 255 |
+
------------------------------------------
|
| 256 |
+
|
| 257 |
+
Prior to Python 2.7, database cursors could be used as a context manager. The
|
| 258 |
+
specific backend's cursor defined the behavior of the context manager. The
|
| 259 |
+
behavior of magic method lookups was changed with Python 2.7 and cursors were
|
| 260 |
+
no longer usable as context managers.
|
| 261 |
+
|
| 262 |
+
Django 1.7 allows a cursor to be used as a context manager. That is,
|
| 263 |
+
the following can be used::
|
| 264 |
+
|
| 265 |
+
with connection.cursor() as c:
|
| 266 |
+
c.execute(...)
|
| 267 |
+
|
| 268 |
+
instead of::
|
| 269 |
+
|
| 270 |
+
c = connection.cursor()
|
| 271 |
+
try:
|
| 272 |
+
c.execute(...)
|
| 273 |
+
finally:
|
| 274 |
+
c.close()
|
| 275 |
+
|
| 276 |
+
Custom lookups
|
| 277 |
+
--------------
|
| 278 |
+
|
| 279 |
+
It is now possible to write custom lookups and transforms for the ORM.
|
| 280 |
+
Custom lookups work just like Django's built-in lookups (e.g. ``lte``,
|
| 281 |
+
``icontains``) while transforms are a new concept.
|
| 282 |
+
|
| 283 |
+
The :class:`django.db.models.Lookup` class provides a way to add lookup
|
| 284 |
+
operators for model fields. As an example it is possible to add ``day_lte``
|
| 285 |
+
operator for ``DateFields``.
|
| 286 |
+
|
| 287 |
+
The :class:`django.db.models.Transform` class allows transformations of
|
| 288 |
+
database values prior to the final lookup. For example it is possible to
|
| 289 |
+
write a ``year`` transform that extracts year from the field's value.
|
| 290 |
+
Transforms allow for chaining. After the ``year`` transform has been added
|
| 291 |
+
to ``DateField`` it is possible to filter on the transformed value, for
|
| 292 |
+
example ``qs.filter(author__birthdate__year__lte=1981)``.
|
| 293 |
+
|
| 294 |
+
For more information about both custom lookups and transforms refer to
|
| 295 |
+
the :doc:`custom lookups </howto/custom-lookups>` documentation.
|
| 296 |
+
|
| 297 |
+
Improvements to ``Form`` error handling
|
| 298 |
+
---------------------------------------
|
| 299 |
+
|
| 300 |
+
``Form.add_error()``
|
| 301 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 302 |
+
|
| 303 |
+
Previously there were two main patterns for handling errors in forms:
|
| 304 |
+
|
| 305 |
+
* Raising a :exc:`~django.core.exceptions.ValidationError` from within certain
|
| 306 |
+
functions (e.g. ``Field.clean()``, ``Form.clean_<fieldname>()``, or
|
| 307 |
+
``Form.clean()`` for non-field errors.)
|
| 308 |
+
|
| 309 |
+
* Fiddling with ``Form._errors`` when targeting a specific field in
|
| 310 |
+
``Form.clean()`` or adding errors from outside of a "clean" method
|
| 311 |
+
(e.g. directly from a view).
|
| 312 |
+
|
| 313 |
+
Using the former pattern was straightforward since the form can guess from the
|
| 314 |
+
context (i.e. which method raised the exception) where the errors belong and
|
| 315 |
+
automatically process them. This remains the canonical way of adding errors
|
| 316 |
+
when possible. However the latter was fiddly and error-prone, since the burden
|
| 317 |
+
of handling edge cases fell on the user.
|
| 318 |
+
|
| 319 |
+
The new :meth:`~django.forms.Form.add_error()` method allows adding errors
|
| 320 |
+
to specific form fields from anywhere without having to worry about the details
|
| 321 |
+
such as creating instances of ``django.forms.utils.ErrorList`` or dealing with
|
| 322 |
+
``Form.cleaned_data``. This new API replaces manipulating ``Form._errors``
|
| 323 |
+
which now becomes a private API.
|
| 324 |
+
|
| 325 |
+
See :ref:`validating-fields-with-clean` for an example using
|
| 326 |
+
``Form.add_error()``.
|
| 327 |
+
|
| 328 |
+
Error metadata
|
| 329 |
+
~~~~~~~~~~~~~~
|
| 330 |
+
|
| 331 |
+
The :exc:`~django.core.exceptions.ValidationError` constructor accepts metadata
|
| 332 |
+
such as error ``code`` or ``params`` which are then available for interpolating
|
| 333 |
+
into the error message (see :ref:`raising-validation-error` for more details);
|
| 334 |
+
however, before Django 1.7 those metadata were discarded as soon as the errors
|
| 335 |
+
were added to :attr:`Form.errors <django.forms.Form.errors>`.
|
| 336 |
+
|
| 337 |
+
:attr:`Form.errors <django.forms.Form.errors>` and
|
| 338 |
+
``django.forms.utils.ErrorList`` now store the ``ValidationError`` instances
|
| 339 |
+
so these metadata can be retrieved at any time through the new
|
| 340 |
+
:meth:`Form.errors.as_data <django.forms.Form.errors.as_data()>` method.
|
| 341 |
+
|
| 342 |
+
The retrieved ``ValidationError`` instances can then be identified thanks to
|
| 343 |
+
their error ``code`` which enables things like rewriting the error's message
|
| 344 |
+
or writing custom logic in a view when a given error is present. It can also
|
| 345 |
+
be used to serialize the errors in a custom format such as XML.
|
| 346 |
+
|
| 347 |
+
The new :meth:`Form.errors.as_json() <django.forms.Form.errors.as_json()>`
|
| 348 |
+
method is a convenience method which returns error messages along with error
|
| 349 |
+
codes serialized as JSON. ``as_json()`` uses ``as_data()`` and gives an idea
|
| 350 |
+
of how the new system could be extended.
|
| 351 |
+
|
| 352 |
+
Error containers and backward compatibility
|
| 353 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 354 |
+
|
| 355 |
+
Heavy changes to the various error containers were necessary in order
|
| 356 |
+
to support the features above, specifically
|
| 357 |
+
:attr:`Form.errors <django.forms.Form.errors>`,
|
| 358 |
+
``django.forms.utils.ErrorList``, and the internal storages of
|
| 359 |
+
:exc:`~django.core.exceptions.ValidationError`. These containers which used
|
| 360 |
+
to store error strings now store ``ValidationError`` instances and public APIs
|
| 361 |
+
have been adapted to make this as transparent as possible, but if you've been
|
| 362 |
+
using private APIs, some of the changes are backwards incompatible; see
|
| 363 |
+
:ref:`validation-error-constructor-and-internal-storage` for more details.
|
| 364 |
+
|
| 365 |
+
Minor features
|
| 366 |
+
--------------
|
| 367 |
+
|
| 368 |
+
:mod:`django.contrib.admin`
|
| 369 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 370 |
+
|
| 371 |
+
* You can now implement :attr:`~django.contrib.admin.AdminSite.site_header`,
|
| 372 |
+
:attr:`~django.contrib.admin.AdminSite.site_title`, and
|
| 373 |
+
:attr:`~django.contrib.admin.AdminSite.index_title` attributes on a custom
|
| 374 |
+
:class:`~django.contrib.admin.AdminSite` in order to easily change the admin
|
| 375 |
+
site's page title and header text. No more needing to override templates!
|
| 376 |
+
|
| 377 |
+
* Buttons in :mod:`django.contrib.admin` now use the ``border-radius`` CSS
|
| 378 |
+
property for rounded corners rather than GIF background images.
|
| 379 |
+
|
| 380 |
+
* Some admin templates now have ``app-<app_name>`` and ``model-<model_name>``
|
| 381 |
+
classes in their ``<body>`` tag to allow customizing the CSS per app or per
|
| 382 |
+
model.
|
| 383 |
+
|
| 384 |
+
* The admin changelist cells now have a ``field-<field_name>`` class in the
|
| 385 |
+
HTML to enable style customizations.
|
| 386 |
+
|
| 387 |
+
* The admin's search fields can now be customized per-request thanks to the new
|
| 388 |
+
:meth:`django.contrib.admin.ModelAdmin.get_search_fields` method.
|
| 389 |
+
|
| 390 |
+
* The :meth:`ModelAdmin.get_fields()
|
| 391 |
+
<django.contrib.admin.ModelAdmin.get_fields>` method may be overridden to
|
| 392 |
+
customize the value of :attr:`ModelAdmin.fields
|
| 393 |
+
<django.contrib.admin.ModelAdmin.fields>`.
|
| 394 |
+
|
| 395 |
+
* In addition to the existing ``admin.site.register`` syntax, you can use the
|
| 396 |
+
new :func:`~django.contrib.admin.register` decorator to register a
|
| 397 |
+
:class:`~django.contrib.admin.ModelAdmin`.
|
| 398 |
+
|
| 399 |
+
* You may specify :meth:`ModelAdmin.list_display_links
|
| 400 |
+
<django.contrib.admin.ModelAdmin.list_display_links>` ``= None`` to disable
|
| 401 |
+
links on the change list page grid.
|
| 402 |
+
|
| 403 |
+
* You may now specify :attr:`ModelAdmin.view_on_site
|
| 404 |
+
<django.contrib.admin.ModelAdmin.view_on_site>` to control whether or not to
|
| 405 |
+
display the "View on site" link.
|
| 406 |
+
|
| 407 |
+
* You can specify a descending ordering for a :attr:`ModelAdmin.list_display
|
| 408 |
+
<django.contrib.admin.ModelAdmin.list_display>` value by prefixing the
|
| 409 |
+
``admin_order_field`` value with a hyphen.
|
| 410 |
+
|
| 411 |
+
* The :meth:`ModelAdmin.get_changeform_initial_data()
|
| 412 |
+
<django.contrib.admin.ModelAdmin.get_changeform_initial_data>` method may be
|
| 413 |
+
overridden to define custom behavior for setting initial change form data.
|
| 414 |
+
|
| 415 |
+
:mod:`django.contrib.auth`
|
| 416 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 417 |
+
|
| 418 |
+
* Any ``**kwargs`` passed to
|
| 419 |
+
:meth:`~django.contrib.auth.models.User.email_user()` are passed to the
|
| 420 |
+
underlying :meth:`~django.core.mail.send_mail()` call.
|
| 421 |
+
|
| 422 |
+
* The :func:`~django.contrib.auth.decorators.permission_required` decorator can
|
| 423 |
+
take a list of permissions as well as a single permission.
|
| 424 |
+
|
| 425 |
+
* You can override the new :meth:`AuthenticationForm.confirm_login_allowed()
|
| 426 |
+
<django.contrib.auth.forms.AuthenticationForm.confirm_login_allowed>` method
|
| 427 |
+
to more easily customize the login policy.
|
| 428 |
+
|
| 429 |
+
* ``django.contrib.auth.views.password_reset()`` takes an optional
|
| 430 |
+
``html_email_template_name`` parameter used to send a multipart HTML email
|
| 431 |
+
for password resets.
|
| 432 |
+
|
| 433 |
+
* The :meth:`AbstractBaseUser.get_session_auth_hash()
|
| 434 |
+
<django.contrib.auth.models.AbstractBaseUser.get_session_auth_hash>`
|
| 435 |
+
method was added and if your :setting:`AUTH_USER_MODEL` inherits from
|
| 436 |
+
:class:`~django.contrib.auth.models.AbstractBaseUser`, changing a user's
|
| 437 |
+
password now invalidates old sessions if the
|
| 438 |
+
``django.contrib.auth.middleware.SessionAuthenticationMiddleware`` is
|
| 439 |
+
enabled. See :ref:`session-invalidation-on-password-change` for more details.
|
| 440 |
+
|
| 441 |
+
``django.contrib.formtools``
|
| 442 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 443 |
+
|
| 444 |
+
* Calls to ``WizardView.done()`` now include a ``form_dict`` to allow easier
|
| 445 |
+
access to forms by their step name.
|
| 446 |
+
|
| 447 |
+
:mod:`django.contrib.gis`
|
| 448 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 449 |
+
|
| 450 |
+
* The default OpenLayers library version included in widgets has been updated
|
| 451 |
+
from 2.11 to 2.13.
|
| 452 |
+
|
| 453 |
+
* Prepared geometries now also support the ``crosses``, ``disjoint``,
|
| 454 |
+
``overlaps``, ``touches`` and ``within`` predicates, if GEOS 3.3 or later is
|
| 455 |
+
installed.
|
| 456 |
+
|
| 457 |
+
:mod:`django.contrib.messages`
|
| 458 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 459 |
+
|
| 460 |
+
* The backends for :mod:`django.contrib.messages` that use cookies, will now
|
| 461 |
+
follow the :setting:`SESSION_COOKIE_SECURE` and
|
| 462 |
+
:setting:`SESSION_COOKIE_HTTPONLY` settings.
|
| 463 |
+
|
| 464 |
+
* The :ref:`messages context processor <message-displaying>` now adds a
|
| 465 |
+
dictionary of default levels under the name ``DEFAULT_MESSAGE_LEVELS``.
|
| 466 |
+
|
| 467 |
+
* :class:`~django.contrib.messages.storage.base.Message` objects now have a
|
| 468 |
+
``level_tag`` attribute that contains the string representation of the
|
| 469 |
+
message level.
|
| 470 |
+
|
| 471 |
+
:mod:`django.contrib.redirects`
|
| 472 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 473 |
+
|
| 474 |
+
* :class:`~django.contrib.redirects.middleware.RedirectFallbackMiddleware`
|
| 475 |
+
has two new attributes
|
| 476 |
+
(:attr:`~django.contrib.redirects.middleware.RedirectFallbackMiddleware.response_gone_class`
|
| 477 |
+
and
|
| 478 |
+
:attr:`~django.contrib.redirects.middleware.RedirectFallbackMiddleware.response_redirect_class`)
|
| 479 |
+
that specify the types of :class:`~django.http.HttpResponse` instances the
|
| 480 |
+
middleware returns.
|
| 481 |
+
|
| 482 |
+
:mod:`django.contrib.sessions`
|
| 483 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 484 |
+
|
| 485 |
+
* The ``"django.contrib.sessions.backends.cached_db"`` session backend now
|
| 486 |
+
respects :setting:`SESSION_CACHE_ALIAS`. In previous versions, it always used
|
| 487 |
+
the ``default`` cache.
|
| 488 |
+
|
| 489 |
+
:mod:`django.contrib.sitemaps`
|
| 490 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 491 |
+
|
| 492 |
+
* The :mod:`sitemap framework<django.contrib.sitemaps>` now makes use of
|
| 493 |
+
:attr:`~django.contrib.sitemaps.Sitemap.lastmod` to set a ``Last-Modified``
|
| 494 |
+
header in the response. This makes it possible for the
|
| 495 |
+
:class:`~django.middleware.http.ConditionalGetMiddleware` to handle
|
| 496 |
+
conditional ``GET`` requests for sitemaps which set ``lastmod``.
|
| 497 |
+
|
| 498 |
+
:mod:`django.contrib.sites`
|
| 499 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 500 |
+
|
| 501 |
+
* The new :class:`django.contrib.sites.middleware.CurrentSiteMiddleware` allows
|
| 502 |
+
setting the current site on each request.
|
| 503 |
+
|
| 504 |
+
:mod:`django.contrib.staticfiles`
|
| 505 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 506 |
+
|
| 507 |
+
* The :ref:`static files storage classes <staticfiles-storages>` may be
|
| 508 |
+
subclassed to override the permissions that collected static files and
|
| 509 |
+
directories receive by setting the
|
| 510 |
+
:attr:`~django.core.files.storage.FileSystemStorage.file_permissions_mode`
|
| 511 |
+
and :attr:`~django.core.files.storage.FileSystemStorage.directory_permissions_mode`
|
| 512 |
+
parameters. See :djadmin:`collectstatic` for example usage.
|
| 513 |
+
|
| 514 |
+
* The ``CachedStaticFilesStorage`` backend gets a sibling class called
|
| 515 |
+
:class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage`
|
| 516 |
+
that doesn't use the cache system at all but instead a JSON file called
|
| 517 |
+
``staticfiles.json`` for storing the mapping between the original file name
|
| 518 |
+
(e.g. ``css/styles.css``) and the hashed file name (e.g.
|
| 519 |
+
``css/styles.55e7cbb9ba48.css``). The ``staticfiles.json`` file is created
|
| 520 |
+
when running the :djadmin:`collectstatic` management command and should
|
| 521 |
+
be a less expensive alternative for remote storages such as Amazon S3.
|
| 522 |
+
|
| 523 |
+
See the :class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage`
|
| 524 |
+
docs for more information.
|
| 525 |
+
|
| 526 |
+
* :djadmin:`findstatic` now accepts verbosity flag level 2, meaning it will
|
| 527 |
+
show the relative paths of the directories it searched. See
|
| 528 |
+
:djadmin:`findstatic` for example output.
|
| 529 |
+
|
| 530 |
+
:mod:`django.contrib.syndication`
|
| 531 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 532 |
+
|
| 533 |
+
* The :class:`~django.utils.feedgenerator.Atom1Feed` syndication feed's
|
| 534 |
+
``updated`` element now utilizes ``updateddate`` instead of ``pubdate``,
|
| 535 |
+
allowing the ``published`` element to be included in the feed (which
|
| 536 |
+
relies on ``pubdate``).
|
| 537 |
+
|
| 538 |
+
Cache
|
| 539 |
+
~~~~~
|
| 540 |
+
|
| 541 |
+
* Access to caches configured in :setting:`CACHES` is now available via
|
| 542 |
+
:data:`django.core.cache.caches`. This dict-like object provides a different
|
| 543 |
+
instance per thread. It supersedes ``django.core.cache.get_cache()`` which
|
| 544 |
+
is now deprecated.
|
| 545 |
+
|
| 546 |
+
* If you instantiate cache backends directly, be aware that they aren't
|
| 547 |
+
thread-safe any more, as :data:`django.core.cache.caches` now yields
|
| 548 |
+
different instances per thread.
|
| 549 |
+
|
| 550 |
+
* Defining the :setting:`TIMEOUT <CACHES-TIMEOUT>` argument of the
|
| 551 |
+
:setting:`CACHES` setting as ``None`` will set the cache keys as
|
| 552 |
+
"non-expiring" by default. Previously, it was only possible to pass
|
| 553 |
+
``timeout=None`` to the cache backend's ``set()`` method.
|
| 554 |
+
|
| 555 |
+
Cross Site Request Forgery
|
| 556 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 557 |
+
|
| 558 |
+
* The :setting:`CSRF_COOKIE_AGE` setting facilitates the use of session-based
|
| 559 |
+
CSRF cookies.
|
| 560 |
+
|
| 561 |
+
Email
|
| 562 |
+
~~~~~
|
| 563 |
+
|
| 564 |
+
* :func:`~django.core.mail.send_mail` now accepts an ``html_message``
|
| 565 |
+
parameter for sending a multipart :mimetype:`text/plain` and
|
| 566 |
+
:mimetype:`text/html` email.
|
| 567 |
+
|
| 568 |
+
* The SMTP :class:`~django.core.mail.backends.smtp.EmailBackend` now accepts a
|
| 569 |
+
``timeout`` parameter.
|
| 570 |
+
|
| 571 |
+
File Storage
|
| 572 |
+
~~~~~~~~~~~~
|
| 573 |
+
|
| 574 |
+
* File locking on Windows previously depended on the PyWin32 package; if it
|
| 575 |
+
wasn't installed, file locking failed silently. That dependency has been
|
| 576 |
+
removed, and file locking is now implemented natively on both Windows
|
| 577 |
+
and Unix.
|
| 578 |
+
|
| 579 |
+
File Uploads
|
| 580 |
+
~~~~~~~~~~~~
|
| 581 |
+
|
| 582 |
+
* The new :attr:`UploadedFile.content_type_extra
|
| 583 |
+
<django.core.files.uploadedfile.UploadedFile.content_type_extra>` attribute
|
| 584 |
+
contains extra parameters passed to the ``content-type`` header on a file
|
| 585 |
+
upload.
|
| 586 |
+
|
| 587 |
+
* The new :setting:`FILE_UPLOAD_DIRECTORY_PERMISSIONS` setting controls
|
| 588 |
+
the file system permissions of directories created during file upload, like
|
| 589 |
+
:setting:`FILE_UPLOAD_PERMISSIONS` does for the files themselves.
|
| 590 |
+
|
| 591 |
+
* The :attr:`FileField.upload_to <django.db.models.FileField.upload_to>`
|
| 592 |
+
attribute is now optional. If it is omitted or given ``None`` or an empty
|
| 593 |
+
string, a subdirectory won't be used for storing the uploaded files.
|
| 594 |
+
|
| 595 |
+
* Uploaded files are now explicitly closed before the response is delivered to
|
| 596 |
+
the client. Partially uploaded files are also closed as long as they are
|
| 597 |
+
named ``file`` in the upload handler.
|
| 598 |
+
|
| 599 |
+
* :meth:`Storage.get_available_name()
|
| 600 |
+
<django.core.files.storage.Storage.get_available_name>` now appends an
|
| 601 |
+
underscore plus a random 7 character alphanumeric string (e.g.
|
| 602 |
+
``"_x3a1gho"``), rather than iterating through an underscore followed by a
|
| 603 |
+
number (e.g. ``"_1"``, ``"_2"``, etc.) to prevent a denial-of-service attack.
|
| 604 |
+
This change was also made in the 1.6.6, 1.5.9, and 1.4.14 security releases.
|
| 605 |
+
|
| 606 |
+
Forms
|
| 607 |
+
~~~~~
|
| 608 |
+
|
| 609 |
+
* The ``<label>`` and ``<input>`` tags rendered by
|
| 610 |
+
:class:`~django.forms.RadioSelect` and
|
| 611 |
+
:class:`~django.forms.CheckboxSelectMultiple` when looping over the radio
|
| 612 |
+
buttons or checkboxes now include ``for`` and ``id`` attributes, respectively.
|
| 613 |
+
Each radio button or checkbox includes an ``id_for_label`` attribute to
|
| 614 |
+
output the element's ID.
|
| 615 |
+
|
| 616 |
+
* The ``<textarea>`` tags rendered by :class:`~django.forms.Textarea` now
|
| 617 |
+
include a ``maxlength`` attribute if the :class:`~django.db.models.TextField`
|
| 618 |
+
model field has a ``max_length``.
|
| 619 |
+
|
| 620 |
+
* :attr:`Field.choices<django.db.models.Field.choices>` now allows you to
|
| 621 |
+
customize the "empty choice" label by including a tuple with an empty string
|
| 622 |
+
or ``None`` for the key and the custom label as the value. The default blank
|
| 623 |
+
option ``"----------"`` will be omitted in this case.
|
| 624 |
+
|
| 625 |
+
* :class:`~django.forms.MultiValueField` allows optional subfields by setting
|
| 626 |
+
the ``require_all_fields`` argument to ``False``. The ``required`` attribute
|
| 627 |
+
for each individual field will be respected, and a new ``incomplete``
|
| 628 |
+
validation error will be raised when any required fields are empty.
|
| 629 |
+
|
| 630 |
+
* The :meth:`~django.forms.Form.clean` method on a form no longer needs to
|
| 631 |
+
return ``self.cleaned_data``. If it does return a changed dictionary then
|
| 632 |
+
that will still be used.
|
| 633 |
+
|
| 634 |
+
* After a temporary regression in Django 1.6, it's now possible again to make
|
| 635 |
+
:class:`~django.forms.TypedChoiceField` ``coerce`` method return an arbitrary
|
| 636 |
+
value.
|
| 637 |
+
|
| 638 |
+
* :attr:`SelectDateWidget.months
|
| 639 |
+
<django.forms.SelectDateWidget.months>` can be used to
|
| 640 |
+
customize the wording of the months displayed in the select widget.
|
| 641 |
+
|
| 642 |
+
* The ``min_num`` and ``validate_min`` parameters were added to
|
| 643 |
+
:func:`~django.forms.formsets.formset_factory` to allow validating
|
| 644 |
+
a minimum number of submitted forms.
|
| 645 |
+
|
| 646 |
+
* The metaclasses used by ``Form`` and ``ModelForm`` have been reworked to
|
| 647 |
+
support more inheritance scenarios. The previous limitation that prevented
|
| 648 |
+
inheriting from both ``Form`` and ``ModelForm`` simultaneously have been
|
| 649 |
+
removed as long as ``ModelForm`` appears first in the MRO.
|
| 650 |
+
|
| 651 |
+
* It's now possible to remove a field from a ``Form`` when subclassing by
|
| 652 |
+
setting the name to ``None``.
|
| 653 |
+
|
| 654 |
+
* It's now possible to customize the error messages for ``ModelForm``’s
|
| 655 |
+
``unique``, ``unique_for_date``, and ``unique_together`` constraints.
|
| 656 |
+
In order to support ``unique_together`` or any other ``NON_FIELD_ERROR``,
|
| 657 |
+
``ModelForm`` now looks for the ``NON_FIELD_ERROR`` key in the
|
| 658 |
+
``error_messages`` dictionary of the ``ModelForm``’s inner ``Meta`` class.
|
| 659 |
+
See :ref:`considerations regarding model's error_messages
|
| 660 |
+
<considerations-regarding-model-errormessages>` for more details.
|
| 661 |
+
|
| 662 |
+
Internationalization
|
| 663 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 664 |
+
|
| 665 |
+
* The :attr:`django.middleware.locale.LocaleMiddleware.response_redirect_class`
|
| 666 |
+
attribute allows you to customize the redirects issued by the middleware.
|
| 667 |
+
|
| 668 |
+
* The :class:`~django.middleware.locale.LocaleMiddleware` now stores the user's
|
| 669 |
+
selected language with the session key ``_language``. This should only be
|
| 670 |
+
accessed using the ``LANGUAGE_SESSION_KEY`` constant. Previously it was
|
| 671 |
+
stored with the key ``django_language`` and the ``LANGUAGE_SESSION_KEY``
|
| 672 |
+
constant did not exist, but keys reserved for Django should start with an
|
| 673 |
+
underscore. For backwards compatibility ``django_language`` is still read
|
| 674 |
+
from in 1.7. Sessions will be migrated to the new key as they are written.
|
| 675 |
+
|
| 676 |
+
* The :ttag:`blocktrans` tag now supports a ``trimmed`` option. This
|
| 677 |
+
option will remove newline characters from the beginning and the end of the
|
| 678 |
+
content of the ``{% blocktrans %}`` tag, replace any whitespace at the
|
| 679 |
+
beginning and end of a line and merge all lines into one using a space
|
| 680 |
+
character to separate them. This is quite useful for indenting the content of
|
| 681 |
+
a ``{% blocktrans %}`` tag without having the indentation characters end up
|
| 682 |
+
in the corresponding entry in the ``.po`` file, which makes the translation
|
| 683 |
+
process easier.
|
| 684 |
+
|
| 685 |
+
* When you run :djadmin:`makemessages` from the root directory of your project,
|
| 686 |
+
any extracted strings will now be automatically distributed to the proper
|
| 687 |
+
app or project message file. See :ref:`how-to-create-language-files` for
|
| 688 |
+
details.
|
| 689 |
+
|
| 690 |
+
* The :djadmin:`makemessages` command now always adds the ``--previous``
|
| 691 |
+
command line flag to the ``msgmerge`` command, keeping previously translated
|
| 692 |
+
strings in ``.po`` files for fuzzy strings.
|
| 693 |
+
|
| 694 |
+
* The following settings to adjust the language cookie options were introduced:
|
| 695 |
+
:setting:`LANGUAGE_COOKIE_AGE`, :setting:`LANGUAGE_COOKIE_DOMAIN`
|
| 696 |
+
and :setting:`LANGUAGE_COOKIE_PATH`.
|
| 697 |
+
|
| 698 |
+
* Added :doc:`/topics/i18n/formatting` for Esperanto.
|
| 699 |
+
|
| 700 |
+
Management Commands
|
| 701 |
+
~~~~~~~~~~~~~~~~~~~
|
| 702 |
+
|
| 703 |
+
* The new :option:`--no-color` option for ``django-admin`` disables the
|
| 704 |
+
colorization of management command output.
|
| 705 |
+
|
| 706 |
+
* The new :option:`dumpdata --natural-foreign` and :option:`dumpdata
|
| 707 |
+
--natural-primary` options, and the new ``use_natural_foreign_keys`` and
|
| 708 |
+
``use_natural_primary_keys`` arguments for ``serializers.serialize()``, allow
|
| 709 |
+
the use of natural primary keys when serializing.
|
| 710 |
+
|
| 711 |
+
* It is no longer necessary to provide the cache table name or the
|
| 712 |
+
``--database`` option for the :djadmin:`createcachetable` command.
|
| 713 |
+
Django takes this information from your settings file. If you have configured
|
| 714 |
+
multiple caches or multiple databases, all cache tables are created.
|
| 715 |
+
|
| 716 |
+
* The :djadmin:`runserver` command received several improvements:
|
| 717 |
+
|
| 718 |
+
* On Linux systems, if :pypi:`pyinotify` is installed, the development server
|
| 719 |
+
will reload immediately when a file is changed. Previously, it polled the
|
| 720 |
+
filesystem for changes every second. That caused a small delay before
|
| 721 |
+
reloads and reduced battery life on laptops.
|
| 722 |
+
|
| 723 |
+
* In addition, the development server automatically reloads when a
|
| 724 |
+
translation file is updated, i.e. after running
|
| 725 |
+
:djadmin:`compilemessages`.
|
| 726 |
+
|
| 727 |
+
* All HTTP requests are logged to the console, including requests for static
|
| 728 |
+
files or ``favicon.ico`` that used to be filtered out.
|
| 729 |
+
|
| 730 |
+
* Management commands can now produce syntax colored output under Windows if
|
| 731 |
+
the ANSICON third-party tool is installed and active.
|
| 732 |
+
|
| 733 |
+
* :djadmin:`collectstatic` command with symlink option is now supported on
|
| 734 |
+
Windows NT 6 (Windows Vista and newer).
|
| 735 |
+
|
| 736 |
+
* Initial SQL data now works better if the :pypi:`sqlparse` Python library is
|
| 737 |
+
installed.
|
| 738 |
+
|
| 739 |
+
Note that it's deprecated in favor of the
|
| 740 |
+
:class:`~django.db.migrations.operations.RunSQL` operation of migrations,
|
| 741 |
+
which benefits from the improved behavior.
|
| 742 |
+
|
| 743 |
+
Models
|
| 744 |
+
~~~~~~
|
| 745 |
+
|
| 746 |
+
* The :meth:`QuerySet.update_or_create()
|
| 747 |
+
<django.db.models.query.QuerySet.update_or_create>` method was added.
|
| 748 |
+
|
| 749 |
+
* The new :attr:`~django.db.models.Options.default_permissions` model
|
| 750 |
+
``Meta`` option allows you to customize (or disable) creation of the default
|
| 751 |
+
add, change, and delete permissions.
|
| 752 |
+
|
| 753 |
+
* Explicit :class:`~django.db.models.OneToOneField` for
|
| 754 |
+
:ref:`multi-table-inheritance` are now discovered in abstract classes.
|
| 755 |
+
|
| 756 |
+
* It is now possible to avoid creating a backward relation for
|
| 757 |
+
:class:`~django.db.models.OneToOneField` by setting its
|
| 758 |
+
:attr:`~django.db.models.ForeignKey.related_name` to
|
| 759 |
+
``'+'`` or ending it with ``'+'``.
|
| 760 |
+
|
| 761 |
+
* :class:`F expressions <django.db.models.F>` support the power operator
|
| 762 |
+
(``**``).
|
| 763 |
+
|
| 764 |
+
* The ``remove()`` and ``clear()`` methods of the related managers created by
|
| 765 |
+
``ForeignKey`` and ``GenericForeignKey`` now accept the ``bulk`` keyword
|
| 766 |
+
argument to control whether or not to perform operations in bulk
|
| 767 |
+
(i.e. using ``QuerySet.update()``). Defaults to ``True``.
|
| 768 |
+
|
| 769 |
+
* It is now possible to use ``None`` as a query value for the :lookup:`iexact`
|
| 770 |
+
lookup.
|
| 771 |
+
|
| 772 |
+
* It is now possible to pass a callable as value for the attribute
|
| 773 |
+
:attr:`~django.db.models.ForeignKey.limit_choices_to` when defining a
|
| 774 |
+
``ForeignKey`` or ``ManyToManyField``.
|
| 775 |
+
|
| 776 |
+
* Calling :meth:`only() <django.db.models.query.QuerySet.only>` and
|
| 777 |
+
:meth:`defer() <django.db.models.query.QuerySet.defer>` on the result of
|
| 778 |
+
:meth:`QuerySet.values() <django.db.models.query.QuerySet.values>` now raises
|
| 779 |
+
an error (before that, it would either result in a database error or
|
| 780 |
+
incorrect data).
|
| 781 |
+
|
| 782 |
+
* You can use a single list for :attr:`~django.db.models.Options.index_together`
|
| 783 |
+
(rather than a list of lists) when specifying a single set of fields.
|
| 784 |
+
|
| 785 |
+
* Custom intermediate models having more than one foreign key to any of the
|
| 786 |
+
models participating in a many-to-many relationship are now permitted,
|
| 787 |
+
provided you explicitly specify which foreign keys should be used by setting
|
| 788 |
+
the new :attr:`ManyToManyField.through_fields <django.db.models.ManyToManyField.through_fields>`
|
| 789 |
+
argument.
|
| 790 |
+
|
| 791 |
+
* Assigning a model instance to a non-relation field will now throw an error.
|
| 792 |
+
Previously this used to work if the field accepted integers as input as it
|
| 793 |
+
took the primary key.
|
| 794 |
+
|
| 795 |
+
* Integer fields are now validated against database backend specific min and
|
| 796 |
+
max values based on their :meth:`internal_type <django.db.models.Field.get_internal_type>`.
|
| 797 |
+
Previously model field validation didn't prevent values out of their associated
|
| 798 |
+
column data type range from being saved resulting in an integrity error.
|
| 799 |
+
|
| 800 |
+
* It is now possible to explicitly :meth:`~django.db.models.query.QuerySet.order_by`
|
| 801 |
+
a relation ``_id`` field by using its attribute name.
|
| 802 |
+
|
| 803 |
+
Signals
|
| 804 |
+
~~~~~~~
|
| 805 |
+
|
| 806 |
+
* The ``enter`` argument was added to the
|
| 807 |
+
:data:`~django.test.signals.setting_changed` signal.
|
| 808 |
+
|
| 809 |
+
* The model signals can be now be connected to using a ``str`` of the
|
| 810 |
+
``'app_label.ModelName'`` form – just like related fields – to lazily
|
| 811 |
+
reference their senders.
|
| 812 |
+
|
| 813 |
+
Templates
|
| 814 |
+
~~~~~~~~~
|
| 815 |
+
|
| 816 |
+
* The :meth:`Context.push() <django.template.Context.push>` method now returns
|
| 817 |
+
a context manager which automatically calls :meth:`pop()
|
| 818 |
+
<django.template.Context.pop>` upon exiting the ``with`` statement.
|
| 819 |
+
Additionally, :meth:`push() <django.template.Context.push>` now accepts
|
| 820 |
+
parameters that are passed to the ``dict`` constructor used to build the new
|
| 821 |
+
context level.
|
| 822 |
+
|
| 823 |
+
* The new :meth:`Context.flatten() <django.template.Context.flatten>` method
|
| 824 |
+
returns a ``Context``'s stack as one flat dictionary.
|
| 825 |
+
|
| 826 |
+
* ``Context`` objects can now be compared for equality (internally, this
|
| 827 |
+
uses :meth:`Context.flatten() <django.template.Context.flatten>` so the
|
| 828 |
+
internal structure of each ``Context``'s stack doesn't matter as long as their
|
| 829 |
+
flattened version is identical).
|
| 830 |
+
|
| 831 |
+
* The :ttag:`widthratio` template tag now accepts an ``"as"`` parameter to
|
| 832 |
+
capture the result in a variable.
|
| 833 |
+
|
| 834 |
+
* The :ttag:`include` template tag will now also accept anything with a
|
| 835 |
+
``render()`` method (such as a ``Template``) as an argument. String
|
| 836 |
+
arguments will be looked up using
|
| 837 |
+
:func:`~django.template.loader.get_template` as always.
|
| 838 |
+
|
| 839 |
+
* It is now possible to :ttag:`include` templates recursively.
|
| 840 |
+
|
| 841 |
+
* Template objects now have an origin attribute set when
|
| 842 |
+
``TEMPLATE_DEBUG`` is ``True``. This allows template origins to be
|
| 843 |
+
inspected and logged outside of the ``django.template`` infrastructure.
|
| 844 |
+
|
| 845 |
+
* ``TypeError`` exceptions are no longer silenced when raised during the
|
| 846 |
+
rendering of a template.
|
| 847 |
+
|
| 848 |
+
* The following functions now accept a ``dirs`` parameter which is a list or
|
| 849 |
+
tuple to override ``TEMPLATE_DIRS``:
|
| 850 |
+
|
| 851 |
+
* :func:`django.template.loader.get_template()`
|
| 852 |
+
* :func:`django.template.loader.select_template()`
|
| 853 |
+
* :func:`django.shortcuts.render()`
|
| 854 |
+
* ``django.shortcuts.render_to_response()``
|
| 855 |
+
|
| 856 |
+
* The :tfilter:`time` filter now accepts timezone-related :ref:`format
|
| 857 |
+
specifiers <date-and-time-formatting-specifiers>` ``'e'``, ``'O'`` , ``'T'``
|
| 858 |
+
and ``'Z'`` and is able to digest :ref:`time-zone-aware
|
| 859 |
+
<naive_vs_aware_datetimes>` ``datetime`` instances performing the expected
|
| 860 |
+
rendering.
|
| 861 |
+
|
| 862 |
+
* The :ttag:`cache` tag will now try to use the cache called
|
| 863 |
+
"template_fragments" if it exists and fall back to using the default cache
|
| 864 |
+
otherwise. It also now accepts an optional ``using`` keyword argument to
|
| 865 |
+
control which cache it uses.
|
| 866 |
+
|
| 867 |
+
* The new :tfilter:`truncatechars_html` filter truncates a string to be no
|
| 868 |
+
longer than the specified number of characters, taking HTML into account.
|
| 869 |
+
|
| 870 |
+
Requests and Responses
|
| 871 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 872 |
+
|
| 873 |
+
* The new :attr:`HttpRequest.scheme <django.http.HttpRequest.scheme>` attribute
|
| 874 |
+
specifies the scheme of the request (``http`` or ``https`` normally).
|
| 875 |
+
|
| 876 |
+
|
| 877 |
+
* The shortcut :func:`redirect() <django.shortcuts.redirect>` now supports
|
| 878 |
+
relative URLs.
|
| 879 |
+
|
| 880 |
+
* The new :class:`~django.http.JsonResponse` subclass of
|
| 881 |
+
:class:`~django.http.HttpResponse` helps easily create JSON-encoded responses.
|
| 882 |
+
|
| 883 |
+
Tests
|
| 884 |
+
~~~~~
|
| 885 |
+
|
| 886 |
+
* :class:`~django.test.runner.DiscoverRunner` has two new attributes,
|
| 887 |
+
:attr:`~django.test.runner.DiscoverRunner.test_suite` and
|
| 888 |
+
:attr:`~django.test.runner.DiscoverRunner.test_runner`, which facilitate
|
| 889 |
+
overriding the way tests are collected and run.
|
| 890 |
+
|
| 891 |
+
* The ``fetch_redirect_response`` argument was added to
|
| 892 |
+
:meth:`~django.test.SimpleTestCase.assertRedirects`. Since the test
|
| 893 |
+
client can't fetch externals URLs, this allows you to use ``assertRedirects``
|
| 894 |
+
with redirects that aren't part of your Django app.
|
| 895 |
+
|
| 896 |
+
* Correct handling of scheme when making comparisons in
|
| 897 |
+
:meth:`~django.test.SimpleTestCase.assertRedirects`.
|
| 898 |
+
|
| 899 |
+
* The ``secure`` argument was added to all the request methods of
|
| 900 |
+
:class:`~django.test.Client`. If ``True``, the request will be made
|
| 901 |
+
through HTTPS.
|
| 902 |
+
|
| 903 |
+
* :meth:`~django.test.TransactionTestCase.assertNumQueries` now prints
|
| 904 |
+
out the list of executed queries if the assertion fails.
|
| 905 |
+
|
| 906 |
+
* The ``WSGIRequest`` instance generated by the test handler is now attached to
|
| 907 |
+
the :attr:`django.test.Response.wsgi_request` attribute.
|
| 908 |
+
|
| 909 |
+
* The database settings for testing have been collected into a dictionary
|
| 910 |
+
named :setting:`TEST <DATABASE-TEST>`.
|
| 911 |
+
|
| 912 |
+
Utilities
|
| 913 |
+
~~~~~~~~~
|
| 914 |
+
|
| 915 |
+
* Improved :func:`~django.utils.html.strip_tags` accuracy (but it still cannot
|
| 916 |
+
guarantee an HTML-safe result, as stated in the documentation).
|
| 917 |
+
|
| 918 |
+
Validators
|
| 919 |
+
~~~~~~~~~~
|
| 920 |
+
|
| 921 |
+
* :class:`~django.core.validators.RegexValidator` now accepts the optional
|
| 922 |
+
:attr:`~django.core.validators.RegexValidator.flags` and
|
| 923 |
+
Boolean :attr:`~django.core.validators.RegexValidator.inverse_match` arguments.
|
| 924 |
+
The :attr:`~django.core.validators.RegexValidator.inverse_match` attribute
|
| 925 |
+
determines if the :exc:`~django.core.exceptions.ValidationError` should
|
| 926 |
+
be raised when the regular expression pattern matches (``True``) or does not
|
| 927 |
+
match (``False``, by default) the provided ``value``. The
|
| 928 |
+
:attr:`~django.core.validators.RegexValidator.flags` attribute sets the flags
|
| 929 |
+
used when compiling a regular expression string.
|
| 930 |
+
|
| 931 |
+
* :class:`~django.core.validators.URLValidator` now accepts an optional
|
| 932 |
+
``schemes`` argument which allows customization of the accepted URI schemes
|
| 933 |
+
(instead of the defaults ``http(s)`` and ``ftp(s)``).
|
| 934 |
+
|
| 935 |
+
* :func:`~django.core.validators.validate_email` now accepts addresses with
|
| 936 |
+
IPv6 literals, like ``example@[2001:db8::1]``, as specified in RFC 5321.
|
| 937 |
+
|
| 938 |
+
.. _backwards-incompatible-1.7:
|
| 939 |
+
|
| 940 |
+
Backwards incompatible changes in 1.7
|
| 941 |
+
=====================================
|
| 942 |
+
|
| 943 |
+
.. warning::
|
| 944 |
+
|
| 945 |
+
In addition to the changes outlined in this section, be sure to review the
|
| 946 |
+
:ref:`deprecation plan <deprecation-removed-in-1.7>` for any features that
|
| 947 |
+
have been removed. If you haven't updated your code within the
|
| 948 |
+
deprecation timeline for a given feature, its removal may appear as a
|
| 949 |
+
backwards incompatible change.
|
| 950 |
+
|
| 951 |
+
``allow_syncdb`` / ``allow_migrate``
|
| 952 |
+
------------------------------------
|
| 953 |
+
|
| 954 |
+
While Django will still look at ``allow_syncdb`` methods even though they
|
| 955 |
+
should be renamed to ``allow_migrate``, there is a subtle difference in which
|
| 956 |
+
models get passed to these methods.
|
| 957 |
+
|
| 958 |
+
For apps with migrations, ``allow_migrate`` will now get passed
|
| 959 |
+
:ref:`historical models <historical-models>`, which are special versioned models
|
| 960 |
+
without custom attributes, methods or managers. Make sure your ``allow_migrate``
|
| 961 |
+
methods are only referring to fields or other items in ``model._meta``.
|
| 962 |
+
|
| 963 |
+
initial_data
|
| 964 |
+
------------
|
| 965 |
+
|
| 966 |
+
Apps with migrations will not load ``initial_data`` fixtures when they have
|
| 967 |
+
finished migrating. Apps without migrations will continue to load these fixtures
|
| 968 |
+
during the phase of ``migrate`` which emulates the old ``syncdb`` behavior,
|
| 969 |
+
but any new apps will not have this support.
|
| 970 |
+
|
| 971 |
+
Instead, you are encouraged to load initial data in migrations if you need it
|
| 972 |
+
(using the ``RunPython`` operation and your model classes);
|
| 973 |
+
this has the added advantage that your initial data will not need updating
|
| 974 |
+
every time you change the schema.
|
| 975 |
+
|
| 976 |
+
Additionally, like the rest of Django's old ``syncdb`` code, ``initial_data``
|
| 977 |
+
has been started down the deprecation path and will be removed in Django 1.9.
|
| 978 |
+
|
| 979 |
+
``deconstruct()`` and serializability
|
| 980 |
+
-------------------------------------
|
| 981 |
+
|
| 982 |
+
Django now requires all Field classes and all of their constructor arguments
|
| 983 |
+
to be serializable. If you modify the constructor signature in your custom
|
| 984 |
+
Field in any way, you'll need to implement a ``deconstruct()`` method;
|
| 985 |
+
we've expanded the custom field documentation with :ref:`instructions
|
| 986 |
+
on implementing this method <custom-field-deconstruct-method>`.
|
| 987 |
+
|
| 988 |
+
The requirement for all field arguments to be
|
| 989 |
+
:ref:`serializable <migration-serializing>` means that any custom class
|
| 990 |
+
instances being passed into Field constructors - things like custom Storage
|
| 991 |
+
subclasses, for instance - need to have a :ref:`deconstruct method defined on
|
| 992 |
+
them as well <custom-deconstruct-method>`, though Django provides a handy
|
| 993 |
+
class decorator that will work for most applications.
|
| 994 |
+
|
| 995 |
+
App-loading changes
|
| 996 |
+
-------------------
|
| 997 |
+
|
| 998 |
+
Start-up sequence
|
| 999 |
+
~~~~~~~~~~~~~~~~~
|
| 1000 |
+
|
| 1001 |
+
Django 1.7 loads application configurations and models as soon as it starts.
|
| 1002 |
+
While this behavior is more straightforward and is believed to be more robust,
|
| 1003 |
+
regressions cannot be ruled out. See :ref:`applications-troubleshooting` for
|
| 1004 |
+
solutions to some problems you may encounter.
|
| 1005 |
+
|
| 1006 |
+
Standalone scripts
|
| 1007 |
+
~~~~~~~~~~~~~~~~~~
|
| 1008 |
+
|
| 1009 |
+
If you're using Django in a plain Python script — rather than a management
|
| 1010 |
+
command — and you rely on the :envvar:`DJANGO_SETTINGS_MODULE` environment
|
| 1011 |
+
variable, you must now explicitly initialize Django at the beginning of your
|
| 1012 |
+
script with:
|
| 1013 |
+
|
| 1014 |
+
.. code-block:: pycon
|
| 1015 |
+
|
| 1016 |
+
>>> import django
|
| 1017 |
+
>>> django.setup()
|
| 1018 |
+
|
| 1019 |
+
Otherwise, you will hit an ``AppRegistryNotReady`` exception.
|
| 1020 |
+
|
| 1021 |
+
WSGI scripts
|
| 1022 |
+
~~~~~~~~~~~~
|
| 1023 |
+
|
| 1024 |
+
Until Django 1.3, the recommended way to create a WSGI application was::
|
| 1025 |
+
|
| 1026 |
+
import django.core.handlers.wsgi
|
| 1027 |
+
|
| 1028 |
+
application = django.core.handlers.wsgi.WSGIHandler()
|
| 1029 |
+
|
| 1030 |
+
In Django 1.4, support for WSGI was improved and the API changed to::
|
| 1031 |
+
|
| 1032 |
+
from django.core.wsgi import get_wsgi_application
|
| 1033 |
+
|
| 1034 |
+
application = get_wsgi_application()
|
| 1035 |
+
|
| 1036 |
+
If you're still using the former style in your WSGI script, you need to
|
| 1037 |
+
upgrade to the latter, or you will hit an ``AppRegistryNotReady`` exception.
|
| 1038 |
+
|
| 1039 |
+
App registry consistency
|
| 1040 |
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
| 1041 |
+
|
| 1042 |
+
It is no longer possible to have multiple installed applications with the same
|
| 1043 |
+
label. In previous versions of Django, this didn't always work correctly, but
|
| 1044 |
+
didn't crash outright either.
|
| 1045 |
+
|
| 1046 |
+
If you have two apps with the same label, you should create an
|
| 1047 |
+
:class:`~django.apps.AppConfig` for one of them and override its
|
| 1048 |
+
:class:`~django.apps.AppConfig.label` there. You should then adjust your code
|
| 1049 |
+
wherever it references this application or its models with the old label.
|
| 1050 |
+
|
| 1051 |
+
It isn't possible to import the same model twice through different paths any
|
| 1052 |
+
more. As of Django 1.6, this may happen only if you're manually putting a
|
| 1053 |
+
directory and a subdirectory on :envvar:`PYTHONPATH`. Refer to the section on
|
| 1054 |
+
the new project layout in the :doc:`1.4 release notes </releases/1.4>` for
|
| 1055 |
+
migration instructions.
|
| 1056 |
+
|
| 1057 |
+
You should make sure that:
|
| 1058 |
+
|
| 1059 |
+
* All models are defined in applications that are listed in
|
| 1060 |
+
:setting:`INSTALLED_APPS` or have an explicit
|
| 1061 |
+
:attr:`~django.db.models.Options.app_label`.
|
| 1062 |
+
|
| 1063 |
+
* Models aren't imported as a side-effect of loading their application.
|
| 1064 |
+
Specifically, you shouldn't import models in the root module of an
|
| 1065 |
+
application nor in the module that define its configuration class.
|
| 1066 |
+
|
| 1067 |
+
Django will enforce these requirements as of version 1.9, after a deprecation
|
| 1068 |
+
period.
|
| 1069 |
+
|
| 1070 |
+
Subclassing AppCommand
|
| 1071 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 1072 |
+
|
| 1073 |
+
Subclasses of :class:`~django.core.management.AppCommand` must now implement a
|
| 1074 |
+
:meth:`~django.core.management.AppCommand.handle_app_config` method instead of
|
| 1075 |
+
``handle_app()``. This method receives an :class:`~django.apps.AppConfig`
|
| 1076 |
+
instance instead of a models module.
|
| 1077 |
+
|
| 1078 |
+
Introspecting applications
|
| 1079 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 1080 |
+
|
| 1081 |
+
Since :setting:`INSTALLED_APPS` now supports application configuration classes
|
| 1082 |
+
in addition to application modules, you should review code that accesses this
|
| 1083 |
+
setting directly and use the app registry (:attr:`django.apps.apps`) instead.
|
| 1084 |
+
|
| 1085 |
+
The app registry has preserved some features of the old app cache. Even though
|
| 1086 |
+
the app cache was a private API, obsolete methods and arguments will be
|
| 1087 |
+
removed through a standard deprecation path, with the exception of the
|
| 1088 |
+
following changes that take effect immediately:
|
| 1089 |
+
|
| 1090 |
+
* ``get_model`` raises :exc:`LookupError` instead of returning ``None`` when no
|
| 1091 |
+
model is found.
|
| 1092 |
+
|
| 1093 |
+
* The ``only_installed`` argument of ``get_model`` and ``get_models`` no
|
| 1094 |
+
longer exists, nor does the ``seed_cache`` argument of ``get_model``.
|
| 1095 |
+
|
| 1096 |
+
Management commands and order of :setting:`INSTALLED_APPS`
|
| 1097 |
+
----------------------------------------------------------
|
| 1098 |
+
|
| 1099 |
+
When several applications provide management commands with the same name,
|
| 1100 |
+
Django loads the command from the application that comes first in
|
| 1101 |
+
:setting:`INSTALLED_APPS`. Previous versions loaded the command from the
|
| 1102 |
+
application that came last.
|
| 1103 |
+
|
| 1104 |
+
This brings discovery of management commands in line with other parts of
|
| 1105 |
+
Django that rely on the order of :setting:`INSTALLED_APPS`, such as static
|
| 1106 |
+
files, templates, and translations.
|
| 1107 |
+
|
| 1108 |
+
.. _validation-error-constructor-and-internal-storage:
|
| 1109 |
+
|
| 1110 |
+
``ValidationError`` constructor and internal storage
|
| 1111 |
+
----------------------------------------------------
|
| 1112 |
+
|
| 1113 |
+
The behavior of the ``ValidationError`` constructor has changed when it
|
| 1114 |
+
receives a container of errors as an argument (e.g. a ``list`` or an
|
| 1115 |
+
``ErrorList``):
|
| 1116 |
+
|
| 1117 |
+
* It converts any strings it finds to instances of ``ValidationError``
|
| 1118 |
+
before adding them to its internal storage.
|
| 1119 |
+
|
| 1120 |
+
* It doesn't store the given container but rather copies its content to its
|
| 1121 |
+
own internal storage; previously the container itself was added to the
|
| 1122 |
+
``ValidationError`` instance and used as internal storage.
|
| 1123 |
+
|
| 1124 |
+
This means that if you access the ``ValidationError`` internal storages, such
|
| 1125 |
+
as ``error_list``; ``error_dict``; or the return value of
|
| 1126 |
+
``update_error_dict()`` you may find instances of ``ValidationError`` where you
|
| 1127 |
+
would have previously found strings.
|
| 1128 |
+
|
| 1129 |
+
Also if you directly assigned the return value of ``update_error_dict()``
|
| 1130 |
+
to ``Form._errors`` you may inadvertently add ``list`` instances where
|
| 1131 |
+
``ErrorList`` instances are expected. This is a problem because unlike a
|
| 1132 |
+
simple ``list``, an ``ErrorList`` knows how to handle instances of
|
| 1133 |
+
``ValidationError``.
|
| 1134 |
+
|
| 1135 |
+
Most use-cases that warranted using these private APIs are now covered by
|
| 1136 |
+
the newly introduced :meth:`Form.add_error() <django.forms.Form.add_error()>`
|
| 1137 |
+
method::
|
| 1138 |
+
|
| 1139 |
+
# Old pattern:
|
| 1140 |
+
try:
|
| 1141 |
+
...
|
| 1142 |
+
except ValidationError as e:
|
| 1143 |
+
self._errors = e.update_error_dict(self._errors)
|
| 1144 |
+
|
| 1145 |
+
# New pattern:
|
| 1146 |
+
try:
|
| 1147 |
+
...
|
| 1148 |
+
except ValidationError as e:
|
| 1149 |
+
self.add_error(None, e)
|
| 1150 |
+
|
| 1151 |
+
If you need both Django <= 1.6 and 1.7 compatibility you can't use
|
| 1152 |
+
:meth:`Form.add_error() <django.forms.Form.add_error()>` since it
|
| 1153 |
+
wasn't available before Django 1.7, but you can use the following
|
| 1154 |
+
workaround to convert any ``list`` into ``ErrorList``::
|
| 1155 |
+
|
| 1156 |
+
try:
|
| 1157 |
+
...
|
| 1158 |
+
except ValidationError as e:
|
| 1159 |
+
self._errors = e.update_error_dict(self._errors)
|
| 1160 |
+
|
| 1161 |
+
# Additional code to ensure ``ErrorDict`` is exclusively
|
| 1162 |
+
# composed of ``ErrorList`` instances.
|
| 1163 |
+
for field, error_list in self._errors.items():
|
| 1164 |
+
if not isinstance(error_list, self.error_class):
|
| 1165 |
+
self._errors[field] = self.error_class(error_list)
|
| 1166 |
+
|
| 1167 |
+
Behavior of ``LocMemCache`` regarding pickle errors
|
| 1168 |
+
---------------------------------------------------
|
| 1169 |
+
|
| 1170 |
+
An inconsistency existed in previous versions of Django regarding how pickle
|
| 1171 |
+
errors are handled by different cache backends.
|
| 1172 |
+
``django.core.cache.backends.locmem.LocMemCache`` used to fail silently when
|
| 1173 |
+
such an error occurs, which is inconsistent with other backends and leads to
|
| 1174 |
+
cache-specific errors. This has been fixed in Django 1.7, see
|
| 1175 |
+
:ticket:`21200` for more details.
|
| 1176 |
+
|
| 1177 |
+
Cache keys are now generated from the request's absolute URL
|
| 1178 |
+
------------------------------------------------------------
|
| 1179 |
+
|
| 1180 |
+
Previous versions of Django generated cache keys using a request's path and
|
| 1181 |
+
query string but not the scheme or host. If a Django application was serving
|
| 1182 |
+
multiple subdomains or domains, cache keys could collide. In Django 1.7, cache
|
| 1183 |
+
keys vary by the absolute URL of the request including scheme, host, path, and
|
| 1184 |
+
query string. For example, the URL portion of a cache key is now generated from
|
| 1185 |
+
``https://www.example.com/path/to/?key=val`` rather than ``/path/to/?key=val``.
|
| 1186 |
+
The cache keys generated by Django 1.7 will be different from the keys
|
| 1187 |
+
generated by older versions of Django. After upgrading to Django 1.7, the first
|
| 1188 |
+
request to any previously cached URL will be a cache miss.
|
| 1189 |
+
|
| 1190 |
+
Passing ``None`` to ``Manager.db_manager()``
|
| 1191 |
+
--------------------------------------------
|
| 1192 |
+
|
| 1193 |
+
In previous versions of Django, it was possible to use
|
| 1194 |
+
``db_manager(using=None)`` on a model manager instance to obtain a manager
|
| 1195 |
+
instance using default routing behavior, overriding any manually specified
|
| 1196 |
+
database routing. In Django 1.7, a value of ``None`` passed to db_manager will
|
| 1197 |
+
produce a router that *retains* any manually assigned database routing -- the
|
| 1198 |
+
manager will *not* be reset. This was necessary to resolve an inconsistency in
|
| 1199 |
+
the way routing information cascaded over joins. See :ticket:`13724` for more
|
| 1200 |
+
details.
|
| 1201 |
+
|
| 1202 |
+
``pytz`` may be required
|
| 1203 |
+
------------------------
|
| 1204 |
+
|
| 1205 |
+
If your project handles datetimes before 1970 or after 2037 and Django raises
|
| 1206 |
+
a :exc:`ValueError` when encountering them, you will have to install
|
| 1207 |
+
:pypi:`pytz`. You may be affected by this problem if you use Django's time
|
| 1208 |
+
zone-related date formats or :mod:`django.contrib.syndication`.
|
| 1209 |
+
|
| 1210 |
+
``remove()`` and ``clear()`` methods of related managers
|
| 1211 |
+
--------------------------------------------------------
|
| 1212 |
+
|
| 1213 |
+
The ``remove()`` and ``clear()`` methods of the related managers created by
|
| 1214 |
+
``ForeignKey``, ``GenericForeignKey``, and ``ManyToManyField`` suffered from a
|
| 1215 |
+
number of issues. Some operations ran multiple data modifying queries without
|
| 1216 |
+
wrapping them in a transaction, and some operations didn't respect default
|
| 1217 |
+
filtering when it was present (i.e. when the default manager on the related
|
| 1218 |
+
model implemented a custom ``get_queryset()``).
|
| 1219 |
+
|
| 1220 |
+
Fixing the issues introduced some backward incompatible changes:
|
| 1221 |
+
|
| 1222 |
+
- The default implementation of ``remove()`` for ``ForeignKey`` related managers
|
| 1223 |
+
changed from a series of ``Model.save()`` calls to a single
|
| 1224 |
+
``QuerySet.update()`` call. The change means that ``pre_save`` and
|
| 1225 |
+
``post_save`` signals aren't sent anymore. You can use the ``bulk=False``
|
| 1226 |
+
keyword argument to revert to the previous behavior.
|
| 1227 |
+
|
| 1228 |
+
- The ``remove()`` and ``clear()`` methods for ``GenericForeignKey`` related
|
| 1229 |
+
managers now perform bulk delete. The ``Model.delete()`` method isn't called
|
| 1230 |
+
on each instance anymore. You can use the ``bulk=False`` keyword argument to
|
| 1231 |
+
revert to the previous behavior.
|
| 1232 |
+
|
| 1233 |
+
- The ``remove()`` and ``clear()`` methods for ``ManyToManyField`` related
|
| 1234 |
+
managers perform nested queries when filtering is involved, which may or
|
| 1235 |
+
may not be an issue depending on your database and your data itself.
|
| 1236 |
+
See :ref:`this note <nested-queries-performance>` for more details.
|
| 1237 |
+
|
| 1238 |
+
Admin login redirection strategy
|
| 1239 |
+
--------------------------------
|
| 1240 |
+
|
| 1241 |
+
Historically, the Django admin site passed the request from an unauthorized or
|
| 1242 |
+
unauthenticated user directly to the login view, without HTTP redirection. In
|
| 1243 |
+
Django 1.7, this behavior changed to conform to a more traditional workflow
|
| 1244 |
+
where any unauthorized request to an admin page will be redirected (by HTTP
|
| 1245 |
+
status code 302) to the login page, with the ``next`` parameter set to the
|
| 1246 |
+
referring path. The user will be redirected there after a successful login.
|
| 1247 |
+
|
| 1248 |
+
Note also that the admin login form has been updated to not contain the
|
| 1249 |
+
``this_is_the_login_form`` field (now unused) and the ``ValidationError`` code
|
| 1250 |
+
has been set to the more regular ``invalid_login`` key.
|
| 1251 |
+
|
| 1252 |
+
``select_for_update()`` requires a transaction
|
| 1253 |
+
----------------------------------------------
|
| 1254 |
+
|
| 1255 |
+
Historically, queries that use
|
| 1256 |
+
:meth:`~django.db.models.query.QuerySet.select_for_update()` could be
|
| 1257 |
+
executed in autocommit mode, outside of a transaction. Before Django
|
| 1258 |
+
1.6, Django's automatic transactions mode allowed this to be used to
|
| 1259 |
+
lock records until the next write operation. Django 1.6 introduced
|
| 1260 |
+
database-level autocommit; since then, execution in such a context
|
| 1261 |
+
voids the effect of ``select_for_update()``. It is, therefore, assumed
|
| 1262 |
+
now to be an error and raises an exception.
|
| 1263 |
+
|
| 1264 |
+
This change was made because such errors can be caused by including an
|
| 1265 |
+
app which expects global transactions (e.g. :setting:`ATOMIC_REQUESTS
|
| 1266 |
+
<DATABASE-ATOMIC_REQUESTS>` set to ``True``), or Django's old autocommit
|
| 1267 |
+
behavior, in a project which runs without them; and further, such
|
| 1268 |
+
errors may manifest as data-corruption bugs. It was also made in
|
| 1269 |
+
Django 1.6.3.
|
| 1270 |
+
|
| 1271 |
+
This change may cause test failures if you use ``select_for_update()``
|
| 1272 |
+
in a test class which is a subclass of
|
| 1273 |
+
:class:`~django.test.TransactionTestCase` rather than
|
| 1274 |
+
:class:`~django.test.TestCase`.
|
| 1275 |
+
|
| 1276 |
+
Contrib middleware removed from default ``MIDDLEWARE_CLASSES``
|
| 1277 |
+
--------------------------------------------------------------
|
| 1278 |
+
|
| 1279 |
+
The :ref:`app-loading refactor <app-loading-refactor-17-release-note>`
|
| 1280 |
+
deprecated using models from apps which are not part of the
|
| 1281 |
+
:setting:`INSTALLED_APPS` setting. This exposed an incompatibility between
|
| 1282 |
+
the default :setting:`INSTALLED_APPS` and ``MIDDLEWARE_CLASSES`` in the
|
| 1283 |
+
global defaults (``django.conf.global_settings``). To bring these settings in
|
| 1284 |
+
sync and prevent deprecation warnings when doing things like testing reusable
|
| 1285 |
+
apps with minimal settings,
|
| 1286 |
+
:class:`~django.contrib.sessions.middleware.SessionMiddleware`,
|
| 1287 |
+
:class:`~django.contrib.auth.middleware.AuthenticationMiddleware`, and
|
| 1288 |
+
:class:`~django.contrib.messages.middleware.MessageMiddleware` were removed
|
| 1289 |
+
from the defaults. These classes will still be included in the default settings
|
| 1290 |
+
generated by :djadmin:`startproject`. Most projects will not be affected by
|
| 1291 |
+
this change but if you were not previously declaring the
|
| 1292 |
+
``MIDDLEWARE_CLASSES`` in your project settings and relying on the
|
| 1293 |
+
global default you should ensure that the new defaults are in line with your
|
| 1294 |
+
project's needs. You should also check for any code that accesses
|
| 1295 |
+
``django.conf.global_settings.MIDDLEWARE_CLASSES`` directly.
|
| 1296 |
+
|
| 1297 |
+
Miscellaneous
|
| 1298 |
+
-------------
|
| 1299 |
+
|
| 1300 |
+
* The :meth:`django.core.files.uploadhandler.FileUploadHandler.new_file()`
|
| 1301 |
+
method is now passed an additional ``content_type_extra`` parameter. If you
|
| 1302 |
+
have a custom :class:`~django.core.files.uploadhandler.FileUploadHandler`
|
| 1303 |
+
that implements ``new_file()``, be sure it accepts this new parameter.
|
| 1304 |
+
|
| 1305 |
+
* :class:`ModelFormSet<django.forms.models.BaseModelFormSet>`\s no longer
|
| 1306 |
+
delete instances when ``save(commit=False)`` is called. See
|
| 1307 |
+
:attr:`~django.forms.formsets.BaseFormSet.can_delete` for instructions on how
|
| 1308 |
+
to manually delete objects from deleted forms.
|
| 1309 |
+
|
| 1310 |
+
* Loading empty fixtures emits a ``RuntimeWarning`` rather than raising
|
| 1311 |
+
:exc:`~django.core.management.CommandError`.
|
| 1312 |
+
|
| 1313 |
+
* :func:`django.contrib.staticfiles.views.serve` will now raise an
|
| 1314 |
+
:exc:`~django.http.Http404` exception instead of
|
| 1315 |
+
:exc:`~django.core.exceptions.ImproperlyConfigured` when :setting:`DEBUG`
|
| 1316 |
+
is ``False``. This change removes the need to conditionally add the view to
|
| 1317 |
+
your root URLconf, which in turn makes it safe to reverse by name. It also
|
| 1318 |
+
removes the ability for visitors to generate spurious HTTP 500 errors by
|
| 1319 |
+
requesting static files that don't exist or haven't been collected yet.
|
| 1320 |
+
|
| 1321 |
+
* The :meth:`django.db.models.Model.__eq__` method is now defined in a
|
| 1322 |
+
way where instances of a proxy model and its base model are considered
|
| 1323 |
+
equal when primary keys match. Previously only instances of exact same
|
| 1324 |
+
class were considered equal on primary key match.
|
| 1325 |
+
|
| 1326 |
+
* The :meth:`django.db.models.Model.__eq__` method has changed such that
|
| 1327 |
+
two ``Model`` instances without primary key values won't be considered
|
| 1328 |
+
equal (unless they are the same instance).
|
| 1329 |
+
|
| 1330 |
+
* The :meth:`django.db.models.Model.__hash__` method will now raise ``TypeError``
|
| 1331 |
+
when called on an instance without a primary key value. This is done to
|
| 1332 |
+
avoid mutable ``__hash__`` values in containers.
|
| 1333 |
+
|
| 1334 |
+
* :class:`~django.db.models.AutoField` columns in SQLite databases will now be
|
| 1335 |
+
created using the ``AUTOINCREMENT`` option, which guarantees monotonic
|
| 1336 |
+
increments. This will cause primary key numbering behavior to change on
|
| 1337 |
+
SQLite, becoming consistent with most other SQL databases. This will only
|
| 1338 |
+
apply to newly created tables. If you have a database created with an older
|
| 1339 |
+
version of Django, you will need to migrate it to take advantage of this
|
| 1340 |
+
feature. For example, you could do the following:
|
| 1341 |
+
|
| 1342 |
+
#) Use :djadmin:`dumpdata` to save your data.
|
| 1343 |
+
#) Rename the existing database file (keep it as a backup).
|
| 1344 |
+
#) Run :djadmin:`migrate` to create the updated schema.
|
| 1345 |
+
#) Use :djadmin:`loaddata` to import the fixtures you exported in (1).
|
| 1346 |
+
|
| 1347 |
+
* ``django.contrib.auth.models.AbstractUser`` no longer defines a
|
| 1348 |
+
:meth:`~django.db.models.Model.get_absolute_url()` method. The old definition
|
| 1349 |
+
returned ``"/users/%s/" % urlquote(self.username)`` which was arbitrary
|
| 1350 |
+
since applications may or may not define such a url in ``urlpatterns``.
|
| 1351 |
+
Define a ``get_absolute_url()`` method on your own custom user object or use
|
| 1352 |
+
:setting:`ABSOLUTE_URL_OVERRIDES` if you want a URL for your user.
|
| 1353 |
+
|
| 1354 |
+
* The static asset-serving functionality of the
|
| 1355 |
+
:class:`django.test.LiveServerTestCase` class has been simplified: Now it's
|
| 1356 |
+
only able to serve content already present in :setting:`STATIC_ROOT` when
|
| 1357 |
+
tests are run. The ability to transparently serve all the static assets
|
| 1358 |
+
(similarly to what one gets with :setting:`DEBUG = True <DEBUG>` at
|
| 1359 |
+
development-time) has been moved to a new class that lives in the
|
| 1360 |
+
``staticfiles`` application (the one actually in charge of such feature):
|
| 1361 |
+
:class:`django.contrib.staticfiles.testing.StaticLiveServerTestCase`. In other
|
| 1362 |
+
words, ``LiveServerTestCase`` itself is less powerful but at the same time
|
| 1363 |
+
has less magic.
|
| 1364 |
+
|
| 1365 |
+
Rationale behind this is removal of dependency of non-contrib code on
|
| 1366 |
+
contrib applications.
|
| 1367 |
+
|
| 1368 |
+
* The old cache URI syntax (e.g. ``"locmem://"``) is no longer supported. It
|
| 1369 |
+
still worked, even though it was not documented or officially supported. If
|
| 1370 |
+
you're still using it, please update to the current :setting:`CACHES` syntax.
|
| 1371 |
+
|
| 1372 |
+
* The default ordering of ``Form`` fields in case of inheritance has changed to
|
| 1373 |
+
follow normal Python MRO. Fields are now discovered by iterating through the
|
| 1374 |
+
MRO in reverse with the topmost class coming last. This only affects you if
|
| 1375 |
+
you relied on the default field ordering while having fields defined on both
|
| 1376 |
+
the current class *and* on a parent ``Form``.
|
| 1377 |
+
|
| 1378 |
+
* The ``required`` argument of
|
| 1379 |
+
:class:`~django.forms.SelectDateWidget` has been removed.
|
| 1380 |
+
This widget now respects the form field's ``is_required`` attribute like
|
| 1381 |
+
other widgets.
|
| 1382 |
+
|
| 1383 |
+
* ``Widget.is_hidden`` is now a read-only property, getting its value by
|
| 1384 |
+
introspecting the presence of ``input_type == 'hidden'``.
|
| 1385 |
+
|
| 1386 |
+
* :meth:`~django.db.models.query.QuerySet.select_related` now chains in the
|
| 1387 |
+
same way as other similar calls like ``prefetch_related``. That is,
|
| 1388 |
+
``select_related('foo', 'bar')`` is equivalent to
|
| 1389 |
+
``select_related('foo').select_related('bar')``. Previously the latter would
|
| 1390 |
+
have been equivalent to ``select_related('bar')``.
|
| 1391 |
+
|
| 1392 |
+
* GeoDjango dropped support for GEOS < 3.1.
|
| 1393 |
+
|
| 1394 |
+
* The ``init_connection_state`` method of database backends now executes in
|
| 1395 |
+
autocommit mode (unless you set :setting:`AUTOCOMMIT <DATABASE-AUTOCOMMIT>`
|
| 1396 |
+
to ``False``). If you maintain a custom database backend, you should check
|
| 1397 |
+
that method.
|
| 1398 |
+
|
| 1399 |
+
* The ``django.db.backends.BaseDatabaseFeatures.allows_primary_key_0``
|
| 1400 |
+
attribute has been renamed to ``allows_auto_pk_0`` to better describe it.
|
| 1401 |
+
It's ``True`` for all database backends included with Django except MySQL
|
| 1402 |
+
which does allow primary keys with value 0. It only forbids *autoincrement*
|
| 1403 |
+
primary keys with value 0.
|
| 1404 |
+
|
| 1405 |
+
* Shadowing model fields defined in a parent model has been forbidden as this
|
| 1406 |
+
creates ambiguity in the expected model behavior. In addition, clashing
|
| 1407 |
+
fields in the model inheritance hierarchy result in a system check error.
|
| 1408 |
+
For example, if you use multi-inheritance, you need to define custom primary
|
| 1409 |
+
key fields on parent models, otherwise the default ``id`` fields will clash.
|
| 1410 |
+
See :ref:`model-multiple-inheritance-topic` for details.
|
| 1411 |
+
|
| 1412 |
+
* ``django.utils.translation.parse_accept_lang_header()`` now returns
|
| 1413 |
+
lowercase locales, instead of the case as it was provided. As locales should
|
| 1414 |
+
be treated case-insensitive this allows us to speed up locale detection.
|
| 1415 |
+
|
| 1416 |
+
* ``django.utils.translation.get_language_from_path()`` and
|
| 1417 |
+
``django.utils.translation.trans_real.get_supported_language_variant()``
|
| 1418 |
+
now no longer have a ``supported`` argument.
|
| 1419 |
+
|
| 1420 |
+
* The ``shortcut`` view in ``django.contrib.contenttypes.views`` now supports
|
| 1421 |
+
protocol-relative URLs (e.g. ``//example.com``).
|
| 1422 |
+
|
| 1423 |
+
* :class:`~django.contrib.contenttypes.fields.GenericRelation` now supports an
|
| 1424 |
+
optional ``related_query_name`` argument. Setting ``related_query_name`` adds
|
| 1425 |
+
a relation from the related object back to the content type for filtering,
|
| 1426 |
+
ordering and other query operations.
|
| 1427 |
+
|
| 1428 |
+
* When running tests on PostgreSQL, the :setting:`USER` will need read access
|
| 1429 |
+
to the built-in ``postgres`` database. This is in lieu of the previous
|
| 1430 |
+
behavior of connecting to the actual non-test database.
|
| 1431 |
+
|
| 1432 |
+
* As part of the :doc:`System check framework </ref/checks>`, :ref:`fields,
|
| 1433 |
+
models, and model managers <field-checking>` all implement a ``check()``
|
| 1434 |
+
method that is registered with the check framework. If you have an existing
|
| 1435 |
+
method called ``check()`` on one of these objects, you will need to rename it.
|
| 1436 |
+
|
| 1437 |
+
* As noted above in the "Cache" section of "Minor Features", defining the
|
| 1438 |
+
:setting:`TIMEOUT <CACHES-TIMEOUT>` argument of the
|
| 1439 |
+
:setting:`CACHES` setting as ``None`` will set the cache keys as
|
| 1440 |
+
"non-expiring". Previously, with the memcache backend, a
|
| 1441 |
+
:setting:`TIMEOUT <CACHES-TIMEOUT>` of ``0`` would set non-expiring keys,
|
| 1442 |
+
but this was inconsistent with the set-and-expire (i.e. no caching) behavior
|
| 1443 |
+
of ``set("key", "value", timeout=0)``. If you want non-expiring keys,
|
| 1444 |
+
please update your settings to use ``None`` instead of ``0`` as the latter
|
| 1445 |
+
now designates set-and-expire in the settings as well.
|
| 1446 |
+
|
| 1447 |
+
* The ``sql*`` management commands now respect the ``allow_migrate()`` method
|
| 1448 |
+
of :setting:`DATABASE_ROUTERS`. If you have models synced to non-default
|
| 1449 |
+
databases, use the ``--database`` flag to get SQL for those models
|
| 1450 |
+
(previously they would always be included in the output).
|
| 1451 |
+
|
| 1452 |
+
* Decoding the query string from URLs now falls back to the ISO-8859-1 encoding
|
| 1453 |
+
when the input is not valid UTF-8.
|
| 1454 |
+
|
| 1455 |
+
* With the addition of the
|
| 1456 |
+
``django.contrib.auth.middleware.SessionAuthenticationMiddleware`` to
|
| 1457 |
+
the default project template (pre-1.7.2 only), a database must be created
|
| 1458 |
+
before accessing a page using :djadmin:`runserver`.
|
| 1459 |
+
|
| 1460 |
+
* The addition of the ``schemes`` argument to ``URLValidator`` will appear
|
| 1461 |
+
as a backwards-incompatible change if you were previously using a custom
|
| 1462 |
+
regular expression to validate schemes. Any scheme not listed in ``schemes``
|
| 1463 |
+
will fail validation, even if the regular expression matches the given URL.
|
| 1464 |
+
|
| 1465 |
+
.. _deprecated-features-1.7:
|
| 1466 |
+
|
| 1467 |
+
Features deprecated in 1.7
|
| 1468 |
+
==========================
|
| 1469 |
+
|
| 1470 |
+
``django.core.cache.get_cache``
|
| 1471 |
+
-------------------------------
|
| 1472 |
+
|
| 1473 |
+
``django.core.cache.get_cache`` has been supplanted by
|
| 1474 |
+
:data:`django.core.cache.caches`.
|
| 1475 |
+
|
| 1476 |
+
``django.utils.dictconfig``/``django.utils.importlib``
|
| 1477 |
+
------------------------------------------------------
|
| 1478 |
+
|
| 1479 |
+
``django.utils.dictconfig`` and ``django.utils.importlib`` were copies of
|
| 1480 |
+
respectively :mod:`logging.config` and :mod:`importlib` provided for Python
|
| 1481 |
+
versions prior to 2.7. They have been deprecated.
|
| 1482 |
+
|
| 1483 |
+
``django.utils.module_loading.import_by_path``
|
| 1484 |
+
----------------------------------------------
|
| 1485 |
+
|
| 1486 |
+
The current ``django.utils.module_loading.import_by_path`` function
|
| 1487 |
+
catches ``AttributeError``, ``ImportError``, and ``ValueError`` exceptions,
|
| 1488 |
+
and re-raises :exc:`~django.core.exceptions.ImproperlyConfigured`. Such
|
| 1489 |
+
exception masking makes it needlessly hard to diagnose circular import
|
| 1490 |
+
problems, because it makes it look like the problem comes from inside Django.
|
| 1491 |
+
It has been deprecated in favor of
|
| 1492 |
+
:meth:`~django.utils.module_loading.import_string`.
|
| 1493 |
+
|
| 1494 |
+
``django.utils.tzinfo``
|
| 1495 |
+
-----------------------
|
| 1496 |
+
|
| 1497 |
+
``django.utils.tzinfo`` provided two :class:`~datetime.tzinfo` subclasses,
|
| 1498 |
+
``LocalTimezone`` and ``FixedOffset``. They've been deprecated in favor of
|
| 1499 |
+
more correct alternatives provided by :mod:`django.utils.timezone`,
|
| 1500 |
+
:func:`django.utils.timezone.get_default_timezone` and
|
| 1501 |
+
:func:`django.utils.timezone.get_fixed_timezone`.
|
| 1502 |
+
|
| 1503 |
+
``django.utils.unittest``
|
| 1504 |
+
-------------------------
|
| 1505 |
+
|
| 1506 |
+
``django.utils.unittest`` provided uniform access to the ``unittest2`` library
|
| 1507 |
+
on all Python versions. Since ``unittest2`` became the standard library's
|
| 1508 |
+
:mod:`unittest` module in Python 2.7, and Django 1.7 drops support for older
|
| 1509 |
+
Python versions, this module isn't useful anymore. It has been deprecated. Use
|
| 1510 |
+
:mod:`unittest` instead.
|
| 1511 |
+
|
| 1512 |
+
``django.utils.datastructures.SortedDict``
|
| 1513 |
+
------------------------------------------
|
| 1514 |
+
|
| 1515 |
+
As :class:`~collections.OrderedDict` was added to the standard library in
|
| 1516 |
+
Python 2.7, ``SortedDict`` is no longer needed and has been deprecated.
|
| 1517 |
+
|
| 1518 |
+
The two additional, deprecated methods provided by ``SortedDict`` (``insert()``
|
| 1519 |
+
and ``value_for_index()``) have been removed. If you relied on these methods to
|
| 1520 |
+
alter structures like form fields, you should now treat these ``OrderedDict``\s
|
| 1521 |
+
as immutable objects and override them to change their content.
|
| 1522 |
+
|
| 1523 |
+
For example, you might want to override ``MyFormClass.base_fields`` (although
|
| 1524 |
+
this attribute isn't considered a public API) to change the ordering of fields
|
| 1525 |
+
for all ``MyFormClass`` instances; or similarly, you could override
|
| 1526 |
+
``self.fields`` from inside ``MyFormClass.__init__()``, to change the fields
|
| 1527 |
+
for a particular form instance. For example (from Django itself)::
|
| 1528 |
+
|
| 1529 |
+
PasswordChangeForm.base_fields = OrderedDict(
|
| 1530 |
+
(k, PasswordChangeForm.base_fields[k])
|
| 1531 |
+
for k in ["old_password", "new_password1", "new_password2"]
|
| 1532 |
+
)
|
| 1533 |
+
|
| 1534 |
+
Custom SQL location for models package
|
| 1535 |
+
--------------------------------------
|
| 1536 |
+
|
| 1537 |
+
Previously, if models were organized in a package (``myapp/models/``) rather
|
| 1538 |
+
than simply ``myapp/models.py``, Django would look for initial SQL data in
|
| 1539 |
+
``myapp/models/sql/``. This bug has been fixed so that Django
|
| 1540 |
+
will search ``myapp/sql/`` as documented. After this issue was fixed, migrations
|
| 1541 |
+
were added which deprecates initial SQL data. Thus, while this change still
|
| 1542 |
+
exists, the deprecation is irrelevant as the entire feature will be removed in
|
| 1543 |
+
Django 1.9.
|
| 1544 |
+
|
| 1545 |
+
Reorganization of ``django.contrib.sites``
|
| 1546 |
+
------------------------------------------
|
| 1547 |
+
|
| 1548 |
+
``django.contrib.sites`` provides reduced functionality when it isn't in
|
| 1549 |
+
:setting:`INSTALLED_APPS`. The app-loading refactor adds some constraints in
|
| 1550 |
+
that situation. As a consequence, two objects were moved, and the old
|
| 1551 |
+
locations are deprecated:
|
| 1552 |
+
|
| 1553 |
+
* :class:`~django.contrib.sites.requests.RequestSite` now lives in
|
| 1554 |
+
``django.contrib.sites.requests``.
|
| 1555 |
+
* :func:`~django.contrib.sites.shortcuts.get_current_site` now lives in
|
| 1556 |
+
``django.contrib.sites.shortcuts``.
|
| 1557 |
+
|
| 1558 |
+
``declared_fieldsets`` attribute on ``ModelAdmin``
|
| 1559 |
+
--------------------------------------------------
|
| 1560 |
+
|
| 1561 |
+
``ModelAdmin.declared_fieldsets`` has been deprecated. Despite being a private
|
| 1562 |
+
API, it will go through a regular deprecation path. This attribute was mostly
|
| 1563 |
+
used by methods that bypassed ``ModelAdmin.get_fieldsets()`` but this was
|
| 1564 |
+
considered a bug and has been addressed.
|
| 1565 |
+
|
| 1566 |
+
Reorganization of ``django.contrib.contenttypes``
|
| 1567 |
+
-------------------------------------------------
|
| 1568 |
+
|
| 1569 |
+
Since ``django.contrib.contenttypes.generic`` defined both admin and model
|
| 1570 |
+
related objects, an import of this module could trigger unexpected side effects.
|
| 1571 |
+
As a consequence, its contents were split into :mod:`~django.contrib.contenttypes`
|
| 1572 |
+
submodules and the ``django.contrib.contenttypes.generic`` module is deprecated:
|
| 1573 |
+
|
| 1574 |
+
* :class:`~django.contrib.contenttypes.fields.GenericForeignKey` and
|
| 1575 |
+
:class:`~django.contrib.contenttypes.fields.GenericRelation` now live in
|
| 1576 |
+
:mod:`~django.contrib.contenttypes.fields`.
|
| 1577 |
+
* :class:`~django.contrib.contenttypes.forms.BaseGenericInlineFormSet` and
|
| 1578 |
+
:func:`~django.contrib.contenttypes.forms.generic_inlineformset_factory` now
|
| 1579 |
+
live in :mod:`~django.contrib.contenttypes.forms`.
|
| 1580 |
+
* :class:`~django.contrib.contenttypes.admin.GenericInlineModelAdmin`,
|
| 1581 |
+
:class:`~django.contrib.contenttypes.admin.GenericStackedInline` and
|
| 1582 |
+
:class:`~django.contrib.contenttypes.admin.GenericTabularInline` now live in
|
| 1583 |
+
:mod:`~django.contrib.contenttypes.admin`.
|
| 1584 |
+
|
| 1585 |
+
``syncdb``
|
| 1586 |
+
----------
|
| 1587 |
+
|
| 1588 |
+
The ``syncdb`` command has been deprecated in favor of the new :djadmin:`migrate`
|
| 1589 |
+
command. ``migrate`` takes the same arguments as ``syncdb`` used to plus a few
|
| 1590 |
+
more, so it's safe to just change the name you're calling and nothing else.
|
| 1591 |
+
|
| 1592 |
+
``util`` modules renamed to ``utils``
|
| 1593 |
+
-------------------------------------
|
| 1594 |
+
|
| 1595 |
+
The following instances of ``util.py`` in the Django codebase have been renamed
|
| 1596 |
+
to ``utils.py`` in an effort to unify all util and utils references:
|
| 1597 |
+
|
| 1598 |
+
* ``django.contrib.admin.util``
|
| 1599 |
+
* ``django.contrib.gis.db.backends.util``
|
| 1600 |
+
* ``django.db.backends.util``
|
| 1601 |
+
* ``django.forms.util``
|
| 1602 |
+
|
| 1603 |
+
``get_formsets`` method on ``ModelAdmin``
|
| 1604 |
+
-----------------------------------------
|
| 1605 |
+
|
| 1606 |
+
``ModelAdmin.get_formsets`` has been deprecated in favor of the new
|
| 1607 |
+
:meth:`~django.contrib.admin.ModelAdmin.get_formsets_with_inlines`, in order to
|
| 1608 |
+
better handle the case of selectively showing inlines on a ``ModelAdmin``.
|
| 1609 |
+
|
| 1610 |
+
``IPAddressField``
|
| 1611 |
+
------------------
|
| 1612 |
+
|
| 1613 |
+
The ``django.db.models.IPAddressField`` and ``django.forms.IPAddressField``
|
| 1614 |
+
fields have been deprecated in favor of
|
| 1615 |
+
:class:`django.db.models.GenericIPAddressField` and
|
| 1616 |
+
:class:`django.forms.GenericIPAddressField`.
|
| 1617 |
+
|
| 1618 |
+
``BaseMemcachedCache._get_memcache_timeout`` method
|
| 1619 |
+
---------------------------------------------------
|
| 1620 |
+
|
| 1621 |
+
The ``BaseMemcachedCache._get_memcache_timeout()`` method has been renamed to
|
| 1622 |
+
``get_backend_timeout()``. Despite being a private API, it will go through the
|
| 1623 |
+
normal deprecation.
|
| 1624 |
+
|
| 1625 |
+
Natural key serialization options
|
| 1626 |
+
---------------------------------
|
| 1627 |
+
|
| 1628 |
+
The ``--natural`` and ``-n`` options for :djadmin:`dumpdata` have been
|
| 1629 |
+
deprecated. Use :option:`dumpdata --natural-foreign` instead.
|
| 1630 |
+
|
| 1631 |
+
Similarly, the ``use_natural_keys`` argument for ``serializers.serialize()``
|
| 1632 |
+
has been deprecated. Use ``use_natural_foreign_keys`` instead.
|
| 1633 |
+
|
| 1634 |
+
Merging of ``POST`` and ``GET`` arguments into ``WSGIRequest.REQUEST``
|
| 1635 |
+
----------------------------------------------------------------------
|
| 1636 |
+
|
| 1637 |
+
It was already strongly suggested that you use ``GET`` and ``POST`` instead of
|
| 1638 |
+
``REQUEST``, because the former are more explicit. The property ``REQUEST`` is
|
| 1639 |
+
deprecated and will be removed in Django 1.9.
|
| 1640 |
+
|
| 1641 |
+
``django.utils.datastructures.MergeDict`` class
|
| 1642 |
+
-----------------------------------------------
|
| 1643 |
+
|
| 1644 |
+
``MergeDict`` exists primarily to support merging ``POST`` and ``GET``
|
| 1645 |
+
arguments into a ``REQUEST`` property on ``WSGIRequest``. To merge
|
| 1646 |
+
dictionaries, use ``dict.update()`` instead. The class ``MergeDict`` is
|
| 1647 |
+
deprecated and will be removed in Django 1.9.
|
| 1648 |
+
|
| 1649 |
+
Language codes ``zh-cn``, ``zh-tw`` and ``fy-nl``
|
| 1650 |
+
-------------------------------------------------
|
| 1651 |
+
|
| 1652 |
+
The currently used language codes for Simplified Chinese ``zh-cn``,
|
| 1653 |
+
Traditional Chinese ``zh-tw`` and (Western) Frysian ``fy-nl`` are deprecated
|
| 1654 |
+
and should be replaced by the language codes ``zh-hans``, ``zh-hant`` and
|
| 1655 |
+
``fy`` respectively. If you use these language codes, you should rename the
|
| 1656 |
+
locale directories and update your settings to reflect these changes. The
|
| 1657 |
+
deprecated language codes will be removed in Django 1.9.
|
| 1658 |
+
|
| 1659 |
+
``django.utils.functional.memoize`` function
|
| 1660 |
+
--------------------------------------------
|
| 1661 |
+
|
| 1662 |
+
The function ``memoize`` is deprecated and should be replaced by the
|
| 1663 |
+
``functools.lru_cache`` decorator (available from Python 3.2 onward).
|
| 1664 |
+
|
| 1665 |
+
Django ships a backport of this decorator for older Python versions and it's
|
| 1666 |
+
available at ``django.utils.lru_cache.lru_cache``. The deprecated function will
|
| 1667 |
+
be removed in Django 1.9.
|
| 1668 |
+
|
| 1669 |
+
Geo Sitemaps
|
| 1670 |
+
------------
|
| 1671 |
+
|
| 1672 |
+
Google has retired support for the Geo Sitemaps format. Hence Django support
|
| 1673 |
+
for Geo Sitemaps is deprecated and will be removed in Django 1.8.
|
| 1674 |
+
|
| 1675 |
+
Passing callable arguments to queryset methods
|
| 1676 |
+
----------------------------------------------
|
| 1677 |
+
|
| 1678 |
+
Callable arguments for querysets were an undocumented feature that was
|
| 1679 |
+
unreliable. It's been deprecated and will be removed in Django 1.9.
|
| 1680 |
+
|
| 1681 |
+
Callable arguments were evaluated when a queryset was constructed rather than
|
| 1682 |
+
when it was evaluated, thus this feature didn't offer any benefit compared to
|
| 1683 |
+
evaluating arguments before passing them to queryset and created confusion that
|
| 1684 |
+
the arguments may have been evaluated at query time.
|
| 1685 |
+
|
| 1686 |
+
``ADMIN_FOR`` setting
|
| 1687 |
+
---------------------
|
| 1688 |
+
|
| 1689 |
+
The ``ADMIN_FOR`` feature, part of the admindocs, has been removed. You can
|
| 1690 |
+
remove the setting from your configuration at your convenience.
|
| 1691 |
+
|
| 1692 |
+
``SplitDateTimeWidget`` with ``DateTimeField``
|
| 1693 |
+
----------------------------------------------
|
| 1694 |
+
|
| 1695 |
+
``SplitDateTimeWidget`` support in :class:`~django.forms.DateTimeField` is
|
| 1696 |
+
deprecated, use ``SplitDateTimeWidget`` with
|
| 1697 |
+
:class:`~django.forms.SplitDateTimeField` instead.
|
| 1698 |
+
|
| 1699 |
+
``validate``
|
| 1700 |
+
------------
|
| 1701 |
+
|
| 1702 |
+
The ``validate`` management command is deprecated in favor of the
|
| 1703 |
+
:djadmin:`check` command.
|
| 1704 |
+
|
| 1705 |
+
``django.core.management.BaseCommand``
|
| 1706 |
+
--------------------------------------
|
| 1707 |
+
|
| 1708 |
+
``requires_model_validation`` is deprecated in favor of a new
|
| 1709 |
+
``requires_system_checks`` flag. If the latter flag is missing, then the
|
| 1710 |
+
value of the former flag is used. Defining both ``requires_system_checks`` and
|
| 1711 |
+
``requires_model_validation`` results in an error.
|
| 1712 |
+
|
| 1713 |
+
The ``check()`` method has replaced the old ``validate()`` method.
|
| 1714 |
+
|
| 1715 |
+
``ModelAdmin`` validators
|
| 1716 |
+
-------------------------
|
| 1717 |
+
|
| 1718 |
+
The ``ModelAdmin.validator_class`` and ``default_validator_class`` attributes
|
| 1719 |
+
are deprecated in favor of the new ``checks_class`` attribute.
|
| 1720 |
+
|
| 1721 |
+
The ``ModelAdmin.validate()`` method is deprecated in favor of
|
| 1722 |
+
``ModelAdmin.check()``.
|
| 1723 |
+
|
| 1724 |
+
The ``django.contrib.admin.validation`` module is deprecated.
|
| 1725 |
+
|
| 1726 |
+
``django.db.backends.DatabaseValidation.validate_field``
|
| 1727 |
+
--------------------------------------------------------
|
| 1728 |
+
|
| 1729 |
+
This method is deprecated in favor of a new ``check_field`` method.
|
| 1730 |
+
The functionality required by ``check_field()`` is the same as that provided
|
| 1731 |
+
by ``validate_field()``, but the output format is different. Third-party database
|
| 1732 |
+
backends needing this functionality should provide an implementation of
|
| 1733 |
+
``check_field()``.
|
| 1734 |
+
|
| 1735 |
+
Loading ``ssi`` and ``url`` template tags from ``future`` library
|
| 1736 |
+
-----------------------------------------------------------------
|
| 1737 |
+
|
| 1738 |
+
Django 1.3 introduced ``{% load ssi from future %}`` and
|
| 1739 |
+
``{% load url from future %}`` syntax for forward compatibility of the
|
| 1740 |
+
``ssi`` and :ttag:`url` template tags. This syntax is now deprecated and
|
| 1741 |
+
will be removed in Django 1.9. You can simply remove the
|
| 1742 |
+
``{% load ... from future %}`` tags.
|
| 1743 |
+
|
| 1744 |
+
``django.utils.text.javascript_quote``
|
| 1745 |
+
--------------------------------------
|
| 1746 |
+
|
| 1747 |
+
``javascript_quote()`` was an undocumented function present in ``django.utils.text``.
|
| 1748 |
+
It was used internally in the ``javascript_catalog()`` view
|
| 1749 |
+
whose implementation was changed to make use of ``json.dumps()`` instead.
|
| 1750 |
+
If you were relying on this function to provide safe output from untrusted
|
| 1751 |
+
strings, you should use ``django.utils.html.escapejs`` or the
|
| 1752 |
+
:tfilter:`escapejs` template filter.
|
| 1753 |
+
If all you need is to generate valid JavaScript strings, you can simply use
|
| 1754 |
+
``json.dumps()``.
|
| 1755 |
+
|
| 1756 |
+
``fix_ampersands`` utils method and template filter
|
| 1757 |
+
---------------------------------------------------
|
| 1758 |
+
|
| 1759 |
+
The ``django.utils.html.fix_ampersands`` method and the ``fix_ampersands``
|
| 1760 |
+
template filter are deprecated, as the escaping of ampersands is already taken care
|
| 1761 |
+
of by Django's standard HTML escaping features. Combining this with ``fix_ampersands``
|
| 1762 |
+
would either result in double escaping, or, if the output is assumed to be safe,
|
| 1763 |
+
a risk of introducing XSS vulnerabilities. Along with ``fix_ampersands``,
|
| 1764 |
+
``django.utils.html.clean_html`` is deprecated, an undocumented function that calls
|
| 1765 |
+
``fix_ampersands``.
|
| 1766 |
+
As this is an accelerated deprecation, ``fix_ampersands`` and ``clean_html``
|
| 1767 |
+
will be removed in Django 1.8.
|
| 1768 |
+
|
| 1769 |
+
Reorganization of database test settings
|
| 1770 |
+
----------------------------------------
|
| 1771 |
+
|
| 1772 |
+
All database settings with a ``TEST_`` prefix have been deprecated in favor of
|
| 1773 |
+
entries in a :setting:`TEST <DATABASE-TEST>` dictionary in the database
|
| 1774 |
+
settings. The old settings will be supported until Django 1.9. For backwards
|
| 1775 |
+
compatibility with older versions of Django, you can define both versions of
|
| 1776 |
+
the settings as long as they match.
|
| 1777 |
+
|
| 1778 |
+
FastCGI support
|
| 1779 |
+
---------------
|
| 1780 |
+
|
| 1781 |
+
FastCGI support via the ``runfcgi`` management command will be removed in
|
| 1782 |
+
Django 1.9. Please deploy your project using WSGI.
|
| 1783 |
+
|
| 1784 |
+
Moved objects in ``contrib.sites``
|
| 1785 |
+
----------------------------------
|
| 1786 |
+
|
| 1787 |
+
Following the app-loading refactor, two objects in
|
| 1788 |
+
``django.contrib.sites.models`` needed to be moved because they must be
|
| 1789 |
+
available without importing ``django.contrib.sites.models`` when
|
| 1790 |
+
``django.contrib.sites`` isn't installed. Import ``RequestSite`` from
|
| 1791 |
+
``django.contrib.sites.requests`` and ``get_current_site()`` from
|
| 1792 |
+
``django.contrib.sites.shortcuts``. The old import locations will work until
|
| 1793 |
+
Django 1.9.
|
| 1794 |
+
|
| 1795 |
+
``django.forms.forms.get_declared_fields()``
|
| 1796 |
+
--------------------------------------------
|
| 1797 |
+
|
| 1798 |
+
Django no longer uses this functional internally. Even though it's a private
|
| 1799 |
+
API, it'll go through the normal deprecation cycle.
|
| 1800 |
+
|
| 1801 |
+
Private Query Lookup APIs
|
| 1802 |
+
-------------------------
|
| 1803 |
+
|
| 1804 |
+
Private APIs ``django.db.models.sql.where.WhereNode.make_atom()`` and
|
| 1805 |
+
``django.db.models.sql.where.Constraint`` are deprecated in favor of the new
|
| 1806 |
+
:doc:`custom lookups API </ref/models/lookups>`.
|
| 1807 |
+
|
| 1808 |
+
.. _removed-features-1.7:
|
| 1809 |
+
|
| 1810 |
+
Features removed in 1.7
|
| 1811 |
+
=======================
|
| 1812 |
+
|
| 1813 |
+
These features have reached the end of their deprecation cycle and are removed
|
| 1814 |
+
in Django 1.7. See :ref:`deprecated-features-1.5` for details, including how to
|
| 1815 |
+
remove usage of these features.
|
| 1816 |
+
|
| 1817 |
+
* ``django.utils.simplejson`` is removed.
|
| 1818 |
+
|
| 1819 |
+
* ``django.utils.itercompat.product`` is removed.
|
| 1820 |
+
|
| 1821 |
+
* INSTALLED_APPS and TEMPLATE_DIRS are no longer corrected from a plain
|
| 1822 |
+
string into a tuple.
|
| 1823 |
+
|
| 1824 |
+
* :class:`~django.http.HttpResponse`,
|
| 1825 |
+
:class:`~django.template.response.SimpleTemplateResponse`,
|
| 1826 |
+
:class:`~django.template.response.TemplateResponse`,
|
| 1827 |
+
``render_to_response()``, :func:`~django.contrib.sitemaps.views.index`, and
|
| 1828 |
+
:func:`~django.contrib.sitemaps.views.sitemap` no longer take a ``mimetype``
|
| 1829 |
+
argument
|
| 1830 |
+
|
| 1831 |
+
* :class:`~django.http.HttpResponse` immediately consumes its content if it's
|
| 1832 |
+
an iterator.
|
| 1833 |
+
|
| 1834 |
+
* The ``AUTH_PROFILE_MODULE`` setting, and the ``get_profile()`` method on
|
| 1835 |
+
the User model are removed.
|
| 1836 |
+
|
| 1837 |
+
* The ``cleanup`` management command is removed.
|
| 1838 |
+
|
| 1839 |
+
* The ``daily_cleanup.py`` script is removed.
|
| 1840 |
+
|
| 1841 |
+
* :meth:`~django.db.models.query.QuerySet.select_related` no longer has a
|
| 1842 |
+
``depth`` keyword argument.
|
| 1843 |
+
|
| 1844 |
+
* The ``get_warnings_state()``/``restore_warnings_state()``
|
| 1845 |
+
functions from :mod:`django.test.utils` and the ``save_warnings_state()``/
|
| 1846 |
+
``restore_warnings_state()``
|
| 1847 |
+
:ref:`django.test.*TestCase <django-testcase-subclasses>` are removed.
|
| 1848 |
+
|
| 1849 |
+
* The ``check_for_test_cookie`` method in
|
| 1850 |
+
:class:`~django.contrib.auth.forms.AuthenticationForm` is removed.
|
| 1851 |
+
|
| 1852 |
+
* The version of ``django.contrib.auth.views.password_reset_confirm()`` that
|
| 1853 |
+
supports base36 encoded user IDs
|
| 1854 |
+
(``django.contrib.auth.views.password_reset_confirm_uidb36``) is removed.
|
| 1855 |
+
|
| 1856 |
+
* The ``django.utils.encoding.StrAndUnicode`` mix-in is removed.
|
testbed/django__django/docs/releases/1.8.11.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
===========================
|
| 2 |
+
Django 1.8.11 release notes
|
| 3 |
+
===========================
|
| 4 |
+
|
| 5 |
+
*March 5, 2016*
|
| 6 |
+
|
| 7 |
+
Django 1.8.11 fixes a regression on Python 2 in the 1.8.10 security release
|
| 8 |
+
where ``utils.http.is_safe_url()`` crashes on bytestring URLs (:ticket:`26308`).
|
testbed/django__django/docs/releases/1.8.2.txt
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.8.2 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*May 20, 2015*
|
| 6 |
+
|
| 7 |
+
Django 1.8.2 fixes a security issue and several bugs in 1.8.1.
|
| 8 |
+
|
| 9 |
+
Fixed session flushing in the ``cached_db`` backend
|
| 10 |
+
===================================================
|
| 11 |
+
|
| 12 |
+
A change to ``session.flush()`` in the ``cached_db`` session backend in Django
|
| 13 |
+
1.8 mistakenly sets the session key to an empty string rather than ``None``. An
|
| 14 |
+
empty string is treated as a valid session key and the session cookie is set
|
| 15 |
+
accordingly. Any users with an empty string in their session cookie will use
|
| 16 |
+
the same session store. ``session.flush()`` is called by
|
| 17 |
+
``django.contrib.auth.logout()`` and, more seriously, by
|
| 18 |
+
``django.contrib.auth.login()`` when a user switches accounts. If a user is
|
| 19 |
+
logged in and logs in again to a different account (without logging out) the
|
| 20 |
+
session is flushed to avoid reuse. After the session is flushed (and its
|
| 21 |
+
session key becomes ``''``) the account details are set on the session and the
|
| 22 |
+
session is saved. Any users with an empty string in their session cookie will
|
| 23 |
+
now be logged into that account.
|
| 24 |
+
|
| 25 |
+
Bugfixes
|
| 26 |
+
========
|
| 27 |
+
|
| 28 |
+
* Fixed check for template engine alias uniqueness (:ticket:`24685`).
|
| 29 |
+
|
| 30 |
+
* Fixed crash when reusing the same ``Case`` instance in a query
|
| 31 |
+
(:ticket:`24752`).
|
| 32 |
+
|
| 33 |
+
* Corrected join promotion for ``Case`` expressions. For example, annotating a
|
| 34 |
+
query with a ``Case`` expression could unexpectedly filter out results
|
| 35 |
+
(:ticket:`24766`).
|
| 36 |
+
|
| 37 |
+
* Fixed negated ``Q`` objects in expressions. Cases like
|
| 38 |
+
``Case(When(~Q(friends__age__lte=30)))`` tried to generate a subquery which
|
| 39 |
+
resulted in a crash (:ticket:`24705`).
|
| 40 |
+
|
| 41 |
+
* Fixed incorrect GROUP BY clause generation on MySQL when the query's model
|
| 42 |
+
has a self-referential foreign key (:ticket:`24748`).
|
| 43 |
+
|
| 44 |
+
* Implemented ``ForeignKey.get_db_prep_value()`` so that ``ForeignKey``\s
|
| 45 |
+
pointing to :class:`~django.db.models.UUIDField` and inheritance on models
|
| 46 |
+
with ``UUIDField`` primary keys work correctly (:ticket:`24698`,
|
| 47 |
+
:ticket:`24712`).
|
| 48 |
+
|
| 49 |
+
* Fixed ``isnull`` lookup for ``HStoreField`` (:ticket:`24751`).
|
| 50 |
+
|
| 51 |
+
* Fixed a MySQL crash when a migration removes a combined index (unique_together
|
| 52 |
+
or index_together) containing a foreign key (:ticket:`24757`).
|
| 53 |
+
|
| 54 |
+
* Fixed session cookie deletion when using :setting:`SESSION_COOKIE_DOMAIN`
|
| 55 |
+
(:ticket:`24799`).
|
| 56 |
+
|
| 57 |
+
* On PostgreSQL, when no access is granted for the ``postgres`` database,
|
| 58 |
+
Django now falls back to the default database when it normally requires a
|
| 59 |
+
"no database" connection (:ticket:`24791`).
|
| 60 |
+
|
| 61 |
+
* Fixed display of ``contrib.admin``’s ``ForeignKey`` widget when it's used
|
| 62 |
+
in a row with other fields (:ticket:`24784`).
|
testbed/django__django/docs/releases/1.8.3.txt
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.8.3 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*July 8, 2015*
|
| 6 |
+
|
| 7 |
+
Django 1.8.3 fixes several security issues and bugs in 1.8.2.
|
| 8 |
+
|
| 9 |
+
Also, ``django.utils.deprecation.RemovedInDjango20Warning`` was renamed to
|
| 10 |
+
``RemovedInDjango110Warning`` as the version roadmap was revised to 1.9, 1.10,
|
| 11 |
+
1.11 (LTS), 2.0 (drops Python 2 support). For backwards compatibility,
|
| 12 |
+
``RemovedInDjango20Warning`` remains as an importable alias.
|
| 13 |
+
|
| 14 |
+
Denial-of-service possibility by filling session store
|
| 15 |
+
======================================================
|
| 16 |
+
|
| 17 |
+
In previous versions of Django, the session backends created a new empty record
|
| 18 |
+
in the session storage anytime ``request.session`` was accessed and there was a
|
| 19 |
+
session key provided in the request cookies that didn't already have a session
|
| 20 |
+
record. This could allow an attacker to easily create many new session records
|
| 21 |
+
simply by sending repeated requests with unknown session keys, potentially
|
| 22 |
+
filling up the session store or causing other users' session records to be
|
| 23 |
+
evicted.
|
| 24 |
+
|
| 25 |
+
The built-in session backends now create a session record only if the session
|
| 26 |
+
is actually modified; empty session records are not created. Thus this
|
| 27 |
+
potential DoS is now only possible if the site chooses to expose a
|
| 28 |
+
session-modifying view to anonymous users.
|
| 29 |
+
|
| 30 |
+
As each built-in session backend was fixed separately (rather than a fix in the
|
| 31 |
+
core sessions framework), maintainers of third-party session backends should
|
| 32 |
+
check whether the same vulnerability is present in their backend and correct
|
| 33 |
+
it if so.
|
| 34 |
+
|
| 35 |
+
Header injection possibility since validators accept newlines in input
|
| 36 |
+
======================================================================
|
| 37 |
+
|
| 38 |
+
Some of Django's built-in validators
|
| 39 |
+
(:class:`~django.core.validators.EmailValidator`, most seriously) didn't
|
| 40 |
+
prohibit newline characters (due to the usage of ``$`` instead of ``\Z`` in the
|
| 41 |
+
regular expressions). If you use values with newlines in HTTP response or email
|
| 42 |
+
headers, you can suffer from header injection attacks. Django itself isn't
|
| 43 |
+
vulnerable because :class:`~django.http.HttpResponse` and the mail sending
|
| 44 |
+
utilities in :mod:`django.core.mail` prohibit newlines in HTTP and SMTP
|
| 45 |
+
headers, respectively. While the validators have been fixed in Django, if
|
| 46 |
+
you're creating HTTP responses or email messages in other ways, it's a good
|
| 47 |
+
idea to ensure that those methods prohibit newlines as well. You might also
|
| 48 |
+
want to validate that any existing data in your application doesn't contain
|
| 49 |
+
unexpected newlines.
|
| 50 |
+
|
| 51 |
+
:func:`~django.core.validators.validate_ipv4_address`,
|
| 52 |
+
:func:`~django.core.validators.validate_slug`, and
|
| 53 |
+
:class:`~django.core.validators.URLValidator` are also affected, however, as
|
| 54 |
+
of Django 1.6 the ``GenericIPAddresseField``, ``IPAddressField``, ``SlugField``,
|
| 55 |
+
and ``URLField`` form fields which use these validators all strip the input, so
|
| 56 |
+
the possibility of newlines entering your data only exists if you are using
|
| 57 |
+
these validators outside of the form fields.
|
| 58 |
+
|
| 59 |
+
The undocumented, internally unused ``validate_integer()`` function is now
|
| 60 |
+
stricter as it validates using a regular expression instead of simply casting
|
| 61 |
+
the value using ``int()`` and checking if an exception was raised.
|
| 62 |
+
|
| 63 |
+
Denial-of-service possibility in URL validation
|
| 64 |
+
===============================================
|
| 65 |
+
|
| 66 |
+
:class:`~django.core.validators.URLValidator` included a regular expression
|
| 67 |
+
that was extremely slow to evaluate against certain invalid inputs. This regular
|
| 68 |
+
expression has been simplified and optimized.
|
| 69 |
+
|
| 70 |
+
Bugfixes
|
| 71 |
+
========
|
| 72 |
+
|
| 73 |
+
* Fixed ``BaseRangeField.prepare_value()`` to use each ``base_field``’s
|
| 74 |
+
``prepare_value()`` method (:ticket:`24841`).
|
| 75 |
+
|
| 76 |
+
* Fixed crash during :djadmin:`makemigrations` if a migrations module either
|
| 77 |
+
is missing ``__init__.py`` or is a file (:ticket:`24848`).
|
| 78 |
+
|
| 79 |
+
* Fixed ``QuerySet.exists()`` returning incorrect results after annotation with
|
| 80 |
+
``Count()`` (:ticket:`24835`).
|
| 81 |
+
|
| 82 |
+
* Corrected ``HStoreField.has_changed()`` (:ticket:`24844`).
|
| 83 |
+
|
| 84 |
+
* Reverted an optimization to the CSRF template context processor which caused
|
| 85 |
+
a regression (:ticket:`24836`).
|
| 86 |
+
|
| 87 |
+
* Fixed a regression which caused template context processors to overwrite
|
| 88 |
+
variables set on a ``RequestContext`` after it's created (:ticket:`24847`).
|
| 89 |
+
|
| 90 |
+
* Prevented the loss of ``null``/``not null`` column properties during field
|
| 91 |
+
renaming of MySQL databases (:ticket:`24817`).
|
| 92 |
+
|
| 93 |
+
* Fixed a crash when using a reverse one-to-one relation in
|
| 94 |
+
``ModelAdmin.list_display`` (:ticket:`24851`).
|
| 95 |
+
|
| 96 |
+
* Fixed quoting of SQL when renaming a field to ``AutoField`` in PostgreSQL
|
| 97 |
+
(:ticket:`24892`).
|
| 98 |
+
|
| 99 |
+
* Fixed lack of unique constraint when changing a field from
|
| 100 |
+
``primary_key=True`` to ``unique=True`` (:ticket:`24893`).
|
| 101 |
+
|
| 102 |
+
* Fixed queryset pickling when using ``prefetch_related()`` after deleting
|
| 103 |
+
objects (:ticket:`24831`).
|
| 104 |
+
|
| 105 |
+
* Allowed using ``choices`` longer than 1 day with ``DurationField``
|
| 106 |
+
(:ticket:`24897`).
|
| 107 |
+
|
| 108 |
+
* Fixed a crash when loading squashed migrations from two apps with a
|
| 109 |
+
dependency between them, where the dependent app's replaced migrations are
|
| 110 |
+
partially applied (:ticket:`24895`).
|
| 111 |
+
|
| 112 |
+
* Fixed recording of applied status for squashed (replacement) migrations
|
| 113 |
+
(:ticket:`24628`).
|
| 114 |
+
|
| 115 |
+
* Fixed queryset annotations when using ``Case`` expressions with ``exclude()``
|
| 116 |
+
(:ticket:`24833`).
|
| 117 |
+
|
| 118 |
+
* Corrected join promotion for multiple ``Case`` expressions. Annotating a
|
| 119 |
+
query with multiple ``Case`` expressions could unexpectedly filter out
|
| 120 |
+
results (:ticket:`24924`).
|
| 121 |
+
|
| 122 |
+
* Fixed usage of transforms in subqueries (:ticket:`24744`).
|
| 123 |
+
|
| 124 |
+
* Fixed ``SimpleTestCase.assertRaisesMessage()`` on Python 2.7.10
|
| 125 |
+
(:ticket:`24903`).
|
| 126 |
+
|
| 127 |
+
* Provided better backwards compatibility for the ``verbosity`` argument in
|
| 128 |
+
``optparse`` management commands by casting it to an integer
|
| 129 |
+
(:ticket:`24769`).
|
| 130 |
+
|
| 131 |
+
* Fixed ``prefetch_related()`` on databases other than PostgreSQL for models
|
| 132 |
+
using UUID primary keys (:ticket:`24912`).
|
| 133 |
+
|
| 134 |
+
* Fixed removing ``unique_together`` constraints on MySQL (:ticket:`24972`).
|
| 135 |
+
|
| 136 |
+
* Fixed crash when uploading images with MIME types that Pillow doesn't detect,
|
| 137 |
+
such as bitmap, in ``forms.ImageField`` (:ticket:`24948`).
|
| 138 |
+
|
| 139 |
+
* Fixed a regression when deleting a model through the admin that has a
|
| 140 |
+
``GenericRelation`` with a ``related_query_name`` (:ticket:`24940`).
|
| 141 |
+
|
| 142 |
+
* Reallowed non-ASCII values for ``ForeignKey.related_name`` on Python 3 by
|
| 143 |
+
fixing the false positive system check (:ticket:`25016`).
|
| 144 |
+
|
| 145 |
+
* Fixed inline forms that use a parent object that has a ``UUIDField`` primary
|
| 146 |
+
key and a child object that has an ``AutoField`` primary key
|
| 147 |
+
(:ticket:`24958`).
|
| 148 |
+
|
| 149 |
+
* Fixed a regression in the ``unordered_list`` template filter on certain
|
| 150 |
+
inputs (:ticket:`25031`).
|
| 151 |
+
|
| 152 |
+
* Fixed a regression in ``URLValidator`` that invalidated Punycode TLDs
|
| 153 |
+
(:ticket:`25059`).
|
| 154 |
+
|
| 155 |
+
* Improved ``pyinotify`` ``runserver`` polling (:ticket:`23882`).
|
testbed/django__django/docs/releases/1.8.txt
ADDED
|
@@ -0,0 +1,1801 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========================
|
| 2 |
+
Django 1.8 release notes
|
| 3 |
+
========================
|
| 4 |
+
|
| 5 |
+
*April 1, 2015*
|
| 6 |
+
|
| 7 |
+
Welcome to Django 1.8!
|
| 8 |
+
|
| 9 |
+
These release notes cover the :ref:`new features <whats-new-1.8>`, as well as
|
| 10 |
+
some :ref:`backwards incompatible changes <backwards-incompatible-1.8>` you'll
|
| 11 |
+
want to be aware of when upgrading from Django 1.7 or older versions. We've
|
| 12 |
+
also :ref:`begun the deprecation process for some features
|
| 13 |
+
<deprecated-features-1.8>`, and some features have reached the end of their
|
| 14 |
+
deprecation process and :ref:`have been removed <removed-features-1.8>`.
|
| 15 |
+
|
| 16 |
+
See the :doc:`/howto/upgrade-version` guide if you're updating an existing
|
| 17 |
+
project.
|
| 18 |
+
|
| 19 |
+
Django 1.8 has been designated as Django's second :term:`long-term support
|
| 20 |
+
release <Long-term support release>`. It will receive security updates for at
|
| 21 |
+
least three years after its release. Support for the previous LTS, Django 1.4,
|
| 22 |
+
will end 6 months from the release date of Django 1.8.
|
| 23 |
+
|
| 24 |
+
Python compatibility
|
| 25 |
+
====================
|
| 26 |
+
|
| 27 |
+
Django 1.8 requires Python 2.7, 3.2, 3.3, 3.4, or 3.5. We **highly recommend**
|
| 28 |
+
and only officially support the latest release of each series.
|
| 29 |
+
|
| 30 |
+
Django 1.8 is the first release to support Python 3.5.
|
| 31 |
+
|
| 32 |
+
Due to the end of upstream support for Python 3.2 in February 2016, we won't
|
| 33 |
+
test Django 1.8.x on Python 3.2 after the end of 2016.
|
| 34 |
+
|
| 35 |
+
.. _whats-new-1.8:
|
| 36 |
+
|
| 37 |
+
What's new in Django 1.8
|
| 38 |
+
========================
|
| 39 |
+
|
| 40 |
+
``Model._meta`` API
|
| 41 |
+
-------------------
|
| 42 |
+
|
| 43 |
+
Django now has a formalized API for :doc:`Model._meta </ref/models/meta>`,
|
| 44 |
+
providing an officially supported way to :ref:`retrieve fields
|
| 45 |
+
<model-meta-field-api>` and filter fields based on their :ref:`attributes
|
| 46 |
+
<model-field-attributes>`.
|
| 47 |
+
|
| 48 |
+
The ``Model._meta`` object has been part of Django since the days of pre-0.96
|
| 49 |
+
"Magic Removal" -- it just wasn't an official, stable API. In recognition of
|
| 50 |
+
this, we've endeavored to maintain backwards-compatibility with the old
|
| 51 |
+
API endpoint where possible. However, API endpoints that aren't part of the
|
| 52 |
+
new official API have been deprecated and will eventually be removed.
|
| 53 |
+
|
| 54 |
+
Multiple template engines
|
| 55 |
+
-------------------------
|
| 56 |
+
|
| 57 |
+
Django 1.8 defines a stable API for integrating template backends. It includes
|
| 58 |
+
built-in support for the Django template language and for
|
| 59 |
+
:class:`~django.template.backends.jinja2.Jinja2`. It supports rendering
|
| 60 |
+
templates with multiple engines within the same project. Learn more about the
|
| 61 |
+
new features in the :doc:`topic guide </topics/templates>` and check the
|
| 62 |
+
upgrade instructions in older versions of the documentation.
|
| 63 |
+
|
| 64 |
+
Security enhancements
|
| 65 |
+
---------------------
|
| 66 |
+
|
| 67 |
+
Several features of the :pypi:`django-secure` third-party library have been
|
| 68 |
+
integrated into Django. :class:`django.middleware.security.SecurityMiddleware`
|
| 69 |
+
provides several security enhancements to the request/response cycle. The new
|
| 70 |
+
:option:`check --deploy` option allows you to check your production settings
|
| 71 |
+
file for ways to increase the security of your site.
|
| 72 |
+
|
| 73 |
+
New PostgreSQL specific functionality
|
| 74 |
+
-------------------------------------
|
| 75 |
+
|
| 76 |
+
Django now has a module with extensions for PostgreSQL specific features, such
|
| 77 |
+
as :class:`~django.contrib.postgres.fields.ArrayField`,
|
| 78 |
+
:class:`~django.contrib.postgres.fields.HStoreField`, :ref:`range-fields`, and
|
| 79 |
+
:lookup:`unaccent` lookup. A full breakdown of the features is available
|
| 80 |
+
:doc:`in the documentation </ref/contrib/postgres/index>`.
|
| 81 |
+
|
| 82 |
+
New data types
|
| 83 |
+
--------------
|
| 84 |
+
|
| 85 |
+
* Django now has a :class:`~django.db.models.UUIDField` for storing
|
| 86 |
+
universally unique identifiers. It is stored as the native ``uuid`` data type
|
| 87 |
+
on PostgreSQL and as a fixed length character field on other backends. There
|
| 88 |
+
is a corresponding :class:`form field <django.forms.UUIDField>`.
|
| 89 |
+
|
| 90 |
+
* Django now has a :class:`~django.db.models.DurationField` for storing periods
|
| 91 |
+
of time - modeled in Python by :class:`~python:datetime.timedelta`. It is
|
| 92 |
+
stored in the native ``interval`` data type on PostgreSQL, as a ``INTERVAL
|
| 93 |
+
DAY(9) TO SECOND(6)`` on Oracle, and as a ``bigint`` of microseconds on other
|
| 94 |
+
backends. Date and time related arithmetic has also been improved on all
|
| 95 |
+
backends. There is a corresponding :class:`form field
|
| 96 |
+
<django.forms.DurationField>`.
|
| 97 |
+
|
| 98 |
+
Query Expressions, Conditional Expressions, and Database Functions
|
| 99 |
+
------------------------------------------------------------------
|
| 100 |
+
|
| 101 |
+
:doc:`Query Expressions </ref/models/expressions>` allow you to create,
|
| 102 |
+
customize, and compose complex SQL expressions. This has enabled annotate
|
| 103 |
+
to accept expressions other than aggregates. Aggregates are now able to
|
| 104 |
+
reference multiple fields, as well as perform arithmetic, similar to ``F()``
|
| 105 |
+
objects. :meth:`~django.db.models.query.QuerySet.order_by` has also gained the
|
| 106 |
+
ability to accept expressions.
|
| 107 |
+
|
| 108 |
+
:doc:`Conditional Expressions </ref/models/conditional-expressions>` allow
|
| 109 |
+
you to use :keyword:`if` ... :keyword:`elif` ... :keyword:`else` logic within
|
| 110 |
+
queries.
|
| 111 |
+
|
| 112 |
+
A collection of :doc:`database functions </ref/models/database-functions>` is
|
| 113 |
+
also included with functionality such as
|
| 114 |
+
:class:`~django.db.models.functions.Coalesce`,
|
| 115 |
+
:class:`~django.db.models.functions.Concat`, and
|
| 116 |
+
:class:`~django.db.models.functions.Substr`.
|
| 117 |
+
|
| 118 |
+
``TestCase`` data setup
|
| 119 |
+
-----------------------
|
| 120 |
+
|
| 121 |
+
:class:`~django.test.TestCase` has been refactored to allow for data
|
| 122 |
+
initialization at the class level using transactions and savepoints. Database
|
| 123 |
+
backends which do not support transactions, like MySQL with the MyISAM storage
|
| 124 |
+
engine, will still be able to run these tests but won't benefit from the
|
| 125 |
+
improvements. Tests are now run within two nested
|
| 126 |
+
:func:`~django.db.transaction.atomic()` blocks: one for the whole class and one
|
| 127 |
+
for each test.
|
| 128 |
+
|
| 129 |
+
* The class method
|
| 130 |
+
:meth:`TestCase.setUpTestData() <django.test.TestCase.setUpTestData>` adds
|
| 131 |
+
the ability to set up test data at the class level. Using this technique can
|
| 132 |
+
speed up the tests as compared to using ``setUp()``.
|
| 133 |
+
|
| 134 |
+
* Fixture loading within ``TestCase`` is now performed once for the whole
|
| 135 |
+
``TestCase``.
|
| 136 |
+
|
| 137 |
+
Minor features
|
| 138 |
+
--------------
|
| 139 |
+
|
| 140 |
+
:mod:`django.contrib.admin`
|
| 141 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 142 |
+
|
| 143 |
+
* :class:`~django.contrib.admin.ModelAdmin` now has a
|
| 144 |
+
:meth:`~django.contrib.admin.ModelAdmin.has_module_permission`
|
| 145 |
+
method to allow limiting access to the module on the admin index page.
|
| 146 |
+
|
| 147 |
+
* :class:`~django.contrib.admin.InlineModelAdmin` now has an attribute
|
| 148 |
+
:attr:`~django.contrib.admin.InlineModelAdmin.show_change_link` that
|
| 149 |
+
supports showing a link to an inline object's change form.
|
| 150 |
+
|
| 151 |
+
* Use the new ``django.contrib.admin.RelatedOnlyFieldListFilter`` in
|
| 152 |
+
:attr:`ModelAdmin.list_filter <django.contrib.admin.ModelAdmin.list_filter>`
|
| 153 |
+
to limit the ``list_filter`` choices to foreign objects which are attached to
|
| 154 |
+
those from the ``ModelAdmin``.
|
| 155 |
+
|
| 156 |
+
* The :meth:`ModelAdmin.delete_view()
|
| 157 |
+
<django.contrib.admin.ModelAdmin.delete_view>` displays a summary of objects
|
| 158 |
+
to be deleted on the deletion confirmation page.
|
| 159 |
+
|
| 160 |
+
* The jQuery library embedded in the admin has been upgraded to version 1.11.2.
|
| 161 |
+
|
| 162 |
+
* You can now specify :attr:`AdminSite.site_url
|
| 163 |
+
<django.contrib.admin.AdminSite.site_url>` in order to display a link to the
|
| 164 |
+
front-end site.
|
| 165 |
+
|
| 166 |
+
* You can now specify :attr:`ModelAdmin.show_full_result_count
|
| 167 |
+
<django.contrib.admin.ModelAdmin.show_full_result_count>` to control whether
|
| 168 |
+
or not the full count of objects should be displayed on a filtered admin page.
|
| 169 |
+
|
| 170 |
+
* The ``AdminSite.password_change()`` method now has an ``extra_context``
|
| 171 |
+
parameter.
|
| 172 |
+
|
| 173 |
+
* You can now control who may login to the admin site by overriding only
|
| 174 |
+
:meth:`AdminSite.has_permission()
|
| 175 |
+
<django.contrib.admin.AdminSite.has_permission>` and
|
| 176 |
+
:attr:`AdminSite.login_form <django.contrib.admin.AdminSite.login_form>`.
|
| 177 |
+
The ``base.html`` template has a new block ``usertools`` which contains the
|
| 178 |
+
user-specific header. A new context variable ``has_permission``, which gets
|
| 179 |
+
its value from :meth:`~django.contrib.admin.AdminSite.has_permission`,
|
| 180 |
+
indicates whether the user may access the site.
|
| 181 |
+
|
| 182 |
+
* Foreign key dropdowns now have buttons for changing or deleting related
|
| 183 |
+
objects using a popup.
|
| 184 |
+
|
| 185 |
+
:mod:`django.contrib.admindocs`
|
| 186 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 187 |
+
|
| 188 |
+
* reStructuredText is now parsed in model docstrings.
|
| 189 |
+
|
| 190 |
+
:mod:`django.contrib.auth`
|
| 191 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 192 |
+
|
| 193 |
+
* Authorization backends can now raise
|
| 194 |
+
:class:`~django.core.exceptions.PermissionDenied` in
|
| 195 |
+
:meth:`~django.contrib.auth.models.User.has_perm`
|
| 196 |
+
and :meth:`~django.contrib.auth.models.User.has_module_perms`
|
| 197 |
+
to short-circuit permission checking.
|
| 198 |
+
* :class:`~django.contrib.auth.forms.PasswordResetForm` now
|
| 199 |
+
has a method :meth:`~django.contrib.auth.forms.PasswordResetForm.send_mail`
|
| 200 |
+
that can be overridden to customize the mail to be sent.
|
| 201 |
+
|
| 202 |
+
* The ``max_length`` of :attr:`Permission.name
|
| 203 |
+
<django.contrib.auth.models.Permission.name>` has been increased from 50 to
|
| 204 |
+
255 characters. Please run the database migration.
|
| 205 |
+
|
| 206 |
+
* :attr:`~django.contrib.auth.models.CustomUser.USERNAME_FIELD` and
|
| 207 |
+
:attr:`~django.contrib.auth.models.CustomUser.REQUIRED_FIELDS` now supports
|
| 208 |
+
:class:`~django.db.models.ForeignKey`\s.
|
| 209 |
+
|
| 210 |
+
* The default iteration count for the PBKDF2 password hasher has been
|
| 211 |
+
increased by 33%. This backwards compatible change will not affect users who
|
| 212 |
+
have subclassed ``django.contrib.auth.hashers.PBKDF2PasswordHasher`` to
|
| 213 |
+
change the default value.
|
| 214 |
+
|
| 215 |
+
:mod:`django.contrib.gis`
|
| 216 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 217 |
+
|
| 218 |
+
* A new :doc:`GeoJSON serializer </ref/contrib/gis/serializers>` is now
|
| 219 |
+
available.
|
| 220 |
+
|
| 221 |
+
* It is now allowed to include a subquery as a geographic lookup argument, for
|
| 222 |
+
example ``City.objects.filter(point__within=Country.objects.filter(continent='Africa').values('mpoly'))``.
|
| 223 |
+
|
| 224 |
+
* The SpatiaLite backend now supports ``Collect`` and ``Extent`` aggregates
|
| 225 |
+
when the database version is 3.0 or later.
|
| 226 |
+
|
| 227 |
+
* The PostGIS 2 ``CREATE EXTENSION postgis`` and the SpatiaLite
|
| 228 |
+
``SELECT InitSpatialMetaData`` initialization commands are now automatically
|
| 229 |
+
run by :djadmin:`migrate`.
|
| 230 |
+
|
| 231 |
+
* The GDAL interface now supports retrieving properties of
|
| 232 |
+
:ref:`raster (image) data file <raster-data-source-objects>`.
|
| 233 |
+
|
| 234 |
+
* Compatibility shims for ``SpatialRefSys`` and ``GeometryColumns`` changed in
|
| 235 |
+
Django 1.2 have been removed.
|
| 236 |
+
|
| 237 |
+
* All GDAL-related exceptions are now raised with ``GDALException``. The former
|
| 238 |
+
``OGRException`` has been kept for backwards compatibility but should not be
|
| 239 |
+
used any longer.
|
| 240 |
+
|
| 241 |
+
:mod:`django.contrib.sessions`
|
| 242 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 243 |
+
|
| 244 |
+
* Session cookie is now deleted after
|
| 245 |
+
:meth:`~django.contrib.sessions.backends.base.SessionBase.flush()` is called.
|
| 246 |
+
|
| 247 |
+
:mod:`django.contrib.sitemaps`
|
| 248 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 249 |
+
|
| 250 |
+
* The new :attr:`Sitemap.i18n <django.contrib.sitemaps.Sitemap.i18n>` attribute
|
| 251 |
+
allows you to generate a sitemap based on the :setting:`LANGUAGES` setting.
|
| 252 |
+
|
| 253 |
+
:mod:`django.contrib.sites`
|
| 254 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 255 |
+
|
| 256 |
+
* :func:`~django.contrib.sites.shortcuts.get_current_site` will now lookup
|
| 257 |
+
the current site based on :meth:`request.get_host()
|
| 258 |
+
<django.http.HttpRequest.get_host>` if the :setting:`SITE_ID` setting is not
|
| 259 |
+
defined.
|
| 260 |
+
|
| 261 |
+
* The default :class:`~django.contrib.sites.models.Site` created when running
|
| 262 |
+
``migrate`` now respects the :setting:`SITE_ID` setting (instead of always
|
| 263 |
+
using ``pk=1``).
|
| 264 |
+
|
| 265 |
+
Cache
|
| 266 |
+
~~~~~
|
| 267 |
+
|
| 268 |
+
* The ``incr()`` method of the
|
| 269 |
+
``django.core.cache.backends.locmem.LocMemCache`` backend is now thread-safe.
|
| 270 |
+
|
| 271 |
+
Cryptography
|
| 272 |
+
~~~~~~~~~~~~
|
| 273 |
+
|
| 274 |
+
* The ``max_age`` parameter of the
|
| 275 |
+
:meth:`django.core.signing.TimestampSigner.unsign` method now also accepts a
|
| 276 |
+
:py:class:`datetime.timedelta` object.
|
| 277 |
+
|
| 278 |
+
Database backends
|
| 279 |
+
~~~~~~~~~~~~~~~~~
|
| 280 |
+
|
| 281 |
+
* The MySQL backend no longer strips microseconds from ``datetime`` values as
|
| 282 |
+
MySQL 5.6.4 and up supports fractional seconds depending on the declaration
|
| 283 |
+
of the datetime field (when ``DATETIME`` includes fractional precision greater
|
| 284 |
+
than 0). New datetime database columns created with Django 1.8 and MySQL 5.6.4
|
| 285 |
+
and up will support microseconds. See the :ref:`MySQL database notes
|
| 286 |
+
<mysql-fractional-seconds>` for more details.
|
| 287 |
+
|
| 288 |
+
* The MySQL backend no longer creates explicit indexes for foreign keys when
|
| 289 |
+
using the InnoDB storage engine, as MySQL already creates them automatically.
|
| 290 |
+
|
| 291 |
+
* The Oracle backend no longer defines the ``connection_persists_old_columns``
|
| 292 |
+
feature as ``True``. Instead, Oracle will now include a cache busting clause
|
| 293 |
+
when getting the description of a table.
|
| 294 |
+
|
| 295 |
+
Email
|
| 296 |
+
~~~~~
|
| 297 |
+
|
| 298 |
+
* :ref:`Email backends <topic-email-backends>` now support the context manager
|
| 299 |
+
protocol for opening and closing connections.
|
| 300 |
+
|
| 301 |
+
* The SMTP email backend now supports ``keyfile`` and ``certfile``
|
| 302 |
+
authentication with the :setting:`EMAIL_SSL_CERTFILE` and
|
| 303 |
+
:setting:`EMAIL_SSL_KEYFILE` settings.
|
| 304 |
+
|
| 305 |
+
* The SMTP :class:`~django.core.mail.backends.smtp.EmailBackend` now supports
|
| 306 |
+
setting the ``timeout`` parameter with the :setting:`EMAIL_TIMEOUT` setting.
|
| 307 |
+
|
| 308 |
+
* :class:`~django.core.mail.EmailMessage` and ``EmailMultiAlternatives`` now
|
| 309 |
+
support the ``reply_to`` parameter.
|
| 310 |
+
|
| 311 |
+
File Storage
|
| 312 |
+
~~~~~~~~~~~~
|
| 313 |
+
|
| 314 |
+
* :meth:`Storage.get_available_name()
|
| 315 |
+
<django.core.files.storage.Storage.get_available_name>` and
|
| 316 |
+
:meth:`Storage.save() <django.core.files.storage.Storage.save>`
|
| 317 |
+
now take a ``max_length`` argument to implement storage-level maximum
|
| 318 |
+
filename length constraints. Filenames exceeding this argument will get
|
| 319 |
+
truncated. This prevents a database error when appending a unique suffix to a
|
| 320 |
+
long filename that already exists on the storage. See the :ref:`deprecation
|
| 321 |
+
note <storage-max-length-update>` about adding this argument to your custom
|
| 322 |
+
storage classes.
|
| 323 |
+
|
| 324 |
+
Forms
|
| 325 |
+
~~~~~
|
| 326 |
+
|
| 327 |
+
* Form widgets now render attributes with a value of ``True`` or ``False``
|
| 328 |
+
as HTML5 boolean attributes.
|
| 329 |
+
|
| 330 |
+
* The new :meth:`~django.forms.Form.has_error()` method allows checking
|
| 331 |
+
if a specific error has happened.
|
| 332 |
+
|
| 333 |
+
* If :attr:`~django.forms.Form.required_css_class` is defined on a form, then
|
| 334 |
+
the ``<label>`` tags for required fields will have this class present in its
|
| 335 |
+
attributes.
|
| 336 |
+
|
| 337 |
+
* The rendering of non-field errors in unordered lists (``<ul>``) now includes
|
| 338 |
+
``nonfield`` in its list of classes to distinguish them from field-specific
|
| 339 |
+
errors.
|
| 340 |
+
|
| 341 |
+
* :class:`~django.forms.Field` now accepts a
|
| 342 |
+
:attr:`~django.forms.Field.label_suffix` argument, which will override the
|
| 343 |
+
form's :attr:`~django.forms.Form.label_suffix`. This enables customizing the
|
| 344 |
+
suffix on a per-field basis — previously it wasn't possible to override
|
| 345 |
+
a form's :attr:`~django.forms.Form.label_suffix` while using shortcuts such
|
| 346 |
+
as ``{{ form.as_p }}`` in templates.
|
| 347 |
+
|
| 348 |
+
* :class:`~django.forms.SelectDateWidget` now accepts an
|
| 349 |
+
:attr:`~django.forms.SelectDateWidget.empty_label` argument, which will
|
| 350 |
+
override the top list choice label when :class:`~django.forms.DateField`
|
| 351 |
+
is not required.
|
| 352 |
+
|
| 353 |
+
* After an :class:`~django.forms.ImageField` has been cleaned and validated, the
|
| 354 |
+
``UploadedFile`` object will have an additional ``image`` attribute containing
|
| 355 |
+
the Pillow ``Image`` instance used to check if the file was a valid image. It
|
| 356 |
+
will also update ``UploadedFile.content_type`` with the image's content type
|
| 357 |
+
as determined by Pillow.
|
| 358 |
+
|
| 359 |
+
* You can now pass a callable that returns an iterable of choices when
|
| 360 |
+
instantiating a :class:`~django.forms.ChoiceField`.
|
| 361 |
+
|
| 362 |
+
Generic Views
|
| 363 |
+
~~~~~~~~~~~~~
|
| 364 |
+
|
| 365 |
+
* Generic views that use :class:`~django.views.generic.list.MultipleObjectMixin`
|
| 366 |
+
may now specify the ordering applied to the
|
| 367 |
+
:attr:`~django.views.generic.list.MultipleObjectMixin.queryset` by setting
|
| 368 |
+
:attr:`~django.views.generic.list.MultipleObjectMixin.ordering` or overriding
|
| 369 |
+
:meth:`~django.views.generic.list.MultipleObjectMixin.get_ordering()`.
|
| 370 |
+
|
| 371 |
+
* The new :attr:`SingleObjectMixin.query_pk_and_slug
|
| 372 |
+
<django.views.generic.detail.SingleObjectMixin.query_pk_and_slug>`
|
| 373 |
+
attribute allows changing the behavior of
|
| 374 |
+
:meth:`~django.views.generic.detail.SingleObjectMixin.get_object()`
|
| 375 |
+
so that it'll perform its lookup using both the primary key and the slug.
|
| 376 |
+
|
| 377 |
+
* The :meth:`~django.views.generic.edit.FormMixin.get_form()` method doesn't
|
| 378 |
+
require a ``form_class`` to be provided anymore. If not provided ``form_class``
|
| 379 |
+
defaults to :meth:`~django.views.generic.edit.FormMixin.get_form_class()`.
|
| 380 |
+
|
| 381 |
+
* Placeholders in :attr:`ModelFormMixin.success_url
|
| 382 |
+
<django.views.generic.edit.ModelFormMixin.success_url>` now support the Python
|
| 383 |
+
:py:meth:`str.format()` syntax. The legacy ``%(<foo>)s`` syntax is still
|
| 384 |
+
supported but will be removed in Django 1.10.
|
| 385 |
+
|
| 386 |
+
Internationalization
|
| 387 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 388 |
+
|
| 389 |
+
* :setting:`FORMAT_MODULE_PATH` can now be a list of strings representing
|
| 390 |
+
module paths. This allows importing several format modules from different
|
| 391 |
+
reusable apps. It also allows overriding those custom formats in your main
|
| 392 |
+
Django project.
|
| 393 |
+
|
| 394 |
+
Logging
|
| 395 |
+
~~~~~~~
|
| 396 |
+
|
| 397 |
+
* The :class:`django.utils.log.AdminEmailHandler` class now has a
|
| 398 |
+
:meth:`~django.utils.log.AdminEmailHandler.send_mail` method to make it more
|
| 399 |
+
subclass friendly.
|
| 400 |
+
|
| 401 |
+
Management Commands
|
| 402 |
+
~~~~~~~~~~~~~~~~~~~
|
| 403 |
+
|
| 404 |
+
* Database connections are now always closed after a management command called
|
| 405 |
+
from the command line has finished doing its job.
|
| 406 |
+
|
| 407 |
+
* Commands from alternate package formats like eggs are now also discovered.
|
| 408 |
+
|
| 409 |
+
* The new :option:`dumpdata --output` option allows specifying a file to which
|
| 410 |
+
the serialized data is written.
|
| 411 |
+
|
| 412 |
+
* The new :option:`makemessages --exclude` and :option:`compilemessages
|
| 413 |
+
--exclude` options allow excluding specific locales from processing.
|
| 414 |
+
|
| 415 |
+
* :djadmin:`compilemessages` now has a ``--use-fuzzy`` or ``-f`` option which
|
| 416 |
+
includes fuzzy translations into compiled files.
|
| 417 |
+
|
| 418 |
+
* The :option:`loaddata --ignorenonexistent` option now ignores data for models
|
| 419 |
+
that no longer exist.
|
| 420 |
+
|
| 421 |
+
* :djadmin:`runserver` now uses daemon threads for faster reloading.
|
| 422 |
+
|
| 423 |
+
* :djadmin:`inspectdb` now outputs ``Meta.unique_together``. It is also able to
|
| 424 |
+
introspect :class:`~django.db.models.AutoField` for MySQL and PostgreSQL
|
| 425 |
+
databases.
|
| 426 |
+
|
| 427 |
+
* When calling management commands with options using
|
| 428 |
+
:func:`~django.core.management.call_command`, the option name can match the
|
| 429 |
+
command line option name (without the initial dashes) or the final option
|
| 430 |
+
destination variable name, but in either case, the resulting option received
|
| 431 |
+
by the command is now always the ``dest`` name specified in the command
|
| 432 |
+
option definition (as long as the command uses the :mod:`argparse` module).
|
| 433 |
+
|
| 434 |
+
* The :djadmin:`dbshell` command now supports MySQL's optional SSL certificate
|
| 435 |
+
authority setting (``--ssl-ca``).
|
| 436 |
+
|
| 437 |
+
* The new :option:`makemigrations --name` allows giving the migration(s) a
|
| 438 |
+
custom name instead of a generated one.
|
| 439 |
+
|
| 440 |
+
* The :djadmin:`loaddata` command now prevents repeated fixture loading. If
|
| 441 |
+
:setting:`FIXTURE_DIRS` contains duplicates or a default fixture directory
|
| 442 |
+
path (``app_name/fixtures``), an exception is raised.
|
| 443 |
+
|
| 444 |
+
* The new ``makemigrations --exit`` option allows exiting with an error
|
| 445 |
+
code if no migrations are created.
|
| 446 |
+
|
| 447 |
+
* The new :djadmin:`showmigrations` command allows listing all migrations and
|
| 448 |
+
their dependencies in a project.
|
| 449 |
+
|
| 450 |
+
Middleware
|
| 451 |
+
~~~~~~~~~~
|
| 452 |
+
|
| 453 |
+
* The :attr:`CommonMiddleware.response_redirect_class
|
| 454 |
+
<django.middleware.common.CommonMiddleware.response_redirect_class>`
|
| 455 |
+
attribute allows you to customize the redirects issued by the middleware.
|
| 456 |
+
|
| 457 |
+
* A debug message will be logged to the ``django.request`` logger when a
|
| 458 |
+
middleware raises a :exc:`~django.core.exceptions.MiddlewareNotUsed` exception
|
| 459 |
+
in :setting:`DEBUG` mode.
|
| 460 |
+
|
| 461 |
+
Migrations
|
| 462 |
+
~~~~~~~~~~
|
| 463 |
+
|
| 464 |
+
* The :class:`~django.db.migrations.operations.RunSQL` operation can now handle
|
| 465 |
+
parameters passed to the SQL statements.
|
| 466 |
+
|
| 467 |
+
* It is now possible to have migrations (most probably :ref:`data migrations
|
| 468 |
+
<data-migrations>`) for applications without models.
|
| 469 |
+
|
| 470 |
+
* Migrations can now :ref:`serialize model managers
|
| 471 |
+
<using-managers-in-migrations>` as part of the model state.
|
| 472 |
+
|
| 473 |
+
* A :ref:`generic mechanism to handle the deprecation of model fields
|
| 474 |
+
<migrations-removing-model-fields>` was added.
|
| 475 |
+
|
| 476 |
+
* The :meth:`RunPython.noop() <django.db.migrations.operations.RunPython.noop>`
|
| 477 |
+
and :attr:`RunSQL.noop <django.db.migrations.operations.RunSQL.noop>` class
|
| 478 |
+
method/attribute were added to ease in making ``RunPython`` and ``RunSQL``
|
| 479 |
+
operations reversible.
|
| 480 |
+
|
| 481 |
+
* The migration operations :class:`~django.db.migrations.operations.RunPython`
|
| 482 |
+
and :class:`~django.db.migrations.operations.RunSQL` now call the
|
| 483 |
+
:meth:`allow_migrate` method of database routers. The router can use the
|
| 484 |
+
newly introduced ``app_label`` and ``hints`` arguments to make a routing
|
| 485 |
+
decision. To take advantage of this feature you need to update the router to
|
| 486 |
+
the new ``allow_migrate`` signature, see the :ref:`deprecation section
|
| 487 |
+
<deprecated-signature-of-allow-migrate>` for more details.
|
| 488 |
+
|
| 489 |
+
Models
|
| 490 |
+
~~~~~~
|
| 491 |
+
|
| 492 |
+
* Django now logs at most 9000 queries in ``connections.queries``, in order
|
| 493 |
+
to prevent excessive memory usage in long-running processes in debug mode.
|
| 494 |
+
|
| 495 |
+
* There is now a model ``Meta`` option to define a
|
| 496 |
+
:attr:`default related name <django.db.models.Options.default_related_name>`
|
| 497 |
+
for all relational fields of a model.
|
| 498 |
+
|
| 499 |
+
* Pickling models and querysets across different versions of Django isn't
|
| 500 |
+
officially supported (it may work, but there's no guarantee). An extra
|
| 501 |
+
variable that specifies the current Django version is now added to the
|
| 502 |
+
pickled state of models and querysets, and Django raises a ``RuntimeWarning``
|
| 503 |
+
when these objects are unpickled in a different version than the one in
|
| 504 |
+
which they were pickled.
|
| 505 |
+
|
| 506 |
+
* Added :meth:`Model.from_db() <django.db.models.Model.from_db()>` which
|
| 507 |
+
Django uses whenever objects are loaded using the ORM. The method allows
|
| 508 |
+
customizing model loading behavior.
|
| 509 |
+
|
| 510 |
+
* ``extra(select={...})`` now allows you to escape a literal ``%s`` sequence
|
| 511 |
+
using ``%%s``.
|
| 512 |
+
|
| 513 |
+
* :doc:`Custom Lookups</howto/custom-lookups>` can now be registered using
|
| 514 |
+
a decorator pattern.
|
| 515 |
+
|
| 516 |
+
* The new :attr:`Transform.bilateral <django.db.models.Transform.bilateral>`
|
| 517 |
+
attribute allows creating bilateral transformations. These transformations
|
| 518 |
+
are applied to both ``lhs`` and ``rhs`` when used in a lookup expression,
|
| 519 |
+
providing opportunities for more sophisticated lookups.
|
| 520 |
+
|
| 521 |
+
* SQL special characters (\, %, _) are now escaped properly when a pattern
|
| 522 |
+
lookup (e.g. ``contains``, ``startswith``, etc.) is used with an ``F()``
|
| 523 |
+
expression as the right-hand side. In those cases, the escaping is performed
|
| 524 |
+
by the database, which can lead to somewhat complex queries involving nested
|
| 525 |
+
``REPLACE`` function calls.
|
| 526 |
+
|
| 527 |
+
* You can now refresh model instances by using :meth:`Model.refresh_from_db()
|
| 528 |
+
<django.db.models.Model.refresh_from_db>`.
|
| 529 |
+
|
| 530 |
+
* You can now get the set of deferred fields for a model using
|
| 531 |
+
:meth:`Model.get_deferred_fields() <django.db.models.Model.get_deferred_fields>`.
|
| 532 |
+
|
| 533 |
+
* Model field ``default``’s are now used when primary key field's are set to
|
| 534 |
+
``None``.
|
| 535 |
+
|
| 536 |
+
Signals
|
| 537 |
+
~~~~~~~
|
| 538 |
+
|
| 539 |
+
* Exceptions from the ``(receiver, exception)`` tuples returned by
|
| 540 |
+
:meth:`Signal.send_robust() <django.dispatch.Signal.send_robust>` now have
|
| 541 |
+
their traceback attached as a ``__traceback__`` attribute.
|
| 542 |
+
|
| 543 |
+
* The ``environ`` argument, which contains the WSGI environment structure from
|
| 544 |
+
the request, was added to the :data:`~django.core.signals.request_started`
|
| 545 |
+
signal.
|
| 546 |
+
|
| 547 |
+
* You can now import the :func:`~django.test.signals.setting_changed` signal
|
| 548 |
+
from ``django.core.signals`` to avoid loading ``django.test`` in non-test
|
| 549 |
+
situations. Django no longer does so itself.
|
| 550 |
+
|
| 551 |
+
System Check Framework
|
| 552 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 553 |
+
|
| 554 |
+
* :attr:`~django.core.checks.register` can now be used as a function.
|
| 555 |
+
|
| 556 |
+
Templates
|
| 557 |
+
~~~~~~~~~
|
| 558 |
+
|
| 559 |
+
* :tfilter:`urlize` now supports domain-only links that include characters after
|
| 560 |
+
the top-level domain (e.g. ``djangoproject.com/`` and
|
| 561 |
+
``djangoproject.com/download/``).
|
| 562 |
+
|
| 563 |
+
* :tfilter:`urlize` doesn't treat exclamation marks at the end of a domain or
|
| 564 |
+
its query string as part of the URL (the URL in e.g. ``'djangoproject.com!``
|
| 565 |
+
is ``djangoproject.com``)
|
| 566 |
+
|
| 567 |
+
* Added a :class:`locmem.Loader <django.template.loaders.locmem.Loader>`
|
| 568 |
+
class that loads Django templates from a Python dictionary.
|
| 569 |
+
|
| 570 |
+
* The :ttag:`now` tag can now store its output in a context variable with the
|
| 571 |
+
usual syntax: ``{% now 'j n Y' as varname %}``.
|
| 572 |
+
|
| 573 |
+
Requests and Responses
|
| 574 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 575 |
+
|
| 576 |
+
* ``WSGIRequest`` now respects paths starting with ``//``.
|
| 577 |
+
|
| 578 |
+
* The :meth:`HttpRequest.build_absolute_uri()
|
| 579 |
+
<django.http.HttpRequest.build_absolute_uri>` method now handles paths
|
| 580 |
+
starting with ``//`` correctly.
|
| 581 |
+
|
| 582 |
+
* If :setting:`DEBUG` is ``True`` and a request raises a
|
| 583 |
+
:exc:`~django.core.exceptions.SuspiciousOperation`, the response will be
|
| 584 |
+
rendered with a detailed error page.
|
| 585 |
+
|
| 586 |
+
* The ``query_string`` argument of :class:`~django.http.QueryDict` is now
|
| 587 |
+
optional, defaulting to ``None``, so a blank ``QueryDict`` can now be
|
| 588 |
+
instantiated with ``QueryDict()`` instead of ``QueryDict(None)`` or
|
| 589 |
+
``QueryDict('')``.
|
| 590 |
+
|
| 591 |
+
* The ``GET`` and ``POST`` attributes of an :class:`~django.http.HttpRequest`
|
| 592 |
+
object are now :class:`~django.http.QueryDict`\s rather than dictionaries,
|
| 593 |
+
and the ``FILES`` attribute is now a ``MultiValueDict``.
|
| 594 |
+
This brings this class into line with the documentation and with
|
| 595 |
+
``WSGIRequest``.
|
| 596 |
+
|
| 597 |
+
* The :attr:`HttpResponse.charset <django.http.HttpResponse.charset>` attribute
|
| 598 |
+
was added.
|
| 599 |
+
|
| 600 |
+
* ``WSGIRequestHandler`` now follows RFC in converting URI to IRI, using
|
| 601 |
+
``uri_to_iri()``.
|
| 602 |
+
|
| 603 |
+
* The :meth:`HttpRequest.get_full_path()
|
| 604 |
+
<django.http.HttpRequest.get_full_path>` method now escapes unsafe characters
|
| 605 |
+
from the path portion of a Uniform Resource Identifier (URI) properly.
|
| 606 |
+
|
| 607 |
+
* :class:`~django.http.HttpResponse` now implements a few additional methods
|
| 608 |
+
like :meth:`~django.http.HttpResponse.getvalue` so that instances can be used
|
| 609 |
+
as stream objects.
|
| 610 |
+
|
| 611 |
+
* The new :meth:`HttpResponse.setdefault()
|
| 612 |
+
<django.http.HttpResponse.setdefault>` method allows setting a header unless
|
| 613 |
+
it has already been set.
|
| 614 |
+
|
| 615 |
+
* You can use the new :class:`~django.http.FileResponse` to stream files.
|
| 616 |
+
|
| 617 |
+
* The :func:`~django.views.decorators.http.condition` decorator for
|
| 618 |
+
conditional view processing now supports the ``If-unmodified-since`` header.
|
| 619 |
+
|
| 620 |
+
Tests
|
| 621 |
+
~~~~~
|
| 622 |
+
|
| 623 |
+
* The :class:`RequestFactory.trace() <django.test.RequestFactory>`
|
| 624 |
+
and :class:`Client.trace() <django.test.Client.trace>` methods were
|
| 625 |
+
implemented, allowing you to create ``TRACE`` requests in your tests.
|
| 626 |
+
|
| 627 |
+
* The ``count`` argument was added to
|
| 628 |
+
:meth:`~django.test.SimpleTestCase.assertTemplateUsed`. This allows you to
|
| 629 |
+
assert that a template was rendered a specific number of times.
|
| 630 |
+
|
| 631 |
+
* The new :meth:`~django.test.SimpleTestCase.assertJSONNotEqual` assertion
|
| 632 |
+
allows you to test that two JSON fragments are not equal.
|
| 633 |
+
|
| 634 |
+
* Added options to the :djadmin:`test` command to preserve the test database
|
| 635 |
+
(:option:`--keepdb <test --keepdb>`), to run the test cases in reverse order
|
| 636 |
+
(:option:`--reverse <test --reverse>`), and to enable SQL logging for failing
|
| 637 |
+
tests (:option:`--debug-sql <test --debug-sql>`).
|
| 638 |
+
|
| 639 |
+
* Added the :attr:`~django.test.Response.resolver_match` attribute to test
|
| 640 |
+
client responses.
|
| 641 |
+
|
| 642 |
+
* Added several settings that allow customization of test tablespace parameters
|
| 643 |
+
for Oracle: :setting:`DATAFILE`, :setting:`DATAFILE_TMP`,
|
| 644 |
+
:setting:`DATAFILE_MAXSIZE` and :setting:`DATAFILE_TMP_MAXSIZE`.
|
| 645 |
+
|
| 646 |
+
* The :func:`~django.test.override_settings` decorator can now affect the
|
| 647 |
+
master router in :setting:`DATABASE_ROUTERS`.
|
| 648 |
+
|
| 649 |
+
* Added test client support for file uploads with file-like objects.
|
| 650 |
+
|
| 651 |
+
* A shared cache is now used when testing with an SQLite in-memory database when
|
| 652 |
+
using Python 3.4+ and SQLite 3.7.13+. This allows sharing the database
|
| 653 |
+
between threads.
|
| 654 |
+
|
| 655 |
+
Validators
|
| 656 |
+
~~~~~~~~~~
|
| 657 |
+
|
| 658 |
+
* :class:`~django.core.validators.URLValidator` now supports IPv6 addresses,
|
| 659 |
+
Unicode domains, and URLs containing authentication data.
|
| 660 |
+
|
| 661 |
+
.. _backwards-incompatible-1.8:
|
| 662 |
+
|
| 663 |
+
Backwards incompatible changes in 1.8
|
| 664 |
+
=====================================
|
| 665 |
+
|
| 666 |
+
.. warning::
|
| 667 |
+
|
| 668 |
+
In addition to the changes outlined in this section, be sure to review the
|
| 669 |
+
:ref:`deprecation plan <deprecation-removed-in-1.8>` for any features that
|
| 670 |
+
have been removed. If you haven't updated your code within the
|
| 671 |
+
deprecation timeline for a given feature, its removal may appear as a
|
| 672 |
+
backwards incompatible change.
|
| 673 |
+
|
| 674 |
+
Related object operations are run in a transaction
|
| 675 |
+
--------------------------------------------------
|
| 676 |
+
|
| 677 |
+
Some operations on related objects such as
|
| 678 |
+
:meth:`~django.db.models.fields.related.RelatedManager.add()` or direct
|
| 679 |
+
assignment ran multiple data modifying queries without wrapping them in
|
| 680 |
+
transactions. To reduce the risk of data corruption, all data modifying methods
|
| 681 |
+
that affect multiple related objects (i.e. ``add()``, ``remove()``,
|
| 682 |
+
``clear()``, and direct assignment) now perform their data modifying queries
|
| 683 |
+
from within a transaction, provided your database supports transactions.
|
| 684 |
+
|
| 685 |
+
This has one backwards incompatible side effect, signal handlers triggered from
|
| 686 |
+
these methods are now executed within the method's transaction and any
|
| 687 |
+
exception in a signal handler will prevent the whole operation.
|
| 688 |
+
|
| 689 |
+
.. _unsaved-model-instance-check-18:
|
| 690 |
+
|
| 691 |
+
Assigning unsaved objects to relations raises an error
|
| 692 |
+
------------------------------------------------------
|
| 693 |
+
|
| 694 |
+
.. note::
|
| 695 |
+
|
| 696 |
+
To more easily allow in-memory usage of models, this change was reverted in
|
| 697 |
+
Django 1.8.4 and replaced with a check during ``model.save()``. For example:
|
| 698 |
+
|
| 699 |
+
.. code-block:: pycon
|
| 700 |
+
|
| 701 |
+
>>> book = Book.objects.create(name="Django")
|
| 702 |
+
>>> book.author = Author(name="John")
|
| 703 |
+
>>> book.save()
|
| 704 |
+
Traceback (most recent call last):
|
| 705 |
+
...
|
| 706 |
+
ValueError: save() prohibited to prevent data loss due to unsaved related object 'author'.
|
| 707 |
+
|
| 708 |
+
A similar check on assignment to reverse one-to-one relations was removed
|
| 709 |
+
in Django 1.8.5.
|
| 710 |
+
|
| 711 |
+
Assigning unsaved objects to a :class:`~django.db.models.ForeignKey`,
|
| 712 |
+
:class:`~django.contrib.contenttypes.fields.GenericForeignKey`, and
|
| 713 |
+
:class:`~django.db.models.OneToOneField` now raises a :exc:`ValueError`.
|
| 714 |
+
|
| 715 |
+
Previously, the assignment of an unsaved object would be silently ignored.
|
| 716 |
+
For example:
|
| 717 |
+
|
| 718 |
+
.. code-block:: pycon
|
| 719 |
+
|
| 720 |
+
>>> book = Book.objects.create(name="Django")
|
| 721 |
+
>>> book.author = Author(name="John")
|
| 722 |
+
>>> book.author.save()
|
| 723 |
+
>>> book.save()
|
| 724 |
+
|
| 725 |
+
>>> Book.objects.get(name="Django")
|
| 726 |
+
>>> book.author
|
| 727 |
+
>>>
|
| 728 |
+
|
| 729 |
+
Now, an error will be raised to prevent data loss:
|
| 730 |
+
|
| 731 |
+
.. code-block:: pycon
|
| 732 |
+
|
| 733 |
+
>>> book.author = Author(name="john")
|
| 734 |
+
Traceback (most recent call last):
|
| 735 |
+
...
|
| 736 |
+
ValueError: Cannot assign "<Author: John>": "Author" instance isn't saved in the database.
|
| 737 |
+
|
| 738 |
+
If you require allowing the assignment of unsaved instances (the old behavior)
|
| 739 |
+
and aren't concerned about the data loss possibility (e.g. you never save the
|
| 740 |
+
objects to the database), you can disable this check by using the
|
| 741 |
+
``ForeignKey.allow_unsaved_instance_assignment`` attribute. (This attribute was
|
| 742 |
+
removed in 1.8.4 as it's no longer relevant.)
|
| 743 |
+
|
| 744 |
+
Management commands that only accept positional arguments
|
| 745 |
+
---------------------------------------------------------
|
| 746 |
+
|
| 747 |
+
If you have written a custom management command that only accepts positional
|
| 748 |
+
arguments and you didn't specify the ``args`` command variable, you might get
|
| 749 |
+
an error like ``Error: unrecognized arguments: ...``, as variable parsing is
|
| 750 |
+
now based on :py:mod:`argparse` which doesn't implicitly accept positional
|
| 751 |
+
arguments. You can make your command backwards compatible by simply setting the
|
| 752 |
+
``args`` class variable. However, if you don't have to keep compatibility with
|
| 753 |
+
older Django versions, it's better to implement the new
|
| 754 |
+
:meth:`~django.core.management.BaseCommand.add_arguments` method as described
|
| 755 |
+
in :doc:`/howto/custom-management-commands`.
|
| 756 |
+
|
| 757 |
+
Custom test management command arguments through test runner
|
| 758 |
+
------------------------------------------------------------
|
| 759 |
+
|
| 760 |
+
The method to add custom arguments to the ``test`` management command through
|
| 761 |
+
the test runner has changed. Previously, you could provide an ``option_list``
|
| 762 |
+
class variable on the test runner to add more arguments (à la
|
| 763 |
+
:py:mod:`optparse`). Now to implement the same behavior, you have to create an
|
| 764 |
+
``add_arguments(cls, parser)`` class method on the test runner and call
|
| 765 |
+
``parser.add_argument`` to add any custom arguments, as parser is now an
|
| 766 |
+
:py:class:`argparse.ArgumentParser` instance.
|
| 767 |
+
|
| 768 |
+
Model check ensures auto-generated column names are within limits specified by database
|
| 769 |
+
---------------------------------------------------------------------------------------
|
| 770 |
+
|
| 771 |
+
A field name that's longer than the column name length supported by a database
|
| 772 |
+
can create problems. For example, with MySQL you'll get an exception trying to
|
| 773 |
+
create the column, and with PostgreSQL the column name is truncated by the
|
| 774 |
+
database (you may see a warning in the PostgreSQL logs).
|
| 775 |
+
|
| 776 |
+
A model check has been introduced to better alert users to this scenario before
|
| 777 |
+
the actual creation of database tables.
|
| 778 |
+
|
| 779 |
+
If you have an existing model where this check seems to be a false positive,
|
| 780 |
+
for example on PostgreSQL where the name was already being truncated, simply
|
| 781 |
+
use :attr:`~django.db.models.Field.db_column` to specify the name that's being
|
| 782 |
+
used.
|
| 783 |
+
|
| 784 |
+
The check also applies to the columns generated in an implicit
|
| 785 |
+
``ManyToManyField.through`` model. If you run into an issue there, use
|
| 786 |
+
:attr:`~django.db.models.ManyToManyField.through` to create an explicit model
|
| 787 |
+
and then specify :attr:`~django.db.models.Field.db_column` on its column(s)
|
| 788 |
+
as needed.
|
| 789 |
+
|
| 790 |
+
Query relation lookups now check object types
|
| 791 |
+
---------------------------------------------
|
| 792 |
+
|
| 793 |
+
Querying for model lookups now checks if the object passed is of correct type
|
| 794 |
+
and raises a :exc:`ValueError` if not. Previously, Django didn't care if the
|
| 795 |
+
object was of correct type; it just used the object's related field attribute
|
| 796 |
+
(e.g. ``id``) for the lookup. Now, an error is raised to prevent incorrect
|
| 797 |
+
lookups:
|
| 798 |
+
|
| 799 |
+
.. code-block:: pycon
|
| 800 |
+
|
| 801 |
+
>>> book = Book.objects.create(name="Django")
|
| 802 |
+
>>> book = Book.objects.filter(author=book)
|
| 803 |
+
Traceback (most recent call last):
|
| 804 |
+
...
|
| 805 |
+
ValueError: Cannot query "<Book: Django>": Must be "Author" instance.
|
| 806 |
+
|
| 807 |
+
``select_related()`` now checks given fields
|
| 808 |
+
--------------------------------------------
|
| 809 |
+
|
| 810 |
+
``select_related()`` now validates that the given fields actually exist.
|
| 811 |
+
Previously, nonexistent fields were silently ignored. Now, an error is raised:
|
| 812 |
+
|
| 813 |
+
.. code-block:: pycon
|
| 814 |
+
|
| 815 |
+
>>> book = Book.objects.select_related("nonexistent_field")
|
| 816 |
+
Traceback (most recent call last):
|
| 817 |
+
...
|
| 818 |
+
FieldError: Invalid field name(s) given in select_related: 'nonexistent_field'
|
| 819 |
+
|
| 820 |
+
The validation also makes sure that the given field is relational:
|
| 821 |
+
|
| 822 |
+
.. code-block:: pycon
|
| 823 |
+
|
| 824 |
+
>>> book = Book.objects.select_related("name")
|
| 825 |
+
Traceback (most recent call last):
|
| 826 |
+
...
|
| 827 |
+
FieldError: Non-relational field given in select_related: 'name'
|
| 828 |
+
|
| 829 |
+
Default ``EmailField.max_length`` increased to 254
|
| 830 |
+
--------------------------------------------------
|
| 831 |
+
|
| 832 |
+
The old default 75 character ``max_length`` was not capable of storing all
|
| 833 |
+
possible RFC3696/5321-compliant email addresses. In order to store all
|
| 834 |
+
possible valid email addresses, the ``max_length`` has been increased to 254
|
| 835 |
+
characters. You will need to generate and apply database migrations for your
|
| 836 |
+
affected models (or add ``max_length=75`` if you wish to keep the length on
|
| 837 |
+
your current fields). A migration for
|
| 838 |
+
:attr:`django.contrib.auth.models.User.email` is included.
|
| 839 |
+
|
| 840 |
+
Support for PostgreSQL versions older than 9.0
|
| 841 |
+
----------------------------------------------
|
| 842 |
+
|
| 843 |
+
The end of upstream support periods was reached in July 2014 for PostgreSQL 8.4.
|
| 844 |
+
As a consequence, Django 1.8 sets 9.0 as the minimum PostgreSQL version it
|
| 845 |
+
officially supports.
|
| 846 |
+
|
| 847 |
+
This also includes dropping support for PostGIS 1.3 and 1.4 as these versions
|
| 848 |
+
are not supported on versions of PostgreSQL later than 8.4.
|
| 849 |
+
|
| 850 |
+
Django also now requires the use of Psycopg2 version 2.4.5 or higher (or 2.5+
|
| 851 |
+
if you want to use :mod:`django.contrib.postgres`).
|
| 852 |
+
|
| 853 |
+
Support for MySQL versions older than 5.5
|
| 854 |
+
-----------------------------------------
|
| 855 |
+
|
| 856 |
+
The end of upstream support periods was reached in January 2012 for MySQL 5.0
|
| 857 |
+
and December 2013 for MySQL 5.1. As a consequence, Django 1.8 sets 5.5 as the
|
| 858 |
+
minimum MySQL version it officially supports.
|
| 859 |
+
|
| 860 |
+
Support for Oracle versions older than 11.1
|
| 861 |
+
-------------------------------------------
|
| 862 |
+
|
| 863 |
+
The end of upstream support periods was reached in July 2010 for Oracle 9.2,
|
| 864 |
+
January 2012 for Oracle 10.1, and July 2013 for Oracle 10.2. As a consequence,
|
| 865 |
+
Django 1.8 sets 11.1 as the minimum Oracle version it officially supports.
|
| 866 |
+
|
| 867 |
+
Specific privileges used instead of roles for tests on Oracle
|
| 868 |
+
-------------------------------------------------------------
|
| 869 |
+
|
| 870 |
+
Earlier versions of Django granted the CONNECT and RESOURCE roles to the test
|
| 871 |
+
user on Oracle. These roles have been deprecated, so Django 1.8 uses the
|
| 872 |
+
specific underlying privileges instead. This changes the privileges required
|
| 873 |
+
of the main user for running tests (unless the project is configured to avoid
|
| 874 |
+
creating a test user). The exact privileges required now are detailed in
|
| 875 |
+
:ref:`Oracle notes <oracle-notes>`.
|
| 876 |
+
|
| 877 |
+
``AbstractUser.last_login`` allows null values
|
| 878 |
+
----------------------------------------------
|
| 879 |
+
|
| 880 |
+
The :attr:`AbstractUser.last_login <django.contrib.auth.models.User.last_login>`
|
| 881 |
+
field now allows null values. Previously, it defaulted to the time when the user
|
| 882 |
+
was created which was misleading if the user never logged in. If you are using
|
| 883 |
+
the default user (:class:`django.contrib.auth.models.User`), run the database
|
| 884 |
+
migration included in ``contrib.auth``.
|
| 885 |
+
|
| 886 |
+
If you are using a custom user model that inherits from ``AbstractUser``,
|
| 887 |
+
you'll need to run :djadmin:`makemigrations` and generate a migration for your
|
| 888 |
+
app that contains that model. Also, if wish to set ``last_login`` to ``NULL``
|
| 889 |
+
for users who haven't logged in, you can run this query::
|
| 890 |
+
|
| 891 |
+
from django.db import models
|
| 892 |
+
from django.contrib.auth import get_user_model
|
| 893 |
+
from django.contrib.auth.models import AbstractBaseUser
|
| 894 |
+
|
| 895 |
+
UserModel = get_user_model()
|
| 896 |
+
if issubclass(UserModel, AbstractBaseUser):
|
| 897 |
+
UserModel._default_manager.filter(last_login=models.F("date_joined")).update(
|
| 898 |
+
last_login=None
|
| 899 |
+
)
|
| 900 |
+
|
| 901 |
+
:mod:`django.contrib.gis`
|
| 902 |
+
-------------------------
|
| 903 |
+
|
| 904 |
+
* Support for GEOS 3.1 and GDAL 1.6 has been dropped.
|
| 905 |
+
|
| 906 |
+
* Support for SpatiaLite < 2.4 has been dropped.
|
| 907 |
+
|
| 908 |
+
* GIS-specific lookups have been refactored to use the
|
| 909 |
+
:class:`django.db.models.Lookup` API.
|
| 910 |
+
|
| 911 |
+
* The default ``str`` representation of
|
| 912 |
+
:class:`~django.contrib.gis.geos.GEOSGeometry` objects has been changed from
|
| 913 |
+
WKT to EWKT format (including the SRID). As this representation is used in
|
| 914 |
+
the serialization framework, that means that ``dumpdata`` output will now
|
| 915 |
+
contain the SRID value of geometry objects.
|
| 916 |
+
|
| 917 |
+
Priority of context processors for ``TemplateResponse`` brought in line with ``render``
|
| 918 |
+
---------------------------------------------------------------------------------------
|
| 919 |
+
|
| 920 |
+
The :class:`~django.template.response.TemplateResponse` constructor is designed to be a
|
| 921 |
+
drop-in replacement for the :func:`~django.shortcuts.render` function. However,
|
| 922 |
+
it had a slight incompatibility, in that for ``TemplateResponse``, context data
|
| 923 |
+
from the passed in context dictionary could be shadowed by context data returned
|
| 924 |
+
from context processors, whereas for ``render`` it was the other way
|
| 925 |
+
around. This was a bug, and the behavior of ``render`` is more appropriate,
|
| 926 |
+
since it allows the globally defined context processors to be overridden locally
|
| 927 |
+
in the view. If you were relying on the fact context data in a
|
| 928 |
+
``TemplateResponse`` could be overridden using a context processor, you will
|
| 929 |
+
need to change your code.
|
| 930 |
+
|
| 931 |
+
Overriding ``setUpClass`` / ``tearDownClass`` in test cases
|
| 932 |
+
-----------------------------------------------------------
|
| 933 |
+
|
| 934 |
+
The decorators :func:`~django.test.override_settings` and
|
| 935 |
+
:func:`~django.test.modify_settings` now act at the class level when used as
|
| 936 |
+
class decorators. As a consequence, when overriding ``setUpClass()`` or
|
| 937 |
+
``tearDownClass()``, the ``super`` implementation should always be called.
|
| 938 |
+
|
| 939 |
+
Removal of ``django.contrib.formtools``
|
| 940 |
+
---------------------------------------
|
| 941 |
+
|
| 942 |
+
The formtools contrib app has been moved to a separate package and the
|
| 943 |
+
relevant documentation pages have been updated or removed.
|
| 944 |
+
|
| 945 |
+
The new package is available `on GitHub`_ and on PyPI.
|
| 946 |
+
|
| 947 |
+
.. _on GitHub: https://github.com/jazzband/django-formtools/
|
| 948 |
+
|
| 949 |
+
Database connection reloading between tests
|
| 950 |
+
-------------------------------------------
|
| 951 |
+
|
| 952 |
+
Django previously closed database connections between each test within a
|
| 953 |
+
``TestCase``. This is no longer the case as Django now wraps the whole
|
| 954 |
+
``TestCase`` within a transaction. If some of your tests relied on the old
|
| 955 |
+
behavior, you should have them inherit from ``TransactionTestCase`` instead.
|
| 956 |
+
|
| 957 |
+
Cleanup of the ``django.template`` namespace
|
| 958 |
+
--------------------------------------------
|
| 959 |
+
|
| 960 |
+
If you've been relying on private APIs exposed in the ``django.template``
|
| 961 |
+
module, you may have to import them from ``django.template.base`` instead.
|
| 962 |
+
|
| 963 |
+
Also private APIs ``django.template.base.compile_string()``,
|
| 964 |
+
``django.template.loader.find_template()``, and
|
| 965 |
+
``django.template.loader.get_template_from_string()`` were removed.
|
| 966 |
+
|
| 967 |
+
``model`` attribute on private model relations
|
| 968 |
+
----------------------------------------------
|
| 969 |
+
|
| 970 |
+
In earlier versions of Django, on a model with a reverse foreign key
|
| 971 |
+
relationship (for example), ``model._meta.get_all_related_objects()`` returned
|
| 972 |
+
the relationship as a ``django.db.models.related.RelatedObject`` with the
|
| 973 |
+
``model`` attribute set to the source of the relationship. Now, this method
|
| 974 |
+
returns the relationship as ``django.db.models.fields.related.ManyToOneRel``
|
| 975 |
+
(private API ``RelatedObject`` has been removed), and the ``model`` attribute
|
| 976 |
+
is set to the target of the relationship instead of the source. The source
|
| 977 |
+
model is accessible on the ``related_model`` attribute instead.
|
| 978 |
+
|
| 979 |
+
Consider this example from the tutorial in Django 1.8:
|
| 980 |
+
|
| 981 |
+
.. code-block:: pycon
|
| 982 |
+
|
| 983 |
+
>>> p = Poll.objects.get(pk=1)
|
| 984 |
+
>>> p._meta.get_all_related_objects()
|
| 985 |
+
[<ManyToOneRel: polls.choice>]
|
| 986 |
+
>>> p._meta.get_all_related_objects()[0].model
|
| 987 |
+
<class 'polls.models.Poll'>
|
| 988 |
+
>>> p._meta.get_all_related_objects()[0].related_model
|
| 989 |
+
<class 'polls.models.Choice'>
|
| 990 |
+
|
| 991 |
+
and compare it to the behavior on older versions:
|
| 992 |
+
|
| 993 |
+
.. code-block:: pycon
|
| 994 |
+
|
| 995 |
+
>>> p._meta.get_all_related_objects()
|
| 996 |
+
[<RelatedObject: polls:choice related to poll>]
|
| 997 |
+
>>> p._meta.get_all_related_objects()[0].model
|
| 998 |
+
<class 'polls.models.Choice'>
|
| 999 |
+
|
| 1000 |
+
To access the source model, you can use a pattern like this to write code that
|
| 1001 |
+
will work with both Django 1.8 and older versions::
|
| 1002 |
+
|
| 1003 |
+
for relation in opts.get_all_related_objects():
|
| 1004 |
+
to_model = getattr(relation, "related_model", relation.model)
|
| 1005 |
+
|
| 1006 |
+
Also note that ``get_all_related_objects()`` is deprecated in 1.8.
|
| 1007 |
+
|
| 1008 |
+
Database backend API
|
| 1009 |
+
--------------------
|
| 1010 |
+
|
| 1011 |
+
The following changes to the database backend API are documented to assist
|
| 1012 |
+
those writing third-party backends in updating their code:
|
| 1013 |
+
|
| 1014 |
+
* ``BaseDatabaseXXX`` classes have been moved to ``django.db.backends.base``.
|
| 1015 |
+
Please import them from the new locations::
|
| 1016 |
+
|
| 1017 |
+
from django.db.backends.base.base import BaseDatabaseWrapper
|
| 1018 |
+
from django.db.backends.base.client import BaseDatabaseClient
|
| 1019 |
+
from django.db.backends.base.creation import BaseDatabaseCreation
|
| 1020 |
+
from django.db.backends.base.features import BaseDatabaseFeatures
|
| 1021 |
+
from django.db.backends.base.introspection import BaseDatabaseIntrospection
|
| 1022 |
+
from django.db.backends.base.introspection import FieldInfo, TableInfo
|
| 1023 |
+
from django.db.backends.base.operations import BaseDatabaseOperations
|
| 1024 |
+
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
| 1025 |
+
from django.db.backends.base.validation import BaseDatabaseValidation
|
| 1026 |
+
|
| 1027 |
+
* The ``data_types``, ``data_types_suffix``, and
|
| 1028 |
+
``data_type_check_constraints`` attributes have moved from the
|
| 1029 |
+
``DatabaseCreation`` class to ``DatabaseWrapper``.
|
| 1030 |
+
|
| 1031 |
+
* The ``SQLCompiler.as_sql()`` method now takes a ``subquery`` parameter
|
| 1032 |
+
(:ticket:`24164`).
|
| 1033 |
+
|
| 1034 |
+
* The ``BaseDatabaseOperations.date_interval_sql()`` method now only takes a
|
| 1035 |
+
``timedelta`` parameter.
|
| 1036 |
+
|
| 1037 |
+
:mod:`django.contrib.admin`
|
| 1038 |
+
---------------------------
|
| 1039 |
+
|
| 1040 |
+
* ``AdminSite`` no longer takes an ``app_name`` argument and its ``app_name``
|
| 1041 |
+
attribute has been removed. The application name is always ``admin`` (as
|
| 1042 |
+
opposed to the instance name which you can still customize using
|
| 1043 |
+
``AdminSite(name="...")``.
|
| 1044 |
+
|
| 1045 |
+
* The ``ModelAdmin.get_object()`` method (private API) now takes a third
|
| 1046 |
+
argument named ``from_field`` in order to specify which field should match
|
| 1047 |
+
the provided ``object_id``.
|
| 1048 |
+
|
| 1049 |
+
* The :meth:`ModelAdmin.response_delete()
|
| 1050 |
+
<django.contrib.admin.ModelAdmin.response_delete>` method
|
| 1051 |
+
now takes a second argument named ``obj_id`` which is the serialized
|
| 1052 |
+
identifier used to retrieve the object before deletion.
|
| 1053 |
+
|
| 1054 |
+
Default autoescaping of functions in ``django.template.defaultfilters``
|
| 1055 |
+
-----------------------------------------------------------------------
|
| 1056 |
+
|
| 1057 |
+
In order to make built-in template filters that output HTML "safe by default"
|
| 1058 |
+
when calling them in Python code, the following functions in
|
| 1059 |
+
``django.template.defaultfilters`` have been changed to automatically escape
|
| 1060 |
+
their input value:
|
| 1061 |
+
|
| 1062 |
+
* ``join``
|
| 1063 |
+
* ``linebreaksbr``
|
| 1064 |
+
* ``linebreaks_filter``
|
| 1065 |
+
* ``linenumbers``
|
| 1066 |
+
* ``unordered_list``
|
| 1067 |
+
* ``urlize``
|
| 1068 |
+
* ``urlizetrunc``
|
| 1069 |
+
|
| 1070 |
+
You can revert to the old behavior by specifying ``autoescape=False`` if you
|
| 1071 |
+
are passing trusted content. This change doesn't have any effect when using
|
| 1072 |
+
the corresponding filters in templates.
|
| 1073 |
+
|
| 1074 |
+
Miscellaneous
|
| 1075 |
+
-------------
|
| 1076 |
+
|
| 1077 |
+
* ``connections.queries`` is now a read-only attribute.
|
| 1078 |
+
|
| 1079 |
+
* Database connections are considered equal only if they're the same object.
|
| 1080 |
+
They aren't hashable any more.
|
| 1081 |
+
|
| 1082 |
+
* :class:`~django.middleware.gzip.GZipMiddleware` used to disable compression
|
| 1083 |
+
for some content types when the request is from Internet Explorer, in order
|
| 1084 |
+
to work around a bug in IE6 and earlier. This behavior could affect
|
| 1085 |
+
performance on IE7 and later. It was removed.
|
| 1086 |
+
|
| 1087 |
+
* ``URLField.to_python`` no longer adds a trailing slash to pathless URLs.
|
| 1088 |
+
|
| 1089 |
+
* The :tfilter:`length` template filter now returns ``0`` for an undefined
|
| 1090 |
+
variable, rather than an empty string.
|
| 1091 |
+
|
| 1092 |
+
* ``ForeignKey.default_error_message['invalid']`` has been changed from
|
| 1093 |
+
``'%(model)s instance with pk %(pk)r does not exist.'`` to
|
| 1094 |
+
``'%(model)s instance with %(field)s %(value)r does not exist.'`` If you are
|
| 1095 |
+
using this message in your own code, please update the list of interpolated
|
| 1096 |
+
parameters. Internally, Django will continue to provide the
|
| 1097 |
+
``pk`` parameter in ``params`` for backwards compatibility.
|
| 1098 |
+
|
| 1099 |
+
* ``UserCreationForm.error_messages['duplicate_username']`` is no longer used.
|
| 1100 |
+
If you wish to customize that error message, :ref:`override it on the form
|
| 1101 |
+
<modelforms-overriding-default-fields>` using the ``'unique'`` key in
|
| 1102 |
+
``Meta.error_messages['username']`` or, if you have a custom form field for
|
| 1103 |
+
``'username'``, using the ``'unique'`` key in its
|
| 1104 |
+
:attr:`~django.forms.Field.error_messages` argument.
|
| 1105 |
+
|
| 1106 |
+
* The block ``usertools`` in the ``base.html`` template of
|
| 1107 |
+
:mod:`django.contrib.admin` now requires the ``has_permission`` context
|
| 1108 |
+
variable to be set. If you have any custom admin views that use this
|
| 1109 |
+
template, update them to pass :meth:`AdminSite.has_permission()
|
| 1110 |
+
<django.contrib.admin.AdminSite.has_permission>` as this new variable's
|
| 1111 |
+
value or simply include :meth:`AdminSite.each_context(request)
|
| 1112 |
+
<django.contrib.admin.AdminSite.each_context>` in the context.
|
| 1113 |
+
|
| 1114 |
+
* Internal changes were made to the :class:`~django.forms.ClearableFileInput`
|
| 1115 |
+
widget to allow more customization. The undocumented ``url_markup_template``
|
| 1116 |
+
attribute was removed in favor of ``template_with_initial``.
|
| 1117 |
+
|
| 1118 |
+
* For consistency with other major vendors, the ``en_GB`` locale now has Monday
|
| 1119 |
+
as the first day of the week.
|
| 1120 |
+
|
| 1121 |
+
* Seconds have been removed from any locales that had them in ``TIME_FORMAT``,
|
| 1122 |
+
``DATETIME_FORMAT``, or ``SHORT_DATETIME_FORMAT``.
|
| 1123 |
+
|
| 1124 |
+
* The default max size of the Oracle test tablespace has increased from 300M
|
| 1125 |
+
(or 200M, before 1.7.2) to 500M.
|
| 1126 |
+
|
| 1127 |
+
* ``reverse()`` and ``reverse_lazy()`` now return Unicode strings instead of
|
| 1128 |
+
bytestrings.
|
| 1129 |
+
|
| 1130 |
+
* The ``CacheClass`` shim has been removed from all cache backends.
|
| 1131 |
+
These aliases were provided for backwards compatibility with Django 1.3.
|
| 1132 |
+
If you are still using them, please update your project to use the real
|
| 1133 |
+
class name found in the :setting:`BACKEND <CACHES-BACKEND>` key of the
|
| 1134 |
+
:setting:`CACHES` setting.
|
| 1135 |
+
|
| 1136 |
+
* By default, :func:`~django.core.management.call_command` now always skips the
|
| 1137 |
+
check framework (unless you pass it ``skip_checks=False``).
|
| 1138 |
+
|
| 1139 |
+
* When iterating over lines, :class:`~django.core.files.File` now uses
|
| 1140 |
+
:pep:`universal newlines <278>`. The following are recognized as ending a
|
| 1141 |
+
line: the Unix end-of-line convention ``'\n'``, the Windows convention
|
| 1142 |
+
``'\r\n'``, and the old Macintosh convention ``'\r'``.
|
| 1143 |
+
|
| 1144 |
+
* The Memcached cache backends ``MemcachedCache`` and ``PyLibMCCache`` will
|
| 1145 |
+
delete a key if ``set()`` fails. This is necessary to ensure the ``cache_db``
|
| 1146 |
+
session store always fetches the most current session data.
|
| 1147 |
+
|
| 1148 |
+
* Private APIs ``override_template_loaders`` and ``override_with_test_loader``
|
| 1149 |
+
in ``django.test.utils`` were removed. Override ``TEMPLATES`` with
|
| 1150 |
+
``override_settings`` instead.
|
| 1151 |
+
|
| 1152 |
+
* Warnings from the MySQL database backend are no longer converted to
|
| 1153 |
+
exceptions when :setting:`DEBUG` is ``True``.
|
| 1154 |
+
|
| 1155 |
+
* :class:`~django.http.HttpRequest` now has a simplified ``repr`` (e.g.
|
| 1156 |
+
``<WSGIRequest: GET '/somepath/'>``). This won't change the behavior of
|
| 1157 |
+
the :class:`~django.views.debug.SafeExceptionReporterFilter` class.
|
| 1158 |
+
|
| 1159 |
+
* Class-based views that use :class:`~django.views.generic.edit.ModelFormMixin`
|
| 1160 |
+
will raise an :exc:`~django.core.exceptions.ImproperlyConfigured` exception
|
| 1161 |
+
when both the ``fields`` and ``form_class`` attributes are specified.
|
| 1162 |
+
Previously, ``fields`` was silently ignored.
|
| 1163 |
+
|
| 1164 |
+
* When following redirects, the test client now raises
|
| 1165 |
+
:exc:`~django.test.client.RedirectCycleError` if it detects a loop or hits a
|
| 1166 |
+
maximum redirect limit (rather than passing silently).
|
| 1167 |
+
|
| 1168 |
+
* Translatable strings set as the ``default`` parameter of the field are cast
|
| 1169 |
+
to concrete strings later, so the return type of ``Field.get_default()`` is
|
| 1170 |
+
different in some cases. There is no change to default values which are the
|
| 1171 |
+
result of a callable.
|
| 1172 |
+
|
| 1173 |
+
* ``GenericIPAddressField.empty_strings_allowed`` is now ``False``. Database
|
| 1174 |
+
backends that interpret empty strings as null (only Oracle among the backends
|
| 1175 |
+
that Django includes) will no longer convert null values back to an empty
|
| 1176 |
+
string. This is consistent with other backends.
|
| 1177 |
+
|
| 1178 |
+
* When the ``BaseCommand.leave_locale_alone``
|
| 1179 |
+
attribute is ``False``, translations are now deactivated instead of forcing
|
| 1180 |
+
the "en-us" locale. In the case your models contained non-English strings and
|
| 1181 |
+
you counted on English translations to be activated in management commands,
|
| 1182 |
+
this will not happen any longer. It might be that new database migrations are
|
| 1183 |
+
generated (once) after migrating to 1.8.
|
| 1184 |
+
|
| 1185 |
+
* :func:`django.utils.translation.get_language()` now returns ``None`` instead
|
| 1186 |
+
of :setting:`LANGUAGE_CODE` when translations are temporarily deactivated.
|
| 1187 |
+
|
| 1188 |
+
* When a translation doesn't exist for a specific literal, the fallback is now
|
| 1189 |
+
taken from the :setting:`LANGUAGE_CODE` language (instead of from the
|
| 1190 |
+
untranslated ``msgid`` message).
|
| 1191 |
+
|
| 1192 |
+
* The ``name`` field of :class:`django.contrib.contenttypes.models.ContentType`
|
| 1193 |
+
has been removed by a migration and replaced by a property. That means it's
|
| 1194 |
+
not possible to query or filter a ``ContentType`` by this field any longer.
|
| 1195 |
+
|
| 1196 |
+
Be careful if you upgrade to Django 1.8 and skip Django 1.7. If you run
|
| 1197 |
+
``manage.py migrate --fake``, this migration will be skipped and you'll see
|
| 1198 |
+
a ``RuntimeError: Error creating new content types.`` exception because the
|
| 1199 |
+
``name`` column won't be dropped from the database. Use ``manage.py migrate
|
| 1200 |
+
--fake-initial`` to fake only the initial migration instead.
|
| 1201 |
+
|
| 1202 |
+
* The new :option:`migrate --fake-initial` option allows faking initial
|
| 1203 |
+
migrations. In 1.7, initial migrations were always automatically faked if all
|
| 1204 |
+
tables created in an initial migration already existed.
|
| 1205 |
+
|
| 1206 |
+
* An app *without* migrations with a ``ForeignKey`` to an app *with* migrations
|
| 1207 |
+
may now result in a foreign key constraint error when migrating the database
|
| 1208 |
+
or running tests. In Django 1.7, this could fail silently and result in a
|
| 1209 |
+
missing constraint. To resolve the error, add migrations to the app without
|
| 1210 |
+
them.
|
| 1211 |
+
|
| 1212 |
+
.. _deprecated-features-1.8:
|
| 1213 |
+
|
| 1214 |
+
Features deprecated in 1.8
|
| 1215 |
+
==========================
|
| 1216 |
+
|
| 1217 |
+
Selected methods in ``django.db.models.options.Options``
|
| 1218 |
+
--------------------------------------------------------
|
| 1219 |
+
|
| 1220 |
+
As part of the formalization of the ``Model._meta`` API (from the
|
| 1221 |
+
:class:`django.db.models.options.Options` class), a number of methods have been
|
| 1222 |
+
deprecated and will be removed in Django 1.10:
|
| 1223 |
+
|
| 1224 |
+
* ``get_all_field_names()``
|
| 1225 |
+
* ``get_all_related_objects()``
|
| 1226 |
+
* ``get_all_related_objects_with_model()``
|
| 1227 |
+
* ``get_all_related_many_to_many_objects()``
|
| 1228 |
+
* ``get_all_related_m2m_objects_with_model()``
|
| 1229 |
+
* ``get_concrete_fields_with_model()``
|
| 1230 |
+
* ``get_field_by_name()``
|
| 1231 |
+
* ``get_fields_with_model()``
|
| 1232 |
+
* ``get_m2m_with_model()``
|
| 1233 |
+
|
| 1234 |
+
Loading ``cycle`` and ``firstof`` template tags from ``future`` library
|
| 1235 |
+
-----------------------------------------------------------------------
|
| 1236 |
+
|
| 1237 |
+
Django 1.6 introduced ``{% load cycle from future %}`` and
|
| 1238 |
+
``{% load firstof from future %}`` syntax for forward compatibility of the
|
| 1239 |
+
:ttag:`cycle` and :ttag:`firstof` template tags. This syntax is now deprecated
|
| 1240 |
+
and will be removed in Django 1.10. You can simply remove the
|
| 1241 |
+
``{% load ... from future %}`` tags.
|
| 1242 |
+
|
| 1243 |
+
``django.conf.urls.patterns()``
|
| 1244 |
+
-------------------------------
|
| 1245 |
+
|
| 1246 |
+
In the olden days of Django, it was encouraged to reference views as strings
|
| 1247 |
+
in ``urlpatterns``::
|
| 1248 |
+
|
| 1249 |
+
urlpatterns = patterns(
|
| 1250 |
+
"",
|
| 1251 |
+
url("^$", "myapp.views.myview"),
|
| 1252 |
+
)
|
| 1253 |
+
|
| 1254 |
+
and Django would magically import ``myapp.views.myview`` internally and turn
|
| 1255 |
+
the string into a real function reference. In order to reduce repetition when
|
| 1256 |
+
referencing many views from the same module, the ``patterns()`` function takes
|
| 1257 |
+
a required initial ``prefix`` argument which is prepended to all
|
| 1258 |
+
views-as-strings in that set of ``urlpatterns``::
|
| 1259 |
+
|
| 1260 |
+
urlpatterns = patterns(
|
| 1261 |
+
"myapp.views",
|
| 1262 |
+
url("^$", "myview"),
|
| 1263 |
+
url("^other/$", "otherview"),
|
| 1264 |
+
)
|
| 1265 |
+
|
| 1266 |
+
In the modern era, we have updated the tutorial to instead recommend importing
|
| 1267 |
+
your views module and referencing your view functions (or classes) directly.
|
| 1268 |
+
This has a number of advantages, all deriving from the fact that we are using
|
| 1269 |
+
normal Python in place of "Django String Magic": the errors when you mistype a
|
| 1270 |
+
view name are less obscure, IDEs can help with autocompletion of view names,
|
| 1271 |
+
etc.
|
| 1272 |
+
|
| 1273 |
+
So these days, the above use of the ``prefix`` arg is much more likely to be
|
| 1274 |
+
written (and is better written) as::
|
| 1275 |
+
|
| 1276 |
+
from myapp import views
|
| 1277 |
+
|
| 1278 |
+
urlpatterns = patterns(
|
| 1279 |
+
"",
|
| 1280 |
+
url("^$", views.myview),
|
| 1281 |
+
url("^other/$", views.otherview),
|
| 1282 |
+
)
|
| 1283 |
+
|
| 1284 |
+
Thus ``patterns()`` serves little purpose and is a burden when teaching new users
|
| 1285 |
+
(answering the newbie's question "why do I need this empty string as the first
|
| 1286 |
+
argument to ``patterns()``?"). For these reasons, we are deprecating it.
|
| 1287 |
+
Updating your code is as simple as ensuring that ``urlpatterns`` is a list of
|
| 1288 |
+
``django.conf.urls.url()`` instances. For example::
|
| 1289 |
+
|
| 1290 |
+
from django.conf.urls import url
|
| 1291 |
+
from myapp import views
|
| 1292 |
+
|
| 1293 |
+
urlpatterns = [
|
| 1294 |
+
url("^$", views.myview),
|
| 1295 |
+
url("^other/$", views.otherview),
|
| 1296 |
+
]
|
| 1297 |
+
|
| 1298 |
+
Passing a string as ``view`` to ``django.conf.urls.url()``
|
| 1299 |
+
----------------------------------------------------------
|
| 1300 |
+
|
| 1301 |
+
Related to the previous item, referencing views as strings in the ``url()``
|
| 1302 |
+
function is deprecated. Pass the callable view as described in the previous
|
| 1303 |
+
section instead.
|
| 1304 |
+
|
| 1305 |
+
Template-related settings
|
| 1306 |
+
-------------------------
|
| 1307 |
+
|
| 1308 |
+
As a consequence of the multiple template engines refactor, several settings
|
| 1309 |
+
are deprecated in favor of :setting:`TEMPLATES`:
|
| 1310 |
+
|
| 1311 |
+
* ``ALLOWED_INCLUDE_ROOTS``
|
| 1312 |
+
* ``TEMPLATE_CONTEXT_PROCESSORS``
|
| 1313 |
+
* ``TEMPLATE_DEBUG``
|
| 1314 |
+
* ``TEMPLATE_DIRS``
|
| 1315 |
+
* ``TEMPLATE_LOADERS``
|
| 1316 |
+
* ``TEMPLATE_STRING_IF_INVALID``
|
| 1317 |
+
|
| 1318 |
+
``django.core.context_processors``
|
| 1319 |
+
----------------------------------
|
| 1320 |
+
|
| 1321 |
+
Built-in template context processors have been moved to
|
| 1322 |
+
``django.template.context_processors``.
|
| 1323 |
+
|
| 1324 |
+
``django.test.SimpleTestCase.urls``
|
| 1325 |
+
-----------------------------------
|
| 1326 |
+
|
| 1327 |
+
The attribute ``SimpleTestCase.urls`` for specifying URLconf configuration in
|
| 1328 |
+
tests has been deprecated and will be removed in Django 1.10. Use
|
| 1329 |
+
:func:`@override_settings(ROOT_URLCONF=...) <django.test.override_settings>`
|
| 1330 |
+
instead.
|
| 1331 |
+
|
| 1332 |
+
``prefix`` argument to :func:`~django.conf.urls.i18n.i18n_patterns`
|
| 1333 |
+
-------------------------------------------------------------------
|
| 1334 |
+
|
| 1335 |
+
Related to the previous item, the ``prefix`` argument to
|
| 1336 |
+
:func:`django.conf.urls.i18n.i18n_patterns` has been deprecated. Simply pass a
|
| 1337 |
+
list of ``django.conf.urls.url()`` instances instead.
|
| 1338 |
+
|
| 1339 |
+
Using an incorrect count of unpacked values in the :ttag:`for` template tag
|
| 1340 |
+
---------------------------------------------------------------------------
|
| 1341 |
+
|
| 1342 |
+
Using an incorrect count of unpacked values in :ttag:`for` tag will raise an
|
| 1343 |
+
exception rather than fail silently in Django 1.10.
|
| 1344 |
+
|
| 1345 |
+
Passing a dotted path to ``reverse()`` and :ttag:`url`
|
| 1346 |
+
------------------------------------------------------
|
| 1347 |
+
|
| 1348 |
+
Reversing URLs by Python path is an expensive operation as it causes the
|
| 1349 |
+
path being reversed to be imported. This behavior has also resulted in a
|
| 1350 |
+
`security issue`_. Use :ref:`named URL patterns <naming-url-patterns>`
|
| 1351 |
+
for reversing instead.
|
| 1352 |
+
|
| 1353 |
+
If you are using :mod:`django.contrib.sitemaps`, add the ``name`` argument to
|
| 1354 |
+
the ``url`` that references :func:`django.contrib.sitemaps.views.sitemap`::
|
| 1355 |
+
|
| 1356 |
+
from django.contrib.sitemaps.views import sitemap
|
| 1357 |
+
|
| 1358 |
+
url(
|
| 1359 |
+
r"^sitemap\.xml$",
|
| 1360 |
+
sitemap,
|
| 1361 |
+
{"sitemaps": sitemaps},
|
| 1362 |
+
name="django.contrib.sitemaps.views.sitemap",
|
| 1363 |
+
)
|
| 1364 |
+
|
| 1365 |
+
to ensure compatibility when reversing by Python path is removed in Django 1.10.
|
| 1366 |
+
|
| 1367 |
+
Similarly for GIS sitemaps, add ``name='django.contrib.gis.sitemaps.views.kml'``
|
| 1368 |
+
or ``name='django.contrib.gis.sitemaps.views.kmz'``.
|
| 1369 |
+
|
| 1370 |
+
If you are using a Python path for the :setting:`LOGIN_URL` or
|
| 1371 |
+
:setting:`LOGIN_REDIRECT_URL` setting, use the name of the ``url()`` instead.
|
| 1372 |
+
|
| 1373 |
+
.. _security issue: https://www.djangoproject.com/weblog/2014/apr/21/security/#s-issue-unexpected-code-execution-using-reverse
|
| 1374 |
+
|
| 1375 |
+
Aggregate methods and modules
|
| 1376 |
+
-----------------------------
|
| 1377 |
+
|
| 1378 |
+
The ``django.db.models.sql.aggregates`` and
|
| 1379 |
+
``django.contrib.gis.db.models.sql.aggregates`` modules (both private API), have
|
| 1380 |
+
been deprecated as ``django.db.models.aggregates`` and
|
| 1381 |
+
``django.contrib.gis.db.models.aggregates`` are now also responsible
|
| 1382 |
+
for SQL generation. The old modules will be removed in Django 1.10.
|
| 1383 |
+
|
| 1384 |
+
If you were using the old modules, see :doc:`Query Expressions
|
| 1385 |
+
</ref/models/expressions>` for instructions on rewriting custom aggregates
|
| 1386 |
+
using the new stable API.
|
| 1387 |
+
|
| 1388 |
+
The following methods and properties of ``django.db.models.sql.query.Query``
|
| 1389 |
+
have also been deprecated and the backwards compatibility shims will be removed
|
| 1390 |
+
in Django 1.10:
|
| 1391 |
+
|
| 1392 |
+
* ``Query.aggregates``, replaced by ``annotations``.
|
| 1393 |
+
* ``Query.aggregate_select``, replaced by ``annotation_select``.
|
| 1394 |
+
* ``Query.add_aggregate()``, replaced by ``add_annotation()``.
|
| 1395 |
+
* ``Query.set_aggregate_mask()``, replaced by ``set_annotation_mask()``.
|
| 1396 |
+
* ``Query.append_aggregate_mask()``, replaced by ``append_annotation_mask()``.
|
| 1397 |
+
|
| 1398 |
+
Extending management command arguments through ``Command.option_list``
|
| 1399 |
+
----------------------------------------------------------------------
|
| 1400 |
+
|
| 1401 |
+
Management commands now use :py:mod:`argparse` instead of :py:mod:`optparse` to
|
| 1402 |
+
parse command-line arguments passed to commands. This also means that the way
|
| 1403 |
+
to add custom arguments to commands has changed: instead of extending the
|
| 1404 |
+
``option_list`` class list, you should now override the
|
| 1405 |
+
:meth:`~django.core.management.BaseCommand.add_arguments` method and add
|
| 1406 |
+
arguments through ``argparse.add_argument()``. See
|
| 1407 |
+
:ref:`this example <custom-commands-options>` for more details.
|
| 1408 |
+
|
| 1409 |
+
``django.core.management.NoArgsCommand``
|
| 1410 |
+
----------------------------------------
|
| 1411 |
+
|
| 1412 |
+
The class ``NoArgsCommand`` is now deprecated and will be removed in Django
|
| 1413 |
+
1.10. Use :class:`~django.core.management.BaseCommand` instead, which takes no
|
| 1414 |
+
arguments by default.
|
| 1415 |
+
|
| 1416 |
+
Listing all migrations in a project
|
| 1417 |
+
-----------------------------------
|
| 1418 |
+
|
| 1419 |
+
The ``--list`` option of the :djadmin:`migrate` management command is
|
| 1420 |
+
deprecated and will be removed in Django 1.10. Use :djadmin:`showmigrations`
|
| 1421 |
+
instead.
|
| 1422 |
+
|
| 1423 |
+
``cache_choices`` option of ``ModelChoiceField`` and ``ModelMultipleChoiceField``
|
| 1424 |
+
---------------------------------------------------------------------------------
|
| 1425 |
+
|
| 1426 |
+
:class:`~django.forms.ModelChoiceField` and
|
| 1427 |
+
:class:`~django.forms.ModelMultipleChoiceField` took an undocumented, untested
|
| 1428 |
+
option ``cache_choices``. This cached querysets between multiple renderings of
|
| 1429 |
+
the same ``Form`` object. This option is subject to an accelerated deprecation
|
| 1430 |
+
and will be removed in Django 1.9.
|
| 1431 |
+
|
| 1432 |
+
``django.template.resolve_variable()``
|
| 1433 |
+
--------------------------------------
|
| 1434 |
+
|
| 1435 |
+
The function has been informally marked as "Deprecated" for some time. Replace
|
| 1436 |
+
``resolve_variable(path, context)`` with
|
| 1437 |
+
``django.template.Variable(path).resolve(context)``.
|
| 1438 |
+
|
| 1439 |
+
``django.contrib.webdesign``
|
| 1440 |
+
----------------------------
|
| 1441 |
+
|
| 1442 |
+
It provided the :ttag:`lorem` template tag which is now included in the
|
| 1443 |
+
built-in tags. Simply remove ``'django.contrib.webdesign'`` from
|
| 1444 |
+
:setting:`INSTALLED_APPS` and ``{% load webdesign %}`` from your templates.
|
| 1445 |
+
|
| 1446 |
+
``error_message`` argument to ``django.forms.RegexField``
|
| 1447 |
+
---------------------------------------------------------
|
| 1448 |
+
|
| 1449 |
+
It provided backwards compatibility for pre-1.0 code, but its functionality is
|
| 1450 |
+
redundant. Use ``Field.error_messages['invalid']`` instead.
|
| 1451 |
+
|
| 1452 |
+
Old :tfilter:`unordered_list` syntax
|
| 1453 |
+
------------------------------------
|
| 1454 |
+
|
| 1455 |
+
An older (pre-1.0), more restrictive and verbose input format for the
|
| 1456 |
+
:tfilter:`unordered_list` template filter has been deprecated::
|
| 1457 |
+
|
| 1458 |
+
["States", [["Kansas", [["Lawrence", []], ["Topeka", []]]], ["Illinois", []]]]
|
| 1459 |
+
|
| 1460 |
+
Using the new syntax, this becomes::
|
| 1461 |
+
|
| 1462 |
+
["States", ["Kansas", ["Lawrence", "Topeka"], "Illinois"]]
|
| 1463 |
+
|
| 1464 |
+
``django.forms.Field._has_changed()``
|
| 1465 |
+
-------------------------------------
|
| 1466 |
+
|
| 1467 |
+
Rename this method to :meth:`~django.forms.Field.has_changed` by removing the
|
| 1468 |
+
leading underscore. The old name will still work until Django 1.10.
|
| 1469 |
+
|
| 1470 |
+
``django.utils.html.remove_tags()`` and ``removetags`` template filter
|
| 1471 |
+
----------------------------------------------------------------------
|
| 1472 |
+
|
| 1473 |
+
``django.utils.html.remove_tags()`` as well as the template filter
|
| 1474 |
+
``removetags`` have been deprecated as they cannot guarantee safe output. Their
|
| 1475 |
+
existence is likely to lead to their use in security-sensitive contexts where
|
| 1476 |
+
they are not actually safe.
|
| 1477 |
+
|
| 1478 |
+
The unused and undocumented ``django.utils.html.strip_entities()`` function has
|
| 1479 |
+
also been deprecated.
|
| 1480 |
+
|
| 1481 |
+
``is_admin_site`` argument to ``django.contrib.auth.views.password_reset()``
|
| 1482 |
+
----------------------------------------------------------------------------
|
| 1483 |
+
|
| 1484 |
+
It's a legacy option that should no longer be necessary.
|
| 1485 |
+
|
| 1486 |
+
``SubfieldBase``
|
| 1487 |
+
----------------
|
| 1488 |
+
|
| 1489 |
+
``django.db.models.fields.subclassing.SubfieldBase`` has been deprecated and
|
| 1490 |
+
will be removed in Django 1.10. Historically, it was used to handle fields where
|
| 1491 |
+
type conversion was needed when loading from the database, but it was not used
|
| 1492 |
+
in ``.values()`` calls or in aggregates. It has been replaced with
|
| 1493 |
+
:meth:`~django.db.models.Field.from_db_value`.
|
| 1494 |
+
|
| 1495 |
+
The new approach doesn't call the :meth:`~django.db.models.Field.to_python`
|
| 1496 |
+
method on assignment as was the case with ``SubfieldBase``. If you need that
|
| 1497 |
+
behavior, reimplement the ``Creator`` class `from Django's source code
|
| 1498 |
+
<https://github.com/django/django/blob/stable/1.8.x/django/db/models/fields/subclassing.py#L31-L44>`_
|
| 1499 |
+
in your project.
|
| 1500 |
+
|
| 1501 |
+
``django.utils.checksums``
|
| 1502 |
+
--------------------------
|
| 1503 |
+
|
| 1504 |
+
The ``django.utils.checksums`` module has been deprecated and will be removed
|
| 1505 |
+
in Django 1.10. The functionality it provided (validating checksum using the
|
| 1506 |
+
Luhn algorithm) was undocumented and not used in Django. The module has been
|
| 1507 |
+
moved to the :pypi:`django-localflavor` package (version 1.1+).
|
| 1508 |
+
|
| 1509 |
+
``InlineAdminForm.original_content_type_id``
|
| 1510 |
+
--------------------------------------------
|
| 1511 |
+
|
| 1512 |
+
The ``original_content_type_id`` attribute on ``InlineAdminForm`` has been
|
| 1513 |
+
deprecated and will be removed in Django 1.10. Historically, it was used
|
| 1514 |
+
to construct the "view on site" URL. This URL is now accessible using the
|
| 1515 |
+
``absolute_url`` attribute of the form.
|
| 1516 |
+
|
| 1517 |
+
``django.views.generic.edit.FormMixin.get_form()``’s ``form_class`` argument
|
| 1518 |
+
----------------------------------------------------------------------------
|
| 1519 |
+
|
| 1520 |
+
``FormMixin`` subclasses that override the ``get_form()`` method should make
|
| 1521 |
+
sure to provide a default value for the ``form_class`` argument since it's
|
| 1522 |
+
now optional.
|
| 1523 |
+
|
| 1524 |
+
Rendering templates loaded by :func:`~django.template.loader.get_template()` with a :class:`~django.template.Context`
|
| 1525 |
+
---------------------------------------------------------------------------------------------------------------------
|
| 1526 |
+
|
| 1527 |
+
The return type of :func:`~django.template.loader.get_template()` has changed
|
| 1528 |
+
in Django 1.8: instead of a :class:`django.template.Template`, it returns a
|
| 1529 |
+
``Template`` instance whose exact type depends on which backend loaded it.
|
| 1530 |
+
|
| 1531 |
+
Both classes provide a ``render()`` method, however, the former takes a
|
| 1532 |
+
:class:`django.template.Context` as an argument while the latter expects a
|
| 1533 |
+
:class:`dict`. This change is enforced through a deprecation path for Django
|
| 1534 |
+
templates.
|
| 1535 |
+
|
| 1536 |
+
All this also applies to :func:`~django.template.loader.select_template()`.
|
| 1537 |
+
|
| 1538 |
+
:class:`~django.template.Template` and :class:`~django.template.Context` classes in template responses
|
| 1539 |
+
------------------------------------------------------------------------------------------------------
|
| 1540 |
+
|
| 1541 |
+
Some methods of :class:`~django.template.response.SimpleTemplateResponse` and
|
| 1542 |
+
:class:`~django.template.response.TemplateResponse` accepted
|
| 1543 |
+
:class:`django.template.Context` and :class:`django.template.Template` objects
|
| 1544 |
+
as arguments. They should now receive :class:`dict` and backend-dependent
|
| 1545 |
+
template objects respectively.
|
| 1546 |
+
|
| 1547 |
+
This also applies to the return types if you have subclassed either template
|
| 1548 |
+
response class.
|
| 1549 |
+
|
| 1550 |
+
Check the :doc:`template response API documentation </ref/template-response>`
|
| 1551 |
+
for details.
|
| 1552 |
+
|
| 1553 |
+
``current_app`` argument of template-related APIs
|
| 1554 |
+
-------------------------------------------------
|
| 1555 |
+
|
| 1556 |
+
The following functions and classes will no longer accept a ``current_app``
|
| 1557 |
+
parameter to set an URL namespace in Django 1.10:
|
| 1558 |
+
|
| 1559 |
+
* ``django.shortcuts.render()``
|
| 1560 |
+
* ``django.template.Context()``
|
| 1561 |
+
* ``django.template.RequestContext()``
|
| 1562 |
+
* ``django.template.response.TemplateResponse()``
|
| 1563 |
+
|
| 1564 |
+
Set ``request.current_app`` instead, where ``request`` is the first argument
|
| 1565 |
+
to these functions or classes. If you're using a plain ``Context``, use a
|
| 1566 |
+
``RequestContext`` instead.
|
| 1567 |
+
|
| 1568 |
+
``dictionary`` and ``context_instance`` arguments of rendering functions
|
| 1569 |
+
------------------------------------------------------------------------
|
| 1570 |
+
|
| 1571 |
+
The following functions will no longer accept the ``dictionary`` and
|
| 1572 |
+
``context_instance`` parameters in Django 1.10:
|
| 1573 |
+
|
| 1574 |
+
* ``django.shortcuts.render()``
|
| 1575 |
+
* ``django.shortcuts.render_to_response()``
|
| 1576 |
+
* ``django.template.loader.render_to_string()``
|
| 1577 |
+
|
| 1578 |
+
Use the ``context`` parameter instead. When ``dictionary`` is passed as a
|
| 1579 |
+
positional argument, which is the most common idiom, no changes are needed.
|
| 1580 |
+
|
| 1581 |
+
If you're passing a :class:`~django.template.Context` in ``context_instance``,
|
| 1582 |
+
pass a :class:`dict` in the ``context`` parameter instead. If you're passing a
|
| 1583 |
+
:class:`~django.template.RequestContext`, pass the request separately in the
|
| 1584 |
+
``request`` parameter.
|
| 1585 |
+
|
| 1586 |
+
``dirs`` argument of template-finding functions
|
| 1587 |
+
-----------------------------------------------
|
| 1588 |
+
|
| 1589 |
+
The following functions will no longer accept a ``dirs`` parameter to override
|
| 1590 |
+
``TEMPLATE_DIRS`` in Django 1.10:
|
| 1591 |
+
|
| 1592 |
+
* :func:`django.template.loader.get_template()`
|
| 1593 |
+
* :func:`django.template.loader.select_template()`
|
| 1594 |
+
* :func:`django.shortcuts.render()`
|
| 1595 |
+
* ``django.shortcuts.render_to_response()``
|
| 1596 |
+
|
| 1597 |
+
The parameter didn't work consistently across different template loaders and
|
| 1598 |
+
didn't work for included templates.
|
| 1599 |
+
|
| 1600 |
+
``django.template.loader.BaseLoader``
|
| 1601 |
+
-------------------------------------
|
| 1602 |
+
|
| 1603 |
+
``django.template.loader.BaseLoader`` was renamed to
|
| 1604 |
+
``django.template.loaders.base.Loader``. If you've written a custom template
|
| 1605 |
+
loader that inherits ``BaseLoader``, you must inherit ``Loader`` instead.
|
| 1606 |
+
|
| 1607 |
+
``django.test.utils.TestTemplateLoader``
|
| 1608 |
+
----------------------------------------
|
| 1609 |
+
|
| 1610 |
+
Private API ``django.test.utils.TestTemplateLoader`` is deprecated in favor of
|
| 1611 |
+
``django.template.loaders.locmem.Loader`` and will be removed in Django 1.9.
|
| 1612 |
+
|
| 1613 |
+
.. _storage-max-length-update:
|
| 1614 |
+
|
| 1615 |
+
Support for the ``max_length`` argument on custom ``Storage`` classes
|
| 1616 |
+
---------------------------------------------------------------------
|
| 1617 |
+
|
| 1618 |
+
``Storage`` subclasses should add ``max_length=None`` as a parameter to
|
| 1619 |
+
:meth:`~django.core.files.storage.Storage.get_available_name` and/or
|
| 1620 |
+
:meth:`~django.core.files.storage.Storage.save` if they override either method.
|
| 1621 |
+
Support for storages that do not accept this argument will be removed in
|
| 1622 |
+
Django 1.10.
|
| 1623 |
+
|
| 1624 |
+
``qn`` replaced by ``compiler``
|
| 1625 |
+
-------------------------------
|
| 1626 |
+
|
| 1627 |
+
In previous Django versions, various internal ORM methods (mostly ``as_sql``
|
| 1628 |
+
methods) accepted a ``qn`` (for "quote name") argument, which was a reference
|
| 1629 |
+
to a function that quoted identifiers for sending to the database. In Django
|
| 1630 |
+
1.8, that argument has been renamed to ``compiler`` and is now a full
|
| 1631 |
+
``SQLCompiler`` instance. For backwards-compatibility, calling a
|
| 1632 |
+
``SQLCompiler`` instance performs the same name-quoting that the ``qn``
|
| 1633 |
+
function used to. However, this backwards-compatibility shim is immediately
|
| 1634 |
+
deprecated: you should rename your ``qn`` arguments to ``compiler``, and call
|
| 1635 |
+
``compiler.quote_name_unless_alias(...)`` where you previously called
|
| 1636 |
+
``qn(...)``.
|
| 1637 |
+
|
| 1638 |
+
Default value of ``RedirectView.permanent``
|
| 1639 |
+
-------------------------------------------
|
| 1640 |
+
|
| 1641 |
+
The default value of the
|
| 1642 |
+
:attr:`RedirectView.permanent <django.views.generic.base.RedirectView.permanent>`
|
| 1643 |
+
attribute will change from ``True`` to ``False`` in Django 1.9.
|
| 1644 |
+
|
| 1645 |
+
Using ``AuthenticationMiddleware`` without ``SessionAuthenticationMiddleware``
|
| 1646 |
+
------------------------------------------------------------------------------
|
| 1647 |
+
|
| 1648 |
+
``django.contrib.auth.middleware.SessionAuthenticationMiddleware`` was
|
| 1649 |
+
added in Django 1.7. In Django 1.7.2, its functionality was moved to
|
| 1650 |
+
``auth.get_user()`` and, for backwards compatibility, enabled only if
|
| 1651 |
+
``'django.contrib.auth.middleware.SessionAuthenticationMiddleware'`` appears in
|
| 1652 |
+
``MIDDLEWARE_CLASSES``.
|
| 1653 |
+
|
| 1654 |
+
In Django 1.10, session verification will be enabled regardless of whether or not
|
| 1655 |
+
``SessionAuthenticationMiddleware`` is enabled (at which point
|
| 1656 |
+
``SessionAuthenticationMiddleware`` will have no significance). You can add it
|
| 1657 |
+
to your ``MIDDLEWARE_CLASSES`` sometime before then to opt-in. Please read the
|
| 1658 |
+
:ref:`upgrade considerations <session-invalidation-on-password-change>` first.
|
| 1659 |
+
|
| 1660 |
+
``django.contrib.sitemaps.FlatPageSitemap``
|
| 1661 |
+
-------------------------------------------
|
| 1662 |
+
|
| 1663 |
+
``django.contrib.sitemaps.FlatPageSitemap`` has moved to
|
| 1664 |
+
``django.contrib.flatpages.sitemaps.FlatPageSitemap``. The old import location
|
| 1665 |
+
is deprecated and will be removed in Django 1.9.
|
| 1666 |
+
|
| 1667 |
+
Model ``Field.related``
|
| 1668 |
+
-----------------------
|
| 1669 |
+
|
| 1670 |
+
Private attribute ``django.db.models.Field.related`` is deprecated in favor
|
| 1671 |
+
of ``Field.rel``. The latter is an instance of
|
| 1672 |
+
``django.db.models.fields.related.ForeignObjectRel`` which replaces
|
| 1673 |
+
``django.db.models.related.RelatedObject``. The ``django.db.models.related``
|
| 1674 |
+
module has been removed and the ``Field.related`` attribute will be removed in
|
| 1675 |
+
Django 1.10.
|
| 1676 |
+
|
| 1677 |
+
``ssi`` template tag
|
| 1678 |
+
--------------------
|
| 1679 |
+
|
| 1680 |
+
The ``ssi`` template tag allows files to be included in a template by
|
| 1681 |
+
absolute path. This is of limited use in most deployment situations, and
|
| 1682 |
+
the :ttag:`include` tag often makes more sense. This tag is now deprecated and
|
| 1683 |
+
will be removed in Django 1.10.
|
| 1684 |
+
|
| 1685 |
+
``=`` as comparison operator in ``if`` template tag
|
| 1686 |
+
---------------------------------------------------
|
| 1687 |
+
|
| 1688 |
+
Using a single equals sign with the ``{% if %}`` template tag for equality
|
| 1689 |
+
testing was undocumented and untested. It's now deprecated in favor of ``==``.
|
| 1690 |
+
|
| 1691 |
+
``%(<foo>)s`` syntax in ``ModelFormMixin.success_url``
|
| 1692 |
+
------------------------------------------------------
|
| 1693 |
+
|
| 1694 |
+
The legacy ``%(<foo>)s`` syntax in :attr:`ModelFormMixin.success_url
|
| 1695 |
+
<django.views.generic.edit.ModelFormMixin.success_url>` is deprecated and
|
| 1696 |
+
will be removed in Django 1.10.
|
| 1697 |
+
|
| 1698 |
+
``GeoQuerySet`` aggregate methods
|
| 1699 |
+
---------------------------------
|
| 1700 |
+
|
| 1701 |
+
The ``collect()``, ``extent()``, ``extent3d()``, ``make_line()``, and
|
| 1702 |
+
``unionagg()`` aggregate methods are deprecated and should be replaced by their
|
| 1703 |
+
function-based aggregate equivalents (``Collect``, ``Extent``, ``Extent3D``,
|
| 1704 |
+
``MakeLine``, and ``Union``).
|
| 1705 |
+
|
| 1706 |
+
.. _deprecated-signature-of-allow-migrate:
|
| 1707 |
+
|
| 1708 |
+
Signature of the ``allow_migrate`` router method
|
| 1709 |
+
------------------------------------------------
|
| 1710 |
+
|
| 1711 |
+
The signature of the :meth:`allow_migrate` method of database routers has
|
| 1712 |
+
changed from ``allow_migrate(db, model)`` to
|
| 1713 |
+
``allow_migrate(db, app_label, model_name=None, **hints)``.
|
| 1714 |
+
|
| 1715 |
+
When ``model_name`` is set, the value that was previously given through the
|
| 1716 |
+
``model`` positional argument may now be found inside the ``hints`` dictionary
|
| 1717 |
+
under the key ``'model'``.
|
| 1718 |
+
|
| 1719 |
+
After switching to the new signature the router will also be called by the
|
| 1720 |
+
:class:`~django.db.migrations.operations.RunPython` and
|
| 1721 |
+
:class:`~django.db.migrations.operations.RunSQL` operations.
|
| 1722 |
+
|
| 1723 |
+
.. _removed-features-1.8:
|
| 1724 |
+
|
| 1725 |
+
Features removed in 1.8
|
| 1726 |
+
=======================
|
| 1727 |
+
|
| 1728 |
+
These features have reached the end of their deprecation cycle and are removed
|
| 1729 |
+
in Django 1.8. See :ref:`deprecated-features-1.6` for details, including how to
|
| 1730 |
+
remove usage of these features.
|
| 1731 |
+
|
| 1732 |
+
* ``django.contrib.comments`` is removed.
|
| 1733 |
+
|
| 1734 |
+
* The following transaction management APIs are removed:
|
| 1735 |
+
|
| 1736 |
+
- ``TransactionMiddleware``
|
| 1737 |
+
- the decorators and context managers ``autocommit``, ``commit_on_success``,
|
| 1738 |
+
and ``commit_manually``, defined in ``django.db.transaction``
|
| 1739 |
+
- the functions ``commit_unless_managed`` and ``rollback_unless_managed``,
|
| 1740 |
+
also defined in ``django.db.transaction``
|
| 1741 |
+
- the ``TRANSACTIONS_MANAGED`` setting
|
| 1742 |
+
|
| 1743 |
+
* The :ttag:`cycle` and :ttag:`firstof` template tags auto-escape their
|
| 1744 |
+
arguments.
|
| 1745 |
+
|
| 1746 |
+
* The ``SEND_BROKEN_LINK_EMAILS`` setting is removed.
|
| 1747 |
+
|
| 1748 |
+
* ``django.middleware.doc.XViewMiddleware`` is removed.
|
| 1749 |
+
|
| 1750 |
+
* The ``Model._meta.module_name`` alias is removed.
|
| 1751 |
+
|
| 1752 |
+
* The backward compatible shims introduced to rename ``get_query_set``
|
| 1753 |
+
and similar queryset methods are removed. This affects the following classes:
|
| 1754 |
+
``BaseModelAdmin``, ``ChangeList``, ``BaseCommentNode``,
|
| 1755 |
+
``GenericForeignKey``, ``Manager``, ``SingleRelatedObjectDescriptor`` and
|
| 1756 |
+
``ReverseSingleRelatedObjectDescriptor``.
|
| 1757 |
+
|
| 1758 |
+
* The backward compatible shims introduced to rename the attributes
|
| 1759 |
+
``ChangeList.root_query_set`` and ``ChangeList.query_set`` are removed.
|
| 1760 |
+
|
| 1761 |
+
* ``django.views.defaults.shortcut`` and ``django.conf.urls.shortcut`` are
|
| 1762 |
+
removed.
|
| 1763 |
+
|
| 1764 |
+
* Support for the Python Imaging Library (PIL) module is removed.
|
| 1765 |
+
|
| 1766 |
+
* The following private APIs are removed:
|
| 1767 |
+
|
| 1768 |
+
- ``django.db.backend``
|
| 1769 |
+
- ``django.db.close_connection()``
|
| 1770 |
+
- ``django.db.backends.creation.BaseDatabaseCreation.set_autocommit()``
|
| 1771 |
+
- ``django.db.transaction.is_managed()``
|
| 1772 |
+
- ``django.db.transaction.managed()``
|
| 1773 |
+
|
| 1774 |
+
* ``django.forms.widgets.RadioInput`` is removed.
|
| 1775 |
+
|
| 1776 |
+
* The module ``django.test.simple`` and the class
|
| 1777 |
+
``django.test.simple.DjangoTestSuiteRunner`` are removed.
|
| 1778 |
+
|
| 1779 |
+
* The module ``django.test._doctest`` is removed.
|
| 1780 |
+
|
| 1781 |
+
* The ``CACHE_MIDDLEWARE_ANONYMOUS_ONLY`` setting is removed. This change
|
| 1782 |
+
affects both ``django.middleware.cache.CacheMiddleware`` and
|
| 1783 |
+
``django.middleware.cache.UpdateCacheMiddleware`` despite the lack of a
|
| 1784 |
+
deprecation warning in the latter class.
|
| 1785 |
+
|
| 1786 |
+
* Usage of the hard-coded *Hold down "Control", or "Command" on a Mac, to select
|
| 1787 |
+
more than one.* string to override or append to user-provided ``help_text`` in
|
| 1788 |
+
forms for ``ManyToMany`` model fields is not performed by Django anymore
|
| 1789 |
+
either at the model or forms layer.
|
| 1790 |
+
|
| 1791 |
+
* The ``Model._meta.get_(add|change|delete)_permission`` methods are removed.
|
| 1792 |
+
|
| 1793 |
+
* The session key ``django_language`` is no longer read for backwards
|
| 1794 |
+
compatibility.
|
| 1795 |
+
|
| 1796 |
+
* Geographic Sitemaps are removed
|
| 1797 |
+
(``django.contrib.gis.sitemaps.views.index`` and
|
| 1798 |
+
``django.contrib.gis.sitemaps.views.sitemap``).
|
| 1799 |
+
|
| 1800 |
+
* ``django.utils.html.fix_ampersands``, the ``fix_ampersands`` template filter,
|
| 1801 |
+
and ``django.utils.html.clean_html`` are removed.
|
testbed/django__django/docs/releases/1.9.5.txt
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 1.9.5 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*April 1, 2016*
|
| 6 |
+
|
| 7 |
+
Django 1.9.5 fixes several bugs in 1.9.4.
|
| 8 |
+
|
| 9 |
+
Bugfixes
|
| 10 |
+
========
|
| 11 |
+
|
| 12 |
+
* Made ``MultiPartParser`` ignore filenames that normalize to an empty string
|
| 13 |
+
to fix crash in ``MemoryFileUploadHandler`` on specially crafted user input
|
| 14 |
+
(:ticket:`26325`).
|
| 15 |
+
|
| 16 |
+
* Fixed a race condition in ``BaseCache.get_or_set()`` (:ticket:`26332`). It
|
| 17 |
+
now returns the ``default`` value instead of ``False`` if there's an error
|
| 18 |
+
when trying to add the value to the cache.
|
| 19 |
+
|
| 20 |
+
* Fixed data loss on SQLite where ``DurationField`` values with fractional
|
| 21 |
+
seconds could be saved as ``None`` (:ticket:`26324`).
|
| 22 |
+
|
| 23 |
+
* The forms in ``contrib.auth`` no longer strip trailing and leading whitespace
|
| 24 |
+
from the password fields (:ticket:`26334`). The change requires users who set
|
| 25 |
+
their password to something with such whitespace after a site updated to
|
| 26 |
+
Django 1.9 to reset their password. It provides backwards-compatibility for
|
| 27 |
+
earlier versions of Django.
|
| 28 |
+
|
| 29 |
+
* Fixed a memory leak in the cached template loader (:ticket:`26306`).
|
| 30 |
+
|
| 31 |
+
* Fixed a regression that caused ``collectstatic --clear`` to fail if the
|
| 32 |
+
storage doesn't implement ``path()`` (:ticket:`26297`).
|
| 33 |
+
|
| 34 |
+
* Fixed a crash when using a reverse lookup with a subquery when a
|
| 35 |
+
``ForeignKey`` has a ``to_field`` set to something other than the primary key
|
| 36 |
+
(:ticket:`26373`).
|
| 37 |
+
|
| 38 |
+
* Fixed a regression in ``CommonMiddleware`` that caused spurious warnings in
|
| 39 |
+
logs on requests missing a trailing slash (:ticket:`26293`).
|
| 40 |
+
|
| 41 |
+
* Restored the functionality of the admin's ``raw_id_fields`` in
|
| 42 |
+
``list_editable`` (:ticket:`26387`).
|
| 43 |
+
|
| 44 |
+
* Fixed a regression with abstract model inheritance and explicit parent links
|
| 45 |
+
(:ticket:`26413`).
|
| 46 |
+
|
| 47 |
+
* Fixed a migrations crash on SQLite when renaming the primary key of a model
|
| 48 |
+
containing a ``ForeignKey`` to ``'self'`` (:ticket:`26384`).
|
| 49 |
+
|
| 50 |
+
* Fixed ``JSONField`` inadvertently escaping its contents when displaying values
|
| 51 |
+
after failed form validation (:ticket:`25532`).
|
testbed/django__django/docs/releases/1.9.txt
ADDED
|
@@ -0,0 +1,1527 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========================
|
| 2 |
+
Django 1.9 release notes
|
| 3 |
+
========================
|
| 4 |
+
|
| 5 |
+
*December 1, 2015*
|
| 6 |
+
|
| 7 |
+
Welcome to Django 1.9!
|
| 8 |
+
|
| 9 |
+
These release notes cover the :ref:`new features <whats-new-1.9>`, as well as
|
| 10 |
+
some :ref:`backwards incompatible changes <backwards-incompatible-1.9>` you'll
|
| 11 |
+
want to be aware of when upgrading from Django 1.8 or older versions. We've
|
| 12 |
+
:ref:`dropped some features<removed-features-1.9>` that have reached the end of
|
| 13 |
+
their deprecation cycle, and we've :ref:`begun the deprecation process for some
|
| 14 |
+
features <deprecated-features-1.9>`.
|
| 15 |
+
|
| 16 |
+
See the :doc:`/howto/upgrade-version` guide if you're updating an existing
|
| 17 |
+
project.
|
| 18 |
+
|
| 19 |
+
Python compatibility
|
| 20 |
+
====================
|
| 21 |
+
|
| 22 |
+
Django 1.9 requires Python 2.7, 3.4, or 3.5. We **highly recommend** and only
|
| 23 |
+
officially support the latest release of each series.
|
| 24 |
+
|
| 25 |
+
The Django 1.8 series is the last to support Python 3.2 and 3.3.
|
| 26 |
+
|
| 27 |
+
.. _whats-new-1.9:
|
| 28 |
+
|
| 29 |
+
What's new in Django 1.9
|
| 30 |
+
========================
|
| 31 |
+
|
| 32 |
+
Performing actions after a transaction commit
|
| 33 |
+
---------------------------------------------
|
| 34 |
+
|
| 35 |
+
The new :func:`~django.db.transaction.on_commit` hook allows performing actions
|
| 36 |
+
after a database transaction is successfully committed. This is useful for
|
| 37 |
+
tasks such as sending notification emails, creating queued tasks, or
|
| 38 |
+
invalidating caches.
|
| 39 |
+
|
| 40 |
+
This functionality from the :pypi:`django-transaction-hooks` package has been
|
| 41 |
+
integrated into Django.
|
| 42 |
+
|
| 43 |
+
Password validation
|
| 44 |
+
-------------------
|
| 45 |
+
|
| 46 |
+
Django now offers password validation to help prevent the usage of weak
|
| 47 |
+
passwords by users. The validation is integrated in the included password
|
| 48 |
+
change and reset forms and is simple to integrate in any other code.
|
| 49 |
+
Validation is performed by one or more validators, configured in the new
|
| 50 |
+
:setting:`AUTH_PASSWORD_VALIDATORS` setting.
|
| 51 |
+
|
| 52 |
+
Four validators are included in Django, which can enforce a minimum length,
|
| 53 |
+
compare the password to the user's attributes like their name, ensure
|
| 54 |
+
passwords aren't entirely numeric, or check against an included list of common
|
| 55 |
+
passwords. You can combine multiple validators, and some validators have
|
| 56 |
+
custom configuration options. For example, you can choose to provide a custom
|
| 57 |
+
list of common passwords. Each validator provides a help text to explain its
|
| 58 |
+
requirements to the user.
|
| 59 |
+
|
| 60 |
+
By default, no validation is performed and all passwords are accepted, so if
|
| 61 |
+
you don't set :setting:`AUTH_PASSWORD_VALIDATORS`, you will not see any
|
| 62 |
+
change. In new projects created with the default :djadmin:`startproject`
|
| 63 |
+
template, a simple set of validators is enabled. To enable basic validation in
|
| 64 |
+
the included auth forms for your project, you could set, for example::
|
| 65 |
+
|
| 66 |
+
AUTH_PASSWORD_VALIDATORS = [
|
| 67 |
+
{
|
| 68 |
+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
| 78 |
+
},
|
| 79 |
+
]
|
| 80 |
+
|
| 81 |
+
See :ref:`password-validation` for more details.
|
| 82 |
+
|
| 83 |
+
Permission mixins for class-based views
|
| 84 |
+
---------------------------------------
|
| 85 |
+
|
| 86 |
+
Django now ships with the mixins
|
| 87 |
+
:class:`~django.contrib.auth.mixins.AccessMixin`,
|
| 88 |
+
:class:`~django.contrib.auth.mixins.LoginRequiredMixin`,
|
| 89 |
+
:class:`~django.contrib.auth.mixins.PermissionRequiredMixin`, and
|
| 90 |
+
:class:`~django.contrib.auth.mixins.UserPassesTestMixin` to provide the
|
| 91 |
+
functionality of the ``django.contrib.auth.decorators`` for class-based views.
|
| 92 |
+
These mixins have been taken from, or are at least inspired by, the
|
| 93 |
+
`django-braces`_ project.
|
| 94 |
+
|
| 95 |
+
There are a few differences between Django's and ``django-braces``\'
|
| 96 |
+
implementation, though:
|
| 97 |
+
|
| 98 |
+
* The :attr:`~django.contrib.auth.mixins.AccessMixin.raise_exception` attribute
|
| 99 |
+
can only be ``True`` or ``False``. Custom exceptions or callables are not
|
| 100 |
+
supported.
|
| 101 |
+
|
| 102 |
+
* The :meth:`~django.contrib.auth.mixins.AccessMixin.handle_no_permission`
|
| 103 |
+
method does not take a ``request`` argument. The current request is available
|
| 104 |
+
in ``self.request``.
|
| 105 |
+
|
| 106 |
+
* The custom ``test_func()`` of :class:`~django.contrib.auth.mixins.UserPassesTestMixin`
|
| 107 |
+
does not take a ``user`` argument. The current user is available in
|
| 108 |
+
``self.request.user``.
|
| 109 |
+
|
| 110 |
+
* The :attr:`permission_required <django.contrib.auth.mixins.PermissionRequiredMixin>`
|
| 111 |
+
attribute supports a string (defining one permission) or a list/tuple of
|
| 112 |
+
strings (defining multiple permissions) that need to be fulfilled to grant
|
| 113 |
+
access.
|
| 114 |
+
|
| 115 |
+
* The new :attr:`~django.contrib.auth.mixins.AccessMixin.permission_denied_message`
|
| 116 |
+
attribute allows passing a message to the ``PermissionDenied`` exception.
|
| 117 |
+
|
| 118 |
+
.. _django-braces: https://django-braces.readthedocs.io/en/latest/index.html
|
| 119 |
+
|
| 120 |
+
New styling for ``contrib.admin``
|
| 121 |
+
---------------------------------
|
| 122 |
+
|
| 123 |
+
The admin sports a modern, flat design with new SVG icons which look perfect
|
| 124 |
+
on HiDPI screens. It still provides a fully-functional experience to `YUI's
|
| 125 |
+
A-grade`_ browsers. Older browser may experience varying levels of graceful
|
| 126 |
+
degradation.
|
| 127 |
+
|
| 128 |
+
.. _YUI's A-grade: https://github.com/yui/yui3/wiki/Graded-Browser-Support
|
| 129 |
+
|
| 130 |
+
Running tests in parallel
|
| 131 |
+
-------------------------
|
| 132 |
+
|
| 133 |
+
The :djadmin:`test` command now supports a :option:`--parallel <test
|
| 134 |
+
--parallel>` option to run a project's tests in multiple processes in parallel.
|
| 135 |
+
|
| 136 |
+
Each process gets its own database. You must ensure that different test cases
|
| 137 |
+
don't access the same resources. For instance, test cases that touch the
|
| 138 |
+
filesystem should create a temporary directory for their own use.
|
| 139 |
+
|
| 140 |
+
This option is enabled by default for Django's own test suite provided:
|
| 141 |
+
|
| 142 |
+
- the OS supports it (all but Windows)
|
| 143 |
+
- the database backend supports it (all the built-in backends but Oracle)
|
| 144 |
+
|
| 145 |
+
Minor features
|
| 146 |
+
--------------
|
| 147 |
+
|
| 148 |
+
:mod:`django.contrib.admin`
|
| 149 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 150 |
+
|
| 151 |
+
* Admin views now have ``model_admin`` or ``admin_site`` attributes.
|
| 152 |
+
|
| 153 |
+
* The URL of the admin change view has been changed (was at
|
| 154 |
+
``/admin/<app>/<model>/<pk>/`` by default and is now at
|
| 155 |
+
``/admin/<app>/<model>/<pk>/change/``). This should not affect your
|
| 156 |
+
application unless you have hardcoded admin URLs. In that case, replace those
|
| 157 |
+
links by :ref:`reversing admin URLs <admin-reverse-urls>` instead. Note that
|
| 158 |
+
the old URL still redirects to the new one for backwards compatibility, but
|
| 159 |
+
it may be removed in a future version.
|
| 160 |
+
|
| 161 |
+
* :meth:`ModelAdmin.get_list_select_related()
|
| 162 |
+
<django.contrib.admin.ModelAdmin.get_list_select_related>` was added to allow
|
| 163 |
+
changing the ``select_related()`` values used in the admin's changelist query
|
| 164 |
+
based on the request.
|
| 165 |
+
|
| 166 |
+
* The ``available_apps`` context variable, which lists the available
|
| 167 |
+
applications for the current user, has been added to the
|
| 168 |
+
:meth:`AdminSite.each_context() <django.contrib.admin.AdminSite.each_context>`
|
| 169 |
+
method.
|
| 170 |
+
|
| 171 |
+
* :attr:`AdminSite.empty_value_display
|
| 172 |
+
<django.contrib.admin.AdminSite.empty_value_display>` and
|
| 173 |
+
:attr:`ModelAdmin.empty_value_display
|
| 174 |
+
<django.contrib.admin.ModelAdmin.empty_value_display>` were added to override
|
| 175 |
+
the display of empty values in admin change list. You can also customize the
|
| 176 |
+
value for each field.
|
| 177 |
+
|
| 178 |
+
* Added jQuery events :ref:`when an inline form is added or removed
|
| 179 |
+
<admin-javascript-inline-form-events>` on the change form page.
|
| 180 |
+
|
| 181 |
+
* The time picker widget includes a '6 p.m' option for consistency of having
|
| 182 |
+
predefined options every 6 hours.
|
| 183 |
+
|
| 184 |
+
* JavaScript slug generation now supports Romanian characters.
|
| 185 |
+
|
| 186 |
+
:mod:`django.contrib.admindocs`
|
| 187 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 188 |
+
|
| 189 |
+
* The model section of the ``admindocs`` now also describes methods that take
|
| 190 |
+
arguments, rather than ignoring them.
|
| 191 |
+
|
| 192 |
+
:mod:`django.contrib.auth`
|
| 193 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 194 |
+
|
| 195 |
+
* The default iteration count for the PBKDF2 password hasher has been increased
|
| 196 |
+
by 20%. This backwards compatible change will not affect users who have
|
| 197 |
+
subclassed ``django.contrib.auth.hashers.PBKDF2PasswordHasher`` to change the
|
| 198 |
+
default value.
|
| 199 |
+
|
| 200 |
+
* The ``BCryptSHA256PasswordHasher`` will now update passwords if its
|
| 201 |
+
``rounds`` attribute is changed.
|
| 202 |
+
|
| 203 |
+
* ``AbstractBaseUser`` and ``BaseUserManager`` were moved to a new
|
| 204 |
+
``django.contrib.auth.base_user`` module so that they can be imported without
|
| 205 |
+
including ``django.contrib.auth`` in :setting:`INSTALLED_APPS` (doing so
|
| 206 |
+
raised a deprecation warning in older versions and is no longer supported in
|
| 207 |
+
Django 1.9).
|
| 208 |
+
|
| 209 |
+
* The permission argument of
|
| 210 |
+
:func:`~django.contrib.auth.decorators.permission_required()` accepts all
|
| 211 |
+
kinds of iterables, not only list and tuples.
|
| 212 |
+
|
| 213 |
+
* The new :class:`~django.contrib.auth.middleware.PersistentRemoteUserMiddleware`
|
| 214 |
+
makes it possible to use ``REMOTE_USER`` for setups where the header is only
|
| 215 |
+
populated on login pages instead of every request in the session.
|
| 216 |
+
|
| 217 |
+
* The ``django.contrib.auth.views.password_reset()`` view accepts an
|
| 218 |
+
``extra_email_context`` parameter.
|
| 219 |
+
|
| 220 |
+
:mod:`django.contrib.contenttypes`
|
| 221 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 222 |
+
|
| 223 |
+
* It's now possible to use
|
| 224 |
+
:attr:`~django.db.models.Options.order_with_respect_to` with a
|
| 225 |
+
``GenericForeignKey``.
|
| 226 |
+
|
| 227 |
+
:mod:`django.contrib.gis`
|
| 228 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 229 |
+
|
| 230 |
+
* All ``GeoQuerySet`` methods have been deprecated and replaced by
|
| 231 |
+
:doc:`equivalent database functions </ref/contrib/gis/functions>`. As soon
|
| 232 |
+
as the legacy methods have been replaced in your code, you should even be
|
| 233 |
+
able to remove the special ``GeoManager`` from your GIS-enabled classes.
|
| 234 |
+
|
| 235 |
+
* The GDAL interface now supports instantiating file-based and in-memory
|
| 236 |
+
:ref:`GDALRaster objects <raster-data-source-objects>` from raw data.
|
| 237 |
+
Setters for raster properties such as projection or pixel values have
|
| 238 |
+
been added.
|
| 239 |
+
|
| 240 |
+
* For PostGIS users, the new :class:`~django.contrib.gis.db.models.RasterField`
|
| 241 |
+
allows :ref:`storing GDALRaster objects <creating-and-saving-raster-models>`.
|
| 242 |
+
It supports automatic spatial index creation and reprojection when saving a
|
| 243 |
+
model. It does not yet support spatial querying.
|
| 244 |
+
|
| 245 |
+
* The new :meth:`GDALRaster.warp() <django.contrib.gis.gdal.GDALRaster.warp>`
|
| 246 |
+
method allows warping a raster by specifying target raster properties such as
|
| 247 |
+
origin, width, height, or pixel size (among others).
|
| 248 |
+
|
| 249 |
+
* The new :meth:`GDALRaster.transform()
|
| 250 |
+
<django.contrib.gis.gdal.GDALRaster.transform>` method allows transforming a
|
| 251 |
+
raster into a different spatial reference system by specifying a target
|
| 252 |
+
``srid``.
|
| 253 |
+
|
| 254 |
+
* The new :class:`~django.contrib.gis.geoip2.GeoIP2` class allows using
|
| 255 |
+
MaxMind's GeoLite2 databases which includes support for IPv6 addresses.
|
| 256 |
+
|
| 257 |
+
* The default OpenLayers library version included in widgets has been updated
|
| 258 |
+
from 2.13 to 2.13.1.
|
| 259 |
+
|
| 260 |
+
:mod:`django.contrib.postgres`
|
| 261 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 262 |
+
|
| 263 |
+
* Added support for the :lookup:`rangefield.contained_by` lookup for some built
|
| 264 |
+
in fields which correspond to the range fields.
|
| 265 |
+
|
| 266 |
+
* Added ``django.contrib.postgres.fields.JSONField``.
|
| 267 |
+
|
| 268 |
+
* Added :doc:`/ref/contrib/postgres/aggregates`.
|
| 269 |
+
|
| 270 |
+
* Added the :class:`~django.contrib.postgres.functions.TransactionNow` database
|
| 271 |
+
function.
|
| 272 |
+
|
| 273 |
+
:mod:`django.contrib.sessions`
|
| 274 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 275 |
+
|
| 276 |
+
* The session model and ``SessionStore`` classes for the ``db`` and
|
| 277 |
+
``cached_db`` backends are refactored to allow a custom database session
|
| 278 |
+
backend to build upon them. See
|
| 279 |
+
:ref:`extending-database-backed-session-engines` for more details.
|
| 280 |
+
|
| 281 |
+
:mod:`django.contrib.sites`
|
| 282 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 283 |
+
|
| 284 |
+
* :func:`~django.contrib.sites.shortcuts.get_current_site` now handles the case
|
| 285 |
+
where ``request.get_host()`` returns ``domain:port``, e.g.
|
| 286 |
+
``example.com:80``. If the lookup fails because the host does not match a
|
| 287 |
+
record in the database and the host has a port, the port is stripped and the
|
| 288 |
+
lookup is retried with the domain part only.
|
| 289 |
+
|
| 290 |
+
:mod:`django.contrib.syndication`
|
| 291 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 292 |
+
|
| 293 |
+
* Support for multiple enclosures per feed item has been added. If multiple
|
| 294 |
+
enclosures are defined on a RSS feed, an exception is raised as RSS feeds,
|
| 295 |
+
unlike Atom feeds, do not support multiple enclosures per feed item.
|
| 296 |
+
|
| 297 |
+
Cache
|
| 298 |
+
~~~~~
|
| 299 |
+
|
| 300 |
+
* ``django.core.cache.backends.base.BaseCache`` now has a ``get_or_set()``
|
| 301 |
+
method.
|
| 302 |
+
|
| 303 |
+
* :func:`django.views.decorators.cache.never_cache` now sends more persuasive
|
| 304 |
+
headers (added ``no-cache, no-store, must-revalidate`` to ``Cache-Control``)
|
| 305 |
+
to better prevent caching. This was also added in Django 1.8.8.
|
| 306 |
+
|
| 307 |
+
CSRF
|
| 308 |
+
~~~~
|
| 309 |
+
|
| 310 |
+
* The request header's name used for CSRF authentication can be customized
|
| 311 |
+
with :setting:`CSRF_HEADER_NAME`.
|
| 312 |
+
|
| 313 |
+
* The CSRF referer header is now validated against the
|
| 314 |
+
:setting:`CSRF_COOKIE_DOMAIN` setting if set. See :ref:`how-csrf-works` for
|
| 315 |
+
details.
|
| 316 |
+
|
| 317 |
+
* The new :setting:`CSRF_TRUSTED_ORIGINS` setting provides a way to allow
|
| 318 |
+
cross-origin unsafe requests (e.g. ``POST``) over HTTPS.
|
| 319 |
+
|
| 320 |
+
Database backends
|
| 321 |
+
~~~~~~~~~~~~~~~~~
|
| 322 |
+
|
| 323 |
+
* The PostgreSQL backend (``django.db.backends.postgresql_psycopg2``) is also
|
| 324 |
+
available as ``django.db.backends.postgresql``. The old name will continue to
|
| 325 |
+
be available for backwards compatibility.
|
| 326 |
+
|
| 327 |
+
File Storage
|
| 328 |
+
~~~~~~~~~~~~
|
| 329 |
+
|
| 330 |
+
* :meth:`Storage.get_valid_name()
|
| 331 |
+
<django.core.files.storage.Storage.get_valid_name>` is now called when
|
| 332 |
+
the :attr:`~django.db.models.FileField.upload_to` is a callable.
|
| 333 |
+
|
| 334 |
+
* :class:`~django.core.files.File` now has the ``seekable()`` method when using
|
| 335 |
+
Python 3.
|
| 336 |
+
|
| 337 |
+
Forms
|
| 338 |
+
~~~~~
|
| 339 |
+
|
| 340 |
+
* :class:`~django.forms.ModelForm` accepts the new ``Meta`` option
|
| 341 |
+
``field_classes`` to customize the type of the fields. See
|
| 342 |
+
:ref:`modelforms-overriding-default-fields` for details.
|
| 343 |
+
|
| 344 |
+
* You can now specify the order in which form fields are rendered with the
|
| 345 |
+
:attr:`~django.forms.Form.field_order` attribute, the ``field_order``
|
| 346 |
+
constructor argument , or the :meth:`~django.forms.Form.order_fields` method.
|
| 347 |
+
|
| 348 |
+
* A form prefix can be specified inside a form class, not only when
|
| 349 |
+
instantiating a form. See :ref:`form-prefix` for details.
|
| 350 |
+
|
| 351 |
+
* You can now :ref:`specify keyword arguments <custom-formset-form-kwargs>`
|
| 352 |
+
that you want to pass to the constructor of forms in a formset.
|
| 353 |
+
|
| 354 |
+
* :class:`~django.forms.SlugField` now accepts an
|
| 355 |
+
:attr:`~django.forms.SlugField.allow_unicode` argument to allow Unicode
|
| 356 |
+
characters in slugs.
|
| 357 |
+
|
| 358 |
+
* :class:`~django.forms.CharField` now accepts a
|
| 359 |
+
:attr:`~django.forms.CharField.strip` argument to strip input data of leading
|
| 360 |
+
and trailing whitespace. As this defaults to ``True`` this is different
|
| 361 |
+
behavior from previous releases.
|
| 362 |
+
|
| 363 |
+
* Form fields now support the :attr:`~django.forms.Field.disabled` argument,
|
| 364 |
+
allowing the field widget to be displayed disabled by browsers.
|
| 365 |
+
|
| 366 |
+
* It's now possible to customize bound fields by overriding a field's
|
| 367 |
+
:meth:`~django.forms.Field.get_bound_field()` method.
|
| 368 |
+
|
| 369 |
+
Generic Views
|
| 370 |
+
~~~~~~~~~~~~~
|
| 371 |
+
|
| 372 |
+
* Class-based views generated using ``as_view()`` now have ``view_class``
|
| 373 |
+
and ``view_initkwargs`` attributes.
|
| 374 |
+
|
| 375 |
+
* :func:`~django.utils.decorators.method_decorator` can now be used with a list
|
| 376 |
+
or tuple of decorators. It can also be used to :ref:`decorate classes instead
|
| 377 |
+
of methods <decorating-class-based-views>`.
|
| 378 |
+
|
| 379 |
+
Internationalization
|
| 380 |
+
~~~~~~~~~~~~~~~~~~~~
|
| 381 |
+
|
| 382 |
+
* The :func:`django.views.i18n.set_language` view now properly redirects to
|
| 383 |
+
:ref:`translated URLs <url-internationalization>`, when available.
|
| 384 |
+
|
| 385 |
+
* The ``django.views.i18n.javascript_catalog()`` view now works correctly
|
| 386 |
+
if used multiple times with different configurations on the same page.
|
| 387 |
+
|
| 388 |
+
* The :func:`django.utils.timezone.make_aware` function gained an ``is_dst``
|
| 389 |
+
argument to help resolve ambiguous times during DST transitions.
|
| 390 |
+
|
| 391 |
+
* You can now use locale variants supported by gettext. These are usually used
|
| 392 |
+
for languages which can be written in different scripts, for example Latin
|
| 393 |
+
and Cyrillic (e.g. ``be@latin``).
|
| 394 |
+
|
| 395 |
+
* Added the ``django.views.i18n.json_catalog()`` view to help build a custom
|
| 396 |
+
client-side i18n library upon Django translations. It returns a JSON object
|
| 397 |
+
containing a translations catalog, formatting settings, and a plural rule.
|
| 398 |
+
|
| 399 |
+
* Added the ``name_translated`` attribute to the object returned by the
|
| 400 |
+
:ttag:`get_language_info` template tag. Also added a corresponding template
|
| 401 |
+
filter: :tfilter:`language_name_translated`.
|
| 402 |
+
|
| 403 |
+
* You can now run :djadmin:`compilemessages` from the root directory of your
|
| 404 |
+
project and it will find all the app message files that were created by
|
| 405 |
+
:djadmin:`makemessages`.
|
| 406 |
+
|
| 407 |
+
* :djadmin:`makemessages` now calls ``xgettext`` once per locale directory
|
| 408 |
+
rather than once per translatable file. This speeds up localization builds.
|
| 409 |
+
|
| 410 |
+
* :ttag:`blocktrans` supports assigning its output to a variable using
|
| 411 |
+
``asvar``.
|
| 412 |
+
|
| 413 |
+
* Two new languages are available: Colombian Spanish and Scottish Gaelic.
|
| 414 |
+
|
| 415 |
+
Management Commands
|
| 416 |
+
~~~~~~~~~~~~~~~~~~~
|
| 417 |
+
|
| 418 |
+
* The new :djadmin:`sendtestemail` command lets you send a test email to
|
| 419 |
+
easily confirm that email sending through Django is working.
|
| 420 |
+
|
| 421 |
+
* To increase the readability of the SQL code generated by
|
| 422 |
+
:djadmin:`sqlmigrate`, the SQL code generated for each migration operation is
|
| 423 |
+
preceded by the operation's description.
|
| 424 |
+
|
| 425 |
+
* The :djadmin:`dumpdata` command output is now deterministically ordered.
|
| 426 |
+
Moreover, when the ``--output`` option is specified, it also shows a progress
|
| 427 |
+
bar in the terminal.
|
| 428 |
+
|
| 429 |
+
* The :djadmin:`createcachetable` command now has a ``--dry-run`` flag to
|
| 430 |
+
print out the SQL rather than execute it.
|
| 431 |
+
|
| 432 |
+
* The :djadmin:`startapp` command creates an ``apps.py`` file. Since it doesn't
|
| 433 |
+
use ``default_app_config`` (:ref:`a discouraged API
|
| 434 |
+
<configuring-applications-ref>`), you must specify the app config's path,
|
| 435 |
+
e.g. ``'polls.apps.PollsConfig'``, in :setting:`INSTALLED_APPS` for it to be
|
| 436 |
+
used (instead of just ``'polls'``).
|
| 437 |
+
|
| 438 |
+
* When using the PostgreSQL backend, the :djadmin:`dbshell` command can connect
|
| 439 |
+
to the database using the password from your settings file (instead of
|
| 440 |
+
requiring it to be manually entered).
|
| 441 |
+
|
| 442 |
+
* The ``django`` package may be run as a script, i.e. ``python -m django``,
|
| 443 |
+
which will behave the same as ``django-admin``.
|
| 444 |
+
|
| 445 |
+
* Management commands that have the ``--noinput`` option now also take
|
| 446 |
+
``--no-input`` as an alias for that option.
|
| 447 |
+
|
| 448 |
+
Migrations
|
| 449 |
+
~~~~~~~~~~
|
| 450 |
+
|
| 451 |
+
* Initial migrations are now marked with an :attr:`initial = True
|
| 452 |
+
<django.db.migrations.Migration.initial>` class attribute which allows
|
| 453 |
+
:option:`migrate --fake-initial` to more easily detect initial migrations.
|
| 454 |
+
|
| 455 |
+
* Added support for serialization of ``functools.partial`` and ``LazyObject``
|
| 456 |
+
instances.
|
| 457 |
+
|
| 458 |
+
* When supplying ``None`` as a value in :setting:`MIGRATION_MODULES`, Django
|
| 459 |
+
will consider the app an app without migrations.
|
| 460 |
+
|
| 461 |
+
* When applying migrations, the "Rendering model states" step that's displayed
|
| 462 |
+
when running migrate with verbosity 2 or higher now computes only the states
|
| 463 |
+
for the migrations that have already been applied. The model states for
|
| 464 |
+
migrations being applied are generated on demand, drastically reducing the
|
| 465 |
+
amount of required memory.
|
| 466 |
+
|
| 467 |
+
However, this improvement is not available when unapplying migrations and
|
| 468 |
+
therefore still requires the precomputation and storage of the intermediate
|
| 469 |
+
migration states.
|
| 470 |
+
|
| 471 |
+
This improvement also requires that Django no longer supports mixed migration
|
| 472 |
+
plans. Mixed plans consist of a list of migrations where some are being
|
| 473 |
+
applied and others are being unapplied. This was never officially supported
|
| 474 |
+
and never had a public API that supports this behavior.
|
| 475 |
+
|
| 476 |
+
* The :djadmin:`squashmigrations` command now supports specifying the starting
|
| 477 |
+
migration from which migrations will be squashed.
|
| 478 |
+
|
| 479 |
+
Models
|
| 480 |
+
~~~~~~
|
| 481 |
+
|
| 482 |
+
* :meth:`QuerySet.bulk_create() <django.db.models.query.QuerySet.bulk_create>`
|
| 483 |
+
now works on proxy models.
|
| 484 |
+
|
| 485 |
+
* Database configuration gained a :setting:`TIME_ZONE <DATABASE-TIME_ZONE>`
|
| 486 |
+
option for interacting with databases that store datetimes in local time and
|
| 487 |
+
don't support time zones when :setting:`USE_TZ` is ``True``.
|
| 488 |
+
|
| 489 |
+
* Added the :meth:`RelatedManager.set()
|
| 490 |
+
<django.db.models.fields.related.RelatedManager.set()>` method to the related
|
| 491 |
+
managers created by ``ForeignKey``, ``GenericForeignKey``, and
|
| 492 |
+
``ManyToManyField``.
|
| 493 |
+
|
| 494 |
+
* The :meth:`~django.db.models.fields.related.RelatedManager.add` method on
|
| 495 |
+
a reverse foreign key now has a ``bulk`` parameter to allow executing one
|
| 496 |
+
query regardless of the number of objects being added rather than one query
|
| 497 |
+
per object.
|
| 498 |
+
|
| 499 |
+
* Added the ``keep_parents`` parameter to :meth:`Model.delete()
|
| 500 |
+
<django.db.models.Model.delete>` to allow deleting only a child's data in a
|
| 501 |
+
model that uses multi-table inheritance.
|
| 502 |
+
|
| 503 |
+
* :meth:`Model.delete() <django.db.models.Model.delete>`
|
| 504 |
+
and :meth:`QuerySet.delete() <django.db.models.query.QuerySet.delete>` return
|
| 505 |
+
the number of objects deleted.
|
| 506 |
+
|
| 507 |
+
* Added a system check to prevent defining both ``Meta.ordering`` and
|
| 508 |
+
``order_with_respect_to`` on the same model.
|
| 509 |
+
|
| 510 |
+
* :lookup:`Date and time <year>` lookups can be chained with other lookups
|
| 511 |
+
(such as :lookup:`exact`, :lookup:`gt`, :lookup:`lt`, etc.). For example:
|
| 512 |
+
``Entry.objects.filter(pub_date__month__gt=6)``.
|
| 513 |
+
|
| 514 |
+
* Time lookups (hour, minute, second) are now supported by
|
| 515 |
+
:class:`~django.db.models.TimeField` for all database backends. Support for
|
| 516 |
+
backends other than SQLite was added but undocumented in Django 1.7.
|
| 517 |
+
|
| 518 |
+
* You can specify the ``output_field`` parameter of the
|
| 519 |
+
:class:`~django.db.models.Avg` aggregate in order to aggregate over
|
| 520 |
+
non-numeric columns, such as ``DurationField``.
|
| 521 |
+
|
| 522 |
+
* Added the :lookup:`date` lookup to :class:`~django.db.models.DateTimeField`
|
| 523 |
+
to allow querying the field by only the date portion.
|
| 524 |
+
|
| 525 |
+
* Added the :class:`~django.db.models.functions.Greatest` and
|
| 526 |
+
:class:`~django.db.models.functions.Least` database functions.
|
| 527 |
+
|
| 528 |
+
* Added the :class:`~django.db.models.functions.Now` database function, which
|
| 529 |
+
returns the current date and time.
|
| 530 |
+
|
| 531 |
+
* :class:`~django.db.models.Transform` is now a subclass of
|
| 532 |
+
:ref:`Func() <func-expressions>` which allows ``Transform``\s to be used on
|
| 533 |
+
the right hand side of an expression, just like regular ``Func``\s. This
|
| 534 |
+
allows registering some database functions like
|
| 535 |
+
:class:`~django.db.models.functions.Length`,
|
| 536 |
+
:class:`~django.db.models.functions.Lower`, and
|
| 537 |
+
:class:`~django.db.models.functions.Upper` as transforms.
|
| 538 |
+
|
| 539 |
+
* :class:`~django.db.models.SlugField` now accepts an
|
| 540 |
+
:attr:`~django.db.models.SlugField.allow_unicode` argument to allow Unicode
|
| 541 |
+
characters in slugs.
|
| 542 |
+
|
| 543 |
+
* Added support for referencing annotations in ``QuerySet.distinct()``.
|
| 544 |
+
|
| 545 |
+
* ``connection.queries`` shows queries with substituted parameters on SQLite.
|
| 546 |
+
|
| 547 |
+
* :doc:`Query expressions </ref/models/expressions>` can now be used when
|
| 548 |
+
creating new model instances using ``save()``, ``create()``, and
|
| 549 |
+
``bulk_create()``.
|
| 550 |
+
|
| 551 |
+
Requests and Responses
|
| 552 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 553 |
+
|
| 554 |
+
* Unless :attr:`HttpResponse.reason_phrase
|
| 555 |
+
<django.http.HttpResponse.reason_phrase>` is explicitly set, it now is
|
| 556 |
+
determined by the current value of :attr:`HttpResponse.status_code
|
| 557 |
+
<django.http.HttpResponse.status_code>`. Modifying the value of
|
| 558 |
+
``status_code`` outside of the constructor will also modify the value of
|
| 559 |
+
``reason_phrase``.
|
| 560 |
+
|
| 561 |
+
* The debug view now shows details of chained exceptions on Python 3.
|
| 562 |
+
|
| 563 |
+
* The default 40x error views now accept a second positional parameter, the
|
| 564 |
+
exception that triggered the view.
|
| 565 |
+
|
| 566 |
+
* View error handlers now support
|
| 567 |
+
:class:`~django.template.response.TemplateResponse`, commonly used with
|
| 568 |
+
class-based views.
|
| 569 |
+
|
| 570 |
+
* Exceptions raised by the ``render()`` method are now passed to the
|
| 571 |
+
``process_exception()`` method of each middleware.
|
| 572 |
+
|
| 573 |
+
* Request middleware can now set :attr:`HttpRequest.urlconf
|
| 574 |
+
<django.http.HttpRequest.urlconf>` to ``None`` to revert any changes made
|
| 575 |
+
by previous middleware and return to using the :setting:`ROOT_URLCONF`.
|
| 576 |
+
|
| 577 |
+
* The :setting:`DISALLOWED_USER_AGENTS` check in
|
| 578 |
+
:class:`~django.middleware.common.CommonMiddleware` now raises a
|
| 579 |
+
:class:`~django.core.exceptions.PermissionDenied` exception as opposed to
|
| 580 |
+
returning an :class:`~django.http.HttpResponseForbidden` so that
|
| 581 |
+
:data:`~django.conf.urls.handler403` is invoked.
|
| 582 |
+
|
| 583 |
+
* Added :meth:`HttpRequest.get_port() <django.http.HttpRequest.get_port>` to
|
| 584 |
+
fetch the originating port of the request.
|
| 585 |
+
|
| 586 |
+
* Added the ``json_dumps_params`` parameter to
|
| 587 |
+
:class:`~django.http.JsonResponse` to allow passing keyword arguments to the
|
| 588 |
+
``json.dumps()`` call used to generate the response.
|
| 589 |
+
|
| 590 |
+
* The :class:`~django.middleware.common.BrokenLinkEmailsMiddleware` now
|
| 591 |
+
ignores 404s when the referer is equal to the requested URL. To circumvent
|
| 592 |
+
the empty referer check already implemented, some web bots set the referer to
|
| 593 |
+
the requested URL.
|
| 594 |
+
|
| 595 |
+
Templates
|
| 596 |
+
~~~~~~~~~
|
| 597 |
+
|
| 598 |
+
* Template tags created with the :meth:`~django.template.Library.simple_tag`
|
| 599 |
+
helper can now store results in a template variable by using the ``as``
|
| 600 |
+
argument.
|
| 601 |
+
|
| 602 |
+
* Added a :meth:`Context.setdefault() <django.template.Context.setdefault>`
|
| 603 |
+
method.
|
| 604 |
+
|
| 605 |
+
* The :ref:`django.template <django-template-logger>` logger was added and
|
| 606 |
+
includes the following messages:
|
| 607 |
+
|
| 608 |
+
* A ``DEBUG`` level message for missing context variables.
|
| 609 |
+
|
| 610 |
+
* A ``WARNING`` level message for uncaught exceptions raised
|
| 611 |
+
during the rendering of an ``{% include %}`` when debug mode is off
|
| 612 |
+
(helpful since ``{% include %}`` silences the exception and returns an
|
| 613 |
+
empty string).
|
| 614 |
+
|
| 615 |
+
* The :ttag:`firstof` template tag supports storing the output in a variable
|
| 616 |
+
using 'as'.
|
| 617 |
+
|
| 618 |
+
* :meth:`Context.update() <django.template.Context.update>` can now be used as
|
| 619 |
+
a context manager.
|
| 620 |
+
|
| 621 |
+
* Django template loaders can now extend templates recursively.
|
| 622 |
+
|
| 623 |
+
* The debug page template postmortem now include output from each engine that
|
| 624 |
+
is installed.
|
| 625 |
+
|
| 626 |
+
* :ref:`Debug page integration <template-debug-integration>` for custom
|
| 627 |
+
template engines was added.
|
| 628 |
+
|
| 629 |
+
* The :class:`~django.template.backends.django.DjangoTemplates` backend gained
|
| 630 |
+
the ability to register libraries and builtins explicitly through the
|
| 631 |
+
template :setting:`OPTIONS <TEMPLATES-OPTIONS>`.
|
| 632 |
+
|
| 633 |
+
* The ``timesince`` and ``timeuntil`` filters were improved to deal with leap
|
| 634 |
+
years when given large time spans.
|
| 635 |
+
|
| 636 |
+
* The ``include`` tag now caches parsed templates objects during template
|
| 637 |
+
rendering, speeding up reuse in places such as for loops.
|
| 638 |
+
|
| 639 |
+
Tests
|
| 640 |
+
~~~~~
|
| 641 |
+
|
| 642 |
+
* Added the :meth:`json() <django.test.Response.json>` method to test client
|
| 643 |
+
responses to give access to the response body as JSON.
|
| 644 |
+
|
| 645 |
+
* Added the :meth:`~django.test.Client.force_login()` method to the test
|
| 646 |
+
client. Use this method to simulate the effect of a user logging into the
|
| 647 |
+
site while skipping the authentication and verification steps of
|
| 648 |
+
:meth:`~django.test.Client.login()`.
|
| 649 |
+
|
| 650 |
+
URLs
|
| 651 |
+
~~~~
|
| 652 |
+
|
| 653 |
+
* Regular expression lookaround assertions are now allowed in URL patterns.
|
| 654 |
+
|
| 655 |
+
* The application namespace can now be set using an ``app_name`` attribute
|
| 656 |
+
on the included module or object. It can also be set by passing a 2-tuple
|
| 657 |
+
of (<list of patterns>, <application namespace>) as the first argument to
|
| 658 |
+
``include()``.
|
| 659 |
+
|
| 660 |
+
* System checks have been added for common URL pattern mistakes.
|
| 661 |
+
|
| 662 |
+
Validators
|
| 663 |
+
~~~~~~~~~~
|
| 664 |
+
|
| 665 |
+
* Added :func:`django.core.validators.int_list_validator` to generate
|
| 666 |
+
validators of strings containing integers separated with a custom character.
|
| 667 |
+
|
| 668 |
+
* :class:`~django.core.validators.EmailValidator` now limits the length of
|
| 669 |
+
domain name labels to 63 characters per :rfc:`1034`.
|
| 670 |
+
|
| 671 |
+
* Added :func:`~django.core.validators.validate_unicode_slug` to validate slugs
|
| 672 |
+
that may contain Unicode characters.
|
| 673 |
+
|
| 674 |
+
.. _backwards-incompatible-1.9:
|
| 675 |
+
|
| 676 |
+
Backwards incompatible changes in 1.9
|
| 677 |
+
=====================================
|
| 678 |
+
|
| 679 |
+
.. warning::
|
| 680 |
+
|
| 681 |
+
In addition to the changes outlined in this section, be sure to review the
|
| 682 |
+
:ref:`removed-features-1.9` for the features that have reached the end of
|
| 683 |
+
their deprecation cycle and therefore been removed. If you haven't updated
|
| 684 |
+
your code within the deprecation timeline for a given feature, its removal
|
| 685 |
+
may appear as a backwards incompatible change.
|
| 686 |
+
|
| 687 |
+
Database backend API
|
| 688 |
+
--------------------
|
| 689 |
+
|
| 690 |
+
* A couple of new tests rely on the ability of the backend to introspect column
|
| 691 |
+
defaults (returning the result as ``Field.default``). You can set the
|
| 692 |
+
``can_introspect_default`` database feature to ``False`` if your backend
|
| 693 |
+
doesn't implement this. You may want to review the implementation on the
|
| 694 |
+
backends that Django includes for reference (:ticket:`24245`).
|
| 695 |
+
|
| 696 |
+
* Registering a global adapter or converter at the level of the DB-API module
|
| 697 |
+
to handle time zone information of :class:`~datetime.datetime` values passed
|
| 698 |
+
as query parameters or returned as query results on databases that don't
|
| 699 |
+
support time zones is discouraged. It can conflict with other libraries.
|
| 700 |
+
|
| 701 |
+
The recommended way to add a time zone to :class:`~datetime.datetime` values
|
| 702 |
+
fetched from the database is to register a converter for ``DateTimeField``
|
| 703 |
+
in ``DatabaseOperations.get_db_converters()``.
|
| 704 |
+
|
| 705 |
+
The ``needs_datetime_string_cast`` database feature was removed. Database
|
| 706 |
+
backends that set it must register a converter instead, as explained above.
|
| 707 |
+
|
| 708 |
+
* The ``DatabaseOperations.value_to_db_<type>()`` methods were renamed to
|
| 709 |
+
``adapt_<type>field_value()`` to mirror the ``convert_<type>field_value()``
|
| 710 |
+
methods.
|
| 711 |
+
|
| 712 |
+
* To use the new ``date`` lookup, third-party database backends may need to
|
| 713 |
+
implement the ``DatabaseOperations.datetime_cast_date_sql()`` method.
|
| 714 |
+
|
| 715 |
+
* The ``DatabaseOperations.time_extract_sql()`` method was added. It calls the
|
| 716 |
+
existing ``date_extract_sql()`` method. This method is overridden by the
|
| 717 |
+
SQLite backend to add time lookups (hour, minute, second) to
|
| 718 |
+
:class:`~django.db.models.TimeField`, and may be needed by third-party
|
| 719 |
+
database backends.
|
| 720 |
+
|
| 721 |
+
* The ``DatabaseOperations.datetime_cast_sql()`` method (not to be confused
|
| 722 |
+
with ``DatabaseOperations.datetime_cast_date_sql()`` mentioned above)
|
| 723 |
+
has been removed. This method served to format dates on Oracle long
|
| 724 |
+
before 1.0, but hasn't been overridden by any core backend in years
|
| 725 |
+
and hasn't been called anywhere in Django's code or tests.
|
| 726 |
+
|
| 727 |
+
* In order to support test parallelization, you must implement the
|
| 728 |
+
``DatabaseCreation._clone_test_db()`` method and set
|
| 729 |
+
``DatabaseFeatures.can_clone_databases = True``. You may have to adjust
|
| 730 |
+
``DatabaseCreation.get_test_db_clone_settings()``.
|
| 731 |
+
|
| 732 |
+
Default settings that were tuples are now lists
|
| 733 |
+
-----------------------------------------------
|
| 734 |
+
|
| 735 |
+
The default settings in ``django.conf.global_settings`` were a combination of
|
| 736 |
+
lists and tuples. All settings that were formerly tuples are now lists.
|
| 737 |
+
|
| 738 |
+
``is_usable`` attribute on template loaders is removed
|
| 739 |
+
------------------------------------------------------
|
| 740 |
+
|
| 741 |
+
Django template loaders previously required an ``is_usable`` attribute to be
|
| 742 |
+
defined. If a loader was configured in the template settings and this attribute
|
| 743 |
+
was ``False``, the loader would be silently ignored. In practice, this was only
|
| 744 |
+
used by the egg loader to detect if setuptools was installed. The ``is_usable``
|
| 745 |
+
attribute is now removed and the egg loader instead fails at runtime if
|
| 746 |
+
setuptools is not installed.
|
| 747 |
+
|
| 748 |
+
Related set direct assignment
|
| 749 |
+
-----------------------------
|
| 750 |
+
|
| 751 |
+
Direct assignment of related objects in the ORM used to perform a ``clear()``
|
| 752 |
+
followed by a call to ``add()``. This caused needlessly large data changes and
|
| 753 |
+
prevented using the :data:`~django.db.models.signals.m2m_changed` signal to
|
| 754 |
+
track individual changes in many-to-many relations.
|
| 755 |
+
|
| 756 |
+
Direct assignment now relies on the new
|
| 757 |
+
:meth:`~django.db.models.fields.related.RelatedManager.set` method on related
|
| 758 |
+
managers which by default only processes changes between the existing related
|
| 759 |
+
set and the one that's newly assigned. The previous behavior can be restored by
|
| 760 |
+
replacing direct assignment by a call to ``set()`` with the keyword argument
|
| 761 |
+
``clear=True``.
|
| 762 |
+
|
| 763 |
+
``ModelForm``, and therefore ``ModelAdmin``, internally rely on direct
|
| 764 |
+
assignment for many-to-many relations and as a consequence now use the new
|
| 765 |
+
behavior.
|
| 766 |
+
|
| 767 |
+
Filesystem-based template loaders catch more specific exceptions
|
| 768 |
+
----------------------------------------------------------------
|
| 769 |
+
|
| 770 |
+
When using the :class:`filesystem.Loader <django.template.loaders.filesystem.Loader>`
|
| 771 |
+
or :class:`app_directories.Loader <django.template.loaders.app_directories.Loader>`
|
| 772 |
+
template loaders, earlier versions of Django raised a
|
| 773 |
+
:exc:`~django.template.TemplateDoesNotExist` error if a template source existed
|
| 774 |
+
but was unreadable. This could happen under many circumstances, such as if
|
| 775 |
+
Django didn't have permissions to open the file, or if the template source was
|
| 776 |
+
a directory. Now, Django only silences the exception if the template source
|
| 777 |
+
does not exist. All other situations result in the original ``IOError`` being
|
| 778 |
+
raised.
|
| 779 |
+
|
| 780 |
+
HTTP redirects no longer forced to absolute URIs
|
| 781 |
+
------------------------------------------------
|
| 782 |
+
|
| 783 |
+
Relative redirects are no longer converted to absolute URIs. :rfc:`2616`
|
| 784 |
+
required the ``Location`` header in redirect responses to be an absolute URI,
|
| 785 |
+
but it has been superseded by :rfc:`7231` which allows relative URIs in
|
| 786 |
+
``Location``, recognizing the actual practice of user agents, almost all of
|
| 787 |
+
which support them.
|
| 788 |
+
|
| 789 |
+
Consequently, the expected URLs passed to ``assertRedirects`` should generally
|
| 790 |
+
no longer include the scheme and domain part of the URLs. For example,
|
| 791 |
+
``self.assertRedirects(response, 'http://testserver/some-url/')`` should be
|
| 792 |
+
replaced by ``self.assertRedirects(response, '/some-url/')`` (unless the
|
| 793 |
+
redirection specifically contained an absolute URL).
|
| 794 |
+
|
| 795 |
+
In the rare case that you need the old behavior (discovered with an ancient
|
| 796 |
+
version of Apache with ``mod_scgi`` that interprets a relative redirect as an
|
| 797 |
+
"internal redirect"), you can restore it by writing a custom middleware::
|
| 798 |
+
|
| 799 |
+
class LocationHeaderFix(object):
|
| 800 |
+
def process_response(self, request, response):
|
| 801 |
+
if "Location" in response:
|
| 802 |
+
response["Location"] = request.build_absolute_uri(response["Location"])
|
| 803 |
+
return response
|
| 804 |
+
|
| 805 |
+
Dropped support for PostgreSQL 9.0
|
| 806 |
+
----------------------------------
|
| 807 |
+
|
| 808 |
+
Upstream support for PostgreSQL 9.0 ended in September 2015. As a consequence,
|
| 809 |
+
Django 1.9 sets 9.1 as the minimum PostgreSQL version it officially supports.
|
| 810 |
+
|
| 811 |
+
Dropped support for Oracle 11.1
|
| 812 |
+
-------------------------------
|
| 813 |
+
|
| 814 |
+
Upstream support for Oracle 11.1 ended in August 2015. As a consequence, Django
|
| 815 |
+
1.9 sets 11.2 as the minimum Oracle version it officially supports.
|
| 816 |
+
|
| 817 |
+
Bulk behavior of ``add()`` method of related managers
|
| 818 |
+
-----------------------------------------------------
|
| 819 |
+
|
| 820 |
+
To improve performance, the ``add()`` methods of the related managers created
|
| 821 |
+
by ``ForeignKey`` and ``GenericForeignKey`` changed from a series of
|
| 822 |
+
``Model.save()`` calls to a single ``QuerySet.update()`` call. The change means
|
| 823 |
+
that ``pre_save`` and ``post_save`` signals aren't sent anymore. You can use
|
| 824 |
+
the ``bulk=False`` keyword argument to revert to the previous behavior.
|
| 825 |
+
|
| 826 |
+
Template ``LoaderOrigin`` and ``StringOrigin`` are removed
|
| 827 |
+
----------------------------------------------------------
|
| 828 |
+
|
| 829 |
+
In previous versions of Django, when a template engine was initialized with
|
| 830 |
+
debug as ``True``, an instance of ``django.template.loader.LoaderOrigin`` or
|
| 831 |
+
``django.template.base.StringOrigin`` was set as the origin attribute on the
|
| 832 |
+
template object. These classes have been combined into
|
| 833 |
+
:class:`~django.template.base.Origin` and is now always set regardless of the
|
| 834 |
+
engine debug setting. For a minimal level of backwards compatibility, the old
|
| 835 |
+
class names will be kept as aliases to the new ``Origin`` class until
|
| 836 |
+
Django 2.0.
|
| 837 |
+
|
| 838 |
+
.. _default-logging-changes-19:
|
| 839 |
+
|
| 840 |
+
Changes to the default logging configuration
|
| 841 |
+
--------------------------------------------
|
| 842 |
+
|
| 843 |
+
To make it easier to write custom logging configurations, Django's default
|
| 844 |
+
logging configuration no longer defines ``django.request`` and
|
| 845 |
+
``django.security`` loggers. Instead, it defines a single ``django`` logger,
|
| 846 |
+
filtered at the ``INFO`` level, with two handlers:
|
| 847 |
+
|
| 848 |
+
* ``console``: filtered at the ``INFO`` level and only active if ``DEBUG=True``.
|
| 849 |
+
* ``mail_admins``: filtered at the ``ERROR`` level and only active if
|
| 850 |
+
``DEBUG=False``.
|
| 851 |
+
|
| 852 |
+
If you aren't overriding Django's default logging, you should see minimal
|
| 853 |
+
changes in behavior, but you might see some new logging to the ``runserver``
|
| 854 |
+
console, for example.
|
| 855 |
+
|
| 856 |
+
If you are overriding Django's default logging, you should check to see how
|
| 857 |
+
your configuration merges with the new defaults.
|
| 858 |
+
|
| 859 |
+
``HttpRequest`` details in error reporting
|
| 860 |
+
------------------------------------------
|
| 861 |
+
|
| 862 |
+
It was redundant to display the full details of the
|
| 863 |
+
:class:`~django.http.HttpRequest` each time it appeared as a stack frame
|
| 864 |
+
variable in the HTML version of the debug page and error email. Thus, the HTTP
|
| 865 |
+
request will now display the same standard representation as other variables
|
| 866 |
+
(``repr(request)``). As a result, the
|
| 867 |
+
``ExceptionReporterFilter.get_request_repr()`` method and the undocumented
|
| 868 |
+
``django.http.build_request_repr()`` function were removed.
|
| 869 |
+
|
| 870 |
+
The contents of the text version of the email were modified to provide a
|
| 871 |
+
traceback of the same structure as in the case of AJAX requests. The traceback
|
| 872 |
+
details are rendered by the ``ExceptionReporter.get_traceback_text()`` method.
|
| 873 |
+
|
| 874 |
+
Removal of time zone aware global adapters and converters for datetimes
|
| 875 |
+
-----------------------------------------------------------------------
|
| 876 |
+
|
| 877 |
+
Django no longer registers global adapters and converters for managing time
|
| 878 |
+
zone information on :class:`~datetime.datetime` values sent to the database as
|
| 879 |
+
query parameters or read from the database in query results. This change
|
| 880 |
+
affects projects that meet all the following conditions:
|
| 881 |
+
|
| 882 |
+
* The :setting:`USE_TZ` setting is ``True``.
|
| 883 |
+
* The database is SQLite, MySQL, Oracle, or a third-party database that
|
| 884 |
+
doesn't support time zones. In doubt, you can check the value of
|
| 885 |
+
``connection.features.supports_timezones``.
|
| 886 |
+
* The code queries the database outside of the ORM, typically with
|
| 887 |
+
``cursor.execute(sql, params)``.
|
| 888 |
+
|
| 889 |
+
If you're passing aware :class:`~datetime.datetime` parameters to such
|
| 890 |
+
queries, you should turn them into naive datetimes in UTC::
|
| 891 |
+
|
| 892 |
+
from django.utils import timezone
|
| 893 |
+
|
| 894 |
+
param = timezone.make_naive(param, timezone.utc)
|
| 895 |
+
|
| 896 |
+
If you fail to do so, the conversion will be performed as in earlier versions
|
| 897 |
+
(with a deprecation warning) up until Django 1.11. Django 2.0 won't perform any
|
| 898 |
+
conversion, which may result in data corruption.
|
| 899 |
+
|
| 900 |
+
If you're reading :class:`~datetime.datetime` values from the results, they
|
| 901 |
+
will be naive instead of aware. You can compensate as follows::
|
| 902 |
+
|
| 903 |
+
from django.utils import timezone
|
| 904 |
+
|
| 905 |
+
value = timezone.make_aware(value, timezone.utc)
|
| 906 |
+
|
| 907 |
+
You don't need any of this if you're querying the database through the ORM,
|
| 908 |
+
even if you're using :meth:`raw() <django.db.models.query.QuerySet.raw>`
|
| 909 |
+
queries. The ORM takes care of managing time zone information.
|
| 910 |
+
|
| 911 |
+
Template tag modules are imported when templates are configured
|
| 912 |
+
---------------------------------------------------------------
|
| 913 |
+
|
| 914 |
+
The :class:`~django.template.backends.django.DjangoTemplates` backend now
|
| 915 |
+
performs discovery on installed template tag modules when instantiated. This
|
| 916 |
+
update enables libraries to be provided explicitly via the ``'libraries'``
|
| 917 |
+
key of :setting:`OPTIONS <TEMPLATES-OPTIONS>` when defining a
|
| 918 |
+
:class:`~django.template.backends.django.DjangoTemplates` backend. Import
|
| 919 |
+
or syntax errors in template tag modules now fail early at instantiation time
|
| 920 |
+
rather than when a template with a :ttag:`{% load %}<load>` tag is first
|
| 921 |
+
compiled.
|
| 922 |
+
|
| 923 |
+
``django.template.base.add_to_builtins()`` is removed
|
| 924 |
+
-----------------------------------------------------
|
| 925 |
+
|
| 926 |
+
Although it was a private API, projects commonly used ``add_to_builtins()`` to
|
| 927 |
+
make template tags and filters available without using the
|
| 928 |
+
:ttag:`{% load %}<load>` tag. This API has been formalized. Projects should now
|
| 929 |
+
define built-in libraries via the ``'builtins'`` key of :setting:`OPTIONS
|
| 930 |
+
<TEMPLATES-OPTIONS>` when defining a
|
| 931 |
+
:class:`~django.template.backends.django.DjangoTemplates` backend.
|
| 932 |
+
|
| 933 |
+
.. _simple-tag-conditional-escape-fix:
|
| 934 |
+
|
| 935 |
+
``simple_tag`` now wraps tag output in ``conditional_escape``
|
| 936 |
+
-------------------------------------------------------------
|
| 937 |
+
|
| 938 |
+
In general, template tags do not autoescape their contents, and this behavior is
|
| 939 |
+
:ref:`documented <tags-auto-escaping>`. For tags like
|
| 940 |
+
:class:`~django.template.Library.inclusion_tag`, this is not a problem because
|
| 941 |
+
the included template will perform autoescaping. For ``assignment_tag()``,
|
| 942 |
+
the output will be escaped when it is used as a variable in the template.
|
| 943 |
+
|
| 944 |
+
For the intended use cases of :class:`~django.template.Library.simple_tag`,
|
| 945 |
+
however, it is very easy to end up with incorrect HTML and possibly an XSS
|
| 946 |
+
exploit. For example::
|
| 947 |
+
|
| 948 |
+
@register.simple_tag(takes_context=True)
|
| 949 |
+
def greeting(context):
|
| 950 |
+
return "Hello {0}!".format(context["request"].user.first_name)
|
| 951 |
+
|
| 952 |
+
In older versions of Django, this will be an XSS issue because
|
| 953 |
+
``user.first_name`` is not escaped.
|
| 954 |
+
|
| 955 |
+
In Django 1.9, this is fixed: if the template context has ``autoescape=True``
|
| 956 |
+
set (the default), then ``simple_tag`` will wrap the output of the tag function
|
| 957 |
+
with :func:`~django.utils.html.conditional_escape`.
|
| 958 |
+
|
| 959 |
+
To fix your ``simple_tag``\s, it is best to apply the following practices:
|
| 960 |
+
|
| 961 |
+
* Any code that generates HTML should use either the template system or
|
| 962 |
+
:func:`~django.utils.html.format_html`.
|
| 963 |
+
|
| 964 |
+
* If the output of a ``simple_tag`` needs escaping, use
|
| 965 |
+
:func:`~django.utils.html.escape` or
|
| 966 |
+
:func:`~django.utils.html.conditional_escape`.
|
| 967 |
+
|
| 968 |
+
* If you are absolutely certain that you are outputting HTML from a trusted
|
| 969 |
+
source (e.g. a CMS field that stores HTML entered by admins), you can mark it
|
| 970 |
+
as such using :func:`~django.utils.safestring.mark_safe`.
|
| 971 |
+
|
| 972 |
+
Tags that follow these rules will be correct and safe whether they are run on
|
| 973 |
+
Django 1.9+ or earlier.
|
| 974 |
+
|
| 975 |
+
``Paginator.page_range``
|
| 976 |
+
------------------------
|
| 977 |
+
|
| 978 |
+
:attr:`Paginator.page_range <django.core.paginator.Paginator.page_range>` is
|
| 979 |
+
now an iterator instead of a list.
|
| 980 |
+
|
| 981 |
+
In versions of Django previous to 1.8, ``Paginator.page_range`` returned a
|
| 982 |
+
``list`` in Python 2 and a ``range`` in Python 3. Django 1.8 consistently
|
| 983 |
+
returned a list, but an iterator is more efficient.
|
| 984 |
+
|
| 985 |
+
Existing code that depends on ``list`` specific features, such as indexing,
|
| 986 |
+
can be ported by converting the iterator into a ``list`` using ``list()``.
|
| 987 |
+
|
| 988 |
+
Implicit ``QuerySet`` ``__in`` lookup removed
|
| 989 |
+
---------------------------------------------
|
| 990 |
+
|
| 991 |
+
In earlier versions, queries such as::
|
| 992 |
+
|
| 993 |
+
Model.objects.filter(related_id=RelatedModel.objects.all())
|
| 994 |
+
|
| 995 |
+
would implicitly convert to::
|
| 996 |
+
|
| 997 |
+
Model.objects.filter(related_id__in=RelatedModel.objects.all())
|
| 998 |
+
|
| 999 |
+
resulting in SQL like ``"related_id IN (SELECT id FROM ...)"``.
|
| 1000 |
+
|
| 1001 |
+
This implicit ``__in`` no longer happens so the "IN" SQL is now "=", and if the
|
| 1002 |
+
subquery returns multiple results, at least some databases will throw an error.
|
| 1003 |
+
|
| 1004 |
+
.. _admin-browser-support-19:
|
| 1005 |
+
|
| 1006 |
+
``contrib.admin`` browser support
|
| 1007 |
+
---------------------------------
|
| 1008 |
+
|
| 1009 |
+
The admin no longer supports Internet Explorer 8 and below, as these browsers
|
| 1010 |
+
have reached end-of-life.
|
| 1011 |
+
|
| 1012 |
+
CSS and images to support Internet Explorer 6 and 7 have been removed. PNG and
|
| 1013 |
+
GIF icons have been replaced with SVG icons, which are not supported by
|
| 1014 |
+
Internet Explorer 8 and earlier.
|
| 1015 |
+
|
| 1016 |
+
The jQuery library embedded in the admin has been upgraded from version 1.11.2
|
| 1017 |
+
to 2.1.4. jQuery 2.x has the same API as jQuery 1.x, but does not support
|
| 1018 |
+
Internet Explorer 6, 7, or 8, allowing for better performance and a smaller
|
| 1019 |
+
file size. If you need to support IE8 and must also use the latest version of
|
| 1020 |
+
Django, you can override the admin's copy of jQuery with your own by creating
|
| 1021 |
+
a Django application with this structure:
|
| 1022 |
+
|
| 1023 |
+
.. code-block:: text
|
| 1024 |
+
|
| 1025 |
+
app/static/admin/js/vendor/
|
| 1026 |
+
jquery.js
|
| 1027 |
+
jquery.min.js
|
| 1028 |
+
|
| 1029 |
+
.. _syntax-error-old-setuptools-django-19:
|
| 1030 |
+
|
| 1031 |
+
``SyntaxError`` when installing Django setuptools 5.5.x
|
| 1032 |
+
-------------------------------------------------------
|
| 1033 |
+
|
| 1034 |
+
When installing Django 1.9 or 1.9.1 with setuptools 5.5.x, you'll see:
|
| 1035 |
+
|
| 1036 |
+
.. code-block:: shell
|
| 1037 |
+
|
| 1038 |
+
Compiling django/conf/app_template/apps.py ...
|
| 1039 |
+
File "django/conf/app_template/apps.py", line 4
|
| 1040 |
+
class {{ camel_case_app_name }}Config(AppConfig):
|
| 1041 |
+
^
|
| 1042 |
+
SyntaxError: invalid syntax
|
| 1043 |
+
|
| 1044 |
+
Compiling django/conf/app_template/models.py ...
|
| 1045 |
+
File "django/conf/app_template/models.py", line 1
|
| 1046 |
+
{{ unicode_literals }}from django.db import models
|
| 1047 |
+
^
|
| 1048 |
+
SyntaxError: invalid syntax
|
| 1049 |
+
|
| 1050 |
+
It's safe to ignore these errors (Django will still install just fine), but you
|
| 1051 |
+
can avoid them by upgrading setuptools to a more recent version. If you're
|
| 1052 |
+
using pip, you can upgrade pip using ``python -m pip install -U pip`` which
|
| 1053 |
+
will also upgrade setuptools. This is resolved in later versions of Django as
|
| 1054 |
+
described in the :doc:`/releases/1.9.2`.
|
| 1055 |
+
|
| 1056 |
+
Miscellaneous
|
| 1057 |
+
-------------
|
| 1058 |
+
|
| 1059 |
+
* The jQuery static files in ``contrib.admin`` have been moved into a
|
| 1060 |
+
``vendor/jquery`` subdirectory.
|
| 1061 |
+
|
| 1062 |
+
* The text displayed for null columns in the admin changelist ``list_display``
|
| 1063 |
+
cells has changed from ``(None)`` (or its translated equivalent) to ``-`` (a
|
| 1064 |
+
dash).
|
| 1065 |
+
|
| 1066 |
+
* ``django.http.responses.REASON_PHRASES`` and
|
| 1067 |
+
``django.core.handlers.wsgi.STATUS_CODE_TEXT`` have been removed. Use
|
| 1068 |
+
Python's Standard Library instead: :data:`http.client.responses` for Python
|
| 1069 |
+
3 and `httplib.responses`_ for Python 2.
|
| 1070 |
+
|
| 1071 |
+
.. _`httplib.responses`: https://docs.python.org/2/library/httplib.html#httplib.responses
|
| 1072 |
+
|
| 1073 |
+
* ``ValuesQuerySet`` and ``ValuesListQuerySet`` have been removed.
|
| 1074 |
+
|
| 1075 |
+
* The ``admin/base.html`` template no longer sets
|
| 1076 |
+
``window.__admin_media_prefix__`` or ``window.__admin_utc_offset__``. Image
|
| 1077 |
+
references in JavaScript that used that value to construct absolute URLs have
|
| 1078 |
+
been moved to CSS for easier customization. The UTC offset is stored on a
|
| 1079 |
+
data attribute of the ``<body>`` tag.
|
| 1080 |
+
|
| 1081 |
+
* ``CommaSeparatedIntegerField`` validation has been refined to forbid values
|
| 1082 |
+
like ``','``, ``',1'``, and ``'1,,2'``.
|
| 1083 |
+
|
| 1084 |
+
* Form initialization was moved from the :meth:`ProcessFormView.get()
|
| 1085 |
+
<django.views.generic.edit.ProcessFormView.get>` method to the new
|
| 1086 |
+
:meth:`FormMixin.get_context_data()
|
| 1087 |
+
<django.views.generic.edit.FormMixin.get_context_data>` method. This may be
|
| 1088 |
+
backwards incompatible if you have overridden the ``get_context_data()``
|
| 1089 |
+
method without calling ``super()``.
|
| 1090 |
+
|
| 1091 |
+
* Support for PostGIS 1.5 has been dropped.
|
| 1092 |
+
|
| 1093 |
+
* The ``django.contrib.sites.models.Site.domain`` field was changed to be
|
| 1094 |
+
:attr:`~django.db.models.Field.unique`.
|
| 1095 |
+
|
| 1096 |
+
* In order to enforce test isolation, database queries are not allowed
|
| 1097 |
+
by default in :class:`~django.test.SimpleTestCase` tests anymore. You
|
| 1098 |
+
can disable this behavior by setting the ``allow_database_queries`` class
|
| 1099 |
+
attribute to ``True`` on your test class.
|
| 1100 |
+
|
| 1101 |
+
* ``ResolverMatch.app_name`` was changed to contain the full namespace path in
|
| 1102 |
+
the case of nested namespaces. For consistency with
|
| 1103 |
+
``ResolverMatch.namespace``, the empty value is now an empty string instead
|
| 1104 |
+
of ``None``.
|
| 1105 |
+
|
| 1106 |
+
* For security hardening, session keys must be at least 8 characters.
|
| 1107 |
+
|
| 1108 |
+
* Private function ``django.utils.functional.total_ordering()`` has been
|
| 1109 |
+
removed. It contained a workaround for a ``functools.total_ordering()`` bug
|
| 1110 |
+
in Python versions older than 2.7.3.
|
| 1111 |
+
|
| 1112 |
+
* XML serialization (either through :djadmin:`dumpdata` or the syndication
|
| 1113 |
+
framework) used to output any characters it received. Now if the content to
|
| 1114 |
+
be serialized contains any control characters not allowed in the XML 1.0
|
| 1115 |
+
standard, the serialization will fail with a :exc:`ValueError`.
|
| 1116 |
+
|
| 1117 |
+
* :class:`~django.forms.CharField` now strips input of leading and trailing
|
| 1118 |
+
whitespace by default. This can be disabled by setting the new
|
| 1119 |
+
:attr:`~django.forms.CharField.strip` argument to ``False``.
|
| 1120 |
+
|
| 1121 |
+
* Template text that is translated and uses two or more consecutive percent
|
| 1122 |
+
signs, e.g. ``"%%"``, may have a new ``msgid`` after ``makemessages`` is run
|
| 1123 |
+
(most likely the translation will be marked fuzzy). The new ``msgid`` will be
|
| 1124 |
+
marked ``"#, python-format"``.
|
| 1125 |
+
|
| 1126 |
+
* If neither :attr:`request.current_app <django.http.HttpRequest.current_app>`
|
| 1127 |
+
nor :class:`Context.current_app <django.template.Context>` are set, the
|
| 1128 |
+
:ttag:`url` template tag will now use the namespace of the current request.
|
| 1129 |
+
Set ``request.current_app`` to ``None`` if you don't want to use a namespace
|
| 1130 |
+
hint.
|
| 1131 |
+
|
| 1132 |
+
* The :setting:`SILENCED_SYSTEM_CHECKS` setting now silences messages of all
|
| 1133 |
+
levels. Previously, messages of ``ERROR`` level or higher were printed to the
|
| 1134 |
+
console.
|
| 1135 |
+
|
| 1136 |
+
* The ``FlatPage.enable_comments`` field is removed from the ``FlatPageAdmin``
|
| 1137 |
+
as it's unused by the application. If your project or a third-party app makes
|
| 1138 |
+
use of it, :ref:`create a custom ModelAdmin <flatpages-admin>` to add it back.
|
| 1139 |
+
|
| 1140 |
+
* The return value of
|
| 1141 |
+
:meth:`~django.test.runner.DiscoverRunner.setup_databases` and the first
|
| 1142 |
+
argument of :meth:`~django.test.runner.DiscoverRunner.teardown_databases`
|
| 1143 |
+
changed. They used to be ``(old_names, mirrors)`` tuples. Now they're just
|
| 1144 |
+
the first item, ``old_names``.
|
| 1145 |
+
|
| 1146 |
+
* By default :class:`~django.test.LiveServerTestCase` attempts to find an
|
| 1147 |
+
available port in the 8081-8179 range instead of just trying port 8081.
|
| 1148 |
+
|
| 1149 |
+
* The system checks for :class:`~django.contrib.admin.ModelAdmin` now check
|
| 1150 |
+
instances rather than classes.
|
| 1151 |
+
|
| 1152 |
+
* The private API to apply mixed migration plans has been dropped for
|
| 1153 |
+
performance reasons. Mixed plans consist of a list of migrations where some
|
| 1154 |
+
are being applied and others are being unapplied.
|
| 1155 |
+
|
| 1156 |
+
* The related model object descriptor classes in
|
| 1157 |
+
``django.db.models.fields.related`` (private API) are moved from the
|
| 1158 |
+
``related`` module to ``related_descriptors`` and renamed as follows:
|
| 1159 |
+
|
| 1160 |
+
* ``ReverseSingleRelatedObjectDescriptor`` is ``ForwardManyToOneDescriptor``
|
| 1161 |
+
* ``SingleRelatedObjectDescriptor`` is ``ReverseOneToOneDescriptor``
|
| 1162 |
+
* ``ForeignRelatedObjectsDescriptor`` is ``ReverseManyToOneDescriptor``
|
| 1163 |
+
* ``ManyRelatedObjectsDescriptor`` is ``ManyToManyDescriptor``
|
| 1164 |
+
|
| 1165 |
+
* If you implement a custom :data:`~django.conf.urls.handler404` view, it must
|
| 1166 |
+
return a response with an HTTP 404 status code. Use
|
| 1167 |
+
:class:`~django.http.HttpResponseNotFound` or pass ``status=404`` to the
|
| 1168 |
+
:class:`~django.http.HttpResponse`. Otherwise, :setting:`APPEND_SLASH` won't
|
| 1169 |
+
work correctly with ``DEBUG=False``.
|
| 1170 |
+
|
| 1171 |
+
.. _deprecated-features-1.9:
|
| 1172 |
+
|
| 1173 |
+
Features deprecated in 1.9
|
| 1174 |
+
==========================
|
| 1175 |
+
|
| 1176 |
+
``assignment_tag()``
|
| 1177 |
+
--------------------
|
| 1178 |
+
|
| 1179 |
+
Django 1.4 added the ``assignment_tag`` helper to ease the creation of
|
| 1180 |
+
template tags that store results in a template variable. The
|
| 1181 |
+
:meth:`~django.template.Library.simple_tag` helper has gained this same
|
| 1182 |
+
ability, making the ``assignment_tag`` obsolete. Tags that use
|
| 1183 |
+
``assignment_tag`` should be updated to use ``simple_tag``.
|
| 1184 |
+
|
| 1185 |
+
``{% cycle %}`` syntax with comma-separated arguments
|
| 1186 |
+
-----------------------------------------------------
|
| 1187 |
+
|
| 1188 |
+
The :ttag:`cycle` tag supports an inferior old syntax from previous Django
|
| 1189 |
+
versions:
|
| 1190 |
+
|
| 1191 |
+
.. code-block:: html+django
|
| 1192 |
+
|
| 1193 |
+
{% cycle row1,row2,row3 %}
|
| 1194 |
+
|
| 1195 |
+
Its parsing caused bugs with the current syntax, so support for the old syntax
|
| 1196 |
+
will be removed in Django 1.10 following an accelerated deprecation.
|
| 1197 |
+
|
| 1198 |
+
``ForeignKey`` and ``OneToOneField`` ``on_delete`` argument
|
| 1199 |
+
-----------------------------------------------------------
|
| 1200 |
+
|
| 1201 |
+
In order to increase awareness about cascading model deletion, the
|
| 1202 |
+
``on_delete`` argument of ``ForeignKey`` and ``OneToOneField`` will be required
|
| 1203 |
+
in Django 2.0.
|
| 1204 |
+
|
| 1205 |
+
Update models and existing migrations to explicitly set the argument. Since the
|
| 1206 |
+
default is ``models.CASCADE``, add ``on_delete=models.CASCADE`` to all
|
| 1207 |
+
``ForeignKey`` and ``OneToOneField``\s that don't use a different option. You
|
| 1208 |
+
can also pass it as the second positional argument if you don't care about
|
| 1209 |
+
compatibility with older versions of Django.
|
| 1210 |
+
|
| 1211 |
+
``Field.rel`` changes
|
| 1212 |
+
---------------------
|
| 1213 |
+
|
| 1214 |
+
``Field.rel`` and its methods and attributes have changed to match the related
|
| 1215 |
+
fields API. The ``Field.rel`` attribute is renamed to ``remote_field`` and many
|
| 1216 |
+
of its methods and attributes are either changed or renamed.
|
| 1217 |
+
|
| 1218 |
+
The aim of these changes is to provide a documented API for relation fields.
|
| 1219 |
+
|
| 1220 |
+
``GeoManager`` and ``GeoQuerySet`` custom methods
|
| 1221 |
+
-------------------------------------------------
|
| 1222 |
+
|
| 1223 |
+
All custom ``GeoQuerySet`` methods (``area()``, ``distance()``, ``gml()``, ...)
|
| 1224 |
+
have been replaced by equivalent geographic expressions in annotations (see in
|
| 1225 |
+
new features). Hence the need to set a custom ``GeoManager`` to GIS-enabled
|
| 1226 |
+
models is now obsolete. As soon as your code doesn't call any of the deprecated
|
| 1227 |
+
methods, you can simply remove the ``objects = GeoManager()`` lines from your
|
| 1228 |
+
models.
|
| 1229 |
+
|
| 1230 |
+
Template loader APIs have changed
|
| 1231 |
+
---------------------------------
|
| 1232 |
+
|
| 1233 |
+
Django template loaders have been updated to allow recursive template
|
| 1234 |
+
extending. This change necessitated a new template loader API. The old
|
| 1235 |
+
``load_template()`` and ``load_template_sources()`` methods are now deprecated.
|
| 1236 |
+
Details about the new API can be found :ref:`in the template loader
|
| 1237 |
+
documentation <custom-template-loaders>`.
|
| 1238 |
+
|
| 1239 |
+
Passing a 3-tuple or an ``app_name`` to ``include()``
|
| 1240 |
+
-----------------------------------------------------
|
| 1241 |
+
|
| 1242 |
+
The instance namespace part of passing a tuple as an argument to ``include()``
|
| 1243 |
+
has been replaced by passing the ``namespace`` argument to ``include()``. For
|
| 1244 |
+
example::
|
| 1245 |
+
|
| 1246 |
+
polls_patterns = [
|
| 1247 |
+
url(...),
|
| 1248 |
+
]
|
| 1249 |
+
|
| 1250 |
+
urlpatterns = [
|
| 1251 |
+
url(r"^polls/", include((polls_patterns, "polls", "author-polls"))),
|
| 1252 |
+
]
|
| 1253 |
+
|
| 1254 |
+
becomes::
|
| 1255 |
+
|
| 1256 |
+
polls_patterns = (
|
| 1257 |
+
[
|
| 1258 |
+
url(...),
|
| 1259 |
+
],
|
| 1260 |
+
"polls",
|
| 1261 |
+
) # 'polls' is the app_name
|
| 1262 |
+
|
| 1263 |
+
urlpatterns = [
|
| 1264 |
+
url(r"^polls/", include(polls_patterns, namespace="author-polls")),
|
| 1265 |
+
]
|
| 1266 |
+
|
| 1267 |
+
The ``app_name`` argument to ``include()`` has been replaced by passing a
|
| 1268 |
+
2-tuple (as above), or passing an object or module with an ``app_name``
|
| 1269 |
+
attribute (as below). If the ``app_name`` is set in this new way, the
|
| 1270 |
+
``namespace`` argument is no longer required. It will default to the value of
|
| 1271 |
+
``app_name``. For example, the URL patterns in the tutorial are changed from:
|
| 1272 |
+
|
| 1273 |
+
.. code-block:: python
|
| 1274 |
+
:caption: ``mysite/urls.py``
|
| 1275 |
+
|
| 1276 |
+
urlpatterns = [url(r"^polls/", include("polls.urls", namespace="polls")), ...]
|
| 1277 |
+
|
| 1278 |
+
to:
|
| 1279 |
+
|
| 1280 |
+
.. code-block:: python
|
| 1281 |
+
:caption: ``mysite/urls.py``
|
| 1282 |
+
|
| 1283 |
+
urlpatterns = [
|
| 1284 |
+
url(r"^polls/", include("polls.urls")), # 'namespace="polls"' removed
|
| 1285 |
+
...,
|
| 1286 |
+
]
|
| 1287 |
+
|
| 1288 |
+
.. code-block:: python
|
| 1289 |
+
:caption: ``polls/urls.py``
|
| 1290 |
+
|
| 1291 |
+
app_name = "polls" # added
|
| 1292 |
+
urlpatterns = [...]
|
| 1293 |
+
|
| 1294 |
+
This change also means that the old way of including an ``AdminSite`` instance
|
| 1295 |
+
is deprecated. Instead, pass ``admin.site.urls`` directly to
|
| 1296 |
+
``django.conf.urls.url()``:
|
| 1297 |
+
|
| 1298 |
+
.. code-block:: python
|
| 1299 |
+
:caption: ``urls.py``
|
| 1300 |
+
|
| 1301 |
+
from django.conf.urls import url
|
| 1302 |
+
from django.contrib import admin
|
| 1303 |
+
|
| 1304 |
+
urlpatterns = [
|
| 1305 |
+
url(r"^admin/", admin.site.urls),
|
| 1306 |
+
]
|
| 1307 |
+
|
| 1308 |
+
URL application namespace required if setting an instance namespace
|
| 1309 |
+
-------------------------------------------------------------------
|
| 1310 |
+
|
| 1311 |
+
In the past, an instance namespace without an application namespace
|
| 1312 |
+
would serve the same purpose as the application namespace, but it was
|
| 1313 |
+
impossible to reverse the patterns if there was an application namespace
|
| 1314 |
+
with the same name. Includes that specify an instance namespace require that
|
| 1315 |
+
the included URLconf sets an application namespace.
|
| 1316 |
+
|
| 1317 |
+
``current_app`` parameter to ``contrib.auth`` views
|
| 1318 |
+
---------------------------------------------------
|
| 1319 |
+
|
| 1320 |
+
All views in ``django.contrib.auth.views`` have the following structure:
|
| 1321 |
+
|
| 1322 |
+
.. code-block:: text
|
| 1323 |
+
|
| 1324 |
+
def view(request, ..., current_app=None, ...):
|
| 1325 |
+
|
| 1326 |
+
...
|
| 1327 |
+
|
| 1328 |
+
if current_app is not None:
|
| 1329 |
+
request.current_app = current_app
|
| 1330 |
+
|
| 1331 |
+
return TemplateResponse(request, template_name, context)
|
| 1332 |
+
|
| 1333 |
+
As of Django 1.8, ``current_app`` is set on the ``request`` object. For
|
| 1334 |
+
consistency, these views will require the caller to set ``current_app`` on the
|
| 1335 |
+
``request`` instead of passing it in a separate argument.
|
| 1336 |
+
|
| 1337 |
+
``django.contrib.gis.geoip``
|
| 1338 |
+
----------------------------
|
| 1339 |
+
|
| 1340 |
+
The :mod:`django.contrib.gis.geoip2` module supersedes
|
| 1341 |
+
``django.contrib.gis.geoip``. The new module provides a similar API except that
|
| 1342 |
+
it doesn't provide the legacy GeoIP-Python API compatibility methods.
|
| 1343 |
+
|
| 1344 |
+
Miscellaneous
|
| 1345 |
+
-------------
|
| 1346 |
+
|
| 1347 |
+
* The ``weak`` argument to ``django.dispatch.signals.Signal.disconnect()`` has
|
| 1348 |
+
been deprecated as it has no effect.
|
| 1349 |
+
|
| 1350 |
+
* The ``check_aggregate_support()`` method of
|
| 1351 |
+
``django.db.backends.base.BaseDatabaseOperations`` has been deprecated and
|
| 1352 |
+
will be removed in Django 2.0. The more general ``check_expression_support()``
|
| 1353 |
+
should be used instead.
|
| 1354 |
+
|
| 1355 |
+
* ``django.forms.extras`` is deprecated. You can find
|
| 1356 |
+
:class:`~django.forms.SelectDateWidget` in ``django.forms.widgets``
|
| 1357 |
+
(or simply ``django.forms``) instead.
|
| 1358 |
+
|
| 1359 |
+
* Private API ``django.db.models.fields.add_lazy_relation()`` is deprecated.
|
| 1360 |
+
|
| 1361 |
+
* The ``django.contrib.auth.tests.utils.skipIfCustomUser()`` decorator is
|
| 1362 |
+
deprecated. With the test discovery changes in Django 1.6, the tests for
|
| 1363 |
+
``django.contrib`` apps are no longer run as part of the user's project.
|
| 1364 |
+
Therefore, the ``@skipIfCustomUser`` decorator is no longer needed to
|
| 1365 |
+
decorate tests in ``django.contrib.auth``.
|
| 1366 |
+
|
| 1367 |
+
* If you customized some :ref:`error handlers <error-views>`, the view
|
| 1368 |
+
signatures with only one request parameter are deprecated. The views should
|
| 1369 |
+
now also accept a second ``exception`` positional parameter.
|
| 1370 |
+
|
| 1371 |
+
* The ``django.utils.feedgenerator.Atom1Feed.mime_type`` and
|
| 1372 |
+
``django.utils.feedgenerator.RssFeed.mime_type`` attributes are deprecated in
|
| 1373 |
+
favor of ``content_type``.
|
| 1374 |
+
|
| 1375 |
+
* :class:`~django.core.signing.Signer` now issues a warning if an invalid
|
| 1376 |
+
separator is used. This will become an exception in Django 1.10.
|
| 1377 |
+
|
| 1378 |
+
* ``django.db.models.Field._get_val_from_obj()`` is deprecated in favor of
|
| 1379 |
+
``Field.value_from_object()``.
|
| 1380 |
+
|
| 1381 |
+
* ``django.template.loaders.eggs.Loader`` is deprecated as distributing
|
| 1382 |
+
applications as eggs is not recommended.
|
| 1383 |
+
|
| 1384 |
+
* The ``callable_obj`` keyword argument to
|
| 1385 |
+
``SimpleTestCase.assertRaisesMessage()`` is deprecated. Pass the callable as
|
| 1386 |
+
a positional argument instead.
|
| 1387 |
+
|
| 1388 |
+
* The ``allow_tags`` attribute on methods of ``ModelAdmin`` has been
|
| 1389 |
+
deprecated. Use :func:`~django.utils.html.format_html`,
|
| 1390 |
+
:func:`~django.utils.html.format_html_join`, or
|
| 1391 |
+
:func:`~django.utils.safestring.mark_safe` when constructing the method's
|
| 1392 |
+
return value instead.
|
| 1393 |
+
|
| 1394 |
+
* The ``enclosure`` keyword argument to ``SyndicationFeed.add_item()`` is
|
| 1395 |
+
deprecated. Use the new ``enclosures`` argument which accepts a list of
|
| 1396 |
+
``Enclosure`` objects instead of a single one.
|
| 1397 |
+
|
| 1398 |
+
* The ``django.template.loader.LoaderOrigin`` and
|
| 1399 |
+
``django.template.base.StringOrigin`` aliases for
|
| 1400 |
+
``django.template.base.Origin`` are deprecated.
|
| 1401 |
+
|
| 1402 |
+
.. _removed-features-1.9:
|
| 1403 |
+
|
| 1404 |
+
Features removed in 1.9
|
| 1405 |
+
=======================
|
| 1406 |
+
|
| 1407 |
+
These features have reached the end of their deprecation cycle and are removed
|
| 1408 |
+
in Django 1.9. See :ref:`deprecated-features-1.7` for details, including how to
|
| 1409 |
+
remove usage of these features.
|
| 1410 |
+
|
| 1411 |
+
* ``django.utils.dictconfig`` is removed.
|
| 1412 |
+
|
| 1413 |
+
* ``django.utils.importlib`` is removed.
|
| 1414 |
+
|
| 1415 |
+
* ``django.utils.tzinfo`` is removed.
|
| 1416 |
+
|
| 1417 |
+
* ``django.utils.unittest`` is removed.
|
| 1418 |
+
|
| 1419 |
+
* The ``syncdb`` command is removed.
|
| 1420 |
+
|
| 1421 |
+
* ``django.db.models.signals.pre_syncdb`` and
|
| 1422 |
+
``django.db.models.signals.post_syncdb`` is removed.
|
| 1423 |
+
|
| 1424 |
+
* Support for ``allow_syncdb`` on database routers is removed.
|
| 1425 |
+
|
| 1426 |
+
* Automatic syncing of apps without migrations is removed. Migrations are
|
| 1427 |
+
compulsory for all apps unless you pass the :option:`migrate --run-syncdb`
|
| 1428 |
+
option.
|
| 1429 |
+
|
| 1430 |
+
* The SQL management commands for apps without migrations, ``sql``, ``sqlall``,
|
| 1431 |
+
``sqlclear``, ``sqldropindexes``, and ``sqlindexes``, are removed.
|
| 1432 |
+
|
| 1433 |
+
* Support for automatic loading of ``initial_data`` fixtures and initial SQL
|
| 1434 |
+
data is removed.
|
| 1435 |
+
|
| 1436 |
+
* All models need to be defined inside an installed application or declare an
|
| 1437 |
+
explicit :attr:`~django.db.models.Options.app_label`. Furthermore, it isn't
|
| 1438 |
+
possible to import them before their application is loaded. In particular, it
|
| 1439 |
+
isn't possible to import models inside the root package of an application.
|
| 1440 |
+
|
| 1441 |
+
* The model and form ``IPAddressField`` is removed. A stub field remains for
|
| 1442 |
+
compatibility with historical migrations.
|
| 1443 |
+
|
| 1444 |
+
* ``AppCommand.handle_app()`` is no longer supported.
|
| 1445 |
+
|
| 1446 |
+
* ``RequestSite`` and ``get_current_site()`` are no longer importable from
|
| 1447 |
+
``django.contrib.sites.models``.
|
| 1448 |
+
|
| 1449 |
+
* FastCGI support via the ``runfcgi`` management command is removed.
|
| 1450 |
+
|
| 1451 |
+
* ``django.utils.datastructures.SortedDict`` is removed.
|
| 1452 |
+
|
| 1453 |
+
* ``ModelAdmin.declared_fieldsets`` is removed.
|
| 1454 |
+
|
| 1455 |
+
* The ``util`` modules that provided backwards compatibility are removed:
|
| 1456 |
+
|
| 1457 |
+
* ``django.contrib.admin.util``
|
| 1458 |
+
* ``django.contrib.gis.db.backends.util``
|
| 1459 |
+
* ``django.db.backends.util``
|
| 1460 |
+
* ``django.forms.util``
|
| 1461 |
+
|
| 1462 |
+
* ``ModelAdmin.get_formsets`` is removed.
|
| 1463 |
+
|
| 1464 |
+
* The backward compatible shims introduced to rename the
|
| 1465 |
+
``BaseMemcachedCache._get_memcache_timeout()`` method to
|
| 1466 |
+
``get_backend_timeout()`` is removed.
|
| 1467 |
+
|
| 1468 |
+
* The ``--natural`` and ``-n`` options for :djadmin:`dumpdata` are removed.
|
| 1469 |
+
|
| 1470 |
+
* The ``use_natural_keys`` argument for ``serializers.serialize()`` is removed.
|
| 1471 |
+
|
| 1472 |
+
* Private API ``django.forms.forms.get_declared_fields()`` is removed.
|
| 1473 |
+
|
| 1474 |
+
* The ability to use a ``SplitDateTimeWidget`` with ``DateTimeField`` is
|
| 1475 |
+
removed.
|
| 1476 |
+
|
| 1477 |
+
* The ``WSGIRequest.REQUEST`` property is removed.
|
| 1478 |
+
|
| 1479 |
+
* The class ``django.utils.datastructures.MergeDict`` is removed.
|
| 1480 |
+
|
| 1481 |
+
* The ``zh-cn`` and ``zh-tw`` language codes are removed.
|
| 1482 |
+
|
| 1483 |
+
* The internal ``django.utils.functional.memoize()`` is removed.
|
| 1484 |
+
|
| 1485 |
+
* ``django.core.cache.get_cache`` is removed.
|
| 1486 |
+
|
| 1487 |
+
* ``django.db.models.loading`` is removed.
|
| 1488 |
+
|
| 1489 |
+
* Passing callable arguments to querysets is no longer possible.
|
| 1490 |
+
|
| 1491 |
+
* ``BaseCommand.requires_model_validation`` is removed in favor of
|
| 1492 |
+
``requires_system_checks``. Admin validators is replaced by admin checks.
|
| 1493 |
+
|
| 1494 |
+
* The ``ModelAdmin.validator_class`` and ``default_validator_class`` attributes
|
| 1495 |
+
are removed.
|
| 1496 |
+
|
| 1497 |
+
* ``ModelAdmin.validate()`` is removed.
|
| 1498 |
+
|
| 1499 |
+
* ``django.db.backends.DatabaseValidation.validate_field`` is removed in
|
| 1500 |
+
favor of the ``check_field`` method.
|
| 1501 |
+
|
| 1502 |
+
* The ``validate`` management command is removed.
|
| 1503 |
+
|
| 1504 |
+
* ``django.utils.module_loading.import_by_path`` is removed in favor of
|
| 1505 |
+
``django.utils.module_loading.import_string``.
|
| 1506 |
+
|
| 1507 |
+
* ``ssi`` and ``url`` template tags are removed from the ``future`` template
|
| 1508 |
+
tag library.
|
| 1509 |
+
|
| 1510 |
+
* ``django.utils.text.javascript_quote()`` is removed.
|
| 1511 |
+
|
| 1512 |
+
* Database test settings as independent entries in the database settings,
|
| 1513 |
+
prefixed by ``TEST_``, are no longer supported.
|
| 1514 |
+
|
| 1515 |
+
* The ``cache_choices`` option to :class:`~django.forms.ModelChoiceField` and
|
| 1516 |
+
:class:`~django.forms.ModelMultipleChoiceField` is removed.
|
| 1517 |
+
|
| 1518 |
+
* The default value of the
|
| 1519 |
+
:attr:`RedirectView.permanent <django.views.generic.base.RedirectView.permanent>`
|
| 1520 |
+
attribute has changed from ``True`` to ``False``.
|
| 1521 |
+
|
| 1522 |
+
* ``django.contrib.sitemaps.FlatPageSitemap`` is removed in favor of
|
| 1523 |
+
``django.contrib.flatpages.sitemaps.FlatPageSitemap``.
|
| 1524 |
+
|
| 1525 |
+
* Private API ``django.test.utils.TestTemplateLoader`` is removed.
|
| 1526 |
+
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========================
|
| 2 |
+
Django 2.0 release notes
|
| 3 |
+
========================
|
| 4 |
+
|
| 5 |
+
*December 2, 2017*
|
| 6 |
+
|
| 7 |
+
Welcome to Django 2.0!
|
| 8 |
+
|
| 9 |
+
These release notes cover the :ref:`new features <whats-new-2.0>`, as well as
|
| 10 |
+
some :ref:`backwards incompatible changes <backwards-incompatible-2.0>` you'll
|
| 11 |
+
want to be aware of when upgrading from Django 1.11 or earlier. We've
|
| 12 |
+
:ref:`dropped some features<removed-features-2.0>` that have reached the end of
|
| 13 |
+
their deprecation cycle, and we've :ref:`begun the deprecation process for some
|
| 14 |
+
features <deprecated-features-2.0>`.
|
| 15 |
+
|
| 16 |
+
This release starts Django's use of a :ref:`loose form of semantic versioning
|
| 17 |
+
<internal-release-cadence>`, but there aren't any major backwards incompatible
|
| 18 |
+
changes that might be expected of a 2.0 release. Upgrading should be a similar
|
| 19 |
+
amount of effort as past feature releases.
|
| 20 |
+
|
| 21 |
+
See the :doc:`/howto/upgrade-version` guide if you're updating an existing
|
| 22 |
+
project.
|
| 23 |
+
|
| 24 |
+
Python compatibility
|
| 25 |
+
====================
|
| 26 |
+
|
| 27 |
+
Django 2.0 supports Python 3.4, 3.5, 3.6, and 3.7. We **highly recommend** and
|
| 28 |
+
only officially support the latest release of each series.
|
| 29 |
+
|
| 30 |
+
The Django 1.11.x series is the last to support Python 2.7.
|
| 31 |
+
|
| 32 |
+
Django 2.0 will be the last release series to support Python 3.4. If you plan
|
| 33 |
+
a deployment of Python 3.4 beyond the end-of-life for Django 2.0 (April 2019),
|
| 34 |
+
stick with Django 1.11 LTS (supported until April 2020) instead. Note, however,
|
| 35 |
+
that the end-of-life for Python 3.4 is March 2019.
|
| 36 |
+
|
| 37 |
+
Third-party library support for older version of Django
|
| 38 |
+
=======================================================
|
| 39 |
+
|
| 40 |
+
Following the release of Django 2.0, we suggest that third-party app authors
|
| 41 |
+
drop support for all versions of Django prior to 1.11. At that time, you should
|
| 42 |
+
be able to run your package's tests using ``python -Wd`` so that deprecation
|
| 43 |
+
warnings do appear. After making the deprecation warning fixes, your app should
|
| 44 |
+
be compatible with Django 2.0.
|
| 45 |
+
|
| 46 |
+
.. _whats-new-2.0:
|
| 47 |
+
|
| 48 |
+
What's new in Django 2.0
|
| 49 |
+
========================
|
| 50 |
+
|
| 51 |
+
Simplified URL routing syntax
|
| 52 |
+
-----------------------------
|
| 53 |
+
|
| 54 |
+
The new :func:`django.urls.path()` function allows a simpler, more readable URL
|
| 55 |
+
routing syntax. For example, this example from previous Django releases::
|
| 56 |
+
|
| 57 |
+
url(r"^articles/(?P<year>[0-9]{4})/$", views.year_archive),
|
| 58 |
+
|
| 59 |
+
could be written as::
|
| 60 |
+
|
| 61 |
+
path("articles/<int:year>/", views.year_archive),
|
| 62 |
+
|
| 63 |
+
The new syntax supports type coercion of URL parameters. In the example, the
|
| 64 |
+
view will receive the ``year`` keyword argument as an integer rather than as
|
| 65 |
+
a string. Also, the URLs that will match are slightly less constrained in the
|
| 66 |
+
rewritten example. For example, the year 10000 will now match since the year
|
| 67 |
+
integers aren't constrained to be exactly four digits long as they are in the
|
| 68 |
+
regular expression.
|
| 69 |
+
|
| 70 |
+
The ``django.conf.urls.url()`` function from previous versions is now available
|
| 71 |
+
as :func:`django.urls.re_path`. The old location remains for backwards
|
| 72 |
+
compatibility, without an imminent deprecation. The old
|
| 73 |
+
``django.conf.urls.include()`` function is now importable from ``django.urls``
|
| 74 |
+
so you can use ``from django.urls import include, path, re_path`` in your
|
| 75 |
+
URLconfs.
|
| 76 |
+
|
| 77 |
+
The :doc:`/topics/http/urls` document is rewritten to feature the new syntax
|
| 78 |
+
and provide more details.
|
| 79 |
+
|
| 80 |
+
Mobile-friendly ``contrib.admin``
|
| 81 |
+
---------------------------------
|
| 82 |
+
|
| 83 |
+
The admin is now responsive and supports all major mobile devices. Older
|
| 84 |
+
browsers may experience varying levels of graceful degradation.
|
| 85 |
+
|
| 86 |
+
Window expressions
|
| 87 |
+
------------------
|
| 88 |
+
|
| 89 |
+
The new :class:`~django.db.models.expressions.Window` expression allows
|
| 90 |
+
adding an ``OVER`` clause to querysets. You can use :ref:`window functions
|
| 91 |
+
<window-functions>` and :ref:`aggregate functions <aggregation-functions>` in
|
| 92 |
+
the expression.
|
| 93 |
+
|
| 94 |
+
Minor features
|
| 95 |
+
--------------
|
| 96 |
+
|
| 97 |
+
:mod:`django.contrib.admin`
|
| 98 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 99 |
+
|
| 100 |
+
* The new :attr:`.ModelAdmin.autocomplete_fields` attribute and
|
| 101 |
+
:meth:`.ModelAdmin.get_autocomplete_fields` method allow using a
|
| 102 |
+
`Select2 <https://select2.org/>`_ search widget for ``ForeignKey`` and
|
| 103 |
+
``ManyToManyField``.
|
| 104 |
+
|
| 105 |
+
:mod:`django.contrib.auth`
|
| 106 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 107 |
+
|
| 108 |
+
* The default iteration count for the PBKDF2 password hasher is increased from
|
| 109 |
+
36,000 to 100,000.
|
| 110 |
+
|
| 111 |
+
:mod:`django.contrib.gis`
|
| 112 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 113 |
+
|
| 114 |
+
* Added MySQL support for the
|
| 115 |
+
:class:`~django.contrib.gis.db.models.functions.AsGeoJSON` function,
|
| 116 |
+
:class:`~django.contrib.gis.db.models.functions.GeoHash` function,
|
| 117 |
+
:class:`~django.contrib.gis.db.models.functions.IsValid` function,
|
| 118 |
+
:lookup:`isvalid` lookup, and :ref:`distance lookups <distance-lookups>`.
|
| 119 |
+
|
| 120 |
+
* Added the :class:`~django.contrib.gis.db.models.functions.Azimuth` and
|
| 121 |
+
:class:`~django.contrib.gis.db.models.functions.LineLocatePoint` functions,
|
| 122 |
+
supported on PostGIS and SpatiaLite.
|
| 123 |
+
|
| 124 |
+
* Any :class:`~django.contrib.gis.geos.GEOSGeometry` imported from GeoJSON now
|
| 125 |
+
has its SRID set.
|
| 126 |
+
|
| 127 |
+
* Added the :attr:`.OSMWidget.default_zoom` attribute to customize the map's
|
| 128 |
+
default zoom level.
|
| 129 |
+
|
| 130 |
+
* Made metadata readable and editable on rasters through the
|
| 131 |
+
:attr:`~django.contrib.gis.gdal.GDALRaster.metadata`,
|
| 132 |
+
:attr:`~django.contrib.gis.gdal.GDALRaster.info`, and
|
| 133 |
+
:attr:`~django.contrib.gis.gdal.GDALBand.metadata` attributes.
|
| 134 |
+
|
| 135 |
+
* Allowed passing driver-specific creation options to
|
| 136 |
+
:class:`~django.contrib.gis.gdal.GDALRaster` objects using ``papsz_options``.
|
| 137 |
+
|
| 138 |
+
* Allowed creating :class:`~django.contrib.gis.gdal.GDALRaster` objects in
|
| 139 |
+
GDAL's internal virtual filesystem. Rasters can now be :ref:`created from and
|
| 140 |
+
converted to binary data <gdal-raster-vsimem>` in-memory.
|
| 141 |
+
|
| 142 |
+
* The new :meth:`GDALBand.color_interp()
|
| 143 |
+
<django.contrib.gis.gdal.GDALBand.color_interp>` method returns the color
|
| 144 |
+
interpretation for the band.
|
| 145 |
+
|
| 146 |
+
:mod:`django.contrib.postgres`
|
| 147 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 148 |
+
|
| 149 |
+
* The new ``distinct`` argument for
|
| 150 |
+
:class:`~django.contrib.postgres.aggregates.ArrayAgg` determines if
|
| 151 |
+
concatenated values will be distinct.
|
| 152 |
+
|
| 153 |
+
* The new :class:`~django.contrib.postgres.functions.RandomUUID` database
|
| 154 |
+
function returns a version 4 UUID. It requires use of PostgreSQL's
|
| 155 |
+
``pgcrypto`` extension which can be activated using the new
|
| 156 |
+
:class:`~django.contrib.postgres.operations.CryptoExtension` migration
|
| 157 |
+
operation.
|
| 158 |
+
|
| 159 |
+
* :class:`django.contrib.postgres.indexes.GinIndex` now supports the
|
| 160 |
+
``fastupdate`` and ``gin_pending_list_limit`` parameters.
|
| 161 |
+
|
| 162 |
+
* The new :class:`~django.contrib.postgres.indexes.GistIndex` class allows
|
| 163 |
+
creating ``GiST`` indexes in the database. The new
|
| 164 |
+
:class:`~django.contrib.postgres.operations.BtreeGistExtension` migration
|
| 165 |
+
operation installs the ``btree_gist`` extension to add support for operator
|
| 166 |
+
classes that aren't built-in.
|
| 167 |
+
|
| 168 |
+
* :djadmin:`inspectdb` can now introspect ``JSONField`` and various
|
| 169 |
+
``RangeField``\s (``django.contrib.postgres`` must be in ``INSTALLED_APPS``).
|
| 170 |
+
|
| 171 |
+
:mod:`django.contrib.sitemaps`
|
| 172 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 173 |
+
|
| 174 |
+
* Added the ``protocol`` keyword argument to the
|
| 175 |
+
:class:`~django.contrib.sitemaps.GenericSitemap` constructor.
|
| 176 |
+
|
| 177 |
+
Cache
|
| 178 |
+
~~~~~
|
| 179 |
+
|
| 180 |
+
* ``cache.set_many()`` now returns a list of keys that failed to be inserted.
|
| 181 |
+
For the built-in backends, failed inserts can only happen on memcached.
|
| 182 |
+
|
| 183 |
+
File Storage
|
| 184 |
+
~~~~~~~~~~~~
|
| 185 |
+
|
| 186 |
+
* :meth:`File.open() <django.core.files.File.open>` can be used as a context
|
| 187 |
+
manager, e.g. ``with file.open() as f:``.
|
| 188 |
+
|
| 189 |
+
Forms
|
| 190 |
+
~~~~~
|
| 191 |
+
|
| 192 |
+
* The new ``date_attrs`` and ``time_attrs`` arguments for
|
| 193 |
+
:class:`~django.forms.SplitDateTimeWidget` and
|
| 194 |
+
:class:`~django.forms.SplitHiddenDateTimeWidget` allow specifying different
|
| 195 |
+
HTML attributes for the ``DateInput`` and ``TimeInput`` (or hidden)
|
| 196 |
+
subwidgets.
|
| 197 |
+
|
| 198 |
+
* The new :meth:`Form.errors.get_json_data()
|
| 199 |
+
<django.forms.Form.errors.get_json_data>` method returns form errors as
|
| 200 |
+
a dictionary suitable for including in a JSON response.
|
| 201 |
+
|
| 202 |
+
Generic Views
|
| 203 |
+
~~~~~~~~~~~~~
|
| 204 |
+
|
| 205 |
+
* The new :attr:`.ContextMixin.extra_context` attribute allows adding context
|
| 206 |
+
in ``View.as_view()``.
|
| 207 |
+
|
| 208 |
+
Management Commands
|
| 209 |
+
~~~~~~~~~~~~~~~~~~~
|
| 210 |
+
|
| 211 |
+
* :djadmin:`inspectdb` now translates MySQL's unsigned integer columns to
|
| 212 |
+
``PositiveIntegerField`` or ``PositiveSmallIntegerField``.
|
| 213 |
+
|
| 214 |
+
* The new :option:`makemessages --add-location` option controls the comment
|
| 215 |
+
format in ``.po`` files.
|
| 216 |
+
|
| 217 |
+
* :djadmin:`loaddata` can now :ref:`read from stdin <loading-fixtures-stdin>`.
|
| 218 |
+
|
| 219 |
+
* The new :option:`diffsettings --output` option allows formatting the output
|
| 220 |
+
in a unified diff format.
|
| 221 |
+
|
| 222 |
+
* On Oracle, :djadmin:`inspectdb` can now introspect ``AutoField`` if the
|
| 223 |
+
column is created as an identity column.
|
| 224 |
+
|
| 225 |
+
* On MySQL, :djadmin:`dbshell` now supports client-side TLS certificates.
|
| 226 |
+
|
| 227 |
+
Migrations
|
| 228 |
+
~~~~~~~~~~
|
| 229 |
+
|
| 230 |
+
* The new :option:`squashmigrations --squashed-name` option allows naming the
|
| 231 |
+
squashed migration.
|
| 232 |
+
|
| 233 |
+
Models
|
| 234 |
+
~~~~~~
|
| 235 |
+
|
| 236 |
+
* The new :class:`~django.db.models.functions.StrIndex` database function
|
| 237 |
+
finds the starting index of a string inside another string.
|
| 238 |
+
|
| 239 |
+
* On Oracle, ``AutoField`` and ``BigAutoField`` are now created as `identity
|
| 240 |
+
columns <https://docs.oracle.com/en/database/oracle/oracle-database/21/drdaa/
|
| 241 |
+
intro-to-tools-and-products-supporting-migraiton.html#GUID-14E4817B-F3BC-4D99
|
| 242 |
+
-B471-A0ACDC303CC9>`__.
|
| 243 |
+
|
| 244 |
+
* The new ``chunk_size`` parameter of :meth:`.QuerySet.iterator` controls the
|
| 245 |
+
number of rows fetched by the Python database client when streaming results
|
| 246 |
+
from the database. For databases that don't support server-side cursors, it
|
| 247 |
+
controls the number of results Django fetches from the database adapter.
|
| 248 |
+
|
| 249 |
+
* :meth:`.QuerySet.earliest`, :meth:`.QuerySet.latest`, and
|
| 250 |
+
:attr:`Meta.get_latest_by <django.db.models.Options.get_latest_by>` now
|
| 251 |
+
allow ordering by several fields.
|
| 252 |
+
|
| 253 |
+
* Added the :class:`~django.db.models.functions.ExtractQuarter` function to
|
| 254 |
+
extract the quarter from :class:`~django.db.models.DateField` and
|
| 255 |
+
:class:`~django.db.models.DateTimeField`, and exposed it through the
|
| 256 |
+
:lookup:`quarter` lookup.
|
| 257 |
+
|
| 258 |
+
* Added the :class:`~django.db.models.functions.TruncQuarter` function to
|
| 259 |
+
truncate :class:`~django.db.models.DateField` and
|
| 260 |
+
:class:`~django.db.models.DateTimeField` to the first day of a quarter.
|
| 261 |
+
|
| 262 |
+
* Added the :attr:`~django.db.models.Index.db_tablespace` parameter to
|
| 263 |
+
class-based indexes.
|
| 264 |
+
|
| 265 |
+
* If the database supports a native duration field (Oracle and PostgreSQL),
|
| 266 |
+
:class:`~django.db.models.functions.Extract` now works with
|
| 267 |
+
:class:`~django.db.models.DurationField`.
|
| 268 |
+
|
| 269 |
+
* Added the ``of`` argument to :meth:`.QuerySet.select_for_update()`, supported
|
| 270 |
+
on PostgreSQL and Oracle, to lock only rows from specific tables rather than
|
| 271 |
+
all selected tables. It may be helpful particularly when
|
| 272 |
+
:meth:`~.QuerySet.select_for_update()` is used in conjunction with
|
| 273 |
+
:meth:`~.QuerySet.select_related()`.
|
| 274 |
+
|
| 275 |
+
* The new ``field_name`` parameter of :meth:`.QuerySet.in_bulk` allows fetching
|
| 276 |
+
results based on any unique model field.
|
| 277 |
+
|
| 278 |
+
* :meth:`.CursorWrapper.callproc()` now takes an optional dictionary of keyword
|
| 279 |
+
parameters, if the backend supports this feature. Of Django's built-in
|
| 280 |
+
backends, only Oracle supports it.
|
| 281 |
+
|
| 282 |
+
* The new :meth:`connection.execute_wrapper()
|
| 283 |
+
<django.db.backends.base.DatabaseWrapper.execute_wrapper>` method allows
|
| 284 |
+
:doc:`installing wrappers around execution of database queries
|
| 285 |
+
</topics/db/instrumentation>`.
|
| 286 |
+
|
| 287 |
+
* The new ``filter`` argument for built-in aggregates allows :ref:`adding
|
| 288 |
+
different conditionals <conditional-aggregation>` to multiple aggregations
|
| 289 |
+
over the same fields or relations.
|
| 290 |
+
|
| 291 |
+
* Added support for expressions in :attr:`Meta.ordering
|
| 292 |
+
<django.db.models.Options.ordering>`.
|
| 293 |
+
|
| 294 |
+
* The new ``named`` parameter of :meth:`.QuerySet.values_list` allows fetching
|
| 295 |
+
results as named tuples.
|
| 296 |
+
|
| 297 |
+
* The new :class:`.FilteredRelation` class allows adding an ``ON`` clause to
|
| 298 |
+
querysets.
|
| 299 |
+
|
| 300 |
+
Pagination
|
| 301 |
+
~~~~~~~~~~
|
| 302 |
+
|
| 303 |
+
* Added :meth:`Paginator.get_page() <django.core.paginator.Paginator.get_page>`
|
| 304 |
+
to provide the documented pattern of handling invalid page numbers.
|
| 305 |
+
|
| 306 |
+
Requests and Responses
|
| 307 |
+
~~~~~~~~~~~~~~~~~~~~~~
|
| 308 |
+
|
| 309 |
+
* The :djadmin:`runserver` web server supports HTTP 1.1.
|
| 310 |
+
|
| 311 |
+
Templates
|
| 312 |
+
~~~~~~~~~
|
| 313 |
+
|
| 314 |
+
* To increase the usefulness of :meth:`.Engine.get_default` in third-party
|
| 315 |
+
apps, it now returns the first engine if multiple ``DjangoTemplates`` engines
|
| 316 |
+
are configured in ``TEMPLATES`` rather than raising ``ImproperlyConfigured``.
|
| 317 |
+
|
| 318 |
+
* Custom template tags may now accept keyword-only arguments.
|
| 319 |
+
|
| 320 |
+
Tests
|
| 321 |
+
~~~~~
|
| 322 |
+
|
| 323 |
+
* Added threading support to :class:`~django.test.LiveServerTestCase`.
|
| 324 |
+
|
| 325 |
+
* Added settings that allow customizing the test tablespace parameters for
|
| 326 |
+
Oracle: :setting:`DATAFILE_SIZE`, :setting:`DATAFILE_TMP_SIZE`,
|
| 327 |
+
:setting:`DATAFILE_EXTSIZE`, and :setting:`DATAFILE_TMP_EXTSIZE`.
|
| 328 |
+
|
| 329 |
+
Validators
|
| 330 |
+
~~~~~~~~~~
|
| 331 |
+
|
| 332 |
+
* The new :class:`.ProhibitNullCharactersValidator` disallows the null
|
| 333 |
+
character in the input of the :class:`~django.forms.CharField` form field
|
| 334 |
+
and its subclasses. Null character input was observed from vulnerability
|
| 335 |
+
scanning tools. Most databases silently discard null characters, but
|
| 336 |
+
psycopg2 2.7+ raises an exception when trying to save a null character to
|
| 337 |
+
a char/text field with PostgreSQL.
|
| 338 |
+
|
| 339 |
+
.. _backwards-incompatible-2.0:
|
| 340 |
+
|
| 341 |
+
Backwards incompatible changes in 2.0
|
| 342 |
+
=====================================
|
| 343 |
+
|
| 344 |
+
Removed support for bytestrings in some places
|
| 345 |
+
----------------------------------------------
|
| 346 |
+
|
| 347 |
+
To support native Python 2 strings, older Django versions had to accept both
|
| 348 |
+
bytestrings and Unicode strings. Now that Python 2 support is dropped,
|
| 349 |
+
bytestrings should only be encountered around input/output boundaries (handling
|
| 350 |
+
of binary fields or HTTP streams, for example). You might have to update your
|
| 351 |
+
code to limit bytestring usage to a minimum, as Django no longer accepts
|
| 352 |
+
bytestrings in certain code paths. Python's :option:`-b` option may help detect
|
| 353 |
+
that mistake in your code.
|
| 354 |
+
|
| 355 |
+
For example, ``reverse()`` now uses ``str()`` instead of ``force_text()`` to
|
| 356 |
+
coerce the ``args`` and ``kwargs`` it receives, prior to their placement in
|
| 357 |
+
the URL. For bytestrings, this creates a string with an undesired ``b`` prefix
|
| 358 |
+
as well as additional quotes (``str(b'foo')`` is ``"b'foo'"``). To adapt, call
|
| 359 |
+
``decode()`` on the bytestring before passing it to ``reverse()``.
|
| 360 |
+
|
| 361 |
+
Database backend API
|
| 362 |
+
--------------------
|
| 363 |
+
|
| 364 |
+
This section describes changes that may be needed in third-party database
|
| 365 |
+
backends.
|
| 366 |
+
|
| 367 |
+
* The ``DatabaseOperations.datetime_cast_date_sql()``,
|
| 368 |
+
``datetime_cast_time_sql()``, ``datetime_trunc_sql()``,
|
| 369 |
+
``datetime_extract_sql()``, and ``date_interval_sql()`` methods now return
|
| 370 |
+
only the SQL to perform the operation instead of SQL and a list of
|
| 371 |
+
parameters.
|
| 372 |
+
|
| 373 |
+
* Third-party database backends should add a ``DatabaseWrapper.display_name``
|
| 374 |
+
attribute with the name of the database that your backend works with. Django
|
| 375 |
+
may use it in various messages, such as in system checks.
|
| 376 |
+
|
| 377 |
+
* The first argument of ``SchemaEditor._alter_column_type_sql()`` is now
|
| 378 |
+
``model`` rather than ``table``.
|
| 379 |
+
|
| 380 |
+
* The first argument of ``SchemaEditor._create_index_name()`` is now
|
| 381 |
+
``table_name`` rather than ``model``.
|
| 382 |
+
|
| 383 |
+
* To enable ``FOR UPDATE OF`` support, set
|
| 384 |
+
``DatabaseFeatures.has_select_for_update_of = True``. If the database
|
| 385 |
+
requires that the arguments to ``OF`` be columns rather than tables, set
|
| 386 |
+
``DatabaseFeatures.select_for_update_of_column = True``.
|
| 387 |
+
|
| 388 |
+
* To enable support for :class:`~django.db.models.expressions.Window`
|
| 389 |
+
expressions, set ``DatabaseFeatures.supports_over_clause`` to ``True``. You
|
| 390 |
+
may need to customize the ``DatabaseOperations.window_start_rows_start_end()``
|
| 391 |
+
and/or ``window_start_range_start_end()`` methods.
|
| 392 |
+
|
| 393 |
+
* Third-party database backends should add a
|
| 394 |
+
``DatabaseOperations.cast_char_field_without_max_length`` attribute with the
|
| 395 |
+
database data type that will be used in the
|
| 396 |
+
:class:`~django.db.models.functions.Cast` function for a ``CharField`` if the
|
| 397 |
+
``max_length`` argument isn't provided.
|
| 398 |
+
|
| 399 |
+
* The first argument of ``DatabaseCreation._clone_test_db()`` and
|
| 400 |
+
``get_test_db_clone_settings()`` is now ``suffix`` rather
|
| 401 |
+
than ``number`` (in case you want to rename the signatures in your backend
|
| 402 |
+
for consistency). ``django.test`` also now passes those values as strings
|
| 403 |
+
rather than as integers.
|
| 404 |
+
|
| 405 |
+
* Third-party database backends should add a
|
| 406 |
+
``DatabaseIntrospection.get_sequences()`` method based on the stub in
|
| 407 |
+
``BaseDatabaseIntrospection``.
|
| 408 |
+
|
| 409 |
+
Dropped support for Oracle 11.2
|
| 410 |
+
-------------------------------
|
| 411 |
+
|
| 412 |
+
The end of upstream support for Oracle 11.2 is Dec. 2020. Django 1.11 will be
|
| 413 |
+
supported until April 2020 which almost reaches this date. Django 2.0
|
| 414 |
+
officially supports Oracle 12.1+.
|
| 415 |
+
|
| 416 |
+
Default MySQL isolation level is read committed
|
| 417 |
+
-----------------------------------------------
|
| 418 |
+
|
| 419 |
+
MySQL's default isolation level, repeatable read, may cause data loss in
|
| 420 |
+
typical Django usage. To prevent that and for consistency with other databases,
|
| 421 |
+
the default isolation level is now read committed. You can use the
|
| 422 |
+
:setting:`DATABASES` setting to :ref:`use a different isolation level
|
| 423 |
+
<mysql-isolation-level>`, if needed.
|
| 424 |
+
|
| 425 |
+
:attr:`AbstractUser.last_name <django.contrib.auth.models.User.last_name>` ``max_length`` increased to 150
|
| 426 |
+
----------------------------------------------------------------------------------------------------------
|
| 427 |
+
|
| 428 |
+
A migration for :attr:`django.contrib.auth.models.User.last_name` is included.
|
| 429 |
+
If you have a custom user model inheriting from ``AbstractUser``, you'll need
|
| 430 |
+
to generate and apply a database migration for your user model.
|
| 431 |
+
|
| 432 |
+
If you want to preserve the 30 character limit for last names, use a custom
|
| 433 |
+
form::
|
| 434 |
+
|
| 435 |
+
from django.contrib.auth.forms import UserChangeForm
|
| 436 |
+
|
| 437 |
+
|
| 438 |
+
class MyUserChangeForm(UserChangeForm):
|
| 439 |
+
last_name = forms.CharField(max_length=30, required=False)
|
| 440 |
+
|
| 441 |
+
If you wish to keep this restriction in the admin when editing users, set
|
| 442 |
+
``UserAdmin.form`` to use this form::
|
| 443 |
+
|
| 444 |
+
from django.contrib.auth.admin import UserAdmin
|
| 445 |
+
from django.contrib.auth.models import User
|
| 446 |
+
|
| 447 |
+
|
| 448 |
+
class MyUserAdmin(UserAdmin):
|
| 449 |
+
form = MyUserChangeForm
|
| 450 |
+
|
| 451 |
+
|
| 452 |
+
admin.site.unregister(User)
|
| 453 |
+
admin.site.register(User, MyUserAdmin)
|
| 454 |
+
|
| 455 |
+
``QuerySet.reverse()`` and ``last()`` are prohibited after slicing
|
| 456 |
+
------------------------------------------------------------------
|
| 457 |
+
|
| 458 |
+
Calling ``QuerySet.reverse()`` or ``last()`` on a sliced queryset leads to
|
| 459 |
+
unexpected results due to the slice being applied after reordering. This is
|
| 460 |
+
now prohibited, e.g.:
|
| 461 |
+
|
| 462 |
+
.. code-block:: pycon
|
| 463 |
+
|
| 464 |
+
>>> Model.objects.all()[:2].reverse()
|
| 465 |
+
Traceback (most recent call last):
|
| 466 |
+
...
|
| 467 |
+
TypeError: Cannot reverse a query once a slice has been taken.
|
| 468 |
+
|
| 469 |
+
Form fields no longer accept optional arguments as positional arguments
|
| 470 |
+
-----------------------------------------------------------------------
|
| 471 |
+
|
| 472 |
+
To help prevent runtime errors due to incorrect ordering of form field
|
| 473 |
+
arguments, optional arguments of built-in form fields are no longer accepted
|
| 474 |
+
as positional arguments. For example::
|
| 475 |
+
|
| 476 |
+
forms.IntegerField(25, 10)
|
| 477 |
+
|
| 478 |
+
raises an exception and should be replaced with::
|
| 479 |
+
|
| 480 |
+
forms.IntegerField(max_value=25, min_value=10)
|
| 481 |
+
|
| 482 |
+
``call_command()`` validates the options it receives
|
| 483 |
+
----------------------------------------------------
|
| 484 |
+
|
| 485 |
+
``call_command()`` now validates that the argument parser of the command being
|
| 486 |
+
called defines all of the options passed to ``call_command()``.
|
| 487 |
+
|
| 488 |
+
For custom management commands that use options not created using
|
| 489 |
+
``parser.add_argument()``, add a ``stealth_options`` attribute on the command::
|
| 490 |
+
|
| 491 |
+
class MyCommand(BaseCommand):
|
| 492 |
+
stealth_options = ("option_name", ...)
|
| 493 |
+
|
| 494 |
+
Indexes no longer accept positional arguments
|
| 495 |
+
---------------------------------------------
|
| 496 |
+
|
| 497 |
+
For example::
|
| 498 |
+
|
| 499 |
+
models.Index(["headline", "-pub_date"], "index_name")
|
| 500 |
+
|
| 501 |
+
raises an exception and should be replaced with::
|
| 502 |
+
|
| 503 |
+
models.Index(fields=["headline", "-pub_date"], name="index_name")
|
| 504 |
+
|
| 505 |
+
Foreign key constraints are now enabled on SQLite
|
| 506 |
+
-------------------------------------------------
|
| 507 |
+
|
| 508 |
+
This will appear as a backwards-incompatible change (``IntegrityError:
|
| 509 |
+
FOREIGN KEY constraint failed``) if attempting to save an existing model
|
| 510 |
+
instance that's violating a foreign key constraint.
|
| 511 |
+
|
| 512 |
+
Foreign keys are now created with ``DEFERRABLE INITIALLY DEFERRED`` instead of
|
| 513 |
+
``DEFERRABLE IMMEDIATE``. Thus, tables may need to be rebuilt to recreate
|
| 514 |
+
foreign keys with the new definition, particularly if you're using a pattern
|
| 515 |
+
like this::
|
| 516 |
+
|
| 517 |
+
from django.db import transaction
|
| 518 |
+
|
| 519 |
+
with transaction.atomic():
|
| 520 |
+
Book.objects.create(author_id=1)
|
| 521 |
+
Author.objects.create(id=1)
|
| 522 |
+
|
| 523 |
+
If you don't recreate the foreign key as ``DEFERRED``, the first ``create()``
|
| 524 |
+
would fail now that foreign key constraints are enforced.
|
| 525 |
+
|
| 526 |
+
Backup your database first! After upgrading to Django 2.0, you can then
|
| 527 |
+
rebuild tables using a script similar to this::
|
| 528 |
+
|
| 529 |
+
from django.apps import apps
|
| 530 |
+
from django.db import connection
|
| 531 |
+
|
| 532 |
+
for app in apps.get_app_configs():
|
| 533 |
+
for model in app.get_models(include_auto_created=True):
|
| 534 |
+
if model._meta.managed and not (model._meta.proxy or model._meta.swapped):
|
| 535 |
+
for base in model.__bases__:
|
| 536 |
+
if hasattr(base, "_meta"):
|
| 537 |
+
base._meta.local_many_to_many = []
|
| 538 |
+
model._meta.local_many_to_many = []
|
| 539 |
+
with connection.schema_editor() as editor:
|
| 540 |
+
editor._remake_table(model)
|
| 541 |
+
|
| 542 |
+
This script hasn't received extensive testing and needs adaption for various
|
| 543 |
+
cases such as multiple databases. Feel free to contribute improvements.
|
| 544 |
+
|
| 545 |
+
In addition, because of a table alteration limitation of SQLite, it's prohibited
|
| 546 |
+
to perform :class:`~django.db.migrations.operations.RenameModel` and
|
| 547 |
+
:class:`~django.db.migrations.operations.RenameField` operations on models or
|
| 548 |
+
fields referenced by other models in a transaction. In order to allow migrations
|
| 549 |
+
containing these operations to be applied, you must set the
|
| 550 |
+
``Migration.atomic`` attribute to ``False``.
|
| 551 |
+
|
| 552 |
+
Miscellaneous
|
| 553 |
+
-------------
|
| 554 |
+
|
| 555 |
+
* The ``SessionAuthenticationMiddleware`` class is removed. It provided no
|
| 556 |
+
functionality since session authentication is unconditionally enabled in
|
| 557 |
+
Django 1.10.
|
| 558 |
+
|
| 559 |
+
* The default HTTP error handlers (``handler404``, etc.) are now callables
|
| 560 |
+
instead of dotted Python path strings. Django favors callable references
|
| 561 |
+
since they provide better performance and debugging experience.
|
| 562 |
+
|
| 563 |
+
* :class:`~django.views.generic.base.RedirectView` no longer silences
|
| 564 |
+
``NoReverseMatch`` if the ``pattern_name`` doesn't exist.
|
| 565 |
+
|
| 566 |
+
* When ``USE_L10N`` is off, :class:`~django.forms.FloatField` and
|
| 567 |
+
:class:`~django.forms.DecimalField` now respect :setting:`DECIMAL_SEPARATOR`
|
| 568 |
+
and :setting:`THOUSAND_SEPARATOR` during validation. For example, with the
|
| 569 |
+
settings::
|
| 570 |
+
|
| 571 |
+
USE_L10N = False
|
| 572 |
+
USE_THOUSAND_SEPARATOR = True
|
| 573 |
+
DECIMAL_SEPARATOR = ","
|
| 574 |
+
THOUSAND_SEPARATOR = "."
|
| 575 |
+
|
| 576 |
+
an input of ``"1.345"`` is now converted to ``1345`` instead of ``1.345``.
|
| 577 |
+
|
| 578 |
+
* Subclasses of :class:`~django.contrib.auth.models.AbstractBaseUser` are no
|
| 579 |
+
longer required to implement ``get_short_name()`` and ``get_full_name()``.
|
| 580 |
+
(The base implementations that raise ``NotImplementedError`` are removed.)
|
| 581 |
+
``django.contrib.admin`` uses these methods if implemented but doesn't
|
| 582 |
+
require them. Third-party apps that use these methods may want to adopt a
|
| 583 |
+
similar approach.
|
| 584 |
+
|
| 585 |
+
* The ``FIRST_DAY_OF_WEEK`` and ``NUMBER_GROUPING`` format settings are now
|
| 586 |
+
kept as integers in JavaScript and JSON i18n view outputs.
|
| 587 |
+
|
| 588 |
+
* :meth:`~django.test.TransactionTestCase.assertNumQueries` now ignores
|
| 589 |
+
connection configuration queries. Previously, if a test opened a new database
|
| 590 |
+
connection, those queries could be included as part of the
|
| 591 |
+
``assertNumQueries()`` count.
|
| 592 |
+
|
| 593 |
+
* The default size of the Oracle test tablespace is increased from 20M to 50M
|
| 594 |
+
and the default autoextend size is increased from 10M to 25M.
|
| 595 |
+
|
| 596 |
+
* To improve performance when streaming large result sets from the database,
|
| 597 |
+
:meth:`.QuerySet.iterator` now fetches 2000 rows at a time instead of 100.
|
| 598 |
+
The old behavior can be restored using the ``chunk_size`` parameter. For
|
| 599 |
+
example::
|
| 600 |
+
|
| 601 |
+
Book.objects.iterator(chunk_size=100)
|
| 602 |
+
|
| 603 |
+
* Providing unknown package names in the ``packages`` argument of the
|
| 604 |
+
:class:`~django.views.i18n.JavaScriptCatalog` view now raises ``ValueError``
|
| 605 |
+
instead of passing silently.
|
| 606 |
+
|
| 607 |
+
* A model instance's primary key now appears in the default ``Model.__str__()``
|
| 608 |
+
method, e.g. ``Question object (1)``.
|
| 609 |
+
|
| 610 |
+
* ``makemigrations`` now detects changes to the model field ``limit_choices_to``
|
| 611 |
+
option. Add this to your existing migrations or accept an auto-generated
|
| 612 |
+
migration for fields that use it.
|
| 613 |
+
|
| 614 |
+
* Performing queries that require :ref:`automatic spatial transformations
|
| 615 |
+
<automatic-spatial-transformations>` now raises ``NotImplementedError``
|
| 616 |
+
on MySQL instead of silently using non-transformed geometries.
|
| 617 |
+
|
| 618 |
+
* ``django.core.exceptions.DjangoRuntimeWarning`` is removed. It was only used
|
| 619 |
+
in the cache backend as an intermediate class in ``CacheKeyWarning``'s
|
| 620 |
+
inheritance of ``RuntimeWarning``.
|
| 621 |
+
|
| 622 |
+
* Renamed ``BaseExpression._output_field`` to ``output_field``. You may need
|
| 623 |
+
to update custom expressions.
|
| 624 |
+
|
| 625 |
+
* In older versions, forms and formsets combine their ``Media`` with widget
|
| 626 |
+
``Media`` by concatenating the two. The combining now tries to :ref:`preserve
|
| 627 |
+
the relative order of elements in each list <form-media-asset-order>`.
|
| 628 |
+
``MediaOrderConflictWarning`` is issued if the order can't be preserved.
|
| 629 |
+
|
| 630 |
+
* ``django.contrib.gis.gdal.OGRException`` is removed. It's been an alias for
|
| 631 |
+
``GDALException`` since Django 1.8.
|
| 632 |
+
|
| 633 |
+
* Support for GEOS 3.3.x is dropped.
|
| 634 |
+
|
| 635 |
+
* The way data is selected for ``GeometryField`` is changed to improve
|
| 636 |
+
performance, and in raw SQL queries, those fields must now be wrapped in
|
| 637 |
+
``connection.ops.select``. See the :ref:`Raw queries note<gis-raw-sql>` in
|
| 638 |
+
the GIS tutorial for an example.
|
| 639 |
+
|
| 640 |
+
.. _deprecated-features-2.0:
|
| 641 |
+
|
| 642 |
+
Features deprecated in 2.0
|
| 643 |
+
==========================
|
| 644 |
+
|
| 645 |
+
``context`` argument of ``Field.from_db_value()`` and ``Expression.convert_value()``
|
| 646 |
+
------------------------------------------------------------------------------------
|
| 647 |
+
|
| 648 |
+
The ``context`` argument of ``Field.from_db_value()`` and
|
| 649 |
+
``Expression.convert_value()`` is unused as it's always an empty dictionary.
|
| 650 |
+
The signature of both methods is now::
|
| 651 |
+
|
| 652 |
+
(self, value, expression, connection)
|
| 653 |
+
|
| 654 |
+
instead of::
|
| 655 |
+
|
| 656 |
+
(self, value, expression, connection, context)
|
| 657 |
+
|
| 658 |
+
Support for the old signature in custom fields and expressions remains until
|
| 659 |
+
Django 3.0.
|
| 660 |
+
|
| 661 |
+
Miscellaneous
|
| 662 |
+
-------------
|
| 663 |
+
|
| 664 |
+
* The ``django.db.backends.postgresql_psycopg2`` module is deprecated in favor
|
| 665 |
+
of ``django.db.backends.postgresql``. It's been an alias since Django 1.9.
|
| 666 |
+
This only affects code that imports from the module directly. The
|
| 667 |
+
``DATABASES`` setting can still use
|
| 668 |
+
``'django.db.backends.postgresql_psycopg2'``, though you can simplify that by
|
| 669 |
+
using the ``'django.db.backends.postgresql'`` name added in Django 1.9.
|
| 670 |
+
|
| 671 |
+
* ``django.shortcuts.render_to_response()`` is deprecated in favor of
|
| 672 |
+
:func:`django.shortcuts.render`. ``render()`` takes the same arguments
|
| 673 |
+
except that it also requires a ``request``.
|
| 674 |
+
|
| 675 |
+
* The ``DEFAULT_CONTENT_TYPE`` setting is deprecated. It doesn't interact well
|
| 676 |
+
with third-party apps and is obsolete since HTML5 has mostly superseded
|
| 677 |
+
XHTML.
|
| 678 |
+
|
| 679 |
+
* ``HttpRequest.xreadlines()`` is deprecated in favor of iterating over the
|
| 680 |
+
request.
|
| 681 |
+
|
| 682 |
+
* The ``field_name`` keyword argument to :meth:`.QuerySet.earliest` and
|
| 683 |
+
:meth:`.QuerySet.latest` is deprecated in favor of passing the field
|
| 684 |
+
names as arguments. Write ``.earliest('pub_date')`` instead of
|
| 685 |
+
``.earliest(field_name='pub_date')``.
|
| 686 |
+
|
| 687 |
+
.. _removed-features-2.0:
|
| 688 |
+
|
| 689 |
+
Features removed in 2.0
|
| 690 |
+
=======================
|
| 691 |
+
|
| 692 |
+
These features have reached the end of their deprecation cycle and are removed
|
| 693 |
+
in Django 2.0.
|
| 694 |
+
|
| 695 |
+
See :ref:`deprecated-features-1.9` for details on these changes, including how
|
| 696 |
+
to remove usage of these features.
|
| 697 |
+
|
| 698 |
+
* The ``weak`` argument to ``django.dispatch.signals.Signal.disconnect()`` is
|
| 699 |
+
removed.
|
| 700 |
+
|
| 701 |
+
* ``django.db.backends.base.BaseDatabaseOperations.check_aggregate_support()``
|
| 702 |
+
is removed.
|
| 703 |
+
|
| 704 |
+
* The ``django.forms.extras`` package is removed.
|
| 705 |
+
|
| 706 |
+
* The ``assignment_tag`` helper is removed.
|
| 707 |
+
|
| 708 |
+
* The ``host`` argument to ``SimpleTestCase.assertsRedirects()`` is removed.
|
| 709 |
+
The compatibility layer which allows absolute URLs to be considered equal to
|
| 710 |
+
relative ones when the path is identical is also removed.
|
| 711 |
+
|
| 712 |
+
* ``Field.rel`` and ``Field.remote_field.to`` are removed.
|
| 713 |
+
|
| 714 |
+
* The ``on_delete`` argument for ``ForeignKey`` and ``OneToOneField`` is now
|
| 715 |
+
required in models and migrations. Consider squashing migrations so that you
|
| 716 |
+
have fewer of them to update.
|
| 717 |
+
|
| 718 |
+
* ``django.db.models.fields.add_lazy_relation()`` is removed.
|
| 719 |
+
|
| 720 |
+
* When time zone support is enabled, database backends that don't support time
|
| 721 |
+
zones no longer convert aware datetimes to naive values in UTC anymore when
|
| 722 |
+
such values are passed as parameters to SQL queries executed outside of the
|
| 723 |
+
ORM, e.g. with ``cursor.execute()``.
|
| 724 |
+
|
| 725 |
+
* ``django.contrib.auth.tests.utils.skipIfCustomUser()`` is removed.
|
| 726 |
+
|
| 727 |
+
* The ``GeoManager`` and ``GeoQuerySet`` classes are removed.
|
| 728 |
+
|
| 729 |
+
* The ``django.contrib.gis.geoip`` module is removed.
|
| 730 |
+
|
| 731 |
+
* The ``supports_recursion`` check for template loaders is removed from:
|
| 732 |
+
|
| 733 |
+
* ``django.template.engine.Engine.find_template()``
|
| 734 |
+
* ``django.template.loader_tags.ExtendsNode.find_template()``
|
| 735 |
+
* ``django.template.loaders.base.Loader.supports_recursion()``
|
| 736 |
+
* ``django.template.loaders.cached.Loader.supports_recursion()``
|
| 737 |
+
|
| 738 |
+
* The ``load_template`` and ``load_template_sources`` template loader methods
|
| 739 |
+
are removed.
|
| 740 |
+
|
| 741 |
+
* The ``template_dirs`` argument for template loaders is removed:
|
| 742 |
+
|
| 743 |
+
* ``django.template.loaders.base.Loader.get_template()``
|
| 744 |
+
* ``django.template.loaders.cached.Loader.cache_key()``
|
| 745 |
+
* ``django.template.loaders.cached.Loader.get_template()``
|
| 746 |
+
* ``django.template.loaders.cached.Loader.get_template_sources()``
|
| 747 |
+
* ``django.template.loaders.filesystem.Loader.get_template_sources()``
|
| 748 |
+
|
| 749 |
+
* ``django.template.loaders.base.Loader.__call__()`` is removed.
|
| 750 |
+
|
| 751 |
+
* Support for custom error views that don't accept an ``exception`` parameter
|
| 752 |
+
is removed.
|
| 753 |
+
|
| 754 |
+
* The ``mime_type`` attribute of ``django.utils.feedgenerator.Atom1Feed`` and
|
| 755 |
+
``django.utils.feedgenerator.RssFeed`` is removed.
|
| 756 |
+
|
| 757 |
+
* The ``app_name`` argument to ``include()`` is removed.
|
| 758 |
+
|
| 759 |
+
* Support for passing a 3-tuple (including ``admin.site.urls``) as the first
|
| 760 |
+
argument to ``include()`` is removed.
|
| 761 |
+
|
| 762 |
+
* Support for setting a URL instance namespace without an application namespace
|
| 763 |
+
is removed.
|
| 764 |
+
|
| 765 |
+
* ``Field._get_val_from_obj()`` is removed.
|
| 766 |
+
|
| 767 |
+
* ``django.template.loaders.eggs.Loader`` is removed.
|
| 768 |
+
|
| 769 |
+
* The ``current_app`` parameter to the ``contrib.auth`` function-based views is
|
| 770 |
+
removed.
|
| 771 |
+
|
| 772 |
+
* The ``callable_obj`` keyword argument to
|
| 773 |
+
``SimpleTestCase.assertRaisesMessage()`` is removed.
|
| 774 |
+
|
| 775 |
+
* Support for the ``allow_tags`` attribute on ``ModelAdmin`` methods is
|
| 776 |
+
removed.
|
| 777 |
+
|
| 778 |
+
* The ``enclosure`` keyword argument to ``SyndicationFeed.add_item()`` is
|
| 779 |
+
removed.
|
| 780 |
+
|
| 781 |
+
* The ``django.template.loader.LoaderOrigin`` and
|
| 782 |
+
``django.template.base.StringOrigin`` aliases for
|
| 783 |
+
``django.template.base.Origin`` are removed.
|
| 784 |
+
|
| 785 |
+
See :ref:`deprecated-features-1.10` for details on these changes.
|
| 786 |
+
|
| 787 |
+
* The ``makemigrations --exit`` option is removed.
|
| 788 |
+
|
| 789 |
+
* Support for direct assignment to a reverse foreign key or many-to-many
|
| 790 |
+
relation is removed.
|
| 791 |
+
|
| 792 |
+
* The ``get_srid()`` and ``set_srid()`` methods of
|
| 793 |
+
``django.contrib.gis.geos.GEOSGeometry`` are removed.
|
| 794 |
+
|
| 795 |
+
* The ``get_x()``, ``set_x()``, ``get_y()``, ``set_y()``, ``get_z()``, and
|
| 796 |
+
``set_z()`` methods of ``django.contrib.gis.geos.Point`` are removed.
|
| 797 |
+
|
| 798 |
+
* The ``get_coords()`` and ``set_coords()`` methods of
|
| 799 |
+
``django.contrib.gis.geos.Point`` are removed.
|
| 800 |
+
|
| 801 |
+
* The ``cascaded_union`` property of ``django.contrib.gis.geos.MultiPolygon``
|
| 802 |
+
is removed.
|
| 803 |
+
|
| 804 |
+
* ``django.utils.functional.allow_lazy()`` is removed.
|
| 805 |
+
|
| 806 |
+
* The ``shell --plain`` option is removed.
|
| 807 |
+
|
| 808 |
+
* The ``django.core.urlresolvers`` module is removed in favor of its new
|
| 809 |
+
location, ``django.urls``.
|
| 810 |
+
|
| 811 |
+
* ``CommaSeparatedIntegerField`` is removed, except for support in historical
|
| 812 |
+
migrations.
|
| 813 |
+
|
| 814 |
+
* The template ``Context.has_key()`` method is removed.
|
| 815 |
+
|
| 816 |
+
* Support for the ``django.core.files.storage.Storage.accessed_time()``,
|
| 817 |
+
``created_time()``, and ``modified_time()`` methods is removed.
|
| 818 |
+
|
| 819 |
+
* Support for query lookups using the model name when
|
| 820 |
+
``Meta.default_related_name`` is set is removed.
|
| 821 |
+
|
| 822 |
+
* The MySQL ``__search`` lookup is removed.
|
| 823 |
+
|
| 824 |
+
* The shim for supporting custom related manager classes without a
|
| 825 |
+
``_apply_rel_filters()`` method is removed.
|
| 826 |
+
|
| 827 |
+
* Using ``User.is_authenticated()`` and ``User.is_anonymous()`` as methods
|
| 828 |
+
rather than properties is no longer supported.
|
| 829 |
+
|
| 830 |
+
* The ``Model._meta.virtual_fields`` attribute is removed.
|
| 831 |
+
|
| 832 |
+
* The keyword arguments ``virtual_only`` in ``Field.contribute_to_class()`` and
|
| 833 |
+
``virtual`` in ``Model._meta.add_field()`` are removed.
|
| 834 |
+
|
| 835 |
+
* The ``javascript_catalog()`` and ``json_catalog()`` views are removed.
|
| 836 |
+
|
| 837 |
+
* ``django.contrib.gis.utils.precision_wkt()`` is removed.
|
| 838 |
+
|
| 839 |
+
* In multi-table inheritance, implicit promotion of a ``OneToOneField`` to a
|
| 840 |
+
``parent_link`` is removed.
|
| 841 |
+
|
| 842 |
+
* Support for ``Widget._format_value()`` is removed.
|
| 843 |
+
|
| 844 |
+
* ``FileField`` methods ``get_directory_name()`` and ``get_filename()`` are
|
| 845 |
+
removed.
|
| 846 |
+
|
| 847 |
+
* The ``mark_for_escaping()`` function and the classes it uses: ``EscapeData``,
|
| 848 |
+
``EscapeBytes``, ``EscapeText``, ``EscapeString``, and ``EscapeUnicode`` are
|
| 849 |
+
removed.
|
| 850 |
+
|
| 851 |
+
* The ``escape`` filter now uses ``django.utils.html.conditional_escape()``.
|
| 852 |
+
|
| 853 |
+
* ``Manager.use_for_related_fields`` is removed.
|
| 854 |
+
|
| 855 |
+
* Model ``Manager`` inheritance follows MRO inheritance rules. The requirement
|
| 856 |
+
to use ``Meta.manager_inheritance_from_future`` to opt-in to the behavior is
|
| 857 |
+
removed.
|
| 858 |
+
|
| 859 |
+
* Support for old-style middleware using ``settings.MIDDLEWARE_CLASSES`` is
|
| 860 |
+
removed.
|
testbed/django__django/docs/releases/2.1.10.txt
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
===========================
|
| 2 |
+
Django 2.1.10 release notes
|
| 3 |
+
===========================
|
| 4 |
+
|
| 5 |
+
*July 1, 2019*
|
| 6 |
+
|
| 7 |
+
Django 2.1.10 fixes a security issue in 2.1.9.
|
| 8 |
+
|
| 9 |
+
CVE-2019-12781: Incorrect HTTP detection with reverse-proxy connecting via HTTPS
|
| 10 |
+
--------------------------------------------------------------------------------
|
| 11 |
+
|
| 12 |
+
When deployed behind a reverse-proxy connecting to Django via HTTPS,
|
| 13 |
+
:attr:`django.http.HttpRequest.scheme` would incorrectly detect client
|
| 14 |
+
requests made via HTTP as using HTTPS. This entails incorrect results for
|
| 15 |
+
:meth:`~django.http.HttpRequest.is_secure`, and
|
| 16 |
+
:meth:`~django.http.HttpRequest.build_absolute_uri`, and that HTTP
|
| 17 |
+
requests would not be redirected to HTTPS in accordance with
|
| 18 |
+
:setting:`SECURE_SSL_REDIRECT`.
|
| 19 |
+
|
| 20 |
+
``HttpRequest.scheme`` now respects :setting:`SECURE_PROXY_SSL_HEADER`, if it
|
| 21 |
+
is configured, and the appropriate header is set on the request, for both HTTP
|
| 22 |
+
and HTTPS requests.
|
| 23 |
+
|
| 24 |
+
If you deploy Django behind a reverse-proxy that forwards HTTP requests, and
|
| 25 |
+
that connects to Django via HTTPS, be sure to verify that your application
|
| 26 |
+
correctly handles code paths relying on ``scheme``, ``is_secure()``,
|
| 27 |
+
``build_absolute_uri()``, and ``SECURE_SSL_REDIRECT``.
|
testbed/django__django/docs/releases/2.1.6.txt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 2.1.6 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*February 11, 2019*
|
| 6 |
+
|
| 7 |
+
Django 2.1.6 fixes a security issue and a bug in 2.1.5.
|
| 8 |
+
|
| 9 |
+
CVE-2019-6975: Memory exhaustion in ``django.utils.numberformat.format()``
|
| 10 |
+
--------------------------------------------------------------------------
|
| 11 |
+
|
| 12 |
+
If ``django.utils.numberformat.format()`` -- used by ``contrib.admin`` as well
|
| 13 |
+
as the ``floatformat``, ``filesizeformat``, and ``intcomma`` templates filters
|
| 14 |
+
-- received a ``Decimal`` with a large number of digits or a large exponent, it
|
| 15 |
+
could lead to significant memory usage due to a call to ``'{:f}'.format()``.
|
| 16 |
+
|
| 17 |
+
To avoid this, decimals with more than 200 digits are now formatted using
|
| 18 |
+
scientific notation.
|
| 19 |
+
|
| 20 |
+
Bugfixes
|
| 21 |
+
========
|
| 22 |
+
|
| 23 |
+
* Made the ``obj`` argument of ``InlineModelAdmin.has_add_permission()``
|
| 24 |
+
optional to restore backwards compatibility with third-party code that
|
| 25 |
+
doesn't provide it (:ticket:`30097`).
|
testbed/django__django/docs/releases/2.2.1.txt
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
==========================
|
| 2 |
+
Django 2.2.1 release notes
|
| 3 |
+
==========================
|
| 4 |
+
|
| 5 |
+
*May 1, 2019*
|
| 6 |
+
|
| 7 |
+
Django 2.2.1 fixes several bugs in 2.2.
|
| 8 |
+
|
| 9 |
+
Bugfixes
|
| 10 |
+
========
|
| 11 |
+
|
| 12 |
+
* Fixed a regression in Django 2.1 that caused the incorrect quoting of
|
| 13 |
+
database user password when using :djadmin:`dbshell` on Oracle
|
| 14 |
+
(:ticket:`30307`).
|
| 15 |
+
|
| 16 |
+
* Added compatibility for ``psycopg2`` 2.8 (:ticket:`30331`).
|
| 17 |
+
|
| 18 |
+
* Fixed a regression in Django 2.2 that caused a crash when loading the
|
| 19 |
+
template for the technical 500 debug page (:ticket:`30324`).
|
| 20 |
+
|
| 21 |
+
* Fixed crash of ``ordering`` argument in
|
| 22 |
+
:class:`~django.contrib.postgres.aggregates.ArrayAgg` and
|
| 23 |
+
:class:`~django.contrib.postgres.aggregates.StringAgg` when it contains an
|
| 24 |
+
expression with params (:ticket:`30332`).
|
| 25 |
+
|
| 26 |
+
* Fixed a regression in Django 2.2 that caused a single instance fast-delete
|
| 27 |
+
to not set the primary key to ``None`` (:ticket:`30330`).
|
| 28 |
+
|
| 29 |
+
* Prevented :djadmin:`makemigrations` from generating infinite migrations for
|
| 30 |
+
check constraints and partial indexes when ``condition`` contains
|
| 31 |
+
a :class:`~python:range` object (:ticket:`30350`).
|
| 32 |
+
|
| 33 |
+
* Reverted an optimization in Django 2.2 (:ticket:`29725`) that caused the
|
| 34 |
+
inconsistent behavior of ``count()`` and ``exists()`` on a reverse
|
| 35 |
+
many-to-many relationship with a custom manager (:ticket:`30325`).
|
| 36 |
+
|
| 37 |
+
* Fixed a regression in Django 2.2 where
|
| 38 |
+
:class:`~django.core.paginator.Paginator` crashes if ``object_list`` is
|
| 39 |
+
a queryset ordered or aggregated over a nested ``JSONField`` key transform
|
| 40 |
+
(:ticket:`30335`).
|
| 41 |
+
|
| 42 |
+
* Fixed a regression in Django 2.2 where ``IntegerField`` validation of
|
| 43 |
+
database limits crashes if ``limit_value`` attribute in a custom validator is
|
| 44 |
+
callable (:ticket:`30328`).
|
| 45 |
+
|
| 46 |
+
* Fixed a regression in Django 2.2 where
|
| 47 |
+
:class:`~django.contrib.postgres.search.SearchVector` generates SQL that is
|
| 48 |
+
not indexable (:ticket:`30385`).
|
| 49 |
+
|
| 50 |
+
* Fixed a regression in Django 2.2 that caused an exception to be raised when
|
| 51 |
+
a custom error handler could not be imported (:ticket:`30318`).
|
| 52 |
+
|
| 53 |
+
* Relaxed the system check added in Django 2.2 for the admin app's dependencies
|
| 54 |
+
to reallow use of
|
| 55 |
+
:class:`~django.contrib.sessions.middleware.SessionMiddleware` subclasses,
|
| 56 |
+
rather than requiring :mod:`django.contrib.sessions` to be in
|
| 57 |
+
:setting:`INSTALLED_APPS` (:ticket:`30312`).
|
| 58 |
+
|
| 59 |
+
* Increased the default timeout when using ``Watchman`` to 5 seconds to prevent
|
| 60 |
+
falling back to ``StatReloader`` on larger projects and made it customizable
|
| 61 |
+
via the :envvar:`DJANGO_WATCHMAN_TIMEOUT` environment variable
|
| 62 |
+
(:ticket:`30361`).
|
| 63 |
+
|
| 64 |
+
* Fixed a regression in Django 2.2 that caused a crash when migrating
|
| 65 |
+
permissions for proxy models if the target permissions already existed. For
|
| 66 |
+
example, when a permission had been created manually or a model had been
|
| 67 |
+
migrated from concrete to proxy (:ticket:`30351`).
|
| 68 |
+
|
| 69 |
+
* Fixed a regression in Django 2.2 that caused a crash of :djadmin:`runserver`
|
| 70 |
+
when URLConf modules raised exceptions (:ticket:`30323`).
|
| 71 |
+
|
| 72 |
+
* Fixed a regression in Django 2.2 where changes were not reliably detected by
|
| 73 |
+
auto-reloader when using ``StatReloader`` (:ticket:`30323`).
|
| 74 |
+
|
| 75 |
+
* Fixed a migration crash on Oracle and PostgreSQL when adding a check
|
| 76 |
+
constraint with a ``contains``, ``startswith``, or ``endswith`` lookup (or
|
| 77 |
+
their case-insensitive variant) (:ticket:`30408`).
|
| 78 |
+
|
| 79 |
+
* Fixed a migration crash on Oracle and SQLite when adding a check constraint
|
| 80 |
+
with ``condition`` contains ``|`` (``OR``) operator (:ticket:`30412`).
|
testbed/django__django/docs/releases/2.2.11.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
===========================
|
| 2 |
+
Django 2.2.11 release notes
|
| 3 |
+
===========================
|
| 4 |
+
|
| 5 |
+
*March 4, 2020*
|
| 6 |
+
|
| 7 |
+
Django 2.2.11 fixes a security issue and a data loss bug in 2.2.10.
|
| 8 |
+
|
| 9 |
+
CVE-2020-9402: Potential SQL injection via ``tolerance`` parameter in GIS functions and aggregates on Oracle
|
| 10 |
+
============================================================================================================
|
| 11 |
+
|
| 12 |
+
GIS functions and aggregates on Oracle were subject to SQL injection,
|
| 13 |
+
using a suitably crafted ``tolerance``.
|
| 14 |
+
|
| 15 |
+
Bugfixes
|
| 16 |
+
========
|
| 17 |
+
|
| 18 |
+
* Fixed a data loss possibility in the
|
| 19 |
+
:meth:`~django.db.models.query.QuerySet.select_for_update`. When using
|
| 20 |
+
related fields or parent link fields with :ref:`multi-table-inheritance` in
|
| 21 |
+
the ``of`` argument, the corresponding models were not locked
|
| 22 |
+
(:ticket:`31246`).
|