| 1 |
================================= |
| 2 |
Django version 0.96 release notes |
| 3 |
================================= |
| 4 |
|
| 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: https://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`. |