1.2.5.txt 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. ==========================
  2. Django 1.2.5 release notes
  3. ==========================
  4. Welcome to Django 1.2.5!
  5. This is the fifth "bugfix" release in the Django 1.2 series,
  6. improving the stability and performance of the Django 1.2 codebase.
  7. With four exceptions, Django 1.2.5 maintains backwards compatibility
  8. with Django 1.2.4. It also contains a number of fixes and other
  9. improvements. Django 1.2.5 is a recommended upgrade for any
  10. development or deployment currently using or targeting Django 1.2.
  11. For full details on the new features, backwards incompatibilities, and
  12. deprecated features in the 1.2 branch, see the :doc:`/releases/1.2`.
  13. Backwards incompatible changes
  14. ==============================
  15. CSRF exception for AJAX requests
  16. --------------------------------
  17. Django includes a CSRF-protection mechanism, which makes use of a
  18. token inserted into outgoing forms. Middleware then checks for the
  19. token's presence on form submission, and validates it.
  20. Prior to Django 1.2.5, our CSRF protection made an exception for AJAX
  21. requests, on the following basis:
  22. * Many AJAX toolkits add an X-Requested-With header when using
  23. XMLHttpRequest.
  24. * Browsers have strict same-origin policies regarding
  25. XMLHttpRequest.
  26. * In the context of a browser, the only way that a custom header
  27. of this nature can be added is with XMLHttpRequest.
  28. Therefore, for ease of use, we did not apply CSRF checks to requests
  29. that appeared to be AJAX on the basis of the X-Requested-With header.
  30. The Ruby on Rails web framework had a similar exemption.
  31. Recently, engineers at Google made members of the Ruby on Rails
  32. development team aware of a combination of browser plugins and
  33. redirects which can allow an attacker to provide custom HTTP headers
  34. on a request to any website. This can allow a forged request to appear
  35. to be an AJAX request, thereby defeating CSRF protection which trusts
  36. the same-origin nature of AJAX requests.
  37. Michael Koziarski of the Rails team brought this to our attention, and
  38. we were able to produce a proof-of-concept demonstrating the same
  39. vulnerability in Django's CSRF handling.
  40. To remedy this, Django will now apply full CSRF validation to all
  41. requests, regardless of apparent AJAX origin. This is technically
  42. backwards-incompatible, but the security risks have been judged to
  43. outweigh the compatibility concerns in this case.
  44. Additionally, Django will now accept the CSRF token in the custom HTTP
  45. header X-CSRFTOKEN, as well as in the form submission itself, for ease
  46. of use with popular JavaScript toolkits which allow insertion of
  47. custom headers into all AJAX requests.
  48. Please see the :ref:`CSRF docs for example jQuery code <csrf-ajax>`
  49. that demonstrates this technique, ensuring that you are looking at the
  50. documentation for your version of Django, as the exact code necessary
  51. is different for some older versions of Django.
  52. FileField no longer deletes files
  53. ---------------------------------
  54. In earlier Django versions, when a model instance containing a
  55. :class:`~django.db.models.FileField` was deleted,
  56. :class:`~django.db.models.FileField` took it upon itself to also delete the
  57. file from the backend storage. This opened the door to several potentially
  58. serious data-loss scenarios, including rolled-back transactions and fields on
  59. different models referencing the same file. In Django 1.2.5,
  60. :class:`~django.db.models.FileField` will never delete files from the backend
  61. storage. If you need cleanup of orphaned files, you'll need to handle it
  62. yourself (for instance, with a custom management command that can be run
  63. manually or scheduled to run periodically via e.g. cron).
  64. Use of custom SQL to load initial data in tests
  65. -----------------------------------------------
  66. Django provides a custom SQL hooks as a way to inject hand-crafted SQL
  67. into the database synchronization process. One of the possible uses
  68. for this custom SQL is to insert data into your database. If your
  69. custom SQL contains ``INSERT`` statements, those insertions will be
  70. performed every time your database is synchronized. This includes the
  71. synchronization of any test databases that are created when you run a
  72. test suite.
  73. However, in the process of testing the Django 1.3, it was discovered
  74. that this feature has never completely worked as advertised. When
  75. using database backends that don't support transactions, or when using
  76. a TransactionTestCase, data that has been inserted using custom SQL
  77. will not be visible during the testing process.
  78. Unfortunately, there was no way to rectify this problem without
  79. introducing a backwards incompatibility. Rather than leave
  80. SQL-inserted initial data in an uncertain state, Django now enforces
  81. the policy that data inserted by custom SQL will *not* be visible
  82. during testing.
  83. This change only affects the testing process. You can still use custom
  84. SQL to load data into your production database as part of the ``syncdb``
  85. process. If you require data to exist during test conditions, you
  86. should either insert it using :ref:`test fixtures
  87. <topics-testing-fixtures>`, or using the ``setUp()`` method of your
  88. test case.
  89. ModelAdmin.lookup_allowed signature changed
  90. -------------------------------------------
  91. Django 1.2.4 introduced a method ``lookup_allowed`` on ``ModelAdmin``, to cope
  92. with a security issue (changeset `[15033]
  93. <https://code.djangoproject.com/changeset/15033>`_). Although this method was
  94. never documented, it seems some people have overridden ``lookup_allowed``,
  95. especially to cope with regressions introduced by that changeset. While the
  96. method is still undocumented and not marked as stable, it may be helpful to know
  97. that the signature of this function has changed.