1.4-alpha-1.txt 47 KB

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