0.96.txt 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. =================================
  2. Django version 0.96 release notes
  3. =================================
  4. Welcome to Django 0.96!
  5. The primary goal for 0.96 is a cleanup and stabilization of the features
  6. introduced in 0.95. There have been a few small `backwards-incompatible
  7. changes`_ since 0.95, but the upgrade process should be fairly simple
  8. and should not require major changes to existing applications.
  9. However, we're also releasing 0.96 now because we have a set of
  10. backwards-incompatible changes scheduled for the near future. Once
  11. completed, they will involve some code changes for application
  12. developers, so we recommend that you stick with Django 0.96 until the
  13. next official release; then you'll be able to upgrade in one step
  14. instead of needing to make incremental changes to keep up with the
  15. development version of Django.
  16. Backwards-incompatible changes
  17. ==============================
  18. The following changes may require you to update your code when you switch from
  19. 0.95 to 0.96:
  20. ``MySQLdb`` version requirement
  21. -------------------------------
  22. Due to a bug in older versions of the ``MySQLdb`` Python module (which
  23. Django uses to connect to MySQL databases), Django's MySQL backend now
  24. requires version 1.2.1p2 or higher of ``MySQLdb``, and will raise
  25. exceptions if you attempt to use an older version.
  26. If you're currently unable to upgrade your copy of ``MySQLdb`` to meet
  27. this requirement, a separate, backwards-compatible backend, called
  28. "mysql_old", has been added to Django. To use this backend, change
  29. the :setting:`DATABASE_ENGINE` setting in your Django settings file from
  30. this::
  31. DATABASE_ENGINE = "mysql"
  32. to this::
  33. DATABASE_ENGINE = "mysql_old"
  34. However, we strongly encourage MySQL users to upgrade to a more recent
  35. version of ``MySQLdb`` as soon as possible, The "mysql_old" backend is
  36. provided only to ease this transition, and is considered deprecated;
  37. aside from any necessary security fixes, it will not be actively
  38. maintained, and it will be removed in a future release of Django.
  39. Also, note that some features, like the new :setting:`DATABASE_OPTIONS`
  40. setting (see the :doc:`databases documentation </ref/databases>` for details),
  41. are only available on the "mysql" backend, and will not be made available for
  42. "mysql_old".
  43. Database constraint names changed
  44. ---------------------------------
  45. The format of the constraint names Django generates for foreign key
  46. references have changed slightly. These names are generally only used
  47. when it is not possible to put the reference directly on the affected
  48. column, so they are not always visible.
  49. The effect of this change is that running ``manage.py reset`` and
  50. similar commands against an existing database may generate SQL with
  51. the new form of constraint name, while the database itself contains
  52. constraints named in the old form; this will cause the database server
  53. to raise an error message about modifying non-existent constraints.
  54. If you need to work around this, there are two methods available:
  55. 1. Redirect the output of ``manage.py`` to a file, and edit the
  56. generated SQL to use the correct constraint names before
  57. executing it.
  58. 2. Examine the output of ``manage.py sqlall`` to see the new-style
  59. constraint names, and use that as a guide to rename existing
  60. constraints in your database.
  61. Name changes in ``manage.py``
  62. -----------------------------
  63. A few of the options to ``manage.py`` have changed with the addition of fixture
  64. support:
  65. * There are new ``dumpdata`` and ``loaddata`` commands which, as
  66. you might expect, will dump and load data to/from the
  67. database. These commands can operate against any of Django's
  68. supported serialization formats.
  69. * The ``sqlinitialdata`` command has been renamed to ``sqlcustom`` to
  70. emphasize that ``loaddata`` should be used for data (and ``sqlcustom`` for
  71. other custom SQL -- views, stored procedures, etc.).
  72. * The vestigial ``install`` command has been removed. Use ``syncdb``.
  73. Backslash escaping changed
  74. --------------------------
  75. The Django database API now escapes backslashes given as query parameters. If
  76. you have any database API code that matches backslashes, and it was working before
  77. (despite the lack of escaping), you'll have to change your code to "unescape" the
  78. slashes one level.
  79. For example, this used to work::
  80. # Find text containing a single backslash
  81. MyModel.objects.filter(text__contains='\\\\')
  82. The above is now incorrect, and should be rewritten as::
  83. # Find text containing a single backslash
  84. MyModel.objects.filter(text__contains='\\')
  85. Removed ENABLE_PSYCO setting
  86. ----------------------------
  87. The ``ENABLE_PSYCO`` setting no longer exists. If your settings file includes
  88. ``ENABLE_PSYCO`` it will have no effect; to use Psyco_, we recommend
  89. writing a middleware class to activate it.
  90. .. _psyco: http://psyco.sourceforge.net/
  91. What's new in 0.96?
  92. ===================
  93. This revision represents over a thousand source commits and over four hundred
  94. bug fixes, so we can't possibly catalog all the changes. Here, we describe the
  95. most notable changes in this release.
  96. New forms library
  97. -----------------
  98. ``django.newforms`` is Django's new form-handling library. It's a
  99. replacement for ``django.forms``, the old form/manipulator/validation
  100. framework. Both APIs are available in 0.96, but over the next two
  101. releases we plan to switch completely to the new forms system, and
  102. deprecate and remove the old system.
  103. There are three elements to this transition:
  104. * We've copied the current ``django.forms`` to
  105. ``django.oldforms``. This allows you to upgrade your code *now*
  106. rather than waiting for the backwards-incompatible change and
  107. rushing to fix your code after the fact. Just change your
  108. import statements like this::
  109. from django import forms # 0.95-style
  110. from django import oldforms as forms # 0.96-style
  111. * The next official release of Django will move the current
  112. ``django.newforms`` to ``django.forms``. This will be a
  113. backwards-incompatible change, and anyone still using the old
  114. version of ``django.forms`` at that time will need to change
  115. their import statements as described above.
  116. * The next release after that will completely remove
  117. ``django.oldforms``.
  118. Although the ``newforms`` library will continue to evolve, it's ready for use
  119. for most common cases. We recommend that anyone new to form handling skip the
  120. old forms system and start with the new.
  121. For more information about ``django.newforms``, read the :doc:`newforms
  122. documentation </topics/forms/index>`.
  123. URLconf improvements
  124. --------------------
  125. You can now use any callable as the callback in URLconfs (previously, only
  126. strings that referred to callables were allowed). This allows a much more
  127. natural use of URLconfs. For example, this URLconf::
  128. from django.conf.urls.defaults import *
  129. urlpatterns = patterns('',
  130. ('^myview/$', 'mysite.myapp.views.myview')
  131. )
  132. can now be rewritten as::
  133. from django.conf.urls.defaults import *
  134. from mysite.myapp.views import myview
  135. urlpatterns = patterns('',
  136. ('^myview/$', myview)
  137. )
  138. One useful application of this can be seen when using decorators; this
  139. change allows you to apply decorators to views *in your
  140. URLconf*. Thus, you can make a generic view require login very
  141. easily::
  142. from django.conf.urls.defaults import *
  143. from django.contrib.auth.decorators import login_required
  144. from django.views.generic.list_detail import object_list
  145. from mysite.myapp.models import MyModel
  146. info = {
  147. "queryset" : MyModel.objects.all(),
  148. }
  149. urlpatterns = patterns('',
  150. ('^myview/$', login_required(object_list), info)
  151. )
  152. Note that both syntaxes (strings and callables) are valid, and will continue to
  153. be valid for the foreseeable future.
  154. The test framework
  155. ------------------
  156. Django now includes a test framework so you can start transmuting fear into
  157. boredom (with apologies to Kent Beck). You can write tests based on
  158. :mod:`doctest` or :mod:`unittest` and test your views with a simple test client.
  159. There is also new support for "fixtures" -- initial data, stored in any of the
  160. supported :doc:`serialization formats </topics/serialization>`, that will be
  161. loaded into your database at the start of your tests. This makes testing with
  162. real data much easier.
  163. See :doc:`the testing documentation </topics/testing>` for the full details.
  164. Improvements to the admin interface
  165. -----------------------------------
  166. A small change, but a very nice one: dedicated views for adding and
  167. updating users have been added to the admin interface, so you no
  168. longer need to worry about working with hashed passwords in the admin.
  169. Thanks
  170. ======
  171. Since 0.95, a number of people have stepped forward and taken a major
  172. new role in Django's development. We'd like to thank these people for
  173. all their hard work:
  174. * Russell Keith-Magee and Malcolm Tredinnick for their major code
  175. contributions. This release wouldn't have been possible without them.
  176. * Our new release manager, James Bennett, for his work in getting out
  177. 0.95.1, 0.96, and (hopefully) future release.
  178. * Our ticket managers Chris Beaven (aka SmileyChris), Simon Greenhill,
  179. Michael Radziej, and Gary Wilson. They agreed to take on the monumental
  180. task of wrangling our tickets into nicely cataloged submission. Figuring
  181. out what to work on is now about a million times easier; thanks again,
  182. guys.
  183. * Everyone who submitted a bug report, patch or ticket comment. We can't
  184. possibly thank everyone by name -- over 200 developers submitted patches
  185. that went into 0.96 -- but everyone who's contributed to Django is listed
  186. in AUTHORS_.
  187. .. _AUTHORS: https://code.djangoproject.com/browser/django/trunk/AUTHORS