1.10.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. =============================================
  2. Django 1.10 release notes - UNDER DEVELOPMENT
  3. =============================================
  4. Welcome to Django 1.10!
  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.9 or older versions. We've :ref:`dropped some features<removed-features-1.10>`
  8. that have reached the end of their deprecation cycle, and we've `begun the
  9. deprecation process for some features`_.
  10. .. _`new features`: `What's new in Django 1.10`_
  11. .. _`backwards incompatible changes`: `Backwards incompatible changes in 1.10`_
  12. .. _`dropped some features`: `Features removed in 1.10`_
  13. .. _`begun the deprecation process for some features`: `Features deprecated in 1.10`_
  14. Python compatibility
  15. ====================
  16. Like Django 1.9, Django 1.10 requires Python 2.7, 3.4, or 3.5. We **highly
  17. recommend** and only officially support the latest release of each series.
  18. What's new in Django 1.10
  19. =========================
  20. ...
  21. Minor features
  22. ~~~~~~~~~~~~~~
  23. :mod:`django.contrib.admin`
  24. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  25. * For sites running on a subpath, the default :attr:`URL for the "View site"
  26. link <django.contrib.admin.AdminSite.site_url>` at the top of each admin page
  27. will now point to ``request.META['SCRIPT_NAME']`` if set, instead of ``/``.
  28. :mod:`django.contrib.admindocs`
  29. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  30. * ...
  31. :mod:`django.contrib.auth`
  32. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  33. * The default iteration count for the PBKDF2 password hasher has been increased
  34. by 25%. This backwards compatible change will not affect users who have
  35. subclassed ``django.contrib.auth.hashers.PBKDF2PasswordHasher`` to change the
  36. default value.
  37. * The :func:`~django.contrib.auth.views.logout` view sends "no-cache" headers
  38. to prevent an issue where Safari caches redirects and prevents a user from
  39. being able to log out.
  40. :mod:`django.contrib.contenttypes`
  41. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  42. * ...
  43. :mod:`django.contrib.gis`
  44. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  45. * :ref:`Distance lookups <distance-lookups>` now accept expressions as the
  46. distance value parameter.
  47. :mod:`django.contrib.messages`
  48. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  49. * ...
  50. :mod:`django.contrib.postgres`
  51. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  52. * ...
  53. :mod:`django.contrib.redirects`
  54. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  55. * ...
  56. :mod:`django.contrib.sessions`
  57. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  58. * The :djadmin:`clearsessions` management command now removes file-based
  59. sessions.
  60. :mod:`django.contrib.sitemaps`
  61. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  62. * ...
  63. :mod:`django.contrib.sites`
  64. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  65. * ...
  66. :mod:`django.contrib.staticfiles`
  67. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  68. * ...
  69. :mod:`django.contrib.syndication`
  70. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  71. * ...
  72. Cache
  73. ^^^^^
  74. * The file-based cache backend now uses the highest pickling protocol.
  75. CSRF
  76. ^^^^
  77. * ...
  78. Database backends
  79. ^^^^^^^^^^^^^^^^^
  80. * ...
  81. Email
  82. ^^^^^
  83. * ...
  84. File Storage
  85. ^^^^^^^^^^^^
  86. * ...
  87. File Uploads
  88. ^^^^^^^^^^^^
  89. * ...
  90. Forms
  91. ^^^^^
  92. * ...
  93. Generic Views
  94. ^^^^^^^^^^^^^
  95. * ...
  96. Internationalization
  97. ^^^^^^^^^^^^^^^^^^^^
  98. * ...
  99. Management Commands
  100. ^^^^^^^^^^^^^^^^^^^
  101. * The new :djadminopt:`--fail-level` option of the :djadmin:`check` command
  102. allows specifying the message level that will cause the command to exit with
  103. a non-zero status.
  104. * The new :djadminopt:`makemigrations --check <--check>` option makes the
  105. command exit with a non-zero status when model changes without migrations are
  106. detected.
  107. Migrations
  108. ^^^^^^^^^^
  109. * ...
  110. Models
  111. ^^^^^^
  112. * Reverse foreign keys from proxy models are now propagated to their
  113. concrete class. The reverse relation attached by a
  114. :class:`~django.db.models.ForeignKey` pointing to a proxy model is now
  115. accessible as a descriptor on the proxied model class and may be referenced in
  116. queryset filtering.
  117. * The :attr:`~django.db.models.Func.arity` class attribute is added to
  118. :class:`~django.db.models.Func`. This attribute can be used to set the number
  119. of arguments the function accepts.
  120. Requests and Responses
  121. ^^^^^^^^^^^^^^^^^^^^^^
  122. * Added ``request.user`` to the debug view.
  123. * Added :class:`~django.http.HttpResponse` methods
  124. :meth:`~django.http.HttpResponse.readable()` and
  125. :meth:`~django.http.HttpResponse.seekable()` to make an instance a
  126. stream-like object and allow wrapping it with :py:class:`io.TextIOWrapper`.
  127. Serialization
  128. ^^^^^^^^^^^^^
  129. * The ``django.core.serializers.json.DjangoJSONEncoder`` now knows how to
  130. serialize lazy strings, typically used for translatable content.
  131. Signals
  132. ^^^^^^^
  133. * ...
  134. Templates
  135. ^^^^^^^^^
  136. * ...
  137. Tests
  138. ^^^^^
  139. * ...
  140. URLs
  141. ^^^^
  142. * An addition in :func:`django.setup()` allows URL resolving that happens
  143. outside of the request/response cycle (e.g. in management commands and
  144. standalone scripts) to take :setting:`FORCE_SCRIPT_NAME` into account when it
  145. is set.
  146. Validators
  147. ^^^^^^^^^^
  148. * ...
  149. Backwards incompatible changes in 1.10
  150. ======================================
  151. .. warning::
  152. In addition to the changes outlined in this section, be sure to review the
  153. :ref:`removed-features-1.10` for the features that have reached the end of
  154. their deprecation cycle and therefore been removed. If you haven't updated
  155. your code within the deprecation timeline for a given feature, its removal
  156. may appear as a backwards incompatible change.
  157. Database backend API
  158. ~~~~~~~~~~~~~~~~~~~~
  159. * ...
  160. ``select_related()`` prohibits non-relational fields for nested relations
  161. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  162. Django 1.8 added validation for non-relational fields in ``select_related()``::
  163. >>> Book.objects.select_related('title')
  164. Traceback (most recent call last):
  165. ...
  166. FieldError: Non-relational field given in select_related: 'title'
  167. But it didn't prohibit nested non-relation fields as it does now::
  168. >>> Book.objects.select_related('author__name')
  169. Traceback (most recent call last):
  170. ...
  171. FieldError: Non-relational field given in select_related: 'name'
  172. ``_meta.get_fields()`` returns consistent reverse fields for proxy models
  173. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  174. Before Django 1.10, the :meth:`~django.db.models.options.Options.get_fields`
  175. method returned different reverse fields when called on a proxy model compared
  176. to its proxied concrete class. This inconsistency was fixed by returning the
  177. full set of fields pointing to a concrete class or one of its proxies in both
  178. cases.
  179. :attr:`AbstractUser.username <django.contrib.auth.models.User.username>` ``max_length`` increased to 254
  180. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  181. A migration for :attr:`django.contrib.auth.models.User.username` is included.
  182. If you have a custom user model inheriting from ``AbstractUser``, you'll need
  183. to generate and apply a database migration for your user model.
  184. If you want to preserve the 30 character limit for usernames, use a custom form
  185. when creating a user or changing usernames::
  186. from django.contrib.auth.forms import UserCreationForm
  187. class MyUserCreationForm(UserCreationForm):
  188. username = forms.CharField(
  189. max_length=30,
  190. help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.',
  191. )
  192. If you wish to keep this restriction in the admin, set ``UserAdmin.add_form``
  193. to use this form::
  194. from django.contrib.auth.admin import UserAdmin
  195. from django.contrib.auth.models import User
  196. class MyUserAdmin(UserAdmin):
  197. add_form = MyUserCreationForm
  198. admin.site.unregister(User)
  199. admin.site.register(User, MyUserAdmin)
  200. Miscellaneous
  201. ~~~~~~~~~~~~~
  202. * The ``repr()`` of a ``QuerySet`` is wrapped in ``<QuerySet >`` to
  203. disambiguate it from a plain list when debugging.
  204. :mod:`django.contrib.gis`
  205. ~~~~~~~~~~~~~~~~~~~~~~~~~
  206. * Support for SpatiaLite < 3.0 and GEOS < 3.3 is dropped.
  207. .. _deprecated-features-1.10:
  208. Features deprecated in 1.10
  209. ===========================
  210. Direct assignment to a reverse foreign key or many-to-many relation
  211. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  212. Instead of assigning related objects using direct assignment::
  213. >>> new_list = [obj1, obj2, obj3]
  214. >>> e.related_set = new_list
  215. Use the :meth:`~django.db.models.fields.related.RelatedManager.set` method
  216. added in Django 1.9::
  217. >>> e.related_set.set([obj1, obj2, obj3])
  218. This prevents confusion about an assignment resulting in an implicit save.
  219. Miscellaneous
  220. ~~~~~~~~~~~~~
  221. * The ``makemigrations --exit`` option is deprecated in favor of the
  222. :djadminopt:`--check` option.
  223. .. _removed-features-1.10:
  224. Features removed in 1.10
  225. ========================
  226. These features have reached the end of their deprecation cycle and so have been
  227. removed in Django 1.10 (please see the :ref:`deprecation timeline
  228. <deprecation-removed-in-1.10>` for more details):
  229. * Support for calling a ``SQLCompiler`` directly as an alias for calling its
  230. ``quote_name_unless_alias`` method is removed.
  231. * The ``cycle`` and ``firstof`` template tags are removed from the ``future``
  232. template tag library.
  233. * ``django.conf.urls.patterns()`` is removed.
  234. * Support for the ``prefix`` argument to
  235. ``django.conf.urls.i18n.i18n_patterns()`` is removed.
  236. * ``SimpleTestCase.urls`` is removed.
  237. * Using an incorrect count of unpacked values in the ``for`` template tag
  238. raises an exception rather than failing silently.
  239. * The ability to :func:`~django.core.urlresolvers.reverse` URLs using a dotted
  240. Python path is removed.
  241. * Support for ``optparse`` is dropped for custom management commands.
  242. * The class ``django.core.management.NoArgsCommand`` is removed.
  243. * ``django.core.context_processors`` module is removed.
  244. * ``django.db.models.sql.aggregates`` module is removed.
  245. * ``django.contrib.gis.db.models.sql.aggregates`` module is removed.
  246. * The following methods and properties of ``django.db.sql.query.Query`` are
  247. removed:
  248. * Properties: ``aggregates`` and ``aggregate_select``
  249. * Methods: ``add_aggregate``, ``set_aggregate_mask``, and
  250. ``append_aggregate_mask``.
  251. * ``django.template.resolve_variable`` is removed.
  252. * The following private APIs are removed from
  253. :class:`django.db.models.options.Options` (``Model._meta``):
  254. * ``get_field_by_name()``
  255. * ``get_all_field_names()``
  256. * ``get_fields_with_model()``
  257. * ``get_concrete_fields_with_model()``
  258. * ``get_m2m_with_model()``
  259. * ``get_all_related_objects()``
  260. * ``get_all_related_objects_with_model()``
  261. * ``get_all_related_many_to_many_objects()``
  262. * ``get_all_related_m2m_objects_with_model()``
  263. * The ``error_message`` argument of ``django.forms.RegexField`` is removed.
  264. * The ``unordered_list`` filter no longer supports old style lists.
  265. * Support for string ``view`` arguments to ``url()`` is removed.
  266. * The backward compatible shim to rename ``django.forms.Form._has_changed()``
  267. to ``has_changed()`` is removed.
  268. * The ``removetags`` template filter is removed.
  269. * The ``remove_tags()`` and ``strip_entities()`` functions in
  270. ``django.utils.html`` is removed.
  271. * The ``is_admin_site`` argument to
  272. ``django.contrib.auth.views.password_reset()`` is removed.
  273. * ``django.db.models.field.subclassing.SubfieldBase`` is removed.
  274. * ``django.utils.checksums`` is removed.
  275. * The ``original_content_type_id`` attribute on
  276. ``django.contrib.admin.helpers.InlineAdminForm`` is removed.
  277. * The backwards compatibility shim to allow ``FormMixin.get_form()`` to be
  278. defined with no default value for its ``form_class`` argument is removed.
  279. * The following settings are removed:
  280. * ``ALLOWED_INCLUDE_ROOTS``
  281. * ``TEMPLATE_CONTEXT_PROCESSORS``
  282. * ``TEMPLATE_DEBUG``
  283. * ``TEMPLATE_DIRS``
  284. * ``TEMPLATE_LOADERS``
  285. * ``TEMPLATE_STRING_IF_INVALID``
  286. * The backwards compatibility alias ``django.template.loader.BaseLoader`` is
  287. removed.
  288. * Django template objects returned by
  289. :func:`~django.template.loader.get_template` and
  290. :func:`~django.template.loader.select_template` no longer accept a
  291. :class:`~django.template.Context` in their
  292. :meth:`~django.template.backends.base.Template.render()` method.
  293. * :doc:`Template response APIs </ref/template-response>` enforce the use of
  294. :class:`dict` and backend-dependent template objects instead of
  295. :class:`~django.template.Context` and :class:`~django.template.Template`
  296. respectively.
  297. * The ``current_app`` parameter for the following function and classes is
  298. removed:
  299. * ``django.shortcuts.render()``
  300. * ``django.template.Context()``
  301. * ``django.template.RequestContext()``
  302. * ``django.template.response.TemplateResponse()``
  303. * The ``dictionary`` and ``context_instance`` parameters for the following
  304. functions are removed:
  305. * ``django.shortcuts.render()``
  306. * ``django.shortcuts.render_to_response()``
  307. * ``django.template.loader.render_to_string()``
  308. * The ``dirs`` parameter for the following functions is removed:
  309. * ``django.template.loader.get_template()``
  310. * ``django.template.loader.select_template()``
  311. * ``django.shortcuts.render()``
  312. * ``django.shortcuts.render_to_response()``
  313. * Session verification is enabled regardless of whether or not
  314. ``'django.contrib.auth.middleware.SessionAuthenticationMiddleware'`` is in
  315. ``MIDDLEWARE_CLASSES``. ``SessionAuthenticationMiddleware`` no longer has
  316. any purpose and can be removed from ``MIDDLEWARE_CLASSES``. It's kept as
  317. a stub until Django 2.0 as a courtesy for users who don't read this note.
  318. * Private attribute ``django.db.models.Field.related`` is removed.
  319. * The ``--list`` option of the ``migrate`` management command is removed.
  320. * The ``ssi`` template tag is removed.
  321. * Support for the ``=`` comparison operator in the ``if`` template tag is
  322. removed.
  323. * The backwards compatibility shims to allow ``Storage.get_available_name()``
  324. and ``Storage.save()`` to be defined without a ``max_length`` argument are
  325. removed.
  326. * Support for the legacy ``%(<foo>)s`` syntax in ``ModelFormMixin.success_url``
  327. is removed.
  328. * ``GeoQuerySet`` aggregate methods ``collect()``, ``extent()``, ``extent3d()``,
  329. ``make_line()``, and ``unionagg()`` are removed.
  330. * The ability to specify ``ContentType.name`` when creating a content type
  331. instance is removed.
  332. * Support for the old signature of ``allow_migrate`` is removed.
  333. * Support for the syntax of ``{% cycle %}`` that uses comma-separated arguments
  334. is removed.
  335. * The warning that :class:`~django.core.signing.Signer` issued when given an
  336. invalid separator is now a ``ValueError``.