1.3-alpha-1.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. ================================
  2. Django 1.3 alpha 1 release notes
  3. ================================
  4. November 11, 2010
  5. Welcome to Django 1.3 alpha 1!
  6. This is the first in a series of preview/development releases leading
  7. up to the eventual release of Django 1.3. This release is primarily
  8. targeted at developers who are interested in trying out new features
  9. and testing the Django codebase to help identify and resolve bugs
  10. prior to the final 1.3 release.
  11. As such, this release is *not* intended for production use, and any such use is
  12. discouraged.
  13. As of this alpha release, Django 1.3 contains a number of nifty `new
  14. features`_, lots of bug fixes, some minor `backwards incompatible
  15. changes`_ and an easy upgrade path from Django 1.2.
  16. .. _new features: `What's new in Django 1.3 alpha 1`_
  17. .. _backwards incompatible changes: backwards-incompatible-changes-1.3-alpha-1_
  18. What's new in Django 1.3 alpha 1
  19. ================================
  20. Class-based views
  21. ~~~~~~~~~~~~~~~~~
  22. Django 1.3 adds a framework that allows you to use a class as a view.
  23. This means you can compose a view out of a collection of methods that
  24. can be subclassed and overridden to provide common views of data without
  25. having to write too much code.
  26. Analogs of all the old function-based generic views have been provided,
  27. along with a completely generic view base class that can be used as
  28. the basis for reusable applications that can be easily extended.
  29. See :doc:`the documentation on Class-based Generic Views
  30. </topics/class-based-views/index>` for more details. There is also a document to
  31. help you `convert your function-based generic views to class-based
  32. views <https://docs.djangoproject.com/en/1.4/topics/generic-views-migration/>`_.
  33. Logging
  34. ~~~~~~~
  35. Django 1.3 adds framework-level support for Python's logging module.
  36. This means you can now easily configure and control logging as part of
  37. your Django project. A number of logging handlers and logging calls
  38. have been added to Django's own code as well -- most notably, the
  39. error emails sent on a HTTP 500 server error are now handled as a
  40. logging activity. See :doc:`the documentation on Django's logging
  41. interface </topics/logging>` for more details.
  42. Extended static files handling
  43. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  44. Django 1.3 ships with a new contrib app ``'django.contrib.staticfiles'``
  45. to help developers handle the static media files (images, CSS, Javascript,
  46. etc.) that are needed to render a complete web page.
  47. In previous versions of Django, it was common to place static assets
  48. in :setting:`MEDIA_ROOT` along with user-uploaded files, and serve
  49. them both at :setting:`MEDIA_URL`. Part of the purpose of introducing
  50. the ``staticfiles`` app is to make it easier to keep static files
  51. separate from user-uploaded files. Static assets should now go in
  52. ``static/`` subdirectories of your apps or in other static assets
  53. directories listed in :setting:`STATICFILES_DIRS`, and will be served
  54. at :setting:`STATIC_URL`.
  55. See the :doc:`reference documentation of the app </ref/contrib/staticfiles>`
  56. for more details or learn how to :doc:`manage static files
  57. </howto/static-files/index>`.
  58. ``unittest2`` support
  59. ~~~~~~~~~~~~~~~~~~~~~
  60. Python 2.7 introduced some major changes to the unittest library,
  61. adding some extremely useful features. To ensure that every Django
  62. project can benefit from these new features, Django ships with a
  63. copy of unittest2_, a copy of the Python 2.7 unittest library,
  64. backported for Python 2.4 compatibility.
  65. To access this library, Django provides the
  66. ``django.utils.unittest`` module alias. If you are using Python
  67. 2.7, or you have installed unittest2 locally, Django will map the
  68. alias to the installed version of the unittest library. Otherwise,
  69. Django will use its own bundled version of unittest2.
  70. To use this alias, simply use::
  71. from django.utils import unittest
  72. wherever you would have historically used::
  73. import unittest
  74. If you want to continue to use the base unittest libary, you can --
  75. you just won't get any of the nice new unittest2 features.
  76. .. _unittest2: http://pypi.python.org/pypi/unittest2
  77. Transaction context managers
  78. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  79. Users of Python 2.5 and above may now use transaction management functions as
  80. `context managers`_. For example::
  81. with transaction.autocommit():
  82. # ...
  83. .. _context managers: http://docs.python.org/glossary.html#term-context-manager
  84. Configurable delete-cascade
  85. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  86. :class:`~django.db.models.ForeignKey` and
  87. :class:`~django.db.models.OneToOneField` now accept an
  88. :attr:`~django.db.models.ForeignKey.on_delete` argument to customize behavior
  89. when the referenced object is deleted. Previously, deletes were always
  90. cascaded; available alternatives now include set null, set default, set to any
  91. value, protect, or do nothing.
  92. For more information, see the :attr:`~django.db.models.ForeignKey.on_delete`
  93. documentation.
  94. Contextual markers in translatable strings
  95. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  96. For translation strings with ambiguous meaning, you can now
  97. use the ``pgettext`` function to specify the context of the string.
  98. For more information, see :ref:`contextual-markers`
  99. Everything else
  100. ~~~~~~~~~~~~~~~
  101. Django :doc:`1.1 <1.1>` and :doc:`1.2 <1.2>` added
  102. lots of big ticket items to Django, like multiple-database support,
  103. model validation, and a session-based messages framework. However,
  104. this focus on big features came at the cost of lots of smaller
  105. features.
  106. To compensate for this, the focus of the Django 1.3 development
  107. process has been on adding lots of smaller, long standing feature
  108. requests. These include:
  109. * Improved tools for accessing and manipulating the current Site via
  110. ``django.contrib.sites.models.get_current_site()``.
  111. * A :class:`~django.test.client.RequestFactory` for mocking
  112. requests in tests.
  113. * A new test assertion --
  114. :meth:`~django.test.TestCase.assertNumQueries` -- making it
  115. easier to test the database activity associated with a view.
  116. .. _backwards-incompatible-changes-1.3-alpha-1:
  117. Backwards-incompatible changes in 1.3 alpha 1
  118. =============================================
  119. PasswordInput default rendering behavior
  120. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  121. The :class:`~django.forms.PasswordInput` form widget, intended for use
  122. with form fields which represent passwords, accepts a boolean keyword
  123. argument ``render_value`` indicating whether to send its data back to
  124. the browser when displaying a submitted form with errors. Prior to
  125. Django 1.3, this argument defaulted to ``True``, meaning that the
  126. submitted password would be sent back to the browser as part of the
  127. form. Developers who wished to add a bit of additional security by
  128. excluding that value from the redisplayed form could instantiate a
  129. :class:`~django.forms.PasswordInput` passing ``render_value=False`` .
  130. Due to the sensitive nature of passwords, however, Django 1.3 takes
  131. this step automatically; the default value of ``render_value`` is now
  132. ``False``, and developers who want the password value returned to the
  133. browser on a submission with errors (the previous behavior) must now
  134. explicitly indicate this. For example::
  135. class LoginForm(forms.Form):
  136. username = forms.CharField(max_length=100)
  137. password = forms.CharField(widget=forms.PasswordInput(render_value=True))
  138. Clearable default widget for FileField
  139. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  140. Django 1.3 now includes a ``ClearableFileInput`` form widget in addition to
  141. ``FileInput``. ``ClearableFileInput`` renders with a checkbox to clear the
  142. field's value (if the field has a value and is not required); ``FileInput``
  143. provided no means for clearing an existing file from a ``FileField``.
  144. ``ClearableFileInput`` is now the default widget for a ``FileField``, so
  145. existing forms including ``FileField`` without assigning a custom widget will
  146. need to account for the possible extra checkbox in the rendered form output.
  147. To return to the previous rendering (without the ability to clear the
  148. ``FileField``), use the ``FileInput`` widget in place of
  149. ``ClearableFileInput``. For instance, in a ``ModelForm`` for a hypothetical
  150. ``Document`` model with a ``FileField`` named ``document``::
  151. from django import forms
  152. from myapp.models import Document
  153. class DocumentForm(forms.ModelForm):
  154. class Meta:
  155. model = Document
  156. widgets = {'document': forms.FileInput}
  157. New index on database session table
  158. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  159. Prior to Django 1.3, the database table used by the database backend
  160. for the :doc:`sessions </topics/http/sessions>` app had no index on
  161. the ``expire_date`` column. As a result, date-based queries on the
  162. session table -- such as the query that is needed to purge old
  163. sessions -- would be very slow if there were lots of sessions.
  164. If you have an existing project that is using the database session
  165. backend, you don't have to do anything to accommodate this change.
  166. However, you may get a significant performance boost if you manually
  167. add the new index to the session table. The SQL that will add the
  168. index can be found by running the :djadmin:`sqlindexes` admin
  169. command::
  170. python manage.py sqlindexes sessions
  171. No more naughty words
  172. ~~~~~~~~~~~~~~~~~~~~~
  173. Django has historically provided (and enforced) a list of profanities.
  174. The :doc:`comments app </ref/contrib/comments/index>` has enforced this
  175. list of profanities, preventing people from submitting comments that
  176. contained one of those profanities.
  177. Unfortunately, the technique used to implement this profanities list
  178. was woefully naive, and prone to the `Scunthorpe problem`_. Fixing the
  179. built in filter to fix this problem would require significant effort,
  180. and since natural language processing isn't the normal domain of a web
  181. framework, we have "fixed" the problem by making the list of
  182. prohibited words an empty list.
  183. If you want to restore the old behavior, simply put a
  184. :setting:`PROFANITIES_LIST` setting in your settings file that includes the
  185. words that you want to prohibit (see the `commit that implemented this
  186. change`_ if you want to see the list of words that was historically
  187. prohibited). However, if avoiding profanities is important to you, you
  188. would be well advised to seek out a better, less naive approach to the
  189. problem.
  190. .. _Scunthorpe problem: http://en.wikipedia.org/wiki/Scunthorpe_problem
  191. .. _commit that implemented this change: https://code.djangoproject.com/changeset/13996
  192. Localflavor changes
  193. ~~~~~~~~~~~~~~~~~~~
  194. Django 1.3 introduces the following backwards-incompatible changes to
  195. local flavors:
  196. * Indonesia (id) -- The province "Nanggroe Aceh Darussalam (NAD)"
  197. has been removed from the province list in favor of the new
  198. official designation "Aceh (ACE)".
  199. Features deprecated in 1.3
  200. ==========================
  201. Django 1.3 deprecates some features from earlier releases.
  202. These features are still supported, but will be gradually phased out
  203. over the next few release cycles.
  204. Code taking advantage of any of the features below will raise a
  205. ``PendingDeprecationWarning`` in Django 1.3. This warning will be
  206. silent by default, but may be turned on using Python's :mod:`warnings`
  207. module, or by running Python with a ``-Wd`` or ``-Wall`` flag.
  208. In Django 1.4, these warnings will become a ``DeprecationWarning``,
  209. which is *not* silent. In Django 1.5 support for these features will
  210. be removed entirely.
  211. .. seealso::
  212. For more details, see the documentation :doc:`Django's release process
  213. </internals/release-process>` and our :doc:`deprecation timeline
  214. </internals/deprecation>`.
  215. ``mod_python`` support
  216. ~~~~~~~~~~~~~~~~~~~~~~
  217. The ``mod_python`` library has not had a release since 2007 or a commit since
  218. 2008. The Apache Foundation board voted to remove ``mod_python`` from the set
  219. of active projects in its version control repositories, and its lead developer
  220. has shifted all of his efforts toward the lighter, slimmer, more stable, and
  221. more flexible ``mod_wsgi`` backend.
  222. If you are currently using the ``mod_python`` request handler, you are strongly
  223. encouraged to redeploy your Django instances using :doc:`mod_wsgi
  224. </howto/deployment/wsgi/modwsgi>`.
  225. Function-based generic views
  226. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  227. As a result of the introduction of class-based generic views, the
  228. function-based generic views provided by Django have been deprecated.
  229. The following modules and the views they contain have been deprecated:
  230. * ``django.views.generic.create_update``
  231. * ``django.views.generic.date_based``
  232. * ``django.views.generic.list_detail``
  233. * ``django.views.generic.simple``
  234. Test client response ``template`` attribute
  235. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  236. Django's :ref:`test client <test-client>` returns
  237. :class:`~django.test.client.Response` objects annotated with extra testing
  238. information. In Django versions prior to 1.3, this included a ``template``
  239. attribute containing information about templates rendered in generating the
  240. response: either None, a single :class:`~django.template.Template` object, or a
  241. list of :class:`~django.template.Template` objects. This inconsistency in
  242. return values (sometimes a list, sometimes not) made the attribute difficult
  243. to work with.
  244. In Django 1.3 the ``template`` attribute is deprecated in favor of a new
  245. :attr:`~django.test.client.Response.templates` attribute, which is always a
  246. list, even if it has only a single element or no elements.
  247. ``DjangoTestRunner``
  248. ~~~~~~~~~~~~~~~~~~~~
  249. As a result of the introduction of support for unittest2, the features
  250. of ``django.test.simple.DjangoTestRunner`` (including fail-fast
  251. and Ctrl-C test termination) have been made redundant. In view of this
  252. redundancy, ``DjangoTestRunner`` has been turned into an empty placeholder
  253. class, and will be removed entirely in Django 1.5.
  254. The Django 1.3 roadmap
  255. ======================
  256. Before the final Django 1.3 release, several other preview/development
  257. releases will be made available. The current schedule consists of at
  258. least the following:
  259. * Week of **November 29, 2010**: First Django 1.3 beta release. Final
  260. feature freeze for Django 1.3.
  261. * Week of **January 10, 2011**: First Django 1.3 release
  262. candidate. String freeze for translations.
  263. * Week of **January 17, 2011**: Django 1.3 final release.
  264. If necessary, additional alpha, beta or release-candidate packages
  265. will be issued prior to the final 1.3 release. Django 1.3 will be
  266. released approximately one week after the final release candidate.
  267. What you can do to help
  268. =======================
  269. In order to provide a high-quality 1.3 release, we need your help. Although this
  270. alpha release is, again, *not* intended for production use, you can help the
  271. Django team by trying out the alpha codebase in a safe test environment and
  272. reporting any bugs or issues you encounter. The Django ticket tracker is the
  273. central place to search for open issues:
  274. * https://code.djangoproject.com/timeline
  275. Please open new tickets if no existing ticket corresponds to a problem you're
  276. running into.
  277. Additionally, discussion of Django development, including progress toward the
  278. 1.3 release, takes place daily on the django-developers mailing list:
  279. * http://groups.google.com/group/django-developers
  280. ... and in the ``#django-dev`` IRC channel on ``irc.freenode.net``. If you're
  281. interested in helping out with Django's development, feel free to join the
  282. discussions there.
  283. Django's online documentation also includes pointers on how to contribute to
  284. Django:
  285. * :doc:`How to contribute to Django </internals/contributing/index>`
  286. Contributions on any level -- developing code, writing documentation or simply
  287. triaging tickets and helping to test proposed bugfixes -- are always welcome and
  288. appreciated.
  289. Several development sprints will also be taking place before the 1.3
  290. release; these will typically be announced in advance on the
  291. django-developers mailing list, and anyone who wants to help is
  292. welcome to join in.