1.10.txt 38 KB

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