1.4-beta-1.txt 50 KB

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