1.3.txt 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. ============================================
  2. Django 1.3 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. This page documents release notes for the as-yet-unreleased Django
  5. 1.3. As such, it's tentative and subject to change. It provides
  6. up-to-date information for those who are following trunk.
  7. Django 1.3 includes a number of nifty `new features`_, lots of bug
  8. fixes, some minor `backwards incompatible changes`_ and an easy
  9. upgrade path from Django 1.2.
  10. .. _new features: `What's new in Django 1.3`_
  11. .. _backwards incompatible changes: backwards-incompatible-changes-1.3_
  12. What's new in Django 1.3
  13. ========================
  14. Class-based views
  15. ~~~~~~~~~~~~~~~~~
  16. Django 1.3 adds a framework that allows you to use a class as a view.
  17. This means you can compose a view out of a collection of methods that
  18. can be subclassed and overridden to provide
  19. Analogs of all the old function-based generic views have been
  20. provided, along with a completely generic view base class that can be
  21. used as the basis for reusable applications that can be easily
  22. extended.
  23. See :doc:`the documentation on Generic Views</topics/generic-views>`
  24. for more details. There is also a document to help you :doc:`convert
  25. your function-based generic views to class-based
  26. views</topics/generic-views-migration>`.
  27. Logging
  28. ~~~~~~~
  29. Django 1.3 adds framework-level support for Python's logging module.
  30. This means you can now easily configure and control logging as part of
  31. your Django project. A number of logging handlers and logging calls
  32. have been added to Django's own code as well -- most notably, the
  33. error emails sent on a HTTP 500 server error are now handled as a
  34. logging activity. See :doc:`the documentation on Django's logging
  35. interface </topics/logging>` for more details.
  36. ``unittest2`` support
  37. ~~~~~~~~~~~~~~~~~~~~~
  38. Python 2.7 introduced some major changes to the unittest library,
  39. adding some extremely useful features. To ensure that every Django
  40. project can benefit from these new features, Django ships with a
  41. copy of unittest2_, a copy of the Python 2.7 unittest library,
  42. backported for Python 2.4 compatibility.
  43. To access this library, Django provides the
  44. ``django.utils.unittest`` module alias. If you are using Python
  45. 2.7, or you have installed unittest2 locally, Django will map the
  46. alias to the installed version of the unittest library. Otherwise,
  47. Django will use it's own bundled version of unittest2.
  48. To use this alias, simply use::
  49. from django.utils import unittest
  50. wherever you would have historically used::
  51. import unittest
  52. If you want to continue to use the base unittest libary, you can --
  53. you just won't get any of the nice new unittest2 features.
  54. .. _unittest2: http://pypi.python.org/pypi/unittest2
  55. Everything else
  56. ~~~~~~~~~~~~~~~
  57. Django :doc:`1.1 <1.1>` and :doc:`1.2 <1.2>` added
  58. lots of big ticket items to Django, like multiple-database support,
  59. model validation, and a session-based messages framework. However,
  60. this focus on big features came at the cost of lots of smaller
  61. features.
  62. To compensate for this, the focus of the Django 1.3 development
  63. process has been on adding lots of smaller, long standing feature
  64. requests. These include:
  65. * Improved tools for accessing and manipulating the current Site.
  66. * A :class:`~django.test.client.RequestFactory` for mocking
  67. requests in tests.
  68. * A new test assertion --
  69. :meth:`~django.test.client.Client.assertNumQueries` -- making it
  70. easier to test the database activity associated with a view.
  71. .. _backwards-incompatible-changes-1.3:
  72. Backwards-incompatible changes in 1.3
  73. =====================================
  74. PasswordInput default rendering behavior
  75. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  76. Prior to Django 1.3, a :class:`~django.forms.PasswordInput` would render
  77. data values like any other form. If a form submission raised an error,
  78. the password that was submitted would be reflected to the client as form
  79. data populating the form for resubmission.
  80. This had the potential to leak passwords, as any failed password
  81. attempt would cause the password that was typed to be sent back to the
  82. client.
  83. In Django 1.3, the default behavior of
  84. :class:`~django.forms.PasswordInput` is to suppress the display of
  85. password values. This change doesn't alter the way form data is
  86. validated or handled. It only affects the user experience with
  87. passwords on a form when they make an error submitting form data (such
  88. as on unsuccessful logins, or when completing a registration form).
  89. If you want restore the pre-Django 1.3 behavior, you need to pass in a
  90. custom widget to your form that sets the ``render_value`` argument::
  91. class LoginForm(forms.Form):
  92. username = forms.CharField(max_length=100)
  93. password = forms.CharField(widget=forms.PasswordInput(render_value=True))
  94. Clearable default widget for FileField
  95. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  96. Django 1.3 now includes a ``ClearableFileInput`` form widget in addition to
  97. ``FileInput``. ``ClearableFileInput`` renders with a checkbox to clear the
  98. field's value (if the field has a value and is not required); ``FileInput``
  99. provided no means for clearing an existing file from a ``FileField``.
  100. ``ClearableFileInput`` is now the default widget for a ``FileField``, so
  101. existing forms including ``FileField`` without assigning a custom widget will
  102. need to account for the possible extra checkbox in the rendered form output.
  103. To return to the previous rendering (without the ability to clear the
  104. ``FileField``), use the ``FileInput`` widget in place of
  105. ``ClearableFileInput``. For instance, in a ``ModelForm`` for a hypothetical
  106. ``Document`` model with a ``FileField`` named ``document``::
  107. from django import forms
  108. from myapp.models import Document
  109. class DocumentForm(forms.ModelForm):
  110. class Meta:
  111. model = Document
  112. widgets = {'document': forms.FileInput}
  113. .. _deprecated-features-1.3:
  114. Features deprecated in 1.3
  115. ==========================
  116. Django 1.3 deprecates some features from earlier releases.
  117. These features are still supported, but will be gradually phased out
  118. over the next few release cycles.
  119. Code taking advantage of any of the features below will raise a
  120. ``PendingDeprecationWarning`` in Django 1.3. This warning will be
  121. silent by default, but may be turned on using Python's `warnings
  122. module`_, or by running Python with a ``-Wd`` or `-Wall` flag.
  123. .. _warnings module: http://docs.python.org/library/warnings.html
  124. In Django 1.4, these warnings will become a ``DeprecationWarning``,
  125. which is *not* silent. In Django 1.5 support for these features will
  126. be removed entirely.
  127. .. seealso::
  128. For more details, see the documentation :doc:`Django's release process
  129. </internals/release-process>` and our :doc:`deprecation timeline
  130. </internals/deprecation>`.`
  131. ``mod_python`` support
  132. ~~~~~~~~~~~~~~~~~~~~~~
  133. The ``mod_python`` library has not had a release since 2007 or a commit since
  134. 2008. The Apache Foundation board voted to remove ``mod_python`` from the set
  135. of active projects in its version control repositories, and its lead developer
  136. has shifted all of his efforts toward the lighter, slimmer, more stable, and
  137. more flexible ``mod_wsgi`` backend.
  138. If you are currently using the ``mod_python`` request handler, it is strongly
  139. encouraged you redeploy your Django instances using :doc:`mod_wsgi
  140. </howto/deployment/modwsgi>`.
  141. Function-based generic views
  142. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  143. As a result of the introduction of class-based generic views, the
  144. function-based generic views provided by Django have been deprecated.
  145. The following modules and the views they contain have been deprecated:
  146. * :mod:`django.views.generic.create_update`
  147. * :mod:`django.views.generic.date_based`
  148. * :mod:`django.views.generic.list_detail`
  149. * :mod:`django.views.generic.simple`
  150. Test client response ``template`` attribute
  151. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  152. Django's :ref:`test client <test-client>` returns
  153. :class:`~django.test.client.Response` objects annotated with extra testing
  154. information. In Django versions prior to 1.3, this included a
  155. :attr:`~django.test.client.Response.template` attribute containing information
  156. about templates rendered in generating the response: either None, a single
  157. :class:`~django.template.Template` object, or a list of
  158. :class:`~django.template.Template` objects. This inconsistency in return values
  159. (sometimes a list, sometimes not) made the attribute difficult to work with.
  160. In Django 1.3 the :attr:`~django.test.client.Response.template` attribute is
  161. deprecated in favor of a new :attr:`~django.test.client.Response.templates`
  162. attribute, which is always a list, even if it has only a single element or no
  163. elements.
  164. ``DjangoTestRunner``
  165. ~~~~~~~~~~~~~~~~~~~~
  166. As a result of the introduction of support for unittest2, the features
  167. of :class:`django.test.simple.DjangoTestRunner` (including fail-fast
  168. and Ctrl-C test termination) have been made redundant. In view of this
  169. redundancy, :class:`~django.test.simple.DjangoTestRunner` has been
  170. turned into an empty placeholder class, and will be removed entirely
  171. in Django 1.5.