1.5-alpha-1.txt 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. ==============================
  2. Django 1.5 alpha release notes
  3. ==============================
  4. October 25, 2012.
  5. Welcome to Django 1.5 alpha!
  6. This is the first in a series of preview/development releases leading up to the
  7. eventual release of Django 1.5, scheduled for December 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.5 release.
  11. As such, this release is *not* intended for production use, and any such use
  12. is discouraged.
  13. In particular, we need the community's help to test Django 1.5's new `Python 3
  14. support`_ -- not just to report bugs on Python 3, but also regressions on Python
  15. 2. While Django is very conservative with regards to backwards compatibility,
  16. mistakes are always possible, and it's likely that the Python 3 refactoring work
  17. introduced some regressions.
  18. Django 1.5 alpha includes various `new features`_ and some minor `backwards
  19. incompatible changes`_. There are also some features that have been dropped,
  20. which are detailed in :doc:`our deprecation plan </internals/deprecation>`,
  21. and we've `begun the deprecation process for some features`_.
  22. .. _`new features`: `What's new in Django 1.5`_
  23. .. _`backwards incompatible changes`: `Backwards incompatible changes in 1.5`_
  24. .. _`begun the deprecation process for some features`: `Features deprecated in 1.5`_
  25. Overview
  26. ========
  27. The biggest new feature in Django 1.5 is the `configurable User model`_. Before
  28. Django 1.5, applications that wanted to use Django's auth framework
  29. (:mod:`django.contrib.auth`) were forced to use Django's definition of a "user".
  30. In Django 1.5, you can now swap out the ``User`` model for one that you write
  31. yourself. This could be a simple extension to the existing ``User`` model -- for
  32. example, you could add a Twitter or Facebook ID field -- or you could completely
  33. replace the ``User`` with one totally customized for your site.
  34. Django 1.5 is also the first release with `Python 3 support`_! We're labeling
  35. this support "experimental" because we don't yet consider it production-ready,
  36. but everything's in place for you to start porting your apps to Python 3.
  37. Our next release, Django 1.6, will support Python 3 without reservations.
  38. Other notable new features in Django 1.5 include:
  39. * `Support for saving a subset of model's fields`_ -
  40. :meth:`Model.save() <django.db.models.Model.save()>` now accepts an
  41. ``update_fields`` argument, letting you specify which fields are
  42. written back to the database when you call ``save()``. This can help
  43. in high-concurrency operations, and can improve performance.
  44. * Better `support for streaming responses <#explicit-streaming-responses>`_ via
  45. the new :class:`~django.http.StreamingHttpResponse` response class.
  46. * `GeoDjango`_ now supports PostGIS 2.0.
  47. * ... and more; `see below <#what-s-new-in-django-1-5>`_.
  48. Wherever possible we try to introduce new features in a backwards-compatible
  49. manner per :doc:`our API stability policy </misc/api-stability>` policy.
  50. However, as with previous releases, Django 1.5 ships with some minor
  51. `backwards incompatible changes`_; people upgrading from previous versions
  52. of Django should read that list carefully.
  53. One deprecated feature worth noting is the shift to "new-style" :ttag:`url` tag.
  54. Prior to Django 1.3, syntax like ``{% url myview %}`` was interpreted
  55. incorrectly (Django considered ``"myview"`` to be a literal name of a view, not
  56. a template variable named ``myview``). Django 1.3 and above introduced the
  57. ``{% load url from future %}`` syntax to bring in the corrected behavior where
  58. ``myview`` was seen as a variable.
  59. The upshot of this is that if you are not using ``{% load url from future %}``
  60. in your templates, you'll need to change tags like ``{% url myview %}`` to
  61. ``{% url "myview" %}``. If you *were* using ``{% load url from future %}`` you
  62. can simply remove that line under Django 1.5
  63. Python compatibility
  64. ====================
  65. Django 1.5 requires Python 2.6.5 or above, though we **highly recommended**
  66. Python 2.7.3 or above. Support for Python 2.5 and below has been dropped.
  67. This change should affect only a small number of Django users, as most
  68. operating-system vendors today are shipping Python 2.6 or newer as their default
  69. version. If you're still using Python 2.5, however, you'll need to stick to
  70. Django 1.4 until you can upgrade your Python version. Per :doc:`our support
  71. policy </internals/release-process>`, Django 1.4 will continue to receive
  72. security support until the release of Django 1.6.
  73. Django 1.5 does not run on a Jython final release, because Jython's latest
  74. release doesn't currently support Python 2.6. However, Jython currently does
  75. offer an alpha release featuring 2.7 support, and Django 1.5 supports that alpha
  76. release.
  77. Python 3 support
  78. ~~~~~~~~~~~~~~~~
  79. Django 1.5 introduces support for Python 3 - specifically, Python
  80. 3.2 and above. This comes in the form of a **single** codebase; you don't
  81. need to install a different version of Django on Python 3. This means that
  82. you can write application targeted for just Python 2, just Python 3, or single
  83. applications that support both platforms.
  84. However, we're labeling this support "experimental" for now: although it's
  85. received extensive testing via our automated test suite, it's received very
  86. little real-world testing. We've done our best to eliminate bugs, but we can't
  87. be sure we covered all possible uses of Django. Further, Django's more than a
  88. web framework; it's an ecosystem of pluggable components. At this point, very
  89. few third-party applications have been ported to Python 3, so it's unlikely
  90. that a real-world application will have all its dependencies satisfied under
  91. Python 3.
  92. Thus, we're recommending that Django 1.5 not be used in production under Python
  93. 3. Instead, use this opportunity to begin :doc:`porting applications to Python 3
  94. </topics/python3>`. If you're an author of a pluggable component, we encourage you
  95. to start porting now.
  96. We plan to offer first-class, production-ready support for Python 3 in our next
  97. release, Django 1.6.
  98. What's new in Django 1.5
  99. ========================
  100. Configurable User model
  101. ~~~~~~~~~~~~~~~~~~~~~~~
  102. In Django 1.5, you can now use your own model as the store for user-related
  103. data. If your project needs a username with more than 30 characters, or if
  104. you want to store usernames in a format other than first name/last name, or
  105. you want to put custom profile information onto your User object, you can
  106. now do so.
  107. If you have a third-party reusable application that references the User model,
  108. you may need to make some changes to the way you reference User instances. You
  109. should also document any specific features of the User model that your
  110. application relies upon.
  111. See the :ref:`documentation on custom User models <auth-custom-user>` for
  112. more details.
  113. Support for saving a subset of model's fields
  114. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  115. The method :meth:`Model.save() <django.db.models.Model.save()>` has a new
  116. keyword argument ``update_fields``. By using this argument it is possible to
  117. save only a select list of model's fields. This can be useful for performance
  118. reasons or when trying to avoid overwriting concurrent changes.
  119. Deferred instances (those loaded by .only() or .defer()) will automatically
  120. save just the loaded fields. If any field is set manually after load, that
  121. field will also get updated on save.
  122. See the :meth:`Model.save() <django.db.models.Model.save()>` documentation for
  123. more details.
  124. Caching of related model instances
  125. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  126. When traversing relations, the ORM will avoid re-fetching objects that were
  127. previously loaded. For example, with the tutorial's models::
  128. >>> first_poll = Poll.objects.all()[0]
  129. >>> first_choice = first_poll.choice_set.all()[0]
  130. >>> first_choice.poll is first_poll
  131. True
  132. In Django 1.5, the third line no longer triggers a new SQL query to fetch
  133. ``first_choice.poll``; it was set by the second line.
  134. For one-to-one relationships, both sides can be cached. For many-to-one
  135. relationships, only the single side of the relationship can be cached. This
  136. is particularly helpful in combination with ``prefetch_related``.
  137. Explicit support for streaming responses
  138. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139. Before Django 1.5, it was possible to create a streaming response by passing
  140. an iterator to :class:`~django.http.HttpResponse`. But this was unreliable:
  141. any middleware that accessed the :attr:`~django.http.HttpResponse.content`
  142. attribute would consume the iterator prematurely.
  143. You can now explicitly generate a streaming response with the new
  144. :class:`~django.http.StreamingHttpResponse` class. This class exposes a
  145. :class:`~django.http.StreamingHttpResponse.streaming_content` attribute which
  146. is an iterator.
  147. Since :class:`~django.http.StreamingHttpResponse` does not have a ``content``
  148. attribute, middleware that needs access to the response content must test for
  149. streaming responses and behave accordingly. See :ref:`response-middleware` for
  150. more information.
  151. ``{% verbatim %}`` template tag
  152. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  153. To make it easier to deal with javascript templates which collide with Django's
  154. syntax, you can now use the :ttag:`verbatim` block tag to avoid parsing the
  155. tag's content.
  156. Retrieval of ``ContentType`` instances associated with proxy models
  157. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  158. The methods :meth:`ContentTypeManager.get_for_model() <django.contrib.contenttypes.models.ContentTypeManager.get_for_model()>`
  159. and :meth:`ContentTypeManager.get_for_models() <django.contrib.contenttypes.models.ContentTypeManager.get_for_models()>`
  160. have a new keyword argument – respectively ``for_concrete_model`` and ``for_concrete_models``.
  161. By passing ``False`` using this argument it is now possible to retrieve the
  162. :class:`ContentType <django.contrib.contenttypes.models.ContentType>`
  163. associated with proxy models.
  164. New ``view`` variable in class-based views context
  165. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  166. In all :doc:`generic class-based views </topics/class-based-views/index>`
  167. (or any class-based view inheriting from ``ContextMixin``), the context dictionary
  168. contains a ``view`` variable that points to the ``View`` instance.
  169. GeoDjango
  170. ~~~~~~~~~
  171. * :class:`~django.contrib.gis.geos.LineString` and
  172. :class:`~django.contrib.gis.geos.MultiLineString` GEOS objects now support the
  173. :meth:`~django.contrib.gis.geos.GEOSGeometry.interpolate()` and
  174. :meth:`~django.contrib.gis.geos.GEOSGeometry.project()` methods
  175. (so-called linear referencing).
  176. * The ``wkb`` and ``hex`` properties of
  177. :class:`~django.contrib.gis.geos.GEOSGeometry` objects preserve the Z
  178. dimension.
  179. * Support for PostGIS 2.0 has been added and support for GDAL < 1.5 has been
  180. dropped.
  181. Minor features
  182. ~~~~~~~~~~~~~~
  183. Django 1.5 also includes several smaller improvements worth noting:
  184. * The template engine now interprets ``True``, ``False`` and ``None`` as the
  185. corresponding Python objects.
  186. * :mod:`django.utils.timezone` provides a helper for converting aware
  187. datetimes between time zones. See :func:`~django.utils.timezone.localtime`.
  188. * The generic views support OPTIONS requests.
  189. * Management commands do not raise ``SystemExit`` any more when called by code
  190. from :ref:`call_command <call-command>`. Any exception raised by the command
  191. (mostly :ref:`CommandError <ref-command-exceptions>`) is propagated.
  192. * The dumpdata management command outputs one row at a time, preventing
  193. out-of-memory errors when dumping large datasets.
  194. * In the localflavor for Canada, "pq" was added to the acceptable codes for
  195. Quebec. It's an old abbreviation.
  196. * The :ref:`receiver <connecting-receiver-functions>` decorator is now able to
  197. connect to more than one signal by supplying a list of signals.
  198. * In the admin, you can now filter users by groups which they are members of.
  199. * :meth:`QuerySet.bulk_create()
  200. <django.db.models.query.QuerySet.bulk_create>` now has a batch_size
  201. argument. By default the batch_size is unlimited except for SQLite where
  202. single batch is limited so that 999 parameters per query isn't exceeded.
  203. * The :setting:`LOGIN_URL` and :setting:`LOGIN_REDIRECT_URL` settings now also
  204. accept view function names and
  205. :ref:`named URL patterns <naming-url-patterns>`. This allows you to reduce
  206. configuration duplication. More information can be found in the
  207. :func:`~django.contrib.auth.decorators.login_required` documentation.
  208. * Django now provides a mod_wsgi :doc:`auth handler
  209. </howto/deployment/wsgi/apache-auth>`.
  210. * The :meth:`QuerySet.delete() <django.db.models.query.QuerySet.delete>`
  211. and :meth:`Model.delete() <django.db.models.Model.delete()>` can now take
  212. fast-path in some cases. The fast-path allows for less queries and less
  213. objects fetched into memory. See :meth:`QuerySet.delete()
  214. <django.db.models.query.QuerySet.delete>` for details.
  215. * An instance of :class:`~django.core.urlresolvers.ResolverMatch` is stored on
  216. the request as ``resolver_match``.
  217. * By default, all logging messages reaching the ``django`` logger when
  218. :setting:`DEBUG` is ``True`` are sent to the console (unless you redefine the
  219. logger in your :setting:`LOGGING` setting).
  220. * When using :class:`~django.template.RequestContext`, it is now possible to
  221. look up permissions by using ``{% if 'someapp.someperm' in perms %}``
  222. in templates.
  223. * It's not required any more to have ``404.html`` and ``500.html`` templates in
  224. the root templates directory. Django will output some basic error messages for
  225. both situations when those templates are not found. Of course, it's still
  226. recommended as good practice to provide those templates in order to present
  227. pretty error pages to the user.
  228. * :mod:`django.contrib.auth` provides a new signal that is emitted
  229. whenever a user fails to login successfully. See
  230. :data:`~django.contrib.auth.signals.user_login_failed`
  231. * The loaddata management command now supports an
  232. :djadminopt:`--ignorenonexistent` option to ignore data for fields that no
  233. longer exist.
  234. * :meth:`~django.test.SimpleTestCase.assertXMLEqual` and
  235. :meth:`~django.test.SimpleTestCase.assertXMLNotEqual` new assertions allow
  236. you to test equality for XML content at a semantic level, without caring for
  237. syntax differences (spaces, attribute order, etc.).
  238. Backwards incompatible changes in 1.5
  239. =====================================
  240. .. warning::
  241. In addition to the changes outlined in this section, be sure to review the
  242. :doc:`deprecation plan </internals/deprecation>` for any features that
  243. have been removed. If you haven't updated your code within the
  244. deprecation timeline for a given feature, its removal may appear as a
  245. backwards incompatible change.
  246. Context in year archive class-based views
  247. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  248. For consistency with the other date-based generic views,
  249. :class:`~django.views.generic.dates.YearArchiveView` now passes ``year`` in
  250. the context as a :class:`datetime.date` rather than a string. If you are
  251. using ``{{ year }}`` in your templates, you must replace it with ``{{
  252. year|date:"Y" }}``.
  253. ``next_year`` and ``previous_year`` were also added in the context. They are
  254. calculated according to ``allow_empty`` and ``allow_future``.
  255. Context in year and month archive class-based views
  256. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  257. :class:`~django.views.generic.dates.YearArchiveView` and
  258. :class:`~django.views.generic.dates.MonthArchiveView` were documented to
  259. provide a ``date_list`` sorted in ascending order in the context, like their
  260. function-based predecessors, but it actually was in descending order. In 1.5,
  261. the documented order was restored. You may want to add (or remove) the
  262. ``reversed`` keyword when you're iterating on ``date_list`` in a template::
  263. {% for date in date_list reversed %}
  264. :class:`~django.views.generic.dates.ArchiveIndexView` still provides a
  265. ``date_list`` in descending order.
  266. Context in TemplateView
  267. ~~~~~~~~~~~~~~~~~~~~~~~
  268. For consistency with the design of the other generic views,
  269. :class:`~django.views.generic.base.TemplateView` no longer passes a ``params``
  270. dictionary into the context, instead passing the variables from the URLconf
  271. directly into the context.
  272. Non-form data in HTTP requests
  273. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  274. :attr:`request.POST <django.http.HttpRequest.POST>` will no longer include data
  275. posted via HTTP requests with non form-specific content-types in the header.
  276. In prior versions, data posted with content-types other than
  277. ``multipart/form-data`` or ``application/x-www-form-urlencoded`` would still
  278. end up represented in the :attr:`request.POST <django.http.HttpRequest.POST>`
  279. attribute. Developers wishing to access the raw POST data for these cases,
  280. should use the :attr:`request.body <django.http.HttpRequest.body>` attribute
  281. instead.
  282. OPTIONS, PUT and DELETE requests in the test client
  283. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  284. Unlike GET and POST, these HTTP methods aren't implemented by web browsers.
  285. Rather, they're used in APIs, which transfer data in various formats such as
  286. JSON or XML. Since such requests may contain arbitrary data, Django doesn't
  287. attempt to decode their body.
  288. However, the test client used to build a query string for OPTIONS and DELETE
  289. requests like for GET, and a request body for PUT requests like for POST. This
  290. encoding was arbitrary and inconsistent with Django's behavior when it
  291. receives the requests, so it was removed in Django 1.5.
  292. If you were using the ``data`` parameter in an OPTIONS or a DELETE request,
  293. you must convert it to a query string and append it to the ``path`` parameter.
  294. If you were using the ``data`` parameter in a PUT request without a
  295. ``content_type``, you must encode your data before passing it to the test
  296. client and set the ``content_type`` argument.
  297. System version of :mod:`simplejson` no longer used
  298. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  299. As explained below, Django 1.5 deprecates
  300. ``django.utils.simplejson`` in favor of Python 2.6's built-in :mod:`json`
  301. module. In theory, this change is harmless. Unfortunately, because of
  302. incompatibilities between versions of :mod:`simplejson`, it may trigger errors
  303. in some circumstances.
  304. JSON-related features in Django 1.4 always used ``django.utils.simplejson``.
  305. This module was actually:
  306. - A system version of :mod:`simplejson`, if one was available (ie. ``import
  307. simplejson`` works), if it was more recent than Django's built-in copy or it
  308. had the C speedups, or
  309. - The :mod:`json` module from the standard library, if it was available (ie.
  310. Python 2.6 or greater), or
  311. - A built-in copy of version 2.0.7 of :mod:`simplejson`.
  312. In Django 1.5, those features use Python's :mod:`json` module, which is based
  313. on version 2.0.9 of :mod:`simplejson`.
  314. There are no known incompatibilities between Django's copy of version 2.0.7 and
  315. Python's copy of version 2.0.9. However, there are some incompatibilities
  316. between other versions of :mod:`simplejson`:
  317. - While the :mod:`simplejson` API is documented as always returning unicode
  318. strings, the optional C implementation can return a byte string. This was
  319. fixed in Python 2.7.
  320. - :class:`simplejson.JSONEncoder` gained a ``namedtuple_as_object`` keyword
  321. argument in version 2.2.
  322. More information on these incompatibilities is available in `ticket #18023`_.
  323. The net result is that, if you have installed :mod:`simplejson` and your code
  324. uses Django's serialization internals directly -- for instance
  325. ``django.core.serializers.json.DjangoJSONEncoder``, the switch from
  326. :mod:`simplejson` to :mod:`json` could break your code. (In general, changes to
  327. internals aren't documented; we're making an exception here.)
  328. At this point, the maintainers of Django believe that using :mod:`json` from
  329. the standard library offers the strongest guarantee of backwards-compatibility.
  330. They recommend to use it from now on.
  331. .. _ticket #18023: https://code.djangoproject.com/ticket/18023#comment:10
  332. String types of hasher method parameters
  333. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  334. If you have written a :ref:`custom password hasher <auth_password_storage>`,
  335. your ``encode()``, ``verify()`` or ``safe_summary()`` methods should accept
  336. Unicode parameters (``password``, ``salt`` or ``encoded``). If any of the
  337. hashing methods need byte strings, you can use the
  338. :func:`~django.utils.encoding.force_bytes` utility to encode the strings.
  339. Validation of previous_page_number and next_page_number
  340. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  341. When using :doc:`object pagination </topics/pagination>`,
  342. the ``previous_page_number()`` and ``next_page_number()`` methods of the
  343. :class:`~django.core.paginator.Page` object did not check if the returned
  344. number was inside the existing page range.
  345. It does check it now and raises an :exc:`~django.core.paginator.InvalidPage`
  346. exception when the number is either too low or too high.
  347. Behavior of autocommit database option on PostgreSQL changed
  348. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  349. PostgreSQL's autocommit option didn't work as advertised previously. It did
  350. work for single transaction block, but after the first block was left the
  351. autocommit behavior was never restored. This bug is now fixed in 1.5. While
  352. this is only a bug fix, it is worth checking your applications behavior if
  353. you are using PostgreSQL together with the autocommit option.
  354. Session not saved on 500 responses
  355. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  356. Django's session middleware will skip saving the session data if the
  357. response's status code is 500.
  358. Email checks on failed admin login
  359. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  360. Prior to Django 1.5, if you attempted to log into the admin interface and
  361. mistakenly used your email address instead of your username, the admin
  362. interface would provide a warning advising that your email address was
  363. not your username. In Django 1.5, the introduction of
  364. :ref:`custom User models <auth-custom-user>` has required the removal of this
  365. warning. This doesn't change the login behavior of the admin site; it only
  366. affects the warning message that is displayed under one particular mode of
  367. login failure.
  368. Changes in tests execution
  369. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  370. Some changes have been introduced in the execution of tests that might be
  371. backward-incompatible for some testing setups:
  372. Database flushing in ``django.test.TransactionTestCase``
  373. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  374. Previously, the test database was truncated *before* each test run in a
  375. :class:`~django.test.TransactionTestCase`.
  376. In order to be able to run unit tests in any order and to make sure they are
  377. always isolated from each other, :class:`~django.test.TransactionTestCase` will
  378. now reset the database *after* each test run instead.
  379. No more implicit DB sequences reset
  380. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  381. :class:`~django.test.TransactionTestCase` tests used to reset primary key
  382. sequences automatically together with the database flushing actions described
  383. above.
  384. This has been changed so no sequences are implicitly reset. This can cause
  385. :class:`~django.test.TransactionTestCase` tests that depend on hard-coded
  386. primary key values to break.
  387. The new :attr:`~django.test.TransactionTestCase.reset_sequences` attribute can
  388. be used to force the old behavior for :class:`~django.test.TransactionTestCase`
  389. that might need it.
  390. Ordering of tests
  391. ^^^^^^^^^^^^^^^^^
  392. In order to make sure all ``TestCase`` code starts with a clean database,
  393. tests are now executed in the following order:
  394. * First, all unittests (including :class:`unittest.TestCase`,
  395. :class:`~django.test.SimpleTestCase`, :class:`~django.test.TestCase` and
  396. :class:`~django.test.TransactionTestCase`) are run with no particular ordering
  397. guaranteed nor enforced among them.
  398. * Then any other tests (e.g. doctests) that may alter the database without
  399. restoring it to its original state are run.
  400. This should not cause any problems unless you have existing doctests which
  401. assume a :class:`~django.test.TransactionTestCase` executed earlier left some
  402. database state behind or unit tests that rely on some form of state being
  403. preserved after the execution of other tests. Such tests are already very
  404. fragile, and must now be changed to be able to run independently.
  405. `cleaned_data` dictionary kept for invalid forms
  406. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  407. The :attr:`~django.forms.Form.cleaned_data` dictionary is now always present
  408. after form validation. When the form doesn't validate, it contains only the
  409. fields that passed validation. You should test the success of the validation
  410. with the :meth:`~django.forms.Form.is_valid()` method and not with the
  411. presence or absence of the :attr:`~django.forms.Form.cleaned_data` attribute
  412. on the form.
  413. Miscellaneous
  414. ~~~~~~~~~~~~~
  415. * :class:`django.forms.ModelMultipleChoiceField` now returns an empty
  416. ``QuerySet`` as the empty value instead of an empty list.
  417. * :func:`~django.utils.http.int_to_base36` properly raises a
  418. :exc:`~exceptions.TypeError` instead of :exc:`~exceptions.ValueError` for
  419. non-integer inputs.
  420. * The ``slugify`` template filter is now available as a standard python
  421. function at :func:`django.utils.text.slugify`. Similarly, ``remove_tags`` is
  422. available at :func:`django.utils.html.remove_tags`.
  423. * Uploaded files are no longer created as executable by default. If you need
  424. them to be executable change :setting:`FILE_UPLOAD_PERMISSIONS` to your
  425. needs. The new default value is ``0666`` (octal) and the current umask value
  426. is first masked out.
  427. * The :class:`F expressions <django.db.models.F>` supported bitwise operators
  428. by ``&`` and ``|``. These operators are now available using ``.bitand()`` and
  429. ``.bitor()`` instead. The removal of ``&`` and ``|`` was done to be
  430. consistent with :ref:`Q() expressions <complex-lookups-with-q>` and
  431. ``QuerySet`` combining where the operators are used as boolean AND and OR
  432. operators.
  433. * The :ttag:`csrf_token` template tag is no longer enclosed in a div. If you need
  434. HTML validation against pre-HTML5 Strict DTDs, you should add a div around it
  435. in your pages.
  436. Features deprecated in 1.5
  437. ==========================
  438. ``AUTH_PROFILE_MODULE`` setting
  439. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  440. With the introduction of :ref:`custom User models <auth-custom-user>`, there is
  441. no longer any need for a built-in mechanism to store user profile data.
  442. You can still define user profiles models that have a one-to-one relation with
  443. the User model - in fact, for many applications needing to associate data with
  444. a User account, this will be an appropriate design pattern to follow. However,
  445. the ``AUTH_PROFILE_MODULE`` setting, and the
  446. ``django.contrib.auth.models.User.get_profile()`` method for accessing
  447. the user profile model, should not be used any longer.
  448. Streaming behavior of :class:`~django.http.HttpResponse`
  449. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  450. Django 1.5 deprecates the ability to stream a response by passing an iterator
  451. to :class:`~django.http.HttpResponse`. If you rely on this behavior, switch to
  452. :class:`~django.http.StreamingHttpResponse`. See above for more details.
  453. In Django 1.7 and above, the iterator will be consumed immediately by
  454. :class:`~django.http.HttpResponse`.
  455. ``django.utils.simplejson``
  456. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  457. Since Django 1.5 drops support for Python 2.5, we can now rely on the
  458. :mod:`json` module being available in Python's standard library, so we've
  459. removed our own copy of :mod:`simplejson`. You should now import :mod:`json`
  460. instead of ``django.utils.simplejson``.
  461. Unfortunately, this change might have unwanted side-effects, because of
  462. incompatibilities between versions of :mod:`simplejson` -- see the backwards-
  463. incompatible changes section. If you rely on features added to :mod:`simplejson`
  464. after it became Python's :mod:`json`, you should import :mod:`simplejson`
  465. explicitly.
  466. ``django.utils.encoding.StrAndUnicode``
  467. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  468. The ``django.utils.encoding.StrAndUnicode`` mix-in has been deprecated.
  469. Define a ``__str__`` method and apply the
  470. :func:`~django.utils.encoding.python_2_unicode_compatible` decorator instead.
  471. ``django.utils.itercompat.product``
  472. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  473. The ``django.utils.itercompat.product`` function has been deprecated. Use
  474. the built-in :func:`itertools.product` instead.
  475. ``django.utils.markup``
  476. ~~~~~~~~~~~~~~~~~~~~~~~
  477. The markup contrib module has been deprecated and will follow an accelerated
  478. deprecation schedule. Direct use of python markup libraries or 3rd party tag
  479. libraries is preferred to Django maintaining this functionality in the
  480. framework.