1.4-alpha-1.txt 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125
  1. ==============================
  2. Django 1.4 alpha release notes
  3. ==============================
  4. December 22, 2011.
  5. Welcome to Django 1.4 alpha!
  6. This is the first in a series of preview/development releases leading up to
  7. the eventual release of Django 1.4, scheduled for March 2012. This release is
  8. primarily targeted at developers who are interested in trying out new features
  9. and testing the Django codebase to help identify and resolve bugs prior to the
  10. final 1.4 release.
  11. As such, this release is *not* intended for production use, and any such use
  12. is discouraged.
  13. Django 1.4 alpha includes various `new features`_ and some minor `backwards
  14. incompatible changes`_. There are also some features that have been dropped,
  15. which are detailed in :doc:`our deprecation plan </internals/deprecation>`,
  16. and we've `begun the deprecation process for some features`_.
  17. .. _new features: `What's new in Django 1.4`_
  18. .. _backwards incompatible changes: `Backwards incompatible changes in 1.4`_
  19. .. _begun the deprecation process for some features: `Features deprecated in 1.4`_
  20. Python compatibility
  21. ====================
  22. While not a new feature, it's important to note that Django 1.4 introduces the
  23. second shift in our Python compatibility policy since Django's initial public
  24. debut. Django 1.2 dropped support for Python 2.3; now Django 1.4 drops support
  25. for Python 2.4. As such, the minimum Python version required for Django is now
  26. 2.5, and Django is tested and supported on Python 2.5, 2.6 and 2.7.
  27. This change should affect only a small number of Django users, as most
  28. operating-system vendors today are shipping Python 2.5 or newer as their default
  29. version. If you're still using Python 2.4, however, you'll need to stick to
  30. Django 1.3 until you can upgrade; per :doc:`our support policy
  31. </internals/release-process>`, Django 1.3 will continue to receive security
  32. support until the release of Django 1.5.
  33. Django does not support Python 3.x at this time. A document outlining our full
  34. timeline for deprecating Python 2.x and moving to Python 3.x will be published
  35. before the release of Django 1.4.
  36. What's new in Django 1.4
  37. ========================
  38. Support for in-browser testing frameworks
  39. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  40. Django 1.4 supports integration with in-browser testing frameworks like
  41. Selenium_. The new :class:`django.test.LiveServerTestCase` base class lets you
  42. test the interactions between your site's front and back ends more
  43. comprehensively. See the
  44. :class:`documentation<django.test.LiveServerTestCase>` for more details and
  45. concrete examples.
  46. .. _Selenium: http://seleniumhq.org/
  47. ``SELECT FOR UPDATE`` support
  48. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49. Django 1.4 now includes a :meth:`QuerySet.select_for_update()
  50. <django.db.models.query.QuerySet.select_for_update>` method which generates a
  51. ``SELECT ... FOR UPDATE`` SQL query. This will lock rows until the end of the
  52. transaction, meaning that other transactions cannot modify or delete rows
  53. matched by a ``FOR UPDATE`` query.
  54. For more details, see the documentation for
  55. :meth:`~django.db.models.query.QuerySet.select_for_update`.
  56. ``Model.objects.bulk_create`` in the ORM
  57. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  58. This method allows for more efficient creation of multiple objects in the ORM.
  59. It can provide significant performance increases if you have many objects.
  60. Django makes use of this internally, meaning some operations (such as database
  61. setup for test suites) have seen a performance benefit as a result.
  62. See the :meth:`~django.db.models.query.QuerySet.bulk_create` docs for more
  63. information.
  64. ``QuerySet.prefetch_related``
  65. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  66. Similar to :meth:`~django.db.models.query.QuerySet.select_related` but with a
  67. different strategy and broader scope,
  68. :meth:`~django.db.models.query.QuerySet.prefetch_related` has been added to
  69. :class:`~django.db.models.query.QuerySet`. This method returns a new
  70. ``QuerySet`` that will prefetch each of the specified related lookups in a
  71. single batch as soon as the query begins to be evaluated. Unlike
  72. ``select_related``, it does the joins in Python, not in the database, and
  73. supports many-to-many relationships,
  74. :class:`~django.contrib.contenttypes.generic.GenericForeignKey` and more. This
  75. allows you to fix a very common performance problem in which your code ends up
  76. doing O(n) database queries (or worse) if objects on your primary ``QuerySet``
  77. each have many related objects that you also need.
  78. Improved password hashing
  79. ~~~~~~~~~~~~~~~~~~~~~~~~~
  80. Django's auth system (``django.contrib.auth``) stores passwords using a one-way
  81. algorithm. Django 1.3 uses the SHA1_ algorithm, but increasing processor speeds
  82. and theoretical attacks have revealed that SHA1 isn't as secure as we'd like.
  83. Thus, Django 1.4 introduces a new password storage system: by default Django now
  84. uses the PBKDF2_ algorithm (as recommended by NIST_). You can also easily choose
  85. a different algorithm (including the popular bcrypt_ algorithm). For more
  86. details, see :ref:`auth_password_storage`.
  87. .. _sha1: http://en.wikipedia.org/wiki/SHA1
  88. .. _pbkdf2: http://en.wikipedia.org/wiki/PBKDF2
  89. .. _nist: http://csrc.nist.gov/publications/nistpubs/800-132/nist-sp800-132.pdf
  90. .. _bcrypt: http://en.wikipedia.org/wiki/Bcrypt
  91. HTML5 Doctype
  92. ~~~~~~~~~~~~~
  93. We've switched the admin and other bundled templates to use the HTML5
  94. doctype. While Django will be careful to maintain compatibility with older
  95. browsers, this change means that you can use any HTML5 features you need in
  96. admin pages without having to lose HTML validity or override the provided
  97. templates to change the doctype.
  98. List filters in admin interface
  99. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100. Prior to Django 1.4, the :mod:`~django.contrib.admin` app allowed you to specify
  101. change list filters by specifying a field lookup, but didn't allow you to create
  102. custom filters. This has been rectified with a simple API (previously used
  103. internally and known as "FilterSpec"). For more details, see the documentation
  104. for :attr:`~django.contrib.admin.ModelAdmin.list_filter`.
  105. Multiple sort in admin interface
  106. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  107. The admin change list now supports sorting on multiple columns. It respects all
  108. elements of the :attr:`~django.contrib.admin.ModelAdmin.ordering` attribute, and
  109. sorting on multiple columns by clicking on headers is designed to mimic the
  110. behavior of desktop GUIs. The
  111. :meth:`~django.contrib.admin.ModelAdmin.get_ordering` method for specifying the
  112. ordering dynamically (e.g. depending on the request) has also been added.
  113. New ``ModelAdmin`` methods
  114. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  115. A new :meth:`~django.contrib.admin.ModelAdmin.save_related` method was added to
  116. :mod:`~django.contrib.admin.ModelAdmin` to ease customization of how
  117. related objects are saved in the admin.
  118. Two other new methods,
  119. :meth:`~django.contrib.admin.ModelAdmin.get_list_display` and
  120. :meth:`~django.contrib.admin.ModelAdmin.get_list_display_links`
  121. were added to :class:`~django.contrib.admin.ModelAdmin` to enable the dynamic
  122. customization of fields and links displayed on the admin change list.
  123. Admin inlines respect user permissions
  124. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  125. Admin inlines will now only allow those actions for which the user has
  126. permission. For ``ManyToMany`` relationships with an auto-created intermediate
  127. model (which does not have its own permissions), the change permission for the
  128. related model determines if the user has the permission to add, change or
  129. delete relationships.
  130. Tools for cryptographic signing
  131. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  132. Django 1.4 adds both a low-level API for signing values and a high-level API
  133. for setting and reading signed cookies, one of the most common uses of
  134. signing in Web applications.
  135. See the :doc:`cryptographic signing </topics/signing>` docs for more
  136. information.
  137. Cookie-based session backend
  138. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139. Django 1.4 introduces a new cookie-based backend for the session framework
  140. which uses the tools for :doc:`cryptographic signing </topics/signing>` to
  141. store the session data in the client's browser.
  142. See the :ref:`cookie-based session backend <cookie-session-backend>` docs for
  143. more information.
  144. New form wizard
  145. ~~~~~~~~~~~~~~~
  146. The previous ``FormWizard`` from the formtools contrib app has been
  147. replaced with a new implementation based on the class-based views
  148. introduced in Django 1.3. It features a pluggable storage API and doesn't
  149. require the wizard to pass around hidden fields for every previous step.
  150. Django 1.4 ships with a session-based storage backend and a cookie-based
  151. storage backend. The latter uses the tools for
  152. :doc:`cryptographic signing </topics/signing>` also introduced in
  153. Django 1.4 to store the wizard's state in the user's cookies.
  154. See the :doc:`form wizard </ref/contrib/formtools/form-wizard>` docs for
  155. more information.
  156. ``reverse_lazy``
  157. ~~~~~~~~~~~~~~~~
  158. A lazily evaluated version of :func:`django.core.urlresolvers.reverse` was
  159. added to allow using URL reversals before the project's URLConf gets loaded.
  160. Translating URL patterns
  161. ~~~~~~~~~~~~~~~~~~~~~~~~
  162. Django 1.4 gained the ability to look for a language prefix in the URL pattern
  163. when using the new :func:`~django.conf.urls.i18n.i18n_patterns` helper function.
  164. Additionally, it's now possible to define translatable URL patterns using
  165. :func:`~django.utils.translation.ugettext_lazy`. See
  166. :ref:`url-internationalization` for more information about the language prefix
  167. and how to internationalize URL patterns.
  168. Contextual translation support for ``{% trans %}`` and ``{% blocktrans %}``
  169. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  170. The :ref:`contextual translation<contextual-markers>` support introduced in
  171. Django 1.3 via the ``pgettext`` function has been extended to the
  172. :ttag:`trans` and :ttag:`blocktrans` template tags using the new ``context``
  173. keyword.
  174. Customizable ``SingleObjectMixin`` URLConf kwargs
  175. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  176. Two new attributes,
  177. :attr:`pk_url_kwarg<django.views.generic.detail.SingleObjectMixin.pk_url_kwarg>`
  178. and
  179. :attr:`slug_url_kwarg<django.views.generic.detail.SingleObjectMixin.slug_url_kwarg>`,
  180. have been added to :class:`~django.views.generic.detail.SingleObjectMixin` to
  181. enable the customization of URLConf keyword arguments used for single
  182. object generic views.
  183. Assignment template tags
  184. ~~~~~~~~~~~~~~~~~~~~~~~~
  185. A new :ref:`assignment_tag<howto-custom-template-tags-assignment-tags>` helper
  186. function was added to ``template.Library`` to ease the creation of template
  187. tags that store data in a specified context variable.
  188. ``*args`` and ``**kwargs`` support for template tag helper functions
  189. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  190. The :ref:`simple_tag<howto-custom-template-tags-simple-tags>`,
  191. :ref:`inclusion_tag <howto-custom-template-tags-inclusion-tags>` and
  192. newly introduced
  193. :ref:`assignment_tag<howto-custom-template-tags-assignment-tags>` template
  194. helper functions may now accept any number of positional or keyword arguments.
  195. For example:
  196. .. code-block:: python
  197. @register.simple_tag
  198. def my_tag(a, b, *args, **kwargs):
  199. warning = kwargs['warning']
  200. profile = kwargs['profile']
  201. ...
  202. return ...
  203. Then in the template any number of arguments may be passed to the template tag.
  204. For example:
  205. .. code-block:: html+django
  206. {% my_tag 123 "abcd" book.title warning=message|lower profile=user.profile %}
  207. No wrapping of exceptions in ``TEMPLATE_DEBUG`` mode
  208. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  209. In previous versions of Django, whenever the :setting:`TEMPLATE_DEBUG` setting
  210. was ``True``, any exception raised during template rendering (even exceptions
  211. unrelated to template syntax) were wrapped in ``TemplateSyntaxError`` and
  212. re-raised. This was done in order to provide detailed template source location
  213. information in the debug 500 page.
  214. In Django 1.4, exceptions are no longer wrapped. Instead, the original
  215. exception is annotated with the source information. This means that catching
  216. exceptions from template rendering is now consistent regardless of the value of
  217. :setting:`TEMPLATE_DEBUG`, and there's no need to catch and unwrap
  218. ``TemplateSyntaxError`` in order to catch other errors.
  219. ``truncatechars`` template filter
  220. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  221. Added a filter which truncates a string to be no longer than the specified
  222. number of characters. Truncated strings end with a translatable ellipsis
  223. sequence ("..."). See the documentation for :tfilter:`truncatechars` for
  224. more details.
  225. ``static`` template tag
  226. ~~~~~~~~~~~~~~~~~~~~~~~
  227. The :mod:`staticfiles<django.contrib.staticfiles>` contrib app has a new
  228. :ttag:`static<staticfiles-static>` template tag to refer to files saved with
  229. the :setting:`STATICFILES_STORAGE` storage backend. It uses the storage
  230. backend's ``url`` method and therefore supports advanced features such as
  231. :ref:`serving files from a cloud service<staticfiles-from-cdn>`.
  232. ``CachedStaticFilesStorage`` storage backend
  233. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  234. In addition to the `static template tag`_, the
  235. :mod:`staticfiles<django.contrib.staticfiles>` contrib app now has a
  236. :class:`~django.contrib.staticfiles.storage.CachedStaticFilesStorage` backend
  237. which caches the files it saves (when running the :djadmin:`collectstatic`
  238. management command) by appending the MD5 hash of the file's content to the
  239. filename. For example, the file ``css/styles.css`` would also be saved as
  240. ``css/styles.55e7cbb9ba48.css``
  241. See the :class:`~django.contrib.staticfiles.storage.CachedStaticFilesStorage`
  242. docs for more information.
  243. Simple clickjacking protection
  244. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  245. We've added a middleware to provide easy protection against `clickjacking
  246. <http://en.wikipedia.org/wiki/Clickjacking>`_ using the ``X-Frame-Options``
  247. header. It's not enabled by default for backwards compatibility reasons, but
  248. you'll almost certainly want to :doc:`enable it </ref/clickjacking/>` to help
  249. plug that security hole for browsers that support the header.
  250. CSRF improvements
  251. ~~~~~~~~~~~~~~~~~
  252. We've made various improvements to our CSRF features, including the
  253. :func:`~django.views.decorators.csrf.ensure_csrf_cookie` decorator which can
  254. help with AJAX heavy sites, protection for PUT and DELETE requests, and the
  255. :setting:`CSRF_COOKIE_SECURE` and :setting:`CSRF_COOKIE_PATH` settings which can
  256. improve the security and usefulness of the CSRF protection. See the :doc:`CSRF
  257. docs </ref/contrib/csrf>` for more information.
  258. Error report filtering
  259. ~~~~~~~~~~~~~~~~~~~~~~
  260. Two new function decorators, :func:`sensitive_variables` and
  261. :func:`sensitive_post_parameters`, were added to allow designating the
  262. local variables and POST parameters which may contain sensitive
  263. information and should be filtered out of error reports.
  264. All POST parameters are now systematically filtered out of error reports for
  265. certain views (``login``, ``password_reset_confirm``, ``password_change``, and
  266. ``add_view`` in :mod:`django.contrib.auth.views`, as well as
  267. ``user_change_password`` in the admin app) to prevent the leaking of sensitive
  268. information such as user passwords.
  269. You may override or customize the default filtering by writing a :ref:`custom
  270. filter<custom-error-reports>`. For more information see the docs on
  271. :ref:`Filtering error reports<filtering-error-reports>`.
  272. Extended IPv6 support
  273. ~~~~~~~~~~~~~~~~~~~~~
  274. The previously added support for IPv6 addresses when using the runserver
  275. management command in Django 1.3 has now been further extended by adding
  276. a :class:`~django.db.models.GenericIPAddressField` model field,
  277. a :class:`~django.forms.GenericIPAddressField` form field and
  278. the validators :data:`~django.core.validators.validate_ipv46_address` and
  279. :data:`~django.core.validators.validate_ipv6_address`
  280. Updated default project layout and ``manage.py``
  281. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  282. Django 1.4 ships with an updated default project layout and ``manage.py`` file
  283. for the :djadmin:`startproject` management command. These fix some issues with
  284. the previous ``manage.py`` handling of Python import paths that caused double
  285. imports, trouble moving from development to deployment, and other
  286. difficult-to-debug path issues.
  287. The previous ``manage.py`` called functions that are now deprecated, and thus
  288. projects upgrading to Django 1.4 should update their ``manage.py``. (The
  289. old-style ``manage.py`` will continue to work as before until Django 1.6; in
  290. 1.5 it will raise ``DeprecationWarning``).
  291. The new recommended ``manage.py`` file should look like this::
  292. #!/usr/bin/env python
  293. import os, sys
  294. if __name__ == "__main__":
  295. os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
  296. from django.core.management import execute_from_command_line
  297. execute_from_command_line(sys.argv)
  298. ``{{ project_name }}`` should be replaced with the Python package name of the
  299. actual project.
  300. If settings, URLconfs, and apps within the project are imported or referenced
  301. using the project name prefix (e.g. ``myproject.settings``, ``ROOT_URLCONF =
  302. "myproject.urls"``, etc), the new ``manage.py`` will need to be moved one
  303. directory up, so it is outside the project package rather than adjacent to
  304. ``settings.py`` and ``urls.py``.
  305. For instance, with the following layout::
  306. manage.py
  307. mysite/
  308. __init__.py
  309. settings.py
  310. urls.py
  311. myapp/
  312. __init__.py
  313. models.py
  314. You could import ``mysite.settings``, ``mysite.urls``, and ``mysite.myapp``,
  315. but not ``settings``, ``urls``, or ``myapp`` as top-level modules.
  316. Anything imported as a top-level module can be placed adjacent to the new
  317. ``manage.py``. For instance, to decouple "myapp" from the project module and
  318. import it as just ``myapp``, place it outside the ``mysite/`` directory::
  319. manage.py
  320. myapp/
  321. __init__.py
  322. models.py
  323. mysite/
  324. __init__.py
  325. settings.py
  326. urls.py
  327. If the same code is imported inconsistently (some places with the project
  328. prefix, some places without it), the imports will need to be cleaned up when
  329. switching to the new ``manage.py``.
  330. Improved WSGI support
  331. ~~~~~~~~~~~~~~~~~~~~~
  332. The :djadmin:`startproject` management command now adds a :file:`wsgi.py`
  333. module to the initial project layout, containing a simple WSGI application that
  334. can be used for :doc:`deploying with WSGI app
  335. servers</howto/deployment/wsgi/index>`.
  336. The :djadmin:`built-in development server<runserver>` now supports using an
  337. externally-defined WSGI callable, so as to make it possible to run runserver
  338. with the same WSGI configuration that is used for deployment. A new
  339. :setting:`WSGI_APPLICATION` setting is available to configure which WSGI
  340. callable :djadmin:`runserver` uses.
  341. (The :djadmin:`runfcgi` management command also internally wraps the WSGI
  342. callable configured via :setting:`WSGI_APPLICATION`.)
  343. Custom project and app templates
  344. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  345. The :djadmin:`startapp` and :djadmin:`startproject` management commands
  346. got a ``--template`` option for specifying a path or URL to a custom app or
  347. project template.
  348. For example, Django will use the ``/path/to/my_project_template`` directory
  349. when running the following command::
  350. django-admin.py startproject --template=/path/to/my_project_template myproject
  351. You can also now provide a destination directory as the second
  352. argument to both :djadmin:`startapp` and :djadmin:`startproject`::
  353. django-admin.py startapp myapp /path/to/new/app
  354. django-admin.py startproject myproject /path/to/new/project
  355. For more information, see the :djadmin:`startapp` and :djadmin:`startproject`
  356. documentation.
  357. Support for time zones
  358. ~~~~~~~~~~~~~~~~~~~~~~
  359. Django 1.4 adds :ref:`support for time zones <time-zones>`. When it's enabled,
  360. Django stores date and time information in UTC in the database, uses time
  361. zone-aware datetime objects internally, and translates them to the end user's
  362. time zone in templates and forms.
  363. Reasons for using this feature include:
  364. - Customizing date and time display for users around the world.
  365. - Storing datetimes in UTC for database portability and interoperability.
  366. (This argument doesn't apply to PostgreSQL, because it already stores
  367. timestamps with time zone information in Django 1.3.)
  368. - Avoiding data corruption problems around DST transitions.
  369. Time zone support is enabled by default in new projects created with
  370. :djadmin:`startproject`. If you want to use this feature in an existing
  371. project, there is a :ref:`migration guide <time-zones-migration-guide>`.
  372. Minor features
  373. ~~~~~~~~~~~~~~
  374. Django 1.4 also includes several smaller improvements worth noting:
  375. * A more usable stacktrace in the technical 500 page: frames in the
  376. stack trace which reference Django's code are dimmed out, while
  377. frames in user code are slightly emphasized. This change makes it
  378. easier to scan a stacktrace for issues in user code.
  379. * :doc:`Tablespace support </topics/db/tablespaces>` in PostgreSQL.
  380. * Customizable names for :meth:`~django.template.Library.simple_tag`.
  381. * In the documentation, a helpful :doc:`security overview </topics/security>`
  382. page.
  383. * The ``django.contrib.auth.models.check_password`` function has been moved
  384. to the ``django.contrib.auth.utils`` module. Importing it from the old
  385. location will still work, but you should update your imports.
  386. * The :djadmin:`collectstatic` management command gained a ``--clear`` option
  387. to delete all files at the destination before copying or linking the static
  388. files.
  389. * It is now possible to load fixtures containing forward references when using
  390. MySQL with the InnoDB database engine.
  391. * A new 403 response handler has been added as
  392. ``'django.views.defaults.permission_denied'``. You can set your own handler by
  393. setting the value of :data:`django.conf.urls.handler403`. See the
  394. documentation about :ref:`the 403 (HTTP Forbidden) view<http_forbidden_view>`
  395. for more information.
  396. * The :ttag:`trans` template tag now takes an optional ``as`` argument to
  397. be able to retrieve a translation string without displaying it but setting
  398. a template context variable instead.
  399. * The :ttag:`if` template tag now supports ``{% elif %}`` clauses.
  400. * A new plain text version of the HTTP 500 status code internal error page
  401. served when :setting:`DEBUG` is ``True`` is now sent to the client when
  402. Django detects that the request has originated in JavaScript code
  403. (:meth:`~django.http.HttpRequest.is_ajax` is used for this).
  404. Similarly to its HTML counterpart, it contains a collection of different
  405. pieces of information about the state of the web application.
  406. This should make it easier to read when debugging interaction with
  407. client-side Javascript code.
  408. * Added the :djadminopt:`--no-location` option to the :djadmin:`makemessages`
  409. command.
  410. * Changed the ``locmem`` cache backend to use
  411. ``pickle.HIGHEST_PROTOCOL`` for better compatibility with the other
  412. cache backends.
  413. * Added support in the ORM for generating ``SELECT`` queries containing
  414. ``DISTINCT ON``.
  415. The ``distinct()`` ``QuerySet`` method now accepts an optional list of model
  416. field names. If specified, then the ``DISTINCT`` statement is limited to these
  417. fields. This is only supported in PostgreSQL.
  418. For more details, see the documentation for
  419. :meth:`~django.db.models.query.QuerySet.distinct`.
  420. Backwards incompatible changes in 1.4
  421. =====================================
  422. django.contrib.admin
  423. ~~~~~~~~~~~~~~~~~~~~
  424. The included administration app ``django.contrib.admin`` has for a long time
  425. shipped with a default set of static files such as JavaScript, images and
  426. stylesheets. Django 1.3 added a new contrib app ``django.contrib.staticfiles``
  427. to handle such files in a generic way and defined conventions for static
  428. files included in apps.
  429. Starting in Django 1.4 the admin's static files also follow this
  430. convention to make it easier to deploy the included files. In previous
  431. versions of Django, it was also common to define an ``ADMIN_MEDIA_PREFIX``
  432. setting to point to the URL where the admin's static files are served by a
  433. web server. This setting has now been deprecated and replaced by the more
  434. general setting :setting:`STATIC_URL`. Django will now expect to find the
  435. admin static files under the URL ``<STATIC_URL>/admin/``.
  436. If you've previously used a URL path for ``ADMIN_MEDIA_PREFIX`` (e.g.
  437. ``/media/``) simply make sure :setting:`STATIC_URL` and :setting:`STATIC_ROOT`
  438. are configured and your web server serves the files correctly. The development
  439. server continues to serve the admin files just like before. Don't hesitate to
  440. consult the :doc:`static files howto </howto/static-files/index>` for further
  441. details.
  442. In case your ``ADMIN_MEDIA_PREFIX`` is set to an specific domain (e.g.
  443. ``http://media.example.com/admin/``) make sure to also set your
  444. :setting:`STATIC_URL` setting to the correct URL, for example
  445. ``http://media.example.com/``.
  446. .. warning::
  447. If you're implicitly relying on the path of the admin static files on
  448. your server's file system when you deploy your site, you have to update
  449. that path. The files were moved from :file:`django/contrib/admin/media/`
  450. to :file:`django/contrib/admin/static/admin/`.
  451. Supported browsers for the admin
  452. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  453. Django hasn't had a clear policy on which browsers are supported for using the
  454. admin app. Django's new policy formalizes existing practices: `YUI's A-grade`_
  455. browsers should provide a fully-functional admin experience, with the notable
  456. exception of IE6, which is no longer supported.
  457. Released over ten years ago, IE6 imposes many limitations on modern web
  458. development. The practical implications of this policy are that contributors
  459. are free to improve the admin without consideration for these limitations.
  460. This new policy **has no impact** on development outside of the admin. Users of
  461. Django are free to develop webapps compatible with any range of browsers.
  462. .. _YUI's A-grade: http://yuilibrary.com/yui/docs/tutorials/gbs/
  463. Removed admin icons
  464. ~~~~~~~~~~~~~~~~~~~
  465. As part of an effort to improve the performance and usability of the admin's
  466. changelist sorting interface and of the admin's :attr:`horizontal
  467. <django.contrib.admin.ModelAdmin.filter_horizontal>` and :attr:`vertical
  468. <django.contrib.admin.ModelAdmin.filter_vertical>` "filter" widgets, some icon
  469. files were removed and grouped into two sprite files.
  470. Specifically: ``selector-add.gif``, ``selector-addall.gif``,
  471. ``selector-remove.gif``, ``selector-removeall.gif``,
  472. ``selector_stacked-add.gif`` and ``selector_stacked-remove.gif`` were
  473. combined into ``selector-icons.gif``; and ``arrow-up.gif`` and
  474. ``arrow-down.gif`` were combined into ``sorting-icons.gif``.
  475. If you used those icons to customize the admin then you will want to replace
  476. them with your own icons or retrieve them from a previous release.
  477. CSS class names in admin forms
  478. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  479. To avoid conflicts with other common CSS class names (e.g. "button"), a prefix
  480. "field-" has been added to all CSS class names automatically generated from the
  481. form field names in the main admin forms, stacked inline forms and tabular
  482. inline cells. You will need to take that prefix into account in your custom
  483. style sheets or javascript files if you previously used plain field names as
  484. selectors for custom styles or javascript transformations.
  485. Compatibility with old signed data
  486. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  487. Django 1.3 changed the cryptographic signing mechanisms used in a number of
  488. places in Django. While Django 1.3 kept fallbacks that would accept hashes
  489. produced by the previous methods, these fallbacks are removed in Django 1.4.
  490. So, if you upgrade to Django 1.4 directly from 1.2 or earlier, you may
  491. lose/invalidate certain pieces of data that have been cryptographically signed
  492. using an old method. To avoid this, use Django 1.3 first for a period of time
  493. to allow the signed data to expire naturally. The affected parts are detailed
  494. below, with 1) the consequences of ignoring this advice and 2) the amount of
  495. time you need to run Django 1.3 for the data to expire or become irrelevant.
  496. * ``contrib.sessions`` data integrity check
  497. * consequences: the user will be logged out, and session data will be lost.
  498. * time period: defined by :setting:`SESSION_COOKIE_AGE`.
  499. * ``contrib.auth`` password reset hash
  500. * consequences: password reset links from before the upgrade will not work.
  501. * time period: defined by :setting:`PASSWORD_RESET_TIMEOUT_DAYS`.
  502. Form-related hashes — these are much shorter lifetime, and are relevant only for
  503. the short window where a user might fill in a form generated by the pre-upgrade
  504. Django instance, and try to submit it to the upgraded Django instance:
  505. * ``contrib.comments`` form security hash
  506. * consequences: the user will see a validation error "Security hash failed".
  507. * time period: the amount of time you expect users to take filling out comment
  508. forms.
  509. * ``FormWizard`` security hash
  510. * consequences: the user will see an error about the form having expired,
  511. and will be sent back to the first page of the wizard, losing the data
  512. they have entered so far.
  513. * time period: the amount of time you expect users to take filling out the
  514. affected forms.
  515. * CSRF check
  516. * Note: This is actually a Django 1.1 fallback, not Django 1.2,
  517. and applies only if you are upgrading from 1.1.
  518. * consequences: the user will see a 403 error with any CSRF protected POST
  519. form.
  520. * time period: the amount of time you expect user to take filling out
  521. such forms.
  522. django.contrib.flatpages
  523. ~~~~~~~~~~~~~~~~~~~~~~~~
  524. Starting in the 1.4 release the
  525. :class:`~django.contrib.flatpages.middleware.FlatpageFallbackMiddleware` only
  526. adds a trailing slash and redirects if the resulting URL refers to an existing
  527. flatpage. For example, requesting ``/notaflatpageoravalidurl`` in a previous
  528. version would redirect to ``/notaflatpageoravalidurl/``, which would
  529. subsequently raise a 404. Requesting ``/notaflatpageoravalidurl`` now will
  530. immediately raise a 404. Additionally redirects returned by flatpages are now
  531. permanent (301 status code) to match the behavior of the
  532. :class:`~django.middleware.common.CommonMiddleware`.
  533. Serialization of :class:`~datetime.datetime` and :class:`~datetime.time`
  534. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  535. As a consequence of time zone support, and according to the ECMA-262
  536. specification, some changes were made to the JSON serializer:
  537. - It includes the time zone for aware datetime objects. It raises an exception
  538. for aware time objects.
  539. - It includes milliseconds for datetime and time objects. There is still
  540. some precision loss, because Python stores microseconds (6 digits) and JSON
  541. only supports milliseconds (3 digits). However, it's better than discarding
  542. microseconds entirely.
  543. The XML serializer was also changed to use the ISO8601 format for datetimes.
  544. The letter ``T`` is used to separate the date part from the time part, instead
  545. of a space. Time zone information is included in the ``[+-]HH:MM`` format.
  546. The serializers will dump datetimes in fixtures with these new formats. They
  547. can still load fixtures that use the old format.
  548. ``supports_timezone`` changed to ``False`` for SQLite
  549. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  550. The database feature ``supports_timezone`` used to be ``True`` for SQLite.
  551. Indeed, if you saved an aware datetime object, SQLite stored a string that
  552. included an UTC offset. However, this offset was ignored when loading the value
  553. back from the database, which could corrupt the data.
  554. In the context of time zone support, this flag was changed to ``False``, and
  555. datetimes are now stored without time zone information in SQLite. When
  556. :setting:`USE_TZ` is ``False``, if you attempt to save an aware datetime
  557. object, Django raises an exception.
  558. Database connection's thread-locality
  559. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  560. ``DatabaseWrapper`` objects (i.e. the connection objects referenced by
  561. ``django.db.connection`` and ``django.db.connections["some_alias"]``) used to
  562. be thread-local. They are now global objects in order to be potentially shared
  563. between multiple threads. While the individual connection objects are now
  564. global, the ``django.db.connections`` dictionary referencing those objects is
  565. still thread-local. Therefore if you just use the ORM or
  566. ``DatabaseWrapper.cursor()`` then the behavior is still the same as before.
  567. Note, however, that ``django.db.connection`` does not directly reference the
  568. default ``DatabaseWrapper`` object anymore and is now a proxy to access that
  569. object's attributes. If you need to access the actual ``DatabaseWrapper``
  570. object, use ``django.db.connections[DEFAULT_DB_ALIAS]`` instead.
  571. As part of this change, all underlying SQLite connections are now enabled for
  572. potential thread-sharing (by passing the ``check_same_thread=False`` attribute
  573. to pysqlite). ``DatabaseWrapper`` however preserves the previous behavior by
  574. disabling thread-sharing by default, so this does not affect any existing
  575. code that purely relies on the ORM or on ``DatabaseWrapper.cursor()``.
  576. Finally, while it is now possible to pass connections between threads, Django
  577. does not make any effort to synchronize access to the underlying backend.
  578. Concurrency behavior is defined by the underlying backend implementation.
  579. Check their documentation for details.
  580. `COMMENTS_BANNED_USERS_GROUP` setting
  581. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  582. Django's :doc:`comments app </ref/contrib/comments/index>` has historically
  583. supported excluding the comments of a special user group, but we've never
  584. documented the feature properly and didn't enforce the exclusion in other parts
  585. of the app such as the template tags. To fix this problem, we removed the code
  586. from the feed class.
  587. If you rely on the feature and want to restore the old behavior, simply use
  588. a custom comment model manager to exclude the user group, like this::
  589. from django.conf import settings
  590. from django.contrib.comments.managers import CommentManager
  591. class BanningCommentManager(CommentManager):
  592. def get_query_set(self):
  593. qs = super(BanningCommentManager, self).get_query_set()
  594. if getattr(settings, 'COMMENTS_BANNED_USERS_GROUP', None):
  595. where = ['user_id NOT IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)']
  596. params = [settings.COMMENTS_BANNED_USERS_GROUP]
  597. qs = qs.extra(where=where, params=params)
  598. return qs
  599. Save this model manager in your custom comment app (e.g. in
  600. ``my_comments_app/managers.py``) and add it your
  601. :ref:`custom comment app model <custom-comment-app-api>`::
  602. from django.db import models
  603. from django.contrib.comments.models import Comment
  604. from my_comments_app.managers import BanningCommentManager
  605. class CommentWithTitle(Comment):
  606. title = models.CharField(max_length=300)
  607. objects = BanningCommentManager()
  608. For more details, see the documentation about
  609. :doc:`customizing the comments framework </ref/contrib/comments/custom>`.
  610. `IGNORABLE_404_STARTS` and `IGNORABLE_404_ENDS` settings
  611. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  612. Until Django 1.3, it was possible to exclude some URLs from Django's
  613. :doc:`404 error reporting</howto/error-reporting>` by adding prefixes to
  614. ``IGNORABLE_404_STARTS`` and suffixes to ``IGNORABLE_404_ENDS``.
  615. In Django 1.4, these two settings are superseded by
  616. :setting:`IGNORABLE_404_URLS`, which is a list of compiled regular
  617. expressions. Django won't send an email for 404 errors on URLs that match any
  618. of them.
  619. Furthermore, the previous settings had some rather arbitrary default values::
  620. IGNORABLE_404_STARTS = ('/cgi-bin/', '/_vti_bin', '/_vti_inf')
  621. IGNORABLE_404_ENDS = ('mail.pl', 'mailform.pl', 'mail.cgi', 'mailform.cgi',
  622. 'favicon.ico', '.php')
  623. It's not Django's role to decide if your website has a legacy ``/cgi-bin/``
  624. section or a ``favicon.ico``. As a consequence, the default values of
  625. :setting:`IGNORABLE_404_URLS`, ``IGNORABLE_404_STARTS``, and
  626. ``IGNORABLE_404_ENDS`` are all now empty.
  627. If you have customized ``IGNORABLE_404_STARTS`` or ``IGNORABLE_404_ENDS``, or
  628. if you want to keep the old default value, you should add the following lines
  629. in your settings file::
  630. import re
  631. IGNORABLE_404_URLS = (
  632. # for each <prefix> in IGNORABLE_404_STARTS
  633. re.compile(r'^<prefix>'),
  634. # for each <suffix> in IGNORABLE_404_ENDS
  635. re.compile(r'<suffix>$'),
  636. )
  637. Don't forget to escape characters that have a special meaning in a regular
  638. expression.
  639. CSRF protection extended to PUT and DELETE
  640. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  641. Previously, Django's :doc:`CSRF protection </ref/contrib/csrf/>` provided
  642. protection against only POST requests. Since use of PUT and DELETE methods in
  643. AJAX applications is becoming more common, we now protect all methods not
  644. defined as safe by :rfc:`2616` i.e. we exempt GET, HEAD, OPTIONS and TRACE, and
  645. enforce protection on everything else.
  646. If you are using PUT or DELETE methods in AJAX applications, please see the
  647. :ref:`instructions about using AJAX and CSRF <csrf-ajax>`.
  648. ``django.core.template_loaders``
  649. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  650. This was an alias to ``django.template.loader`` since 2005, it has been removed
  651. without emitting a warning due to the length of the deprecation. If your code
  652. still referenced this please use ``django.template.loader`` instead.
  653. ``django.db.models.fields.URLField.verify_exists``
  654. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  655. This functionality has been removed due to intractable performance and
  656. security issues. Any existing usage of ``verify_exists`` should be
  657. removed.
  658. ``django.core.files.storage.Storage.open``
  659. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  660. The ``open`` method of the base Storage class took an obscure parameter
  661. ``mixin`` which allowed you to dynamically change the base classes of the
  662. returned file object. This has been removed. In the rare case you relied on the
  663. ``mixin`` parameter, you can easily achieve the same by overriding the ``open``
  664. method, e.g.::
  665. from django.core.files import File
  666. from django.core.files.storage import FileSystemStorage
  667. class Spam(File):
  668. """
  669. Spam, spam, spam, spam and spam.
  670. """
  671. def ham(self):
  672. return 'eggs'
  673. class SpamStorage(FileSystemStorage):
  674. """
  675. A custom file storage backend.
  676. """
  677. def open(self, name, mode='rb'):
  678. return Spam(open(self.path(name), mode))
  679. YAML deserializer now uses ``yaml.safe_load``
  680. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  681. ``yaml.load`` is able to construct any Python object, which may trigger
  682. arbitrary code execution if you process a YAML document that comes from an
  683. untrusted source. This feature isn't necessary for Django's YAML deserializer,
  684. whose primary use is to load fixtures consisting of simple objects. Even though
  685. fixtures are trusted data, for additional security, the YAML deserializer now
  686. uses ``yaml.safe_load``.
  687. Features deprecated in 1.4
  688. ==========================
  689. Old styles of calling ``cache_page`` decorator
  690. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  691. Some legacy ways of calling :func:`~django.views.decorators.cache.cache_page`
  692. have been deprecated, please see the docs for the correct way to use this
  693. decorator.
  694. Support for PostgreSQL versions older than 8.2
  695. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  696. Django 1.3 dropped support for PostgreSQL versions older than 8.0 and the
  697. relevant documents suggested to use a recent version because of performance
  698. reasons but more importantly because end of the upstream support periods for
  699. releases 8.0 and 8.1 was near (November 2010).
  700. Django 1.4 takes that policy further and sets 8.2 as the minimum PostgreSQL
  701. version it officially supports.
  702. Request exceptions are now always logged
  703. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  704. When :doc:`logging support </topics/logging/>` was added to Django in 1.3, the
  705. admin error email support was moved into the
  706. :class:`django.utils.log.AdminEmailHandler`, attached to the
  707. ``'django.request'`` logger. In order to maintain the established behavior of
  708. error emails, the ``'django.request'`` logger was called only when
  709. :setting:`DEBUG` was ``False``.
  710. To increase the flexibility of error logging for requests, the
  711. ``'django.request'`` logger is now called regardless of the value of
  712. :setting:`DEBUG`, and the default settings file for new projects now includes a
  713. separate filter attached to :class:`django.utils.log.AdminEmailHandler` to
  714. prevent admin error emails in ``DEBUG`` mode::
  715. 'filters': {
  716. 'require_debug_false': {
  717. '()': 'django.utils.log.RequireDebugFalse'
  718. }
  719. },
  720. 'handlers': {
  721. 'mail_admins': {
  722. 'level': 'ERROR',
  723. 'filters': ['require_debug_false'],
  724. 'class': 'django.utils.log.AdminEmailHandler'
  725. }
  726. },
  727. If your project was created prior to this change, your :setting:`LOGGING`
  728. setting will not include this new filter. In order to maintain
  729. backwards-compatibility, Django will detect that your ``'mail_admins'`` handler
  730. configuration includes no ``'filters'`` section, and will automatically add
  731. this filter for you and issue a pending-deprecation warning. This will become a
  732. deprecation warning in Django 1.5, and in Django 1.6 the
  733. backwards-compatibility shim will be removed entirely.
  734. The existence of any ``'filters'`` key under the ``'mail_admins'`` handler will
  735. disable this backward-compatibility shim and deprecation warning.
  736. ``django.conf.urls.defaults``
  737. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  738. Until Django 1.3 the functions :func:`~django.conf.urls.include`,
  739. :func:`~django.conf.urls.patterns` and :func:`~django.conf.urls.url` plus
  740. :data:`~django.conf.urls.handler404`, :data:`~django.conf.urls.handler500`
  741. were located in a ``django.conf.urls.defaults`` module.
  742. Starting with Django 1.4 they are now available in :mod:`django.conf.urls`.
  743. ``django.contrib.databrowse``
  744. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  745. Databrowse has not seen active development for some time, and this does not show
  746. any sign of changing. There had been a suggestion for a `GSOC project`_ to
  747. integrate the functionality of databrowse into the admin, but no progress was
  748. made. While Databrowse has been deprecated, an enhancement of
  749. ``django.contrib.admin`` providing a similar feature set is still possible.
  750. .. _GSOC project: https://code.djangoproject.com/wiki/SummerOfCode2011#Integratedatabrowseintotheadmin
  751. The code that powers Databrowse is licensed under the same terms as Django
  752. itself, and so is available to be adopted by an individual or group as
  753. a third-party project.
  754. ``django.core.management.setup_environ``
  755. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  756. This function temporarily modified ``sys.path`` in order to make the parent
  757. "project" directory importable under the old flat :djadmin:`startproject`
  758. layout. This function is now deprecated, as its path workarounds are no longer
  759. needed with the new ``manage.py`` and default project layout.
  760. This function was never documented or part of the public API, but was widely
  761. recommended for use in setting up a "Django environment" for a user script.
  762. These uses should be replaced by setting the ``DJANGO_SETTINGS_MODULE``
  763. environment variable or using :func:`django.conf.settings.configure`.
  764. ``django.core.management.execute_manager``
  765. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  766. This function was previously used by ``manage.py`` to execute a management
  767. command. It is identical to
  768. ``django.core.management.execute_from_command_line``, except that it first
  769. calls ``setup_environ``, which is now deprecated. As such, ``execute_manager``
  770. is also deprecated; ``execute_from_command_line`` can be used instead. Neither
  771. of these functions is documented as part of the public API, but a deprecation
  772. path is needed due to use in existing ``manage.py`` files.
  773. ``is_safe`` and ``needs_autoescape`` attributes of template filters
  774. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  775. Two flags, ``is_safe`` and ``needs_autoescape``, define how each template filter
  776. interacts with Django's auto-escaping behavior. They used to be attributes of
  777. the filter function::
  778. @register.filter
  779. def noop(value):
  780. return value
  781. noop.is_safe = True
  782. However, this technique caused some problems in combination with decorators,
  783. especially :func:`@stringfilter <django.template.defaultfilters.stringfilter>`.
  784. Now, the flags are keyword arguments of :meth:`@register.filter
  785. <django.template.Library.filter>`::
  786. @register.filter(is_safe=True)
  787. def noop(value):
  788. return value
  789. See :ref:`filters and auto-escaping <filters-auto-escaping>` for more information.
  790. Session cookies now have the ``httponly`` flag by default
  791. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  792. Session cookies now include the ``httponly`` attribute by default to
  793. help reduce the impact of potential XSS attacks. For strict backwards
  794. compatibility, use ``SESSION_COOKIE_HTTPONLY = False`` in your settings file.
  795. Wildcard expansion of application names in `INSTALLED_APPS`
  796. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  797. Until Django 1.3, :setting:`INSTALLED_APPS` accepted wildcards in application
  798. names, like ``django.contrib.*``. The expansion was performed by a
  799. filesystem-based implementation of ``from <package> import *``. Unfortunately,
  800. `this can't be done reliably`_.
  801. This behavior was never documented. Since it is un-pythonic and not obviously
  802. useful, it was removed in Django 1.4. If you relied on it, you must edit your
  803. settings file to list all your applications explicitly.
  804. .. _this can't be done reliably: http://docs.python.org/tutorial/modules.html#importing-from-a-package
  805. ``HttpRequest.raw_post_data`` renamed to ``HttpRequest.body``
  806. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  807. This attribute was confusingly named ``HttpRequest.raw_post_data``, but it
  808. actually provided the body of the HTTP request. It's been renamed to
  809. ``HttpRequest.body``, and ``HttpRequest.raw_post_data`` has been deprecated.
  810. The Django 1.4 roadmap
  811. ======================
  812. Before the final Django 1.4 release, several other preview/development releases
  813. will be made available. The current schedule consists of at least the following:
  814. * Week of **January 30, 2012**: First Django 1.4 beta release; final
  815. feature freeze for Django 1.4.
  816. * Week of **February 27, 2012**: First Django 1.4 release
  817. candidate; string freeze for translations.
  818. * Week of **March 5, 2012**: Django 1.4 final release.
  819. If necessary, additional alpha, beta or release-candidate packages
  820. will be issued prior to the final 1.4 release. Django 1.4 will be
  821. released approximately one week after the final release candidate.
  822. What you can do to help
  823. =======================
  824. In order to provide a high-quality 1.4 release, we need your help. Although this
  825. alpha release is, again, *not* intended for production use, you can help the
  826. Django team by trying out the alpha codebase in a safe test environment and
  827. reporting any bugs or issues you encounter. The Django ticket tracker is the
  828. central place to search for open issues:
  829. * https://code.djangoproject.com/timeline
  830. Please open new tickets if no existing ticket corresponds to a problem you're
  831. running into.
  832. Additionally, discussion of Django development, including progress toward the
  833. 1.3 release, takes place daily on the django-developers mailing list:
  834. * http://groups.google.com/group/django-developers
  835. ... and in the ``#django-dev`` IRC channel on ``irc.freenode.net``. If you're
  836. interested in helping out with Django's development, feel free to join the
  837. discussions there.
  838. Django's online documentation also includes pointers on how to contribute to
  839. Django:
  840. * :doc:`How to contribute to Django </internals/contributing/index>`
  841. Contributions on any level -- developing code, writing documentation or simply
  842. triaging tickets and helping to test proposed bugfixes -- are always welcome and
  843. appreciated.
  844. Several development sprints will also be taking place before the 1.4
  845. release; these will typically be announced in advance on the
  846. django-developers mailing list, and anyone who wants to help is
  847. welcome to join in.