1.9.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. ============================================
  2. Django 1.9 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. Welcome to Django 1.9!
  5. These release notes cover the `new features`_, as well as some `backwards
  6. incompatible changes`_ you'll want to be aware of when upgrading from Django
  7. 1.8 or older versions. We've :ref:`dropped some features
  8. <deprecation-removed-in-1.9>` that have reached the end of their deprecation
  9. cycle, and we've `begun the deprecation process for some features`_.
  10. .. _`new features`: `What's new in Django 1.9`_
  11. .. _`backwards incompatible changes`: `Backwards incompatible changes in 1.9`_
  12. .. _`dropped some features`: `Features removed in 1.9`_
  13. .. _`begun the deprecation process for some features`: `Features deprecated in 1.9`_
  14. Python compatibility
  15. ====================
  16. Like Django 1.8, Django 1.9 requires Python 2.7 or above, though we
  17. **highly recommend** the latest minor release. We've dropped support for
  18. Python 3.2 and added support for Python 3.5.
  19. What's new in Django 1.9
  20. ========================
  21. ...
  22. Minor features
  23. ~~~~~~~~~~~~~~
  24. :mod:`django.contrib.admin`
  25. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  26. * Admin views now have ``model_admin`` or ``admin_site`` attributes.
  27. * The URL of the admin change view has been changed (was at
  28. ``/admin/<app>/<model>/<pk>/`` by default and is now at
  29. ``/admin/<app>/<model>/<pk>/change/``). This should not affect your
  30. application unless you have hardcoded admin URLs. In that case, replace those
  31. links by :ref:`reversing admin URLs <admin-reverse-urls>` instead. Note that
  32. the old URL still redirects to the new one for backwards compatibility, but
  33. it may be removed in a future version.
  34. :mod:`django.contrib.auth`
  35. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  36. * The default iteration count for the PBKDF2 password hasher has been increased
  37. by 20%. This backwards compatible change will not affect users who have
  38. subclassed ``django.contrib.auth.hashers.PBKDF2PasswordHasher`` to change the
  39. default value.
  40. :mod:`django.contrib.gis`
  41. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  42. * ...
  43. :mod:`django.contrib.messages`
  44. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  45. * ...
  46. :mod:`django.contrib.redirects`
  47. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  48. * ...
  49. :mod:`django.contrib.sessions`
  50. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  51. * ...
  52. :mod:`django.contrib.sitemaps`
  53. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  54. * ...
  55. :mod:`django.contrib.sites`
  56. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  57. * ...
  58. :mod:`django.contrib.staticfiles`
  59. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  60. * ...
  61. :mod:`django.contrib.syndication`
  62. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  63. * ...
  64. Cache
  65. ^^^^^
  66. * ``django.core.cache.backends.base.BaseCache`` now has a ``get_or_set()``
  67. method.
  68. Email
  69. ^^^^^
  70. * ...
  71. File Storage
  72. ^^^^^^^^^^^^
  73. * ...
  74. File Uploads
  75. ^^^^^^^^^^^^
  76. * ...
  77. Forms
  78. ^^^^^
  79. * :class:`~django.forms.ModelForm` accepts the new ``Meta`` option
  80. ``field_classes`` to customize the type of the fields. See
  81. :ref:`modelforms-overriding-default-fields` for details.
  82. Generic Views
  83. ^^^^^^^^^^^^^
  84. * Class based views generated using ``as_view()`` now have ``view_class``
  85. and ``view_initkwargs`` attributes.
  86. Internationalization
  87. ^^^^^^^^^^^^^^^^^^^^
  88. * The :func:`django.views.i18n.set_language` view now properly redirects to
  89. :ref:`translated URLs <url-internationalization>`, when available.
  90. Management Commands
  91. ^^^^^^^^^^^^^^^^^^^
  92. * ...
  93. Models
  94. ^^^^^^
  95. * Added the :meth:`RelatedManager.set()
  96. <django.db.models.fields.related.RelatedManager.set()>` method to the related
  97. managers created by ``ForeignKey``, ``GenericForeignKey``, and
  98. ``ManyToManyField``.
  99. CSRF
  100. ^^^^
  101. * The request header's name used for CSRF authentication can be customized
  102. with :setting:`CSRF_HEADER_NAME`.
  103. Signals
  104. ^^^^^^^
  105. * ...
  106. Templates
  107. ^^^^^^^^^
  108. * Template tags created with the :meth:`~django.template.Library.simple_tag`
  109. helper can now store results in a template variable by using the ``as``
  110. argument.
  111. Requests and Responses
  112. ^^^^^^^^^^^^^^^^^^^^^^
  113. * Unless :attr:`HttpResponse.reason_phrase
  114. <django.http.HttpResponse.reason_phrase>` is explicitly set, it now is
  115. determined by the current value of :attr:`HttpResponse.status_code
  116. <django.http.HttpResponse.status_code>`. Modifying the value of
  117. ``status_code`` outside of the constructor will also modify the value of
  118. ``reason_phrase``.
  119. Tests
  120. ^^^^^
  121. * ...
  122. Validators
  123. ^^^^^^^^^^
  124. * ...
  125. Backwards incompatible changes in 1.9
  126. =====================================
  127. .. warning::
  128. In addition to the changes outlined in this section, be sure to review the
  129. :doc:`deprecation timeline </internals/deprecation>` for any features that
  130. have been removed. If you haven't updated your code within the
  131. deprecation timeline for a given feature, its removal may appear as a
  132. backwards incompatible change.
  133. Database backend API
  134. ~~~~~~~~~~~~~~~~~~~~
  135. * A couple of new tests rely on the ability of the backend to introspect column
  136. defaults (returning the result as ``Field.default``). You can set the
  137. ``can_introspect_default`` database feature to ``False`` if your backend
  138. doesn't implement this. You may want to review the implementation on the
  139. backends that Django includes for reference (:ticket:`24245`).
  140. Default settings that were tuples are now lists
  141. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  142. The default settings in ``django.conf.global_settings`` were a combination of
  143. lists and tuples. All settings that were formerly tuples are now lists.
  144. ``is_usable`` attribute on template loaders is removed
  145. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  146. Django template loaders previously required an ``is_usable`` attribute to be
  147. defined. If a loader was configured in the template settings and this attribute
  148. was ``False``, the loader would be silently ignored. In practice, this was only
  149. used by the egg loader to detect if setuptools was installed. The ``is_usable``
  150. attribute is now removed and the egg loader instead fails at runtime if
  151. setuptools is not installed.
  152. Related set direct assignment
  153. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  154. :ref:`Direct assignment <direct-assignment>`) used to perform a ``clear()``
  155. followed by a call to ``add()``. This caused needlessly large data changes
  156. and prevented using the :data:`~django.db.models.signals.m2m_changed` signal
  157. to track individual changes in many-to-many relations.
  158. Direct assignment now relies on the the new
  159. :meth:`django.db.models.fields.related.RelatedManager.set()` method on
  160. related managers which by default only processes changes between the
  161. existing related set and the one that's newly assigned. The previous behavior
  162. can be restored by replacing direct assignment by a call to ``set()`` with
  163. the keyword argument ``clear=True``.
  164. ``ModelForm``, and therefore ``ModelAdmin``, internally rely on direct
  165. assignment for many-to-many relations and as a consequence now use the new
  166. behavior.
  167. Filesystem-based template loaders catch more specific exceptions
  168. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  169. When using the :class:`filesystem.Loader <django.template.loaders.filesystem.Loader>`
  170. or :class:`app_directories.Loader <django.template.loaders.app_directories.Loader>`
  171. template loaders, earlier versions of Django raised a
  172. :exc:`~django.template.TemplateDoesNotExist` error if a template source existed
  173. but was unreadable. This could happen under many circumstances, such as if
  174. Django didn't have permissions to open the file, or if the template source was
  175. a directory. Now, Django only silences the exception if the template source
  176. does not exist. All other situations result in the original ``IOError`` being
  177. raised.
  178. Miscellaneous
  179. ~~~~~~~~~~~~~
  180. * CSS and images in ``contrib.admin`` to support Internet Explorer 6 & 7 have
  181. been removed as these browsers have reached end-of-life.
  182. * The text displayed for null columns in the admin changelist ``list_display``
  183. cells has changed from ``(None)`` (or its translated equivalent) to ``-``.
  184. * ``django.http.responses.REASON_PHRASES`` and
  185. ``django.core.handlers.wsgi.STATUS_CODE_TEXT`` have been removed. Use
  186. Python's stdlib instead: :data:`http.client.responses` for Python 3 and
  187. `httplib.responses`_ for Python 2.
  188. .. _`httplib.responses`: https://docs.python.org/2/library/httplib.html#httplib.responses
  189. * ``ValuesQuerySet`` and ``ValuesListQuerySet`` have been removed.
  190. * The ``admin/base.html`` template no longer sets
  191. ``window.__admin_media_prefix__``. Image references in JavaScript that used
  192. that value to construct absolute URLs have been moved to CSS for easier
  193. customization.
  194. .. _deprecated-features-1.9:
  195. Features deprecated in 1.9
  196. ==========================
  197. ``assignment_tag()``
  198. ~~~~~~~~~~~~~~~~~~~~
  199. Django 1.4 added the ``assignment_tag`` helper to ease the creation of
  200. template tags that store results in a template variable. The
  201. :meth:`~django.template.Library.simple_tag` helper has gained this same
  202. ability, making the ``assignment_tag`` obsolete. Tags that use
  203. ``assignment_tag`` should be updated to use ``simple_tag``.
  204. ``{% cycle %}`` syntax with comma-separated arguments
  205. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  206. The :ttag:`cycle` tag supports an inferior old syntax from previous Django
  207. versions:
  208. .. code-block:: html+django
  209. {% cycle row1,row2,row3 %}
  210. Its parsing caused bugs with the current syntax, so support for the old syntax
  211. will be removed in Django 2.0 following an accelerated deprecation.
  212. Miscellaneous
  213. ~~~~~~~~~~~~~
  214. * The ``weak`` argument to ``django.dispatch.signals.Signal.disconnect()`` has
  215. been deprecated as it has no effect.
  216. * The ``check_aggregate_support()`` method of
  217. ``django.db.backends.base.BaseDatabaseOperations`` has been deprecated and
  218. will be removed in Django 2.1. The more general ``check_expression_support()``
  219. should be used instead.
  220. * ``django.forms.extras`` is deprecated. You can find
  221. :class:`~django.forms.SelectDateWidget` in ``django.forms.widgets``
  222. (or simply ``django.forms``) instead.
  223. .. removed-features-1.9:
  224. Features removed in 1.9
  225. =======================
  226. These features have reached the end of their deprecation cycle and so have been
  227. removed in Django 1.9 (please see the :ref:`deprecation timeline
  228. <deprecation-removed-in-1.9>` for more details):
  229. * ``django.utils.dictconfig`` is removed.
  230. * ``django.utils.importlib`` is removed.
  231. * ``django.utils.tzinfo`` is removed.
  232. * ``django.utils.unittest`` is removed.
  233. * The ``syncdb`` command is removed.
  234. * ``django.db.models.signals.pre_syncdb`` and
  235. ``django.db.models.signals.post_syncdb`` is removed.
  236. * Support for ``allow_syncdb`` on database routers is removed.
  237. * The legacy method of syncing apps without migrations is removed,
  238. and migrations are compulsory for all apps. This includes automatic
  239. loading of ``initial_data`` fixtures and support for initial SQL data.
  240. * All models need to be defined inside an installed application or declare an
  241. explicit :attr:`~django.db.models.Options.app_label`. Furthermore, it isn't
  242. possible to import them before their application is loaded. In particular, it
  243. isn't possible to import models inside the root package of an application.
  244. * The model and form ``IPAddressField`` is removed. A stub field remains for
  245. compatibility with historical migrations.
  246. * ``AppCommand.handle_app()`` is no longer be supported.
  247. * ``RequestSite`` and ``get_current_site()`` are no longer importable from
  248. ``django.contrib.sites.models``.
  249. * FastCGI support via the ``runfcgi`` management command is removed.
  250. * ``django.utils.datastructures.SortedDict`` is removed.
  251. * ``ModelAdmin.declared_fieldsets`` is removed.
  252. * The ``util`` modules that provided backwards compatibility are removed:
  253. * ``django.contrib.admin.util``
  254. * ``django.contrib.gis.db.backends.util``
  255. * ``django.db.backends.util``
  256. * ``django.forms.util``
  257. * ``ModelAdmin.get_formsets`` is removed.
  258. * The backward compatible shims introduced to rename the
  259. ``BaseMemcachedCache._get_memcache_timeout()`` method to
  260. ``get_backend_timeout()`` is removed.
  261. * The ``--natural`` and ``-n`` options for :djadmin:`dumpdata` are removed.
  262. * The ``use_natural_keys`` argument for ``serializers.serialize()`` is removed.
  263. * Private API ``django.forms.forms.get_declared_fields()`` is removed.
  264. * The ability to use a ``SplitDateTimeWidget`` with ``DateTimeField`` is
  265. removed.
  266. * The ``WSGIRequest.REQUEST`` property is removed.
  267. * The class ``django.utils.datastructures.MergeDict`` is removed.
  268. * The ``zh-cn`` and ``zh-tw`` language codes are removed.
  269. * The internal ``django.utils.functional.memoize()`` is removed.
  270. * ``django.core.cache.get_cache`` is removed.
  271. * ``django.db.models.loading`` is removed.
  272. * Passing callable arguments to querysets is no longer possible.
  273. * ``BaseCommand.requires_model_validation`` is removed in favor of
  274. ``requires_system_checks``. Admin validators is replaced by admin checks.
  275. * The ``ModelAdmin.validator_class`` and ``default_validator_class`` attributes
  276. are removed.
  277. * ``ModelAdmin.validate()`` is removed.
  278. * ``django.db.backends.DatabaseValidation.validate_field`` is removed in
  279. favor of the ``check_field`` method.
  280. * The ``check`` management command is removed.
  281. * ``django.utils.module_loading.import_by_path`` is removed in favor of
  282. ``django.utils.module_loading.import_string``.
  283. * ``ssi`` and ``url`` template tags are removed from the ``future`` template
  284. tag library.
  285. * ``django.utils.text.javascript_quote()`` is removed.
  286. * Database test settings as independent entries in the database settings,
  287. prefixed by ``TEST_``, are no longer supported.
  288. * The `cache_choices` option to :class:`~django.forms.ModelChoiceField` and
  289. :class:`~django.forms.ModelMultipleChoiceField` is removed.
  290. * The default value of the
  291. :attr:`RedirectView.permanent <django.views.generic.base.RedirectView.permanent>`
  292. attribute has changed from ``True`` to ``False``.
  293. * ``django.contrib.sitemaps.FlatPageSitemap`` is removed in favor of
  294. ``django.contrib.flatpages.sitemaps.FlatPageSitemap``.
  295. * Private API ``django.test.utils.TestTemplateLoader`` is removed.
  296. * The ``django.contrib.contenttypes.generic`` module is removed.