1.10.txt 17 KB

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