1.5.txt 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. ============================================
  2. Django 1.5 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. These release notes cover the `new features`_, as well
  5. as some `backwards incompatible changes`_ you'll want to be aware of
  6. when upgrading from Django 1.4 or older versions. We've also dropped some
  7. features, which are detailed in :doc:`our deprecation plan
  8. </internals/deprecation>`, and we've `begun the deprecation process for some
  9. features`_.
  10. .. _`new features`: `What's new in Django 1.5`_
  11. .. _`backwards incompatible changes`: `Backwards incompatible changes in 1.5`_
  12. .. _`begun the deprecation process for some features`: `Features deprecated in 1.5`_
  13. Python compatibility
  14. ====================
  15. Django 1.5 has dropped support for Python 2.5. Python 2.6 is now the minimum
  16. required Python version. Django is tested and supported on Python 2.6 and
  17. 2.7.
  18. This change should affect only a small number of Django users, as most
  19. operating-system vendors today are shipping Python 2.6 or newer as their default
  20. version. If you're still using Python 2.5, however, you'll need to stick to
  21. Django 1.4 until you can upgrade your Python version. Per :doc:`our support policy
  22. </internals/release-process>`, Django 1.4 will continue to receive security
  23. support until the release of Django 1.6.
  24. Django 1.5 does not run on Jython, because Jython doesn't currently offer any
  25. version compatible with Python 2.6.
  26. What's new in Django 1.5
  27. ========================
  28. Support for saving a subset of model's fields
  29. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  30. The method :meth:`Model.save() <django.db.models.Model.save()>` has a new
  31. keyword argument ``update_fields``. By using this argument it is possible to
  32. save only a select list of model's fields. This can be useful for performance
  33. reasons or when trying to avoid overwriting concurrent changes.
  34. See the :meth:`Model.save() <django.db.models.Model.save()>` documentation for
  35. more details.
  36. Caching of related model instances
  37. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. When traversing relations, the ORM will avoid re-fetching objects that were
  39. previously loaded. For example, with the tutorial's models::
  40. >>> first_poll = Poll.objects.all()[0]
  41. >>> first_choice = first_poll.choice_set.all()[0]
  42. >>> first_choice.poll is first_poll
  43. True
  44. In Django 1.5, the third line no longer triggers a new SQL query to fetch
  45. ``first_choice.poll``; it was set by the second line.
  46. For one-to-one relationships, both sides can be cached. For many-to-one
  47. relationships, only the single side of the relationship can be cached. This
  48. is particularly helpful in combination with ``prefetch_related``.
  49. Minor features
  50. ~~~~~~~~~~~~~~
  51. Django 1.5 also includes several smaller improvements worth noting:
  52. * The template engine now interprets ``True``, ``False`` and ``None`` as the
  53. corresponding Python objects.
  54. * :mod:`django.utils.timezone` provides a helper for converting aware
  55. datetimes between time zones. See :func:`~django.utils.timezone.localtime`.
  56. * The generic views support OPTIONS requests.
  57. * Management commands do not raise ``SystemExit`` any more when called by code
  58. from :ref:`call_command <call-command>`. Any exception raised by the command
  59. (mostly :ref:`CommandError <ref-command-exceptions>`) is propagated.
  60. * The dumpdata management command outputs one row at a time, preventing
  61. out-of-memory errors when dumping large datasets.
  62. * In the localflavor for Canada, "pq" was added to the acceptable codes for
  63. Quebec. It's an old abbreviation.
  64. Backwards incompatible changes in 1.5
  65. =====================================
  66. .. warning::
  67. In addition to the changes outlined in this section, be sure to review the
  68. :doc:`deprecation plan </internals/deprecation>` for any features that
  69. have been removed. If you haven't updated your code within the
  70. deprecation timeline for a given feature, its removal may appear as a
  71. backwards incompatible change.
  72. Context in year archive class-based views
  73. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74. For consistency with the other date-based generic views,
  75. :class:`~django.views.generic.dates.YearArchiveView` now passes ``year`` in
  76. the context as a :class:`datetime.date` rather than a string. If you are
  77. using ``{{ year }}`` in your templates, you must replace it with ``{{
  78. year|date:"Y" }}``.
  79. ``next_year`` and ``previous_year`` were also added in the context. They are
  80. calculated according to ``allow_empty`` and ``allow_future``.
  81. OPTIONS, PUT and DELETE requests in the test client
  82. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  83. Unlike GET and POST, these HTTP methods aren't implemented by web browsers.
  84. Rather, they're used in APIs, which transfer data in various formats such as
  85. JSON or XML. Since such requests may contain arbitrary data, Django doesn't
  86. attempt to decode their body.
  87. However, the test client used to build a query string for OPTIONS and DELETE
  88. requests like for GET, and a request body for PUT requests like for POST. This
  89. encoding was arbitrary and inconsistent with Django's behavior when it
  90. receives the requests, so it was removed in Django 1.5.
  91. If you were using the ``data`` parameter in an OPTIONS or a DELETE request,
  92. you must convert it to a query string and append it to the ``path`` parameter.
  93. If you were using the ``data`` parameter in a PUT request without a
  94. ``content_type``, you must encode your data before passing it to the test
  95. client and set the ``content_type`` argument.
  96. Features deprecated in 1.5
  97. ==========================
  98. ``django.utils.simplejson``
  99. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100. Since Django 1.5 drops support for Python 2.5, we can now rely on the
  101. :mod:`json` module being in Python's standard library -- so we've removed
  102. our own copy of ``simplejson``. You can safely change any use of
  103. :mod:`django.utils.simplejson` to :mod:`json`.
  104. ``itercompat.product``
  105. ~~~~~~~~~~~~~~~~~~~~~~
  106. The :func:`~django.utils.itercompat.product` function has been deprecated. Use
  107. the built-in :func:`itertools.product` instead.