1.10.txt 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  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. * The new :attr:`InlineModelAdmin.classes
  33. <django.contrib.admin.InlineModelAdmin.classes>` attribute allows specifying
  34. classes on inline fieldsets. Inlines with a ``collapse`` class will be
  35. initially collapsed and their header will have a small "show" link.
  36. * If a user doesn't have the add permission, the ``object-tools`` block on a
  37. model's changelist will now be rendered (without the add button, of course).
  38. This makes it easier to add custom tools in this case.
  39. * The :class:`~django.contrib.admin.models.LogEntry` model now stores change
  40. messages in a JSON structure so that the message can be dynamically translated
  41. using the current active language. A new ``LogEntry.get_change_message()``
  42. method is now the preferred way of retrieving the change message.
  43. * Selected objects for fields in ``ModelAdmin.raw_id_fields`` now have a link
  44. to object's change form.
  45. * Added "No date" and "Has date" choices for ``DateFieldListFilter`` if the
  46. field is nullable.
  47. :mod:`django.contrib.admindocs`
  48. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49. * ...
  50. :mod:`django.contrib.auth`
  51. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  52. * The default iteration count for the PBKDF2 password hasher has been increased
  53. by 25%. This backwards compatible change will not affect users who have
  54. subclassed ``django.contrib.auth.hashers.PBKDF2PasswordHasher`` to change the
  55. default value.
  56. * The :func:`~django.contrib.auth.views.logout` view sends "no-cache" headers
  57. to prevent an issue where Safari caches redirects and prevents a user from
  58. being able to log out.
  59. * Added the optional ``backend`` argument to :func:`~django.contrib.auth.login`
  60. to allow using it without credentials.
  61. * The new :setting:`LOGOUT_REDIRECT_URL` setting controls the redirect of the
  62. :func:`~django.contrib.auth.views.logout` view, if the view doesn't get a
  63. ``next_page`` argument.
  64. :mod:`django.contrib.contenttypes`
  65. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  66. * ...
  67. :mod:`django.contrib.gis`
  68. ~~~~~~~~~~~~~~~~~~~~~~~~~
  69. * :ref:`Distance lookups <distance-lookups>` now accept expressions as the
  70. distance value parameter.
  71. * The new :attr:`GEOSGeometry.unary_union
  72. <django.contrib.gis.geos.GEOSGeometry.unary_union>` property computes the
  73. union of all the elements of this geometry.
  74. * Added the :meth:`GEOSGeometry.covers()
  75. <django.contrib.gis.geos.GEOSGeometry.covers>` binary predicate.
  76. * Added the :meth:`GDALBand.statistics()
  77. <django.contrib.gis.gdal.GDALBand.statistics>` method and
  78. :attr:`~django.contrib.gis.gdal.GDALBand.mean`
  79. and :attr:`~django.contrib.gis.gdal.GDALBand.std` attributes.
  80. * Added support for the :class:`~django.contrib.gis.db.models.MakeLine`
  81. aggregate and :class:`~django.contrib.gis.db.models.functions.GeoHash`
  82. function on SpatiaLite.
  83. * Added support for the
  84. :class:`~django.contrib.gis.db.models.functions.Difference`,
  85. :class:`~django.contrib.gis.db.models.functions.Intersection`, and
  86. :class:`~django.contrib.gis.db.models.functions.SymDifference`
  87. functions on MySQL.
  88. * Added support for instantiating empty GEOS geometries.
  89. * The new :attr:`~django.contrib.gis.geos.WKTWriter.trim` and
  90. :attr:`~django.contrib.gis.geos.WKTWriter.precision` properties
  91. of :class:`~django.contrib.gis.geos.WKTWriter` allow controlling
  92. output of the fractional part of the coordinates in WKT.
  93. * Added the :attr:`LineString.closed
  94. <django.contrib.gis.geos.LineString.closed>` and
  95. :attr:`MultiLineString.closed
  96. <django.contrib.gis.geos.MultiLineString.closed>` properties.
  97. * The :doc:`GeoJSON serializer </ref/contrib/gis/serializers>` now outputs the
  98. primary key of objects in the ``properties`` dictionary if specific fields
  99. aren't specified.
  100. :mod:`django.contrib.messages`
  101. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  102. * ...
  103. :mod:`django.contrib.postgres`
  104. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  105. * For convenience, :class:`~django.contrib.postgres.fields.HStoreField` now
  106. casts its keys and values to strings.
  107. :mod:`django.contrib.redirects`
  108. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  109. * ...
  110. :mod:`django.contrib.sessions`
  111. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  112. * The :djadmin:`clearsessions` management command now removes file-based
  113. sessions.
  114. :mod:`django.contrib.sitemaps`
  115. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  116. * ...
  117. :mod:`django.contrib.sites`
  118. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  119. * The :class:`~django.contrib.sites.models.Site` model now supports
  120. :ref:`natural keys <topics-serialization-natural-keys>`.
  121. :mod:`django.contrib.staticfiles`
  122. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  123. * The :ttag:`static` template tag now uses ``django.contrib.staticfiles``
  124. if it's in ``INSTALLED_APPS``. This is especially useful for third-party apps
  125. which can now always use ``{% load static %}`` (instead of
  126. ``{% load staticfiles %}`` or ``{% load static from staticfiles %}``) and
  127. not worry about whether or not the ``staticfiles`` app is installed.
  128. :mod:`django.contrib.syndication`
  129. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  130. * ...
  131. Cache
  132. ~~~~~
  133. * The file-based cache backend now uses the highest pickling protocol.
  134. CSRF
  135. ~~~~
  136. * The default :setting:`CSRF_FAILURE_VIEW`, ``views.csrf.csrf_failure()`` now
  137. accepts an optional ``template_name`` parameter, defaulting to
  138. ``'403_csrf.html'``, to control the template used to render the page.
  139. Database backends
  140. ~~~~~~~~~~~~~~~~~
  141. * ...
  142. Email
  143. ~~~~~
  144. * ...
  145. File Storage
  146. ~~~~~~~~~~~~
  147. * Storage backends now present a timezone-aware API with new methods
  148. :meth:`~django.core.files.storage.Storage.get_accessed_time`,
  149. :meth:`~django.core.files.storage.Storage.get_created_time`, and
  150. :meth:`~django.core.files.storage.Storage.get_modified_time`. They return a
  151. timezone-aware ``datetime`` if :setting:`USE_TZ` is ``True`` and a naive
  152. ``datetime`` in the local timezone otherwise.
  153. File Uploads
  154. ~~~~~~~~~~~~
  155. * ...
  156. Forms
  157. ~~~~~
  158. * Form and widget ``Media`` is now served using
  159. :mod:`django.contrib.staticfiles` if installed.
  160. Generic Views
  161. ~~~~~~~~~~~~~
  162. * The :class:`~django.views.generic.base.View` class can now be imported from
  163. ``django.views``.
  164. Internationalization
  165. ~~~~~~~~~~~~~~~~~~~~
  166. * ...
  167. Management Commands
  168. ~~~~~~~~~~~~~~~~~~~
  169. * :func:`~django.core.management.call_command` now returns the value returned
  170. from the ``command.handle()`` method.
  171. * The new :option:`check --fail-level` option allows specifying the message
  172. level that will cause the command to exit with a non-zero status.
  173. * The new :option:`makemigrations --check` option makes the command exit
  174. with a non-zero status when model changes without migrations are detected.
  175. * :djadmin:`makemigrations` now displays the path to the migration files that
  176. it generates.
  177. * The :option:`shell --interface` option now accepts ``python`` to force use of
  178. the "plain" Python interpreter.
  179. * The new :option:`shell --command` option lets you run a command as Django and
  180. exit, instead of opening the interactive shell.
  181. * Added a warning to :djadmin:`dumpdata` if a proxy model is specified (which
  182. results in no output) without its concrete parent.
  183. * The new :attr:`BaseCommand.requires_migrations_checks
  184. <django.core.management.BaseCommand.requires_migrations_checks>` attribute
  185. may be set to ``True`` if you want your command to print a warning, like
  186. :djadmin:`runserver` does, if the set of migrations on disk don't match the
  187. migrations in the database.
  188. Migrations
  189. ~~~~~~~~~~
  190. * Added support for serialization of ``enum.Enum`` objects.
  191. * Added the ``elidable`` argument to the
  192. :class:`~django.db.migrations.operations.RunSQL` and
  193. :class:`~django.db.migrations.operations.RunPython` operations to allow them
  194. to be removed when squashing migrations.
  195. * Added support for :ref:`non-atomic migrations <non-atomic-migrations>` by
  196. setting the ``atomic`` attribute on a ``Migration``.
  197. Models
  198. ~~~~~~
  199. * Reverse foreign keys from proxy models are now propagated to their
  200. concrete class. The reverse relation attached by a
  201. :class:`~django.db.models.ForeignKey` pointing to a proxy model is now
  202. accessible as a descriptor on the proxied model class and may be referenced in
  203. queryset filtering.
  204. * The new :meth:`Field.rel_db_type() <django.db.models.Field.rel_db_type>`
  205. method returns the database column data type for fields such as ``ForeignKey``
  206. and ``OneToOneField`` that point to another field.
  207. * The :attr:`~django.db.models.Func.arity` class attribute is added to
  208. :class:`~django.db.models.Func`. This attribute can be used to set the number
  209. of arguments the function accepts.
  210. * Added :class:`~django.db.models.BigAutoField` which acts much like an
  211. :class:`~django.db.models.AutoField` except that it is guaranteed
  212. to fit numbers from ``1`` to ``9223372036854775807``.
  213. * :meth:`QuerySet.in_bulk() <django.db.models.query.QuerySet.in_bulk>`
  214. may be called without any arguments to return all objects in the queryset.
  215. * :attr:`~django.db.models.ForeignKey.related_query_name` now supports
  216. app label and class interpolation using the ``'%(app_label)s'`` and
  217. ``'%(class)s'`` strings.
  218. Requests and Responses
  219. ~~~~~~~~~~~~~~~~~~~~~~
  220. * Added ``request.user`` to the debug view.
  221. * Added :class:`~django.http.HttpResponse` methods
  222. :meth:`~django.http.HttpResponse.readable()` and
  223. :meth:`~django.http.HttpResponse.seekable()` to make an instance a
  224. stream-like object and allow wrapping it with :py:class:`io.TextIOWrapper`.
  225. * Added the :attr:`HttpResponse.content_type
  226. <django.http.HttpRequest.content_type>` and
  227. :attr:`~django.http.HttpRequest.content_params` attributes which are
  228. parsed from the ``CONTENT_TYPE`` header.
  229. Serialization
  230. ~~~~~~~~~~~~~
  231. * The ``django.core.serializers.json.DjangoJSONEncoder`` now knows how to
  232. serialize lazy strings, typically used for translatable content.
  233. Signals
  234. ~~~~~~~
  235. * ...
  236. Templates
  237. ~~~~~~~~~
  238. * Added the ``autoescape`` option to the
  239. :class:`~django.template.backends.django.DjangoTemplates` backend and the
  240. :class:`~django.template.Engine` class.
  241. * Added the ``is`` comparison operator to the :ttag:`if` tag.
  242. * Allowed :tfilter:`dictsort` to order a list of lists by an element at a
  243. specified index.
  244. Tests
  245. ~~~~~
  246. * To better catch bugs, :class:`~django.test.TestCase` now checks deferrable
  247. database constraints at the end of each test.
  248. * Tests and test cases can be :ref:`marked with tags <topics-tagging-tests>`
  249. and run selectively with the new :option:`test --tag` and :option:`test
  250. --exclude-tag` options.
  251. URLs
  252. ~~~~
  253. * An addition in :func:`django.setup()` allows URL resolving that happens
  254. outside of the request/response cycle (e.g. in management commands and
  255. standalone scripts) to take :setting:`FORCE_SCRIPT_NAME` into account when it
  256. is set.
  257. Validators
  258. ~~~~~~~~~~
  259. * :class:`~django.core.validators.URLValidator` now limits the length of
  260. domain name labels to 63 characters and the total length of domain
  261. names to 253 characters per :rfc:`1034`.
  262. * :func:`~django.core.validators.int_list_validator` now accepts an optional
  263. ``allow_negative`` boolean parameter, defaulting to ``False``, to allow
  264. negative integers.
  265. Backwards incompatible changes in 1.10
  266. ======================================
  267. .. warning::
  268. In addition to the changes outlined in this section, be sure to review the
  269. :ref:`removed-features-1.10` for the features that have reached the end of
  270. their deprecation cycle and therefore been removed. If you haven't updated
  271. your code within the deprecation timeline for a given feature, its removal
  272. may appear as a backwards incompatible change.
  273. Database backend API
  274. --------------------
  275. * GIS's ``AreaField`` uses an unspecified underlying numeric type that could in
  276. practice be any numeric Python type. ``decimal.Decimal`` values retrieved
  277. from the database are now converted to ``float`` to make it easier to combine
  278. them with values used by the GIS libraries.
  279. ``select_related()`` prohibits non-relational fields for nested relations
  280. -------------------------------------------------------------------------
  281. Django 1.8 added validation for non-relational fields in ``select_related()``::
  282. >>> Book.objects.select_related('title')
  283. Traceback (most recent call last):
  284. ...
  285. FieldError: Non-relational field given in select_related: 'title'
  286. But it didn't prohibit nested non-relation fields as it does now::
  287. >>> Book.objects.select_related('author__name')
  288. Traceback (most recent call last):
  289. ...
  290. FieldError: Non-relational field given in select_related: 'name'
  291. ``_meta.get_fields()`` returns consistent reverse fields for proxy models
  292. -------------------------------------------------------------------------
  293. Before Django 1.10, the :meth:`~django.db.models.options.Options.get_fields`
  294. method returned different reverse fields when called on a proxy model compared
  295. to its proxied concrete class. This inconsistency was fixed by returning the
  296. full set of fields pointing to a concrete class or one of its proxies in both
  297. cases.
  298. :attr:`AbstractUser.username <django.contrib.auth.models.User.username>` ``max_length`` increased to 150
  299. --------------------------------------------------------------------------------------------------------
  300. A migration for :attr:`django.contrib.auth.models.User.username` is included.
  301. If you have a custom user model inheriting from ``AbstractUser``, you'll need
  302. to generate and apply a database migration for your user model.
  303. We considered an increase to 254 characters to more easily allow the use of
  304. email addresses (which are limited to 254 characters) as usernames but rejected
  305. it due to a MySQL limitation. When using the ``utf8mb4`` encoding (recommended
  306. for proper Unicode support), MySQL can only create unique indexes with 191
  307. characters by default. Therefore, if you need a longer length, please use a
  308. custom user model.
  309. If you want to preserve the 30 character limit for usernames, use a custom form
  310. when creating a user or changing usernames::
  311. from django.contrib.auth.forms import UserCreationForm
  312. class MyUserCreationForm(UserCreationForm):
  313. username = forms.CharField(
  314. max_length=30,
  315. help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.',
  316. )
  317. If you wish to keep this restriction in the admin, set ``UserAdmin.add_form``
  318. to use this form::
  319. from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
  320. from django.contrib.auth.models import User
  321. class UserAdmin(BaseUserAdmin):
  322. add_form = MyUserCreationForm
  323. admin.site.unregister(User)
  324. admin.site.register(User, UserAdmin)
  325. Dropped support for PostgreSQL 9.1
  326. ----------------------------------
  327. Upstream support for PostgreSQL 9.1 ends in September 2016. As a consequence,
  328. Django 1.10 sets PostgreSQL 9.2 as the minimum version it officially supports.
  329. ``runserver`` output goes through logging
  330. -----------------------------------------
  331. Request and response handling of the ``runserver`` command is sent to the
  332. :ref:`django-server-logger` logger instead of to ``sys.stderr``. If you
  333. disable Django's logging configuration or override it with your own, you'll
  334. need to add the appropriate logging configuration if you want to see that
  335. output::
  336. 'formatters': {
  337. 'django.server': {
  338. '()': 'django.utils.log.ServerFormatter',
  339. 'format': '[%(server_time)s] %(message)s',
  340. }
  341. },
  342. 'handlers': {
  343. 'django.server': {
  344. 'level': 'INFO',
  345. 'class': 'logging.StreamHandler',
  346. 'formatter': 'django.server',
  347. },
  348. },
  349. 'loggers': {
  350. 'django.server': {
  351. 'handlers': ['django.server'],
  352. 'level': 'INFO',
  353. 'propagate': False,
  354. }
  355. }
  356. ``auth.CustomUser`` and ``auth.ExtensionUser`` test models were removed
  357. -----------------------------------------------------------------------
  358. Since the introduction of migrations for the contrib apps in Django 1.8, the
  359. tables of these custom user test models were not created anymore making them
  360. unusable in a testing context.
  361. Apps registry is no longer auto-populated when unpickling models outside of Django
  362. ----------------------------------------------------------------------------------
  363. The apps registry is no longer auto-populated when unpickling models. This was
  364. added in Django 1.7.2 as an attempt to allow unpickling models outside of
  365. Django, such as in an RQ worker, without calling ``django.setup()``, but it
  366. creates the possibility of a deadlock. To adapt your code in the case of RQ,
  367. you can `provide your own worker script <http://python-rq.org/docs/workers/>`_
  368. that calls ``django.setup()``.
  369. Removed null assignment check for non-null foreign key fields
  370. -------------------------------------------------------------
  371. In older versions, assigning ``None`` to a non-nullable ``ForeignKey`` or
  372. ``OneToOneField`` raised ``ValueError('Cannot assign None: "model.field" does
  373. not allow null values.')``. For consistency with other model fields which don't
  374. have a similar check, this check is removed.
  375. Removed weak password hashers from the default ``PASSWORD_HASHERS`` setting
  376. ---------------------------------------------------------------------------
  377. Django 0.90 stored passwords as unsalted MD5. Django 0.91 added support for
  378. salted SHA1 with automatic upgrade of passwords when a user logs in. Django 1.4
  379. added PBKDF2 as the default password hasher.
  380. If you have an old Django project with MD5 or SHA1 (even salted) encoded
  381. passwords, be aware that these can be cracked fairly easily with today's
  382. hardware. To make Django users acknowledge continued use of weak hashers, the
  383. following hashers are removed from the default :setting:`PASSWORD_HASHERS`
  384. setting::
  385. 'django.contrib.auth.hashers.SHA1PasswordHasher'
  386. 'django.contrib.auth.hashers.MD5PasswordHasher'
  387. 'django.contrib.auth.hashers.UnsaltedSHA1PasswordHasher'
  388. 'django.contrib.auth.hashers.UnsaltedMD5PasswordHasher'
  389. 'django.contrib.auth.hashers.CryptPasswordHasher'
  390. Consider using a :ref:`wrapped password hasher <wrapping-password-hashers>` to
  391. strengthen the hashes in your database. If that's not feasible, add the
  392. :setting:`PASSWORD_HASHERS` setting to your project and add back any hashers
  393. that you need.
  394. You can check if your database has any of the removed hashers like this::
  395. from django.contrib.auth import get_user_model
  396. User = get_user_model()
  397. # Unsalted MD5/SHA1:
  398. User.objects.filter(password__startswith='md5$$')
  399. User.objects.filter(password__startswith='sha1$$')
  400. # Salted MD5/SHA1:
  401. User.objects.filter(password__startswith='md5$').exclude(password__startswith='md5$$')
  402. User.objects.filter(password__startswith='sha1$').exclude(password__startswith='sha1$$')
  403. # Crypt hasher:
  404. User.objects.filter(password__startswith='crypt$$')
  405. from django.db.models import CharField
  406. from django.db.models.functions import Length
  407. CharField.register_lookup(Length)
  408. # Unsalted MD5 passwords might not have an 'md5$$' prefix:
  409. User.objects.filter(password__length=32)
  410. Miscellaneous
  411. -------------
  412. * The ``repr()`` of a ``QuerySet`` is wrapped in ``<QuerySet >`` to
  413. disambiguate it from a plain list when debugging.
  414. * Support for SpatiaLite < 3.0 and GEOS < 3.3 is dropped.
  415. * ``utils.version.get_version()`` returns :pep:`440` compliant release
  416. candidate versions (e.g. '1.10rc1' instead of '1.10c1').
  417. * The ``LOGOUT_URL`` setting is removed as Django hasn't made use of it
  418. since pre-1.0. If you use it in your project, you can add it to your
  419. project's settings. The default value was ``'/accounts/logout/'``.
  420. * The ``add_postgis_srs()`` backwards compatibility alias for
  421. ``django.contrib.gis.utils.add_srs_entry()`` is removed.
  422. * Objects with a ``close()`` method such as files and generators passed to
  423. :class:`~django.http.HttpResponse` are now closed immediately instead of when
  424. the WSGI server calls ``close()`` on the response.
  425. * A redundant ``transaction.atomic()`` call in ``QuerySet.update_or_create()``
  426. is removed. This may affect query counts tested by
  427. ``TransactionTestCase.assertNumQueries()``.
  428. * Support for ``skip_validation`` in ``BaseCommand.execute(**options)`` is
  429. removed. Use ``skip_checks`` (added in Django 1.7) instead.
  430. * :djadmin:`loaddata` now raises a ``CommandError`` instead of showing a
  431. warning when the specified fixture file is not found.
  432. * Instead of directly accessing the ``LogEntry.change_message`` attribute, it's
  433. now better to call the ``LogEntry.get_change_message()`` method which will
  434. provide the message in the current language.
  435. * The default error views now raise ``TemplateDoesNotExist`` if a nonexistent
  436. ``template_name`` is specified.
  437. * The unused ``choices`` keyword argument of the ``Select`` and
  438. ``SelectMultiple`` widgets' ``render()`` method is removed. The ``choices``
  439. argument of the ``render_options()`` method is also removed, making
  440. ``selected_choices`` the first argument.
  441. * On Oracle/GIS, the :class:`~django.contrib.gis.db.models.functions.Area`
  442. aggregate function now returns a ``float`` instead of ``decimal.Decimal``.
  443. (It's still wrapped in a measure of square meters.)
  444. * Tests that violate deferrable database constraints will now error when run on
  445. a database that supports deferrable constraints.
  446. .. _deprecated-features-1.10:
  447. Features deprecated in 1.10
  448. ===========================
  449. Direct assignment to a reverse foreign key or many-to-many relation
  450. -------------------------------------------------------------------
  451. Instead of assigning related objects using direct assignment::
  452. >>> new_list = [obj1, obj2, obj3]
  453. >>> e.related_set = new_list
  454. Use the :meth:`~django.db.models.fields.related.RelatedManager.set` method
  455. added in Django 1.9::
  456. >>> e.related_set.set([obj1, obj2, obj3])
  457. This prevents confusion about an assignment resulting in an implicit save.
  458. Non-timezone-aware :class:`~django.core.files.storage.Storage` API
  459. ------------------------------------------------------------------
  460. The old, non-timezone-aware methods ``accessed_time()``, ``created_time()``,
  461. and ``modified_time()`` are deprecated in favor of the new ``get_*_time()``
  462. methods.
  463. Third-party storage backends should implement the new methods and mark the old
  464. ones as deprecated. Until then, the new ``get_*_time()`` methods on the base
  465. :class:`~django.core.files.storage.Storage` class convert ``datetime``\s from
  466. the old methods as required and emit a deprecation warning as they do so.
  467. Third-party storage backends may retain the old methods as long as they
  468. wish to support earlier versions of Django.
  469. :mod:`django.contrib.gis`
  470. -------------------------
  471. * The ``get_srid()`` and ``set_srid()`` methods of
  472. :class:`~django.contrib.gis.geos.GEOSGeometry` are deprecated in favor
  473. of the :attr:`~django.contrib.gis.geos.GEOSGeometry.srid` property.
  474. * The ``get_x()``, ``set_x()``, ``get_y()``, ``set_y()``, ``get_z()``, and
  475. ``set_z()`` methods of :class:`~django.contrib.gis.geos.Point` are deprecated
  476. in favor of the ``x``, ``y``, and ``z`` properties.
  477. * The ``get_coords()`` and ``set_coords()`` methods of
  478. :class:`~django.contrib.gis.geos.Point` are deprecated in favor of the
  479. ``tuple`` property.
  480. * The ``cascaded_union`` property of
  481. :class:`~django.contrib.gis.geos.MultiPolygon` is deprecated in favor of the
  482. :attr:`~django.contrib.gis.geos.GEOSGeometry.unary_union` property.
  483. ``CommaSeparatedIntegerField`` model field
  484. ------------------------------------------
  485. ``CommaSeparatedIntegerField`` is deprecated in favor of
  486. :class:`~django.db.models.CharField` with the
  487. :func:`~django.core.validators.validate_comma_separated_integer_list`
  488. validator::
  489. from django.core.validators import validate_comma_separated_integer_list
  490. from django.db import models
  491. class MyModel(models.Model):
  492. numbers = models.CharField(..., validators=[validate_comma_separated_integer_list])
  493. If you're using Oracle, ``CharField`` uses a different database field type
  494. (``NVARCHAR2``) than ``CommaSeparatedIntegerField`` (``VARCHAR2``). Depending
  495. on your database settings, this might imply a different encoding, and thus a
  496. different length (in bytes) for the same contents. If your stored values are
  497. longer than the 4000 byte limit of ``NVARCHAR2``, you should use ``TextField``
  498. (``NCLOB``) instead. In this case, if you have any queries that group by the
  499. field (e.g. annotating the model with an aggregation or using ``distinct()``)
  500. you'll need to change them (to defer the field).
  501. Miscellaneous
  502. -------------
  503. * The ``makemigrations --exit`` option is deprecated in favor of the
  504. :option:`makemigrations --check` option.
  505. * ``django.utils.functional.allow_lazy()`` is deprecated in favor of the new
  506. :func:`~django.utils.functional.keep_lazy` function which can be used with a
  507. more natural decorator syntax.
  508. * The ``shell --plain`` option is deprecated in favor of ``-i python`` or
  509. ``--interface python``.
  510. * Importing from the ``django.core.urlresolvers`` module is deprecated in
  511. favor of its new location, :mod:`django.urls`.
  512. * The template ``Context.has_key()`` method is deprecated in favor of ``in``.
  513. .. _removed-features-1.10:
  514. Features removed in 1.10
  515. ========================
  516. These features have reached the end of their deprecation cycle and so have been
  517. removed in Django 1.10 (please see the :ref:`deprecation timeline
  518. <deprecation-removed-in-1.10>` for more details):
  519. * Support for calling a ``SQLCompiler`` directly as an alias for calling its
  520. ``quote_name_unless_alias`` method is removed.
  521. * The ``cycle`` and ``firstof`` template tags are removed from the ``future``
  522. template tag library.
  523. * ``django.conf.urls.patterns()`` is removed.
  524. * Support for the ``prefix`` argument to
  525. ``django.conf.urls.i18n.i18n_patterns()`` is removed.
  526. * ``SimpleTestCase.urls`` is removed.
  527. * Using an incorrect count of unpacked values in the ``for`` template tag
  528. raises an exception rather than failing silently.
  529. * The ability to :func:`~django.urls.reverse` URLs using a dotted Python path
  530. is removed.
  531. * Support for ``optparse`` is dropped for custom management commands.
  532. * The class ``django.core.management.NoArgsCommand`` is removed.
  533. * ``django.core.context_processors`` module is removed.
  534. * ``django.db.models.sql.aggregates`` module is removed.
  535. * ``django.contrib.gis.db.models.sql.aggregates`` module is removed.
  536. * The following methods and properties of ``django.db.sql.query.Query`` are
  537. removed:
  538. * Properties: ``aggregates`` and ``aggregate_select``
  539. * Methods: ``add_aggregate``, ``set_aggregate_mask``, and
  540. ``append_aggregate_mask``.
  541. * ``django.template.resolve_variable`` is removed.
  542. * The following private APIs are removed from
  543. :class:`django.db.models.options.Options` (``Model._meta``):
  544. * ``get_field_by_name()``
  545. * ``get_all_field_names()``
  546. * ``get_fields_with_model()``
  547. * ``get_concrete_fields_with_model()``
  548. * ``get_m2m_with_model()``
  549. * ``get_all_related_objects()``
  550. * ``get_all_related_objects_with_model()``
  551. * ``get_all_related_many_to_many_objects()``
  552. * ``get_all_related_m2m_objects_with_model()``
  553. * The ``error_message`` argument of ``django.forms.RegexField`` is removed.
  554. * The ``unordered_list`` filter no longer supports old style lists.
  555. * Support for string ``view`` arguments to ``url()`` is removed.
  556. * The backward compatible shim to rename ``django.forms.Form._has_changed()``
  557. to ``has_changed()`` is removed.
  558. * The ``removetags`` template filter is removed.
  559. * The ``remove_tags()`` and ``strip_entities()`` functions in
  560. ``django.utils.html`` is removed.
  561. * The ``is_admin_site`` argument to
  562. ``django.contrib.auth.views.password_reset()`` is removed.
  563. * ``django.db.models.field.subclassing.SubfieldBase`` is removed.
  564. * ``django.utils.checksums`` is removed.
  565. * The ``original_content_type_id`` attribute on
  566. ``django.contrib.admin.helpers.InlineAdminForm`` is removed.
  567. * The backwards compatibility shim to allow ``FormMixin.get_form()`` to be
  568. defined with no default value for its ``form_class`` argument is removed.
  569. * The following settings are removed:
  570. * ``ALLOWED_INCLUDE_ROOTS``
  571. * ``TEMPLATE_CONTEXT_PROCESSORS``
  572. * ``TEMPLATE_DEBUG``
  573. * ``TEMPLATE_DIRS``
  574. * ``TEMPLATE_LOADERS``
  575. * ``TEMPLATE_STRING_IF_INVALID``
  576. * The backwards compatibility alias ``django.template.loader.BaseLoader`` is
  577. removed.
  578. * Django template objects returned by
  579. :func:`~django.template.loader.get_template` and
  580. :func:`~django.template.loader.select_template` no longer accept a
  581. :class:`~django.template.Context` in their
  582. :meth:`~django.template.backends.base.Template.render()` method.
  583. * :doc:`Template response APIs </ref/template-response>` enforce the use of
  584. :class:`dict` and backend-dependent template objects instead of
  585. :class:`~django.template.Context` and :class:`~django.template.Template`
  586. respectively.
  587. * The ``current_app`` parameter for the following function and classes is
  588. removed:
  589. * ``django.shortcuts.render()``
  590. * ``django.template.Context()``
  591. * ``django.template.RequestContext()``
  592. * ``django.template.response.TemplateResponse()``
  593. * The ``dictionary`` and ``context_instance`` parameters for the following
  594. functions are removed:
  595. * ``django.shortcuts.render()``
  596. * ``django.shortcuts.render_to_response()``
  597. * ``django.template.loader.render_to_string()``
  598. * The ``dirs`` parameter for the following functions is removed:
  599. * ``django.template.loader.get_template()``
  600. * ``django.template.loader.select_template()``
  601. * ``django.shortcuts.render()``
  602. * ``django.shortcuts.render_to_response()``
  603. * Session verification is enabled regardless of whether or not
  604. ``'django.contrib.auth.middleware.SessionAuthenticationMiddleware'`` is in
  605. ``MIDDLEWARE_CLASSES``. ``SessionAuthenticationMiddleware`` no longer has
  606. any purpose and can be removed from ``MIDDLEWARE_CLASSES``. It's kept as
  607. a stub until Django 2.0 as a courtesy for users who don't read this note.
  608. * Private attribute ``django.db.models.Field.related`` is removed.
  609. * The ``--list`` option of the ``migrate`` management command is removed.
  610. * The ``ssi`` template tag is removed.
  611. * Support for the ``=`` comparison operator in the ``if`` template tag is
  612. removed.
  613. * The backwards compatibility shims to allow ``Storage.get_available_name()``
  614. and ``Storage.save()`` to be defined without a ``max_length`` argument are
  615. removed.
  616. * Support for the legacy ``%(<foo>)s`` syntax in ``ModelFormMixin.success_url``
  617. is removed.
  618. * ``GeoQuerySet`` aggregate methods ``collect()``, ``extent()``, ``extent3d()``,
  619. ``make_line()``, and ``unionagg()`` are removed.
  620. * The ability to specify ``ContentType.name`` when creating a content type
  621. instance is removed.
  622. * Support for the old signature of ``allow_migrate`` is removed.
  623. * Support for the syntax of ``{% cycle %}`` that uses comma-separated arguments
  624. is removed.
  625. * The warning that :class:`~django.core.signing.Signer` issued when given an
  626. invalid separator is now a ``ValueError``.