1.11.txt 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. =============================================
  2. Django 1.11 release notes - UNDER DEVELOPMENT
  3. =============================================
  4. Welcome to Django 1.11!
  5. These release notes cover the :ref:`new features <whats-new-1.11>`, as well as
  6. some :ref:`backwards incompatible changes <backwards-incompatible-1.11>` you'll
  7. want to be aware of when upgrading from Django 1.10 or older versions. We've
  8. :ref:`begun the deprecation process for some features
  9. <deprecated-features-1.11>`.
  10. See the :doc:`/howto/upgrade-version` guide if you're updating an existing
  11. project.
  12. Django 1.11 is designated as a :term:`long-term support release`. It will
  13. receive security updates for at least three years after its release. Support
  14. for the previous LTS, Django 1.8, will end in April 2018.
  15. Python compatibility
  16. ====================
  17. Like Django 1.10, Django 1.11 requires Python 2.7, 3.4, or 3.5. We **highly
  18. recommend** and only officially support the latest release of each series.
  19. The Django 1.11.x series is the last to support Python 2. The next major
  20. release, Django 2.0, will only support Python 3.5+.
  21. Deprecating warnings are no longer loud by default
  22. ==================================================
  23. Unlike older versions of Django, Django's own deprecation warnings are no
  24. longer displayed by default. This is consistent with Python's default behavior.
  25. This change allows third-party apps to support both Django 1.11 LTS and Django
  26. 1.8 LTS without having to add code to avoid deprecation warnings.
  27. Following the release of Django 2.0, we suggest that third-party app authors
  28. drop support for all versions of Django prior to 1.11. At that time, you should
  29. be able run your package's tests using ``python -Wd`` so that deprecation
  30. warnings do appear. After making the deprecation warning fixes, your app should
  31. be compatible with Django 2.0.
  32. .. _whats-new-1.11:
  33. What's new in Django 1.11
  34. =========================
  35. Class-based model indexes
  36. -------------------------
  37. The new :mod:`django.db.models.indexes` module contains classes which ease
  38. creating database indexes. Indexes are added to models using the
  39. :attr:`Meta.indexes <django.db.models.Options.indexes>` option.
  40. The :class:`~django.db.models.Index` class creates a b-tree index, as if you
  41. used :attr:`~django.db.models.Field.db_index` on the model field or
  42. :attr:`~django.db.models.Options.index_together` on the model ``Meta`` class.
  43. It can be subclassed to support different index types, such as
  44. :class:`~django.contrib.postgres.indexes.GinIndex`. It also allows defining the
  45. order (ASC/DESC) for the columns of the index.
  46. Minor features
  47. --------------
  48. :mod:`django.contrib.admin`
  49. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  50. * :attr:`.ModelAdmin.date_hierarchy` can now reference fields across relations.
  51. * The new :meth:`ModelAdmin.get_exclude()
  52. <django.contrib.admin.ModelAdmin.get_exclude>` hook allows specifying the
  53. exclude fields based on the request or model instance.
  54. :mod:`django.contrib.admindocs`
  55. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  56. * ...
  57. :mod:`django.contrib.auth`
  58. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  59. * The default iteration count for the PBKDF2 password hasher is increased by
  60. 20%.
  61. * The :class:`~django.contrib.auth.views.LoginView` and
  62. :class:`~django.contrib.auth.views.LogoutView` class-based views supersede the
  63. deprecated ``login()`` and ``logout()`` function-based views.
  64. * The :class:`~django.contrib.auth.views.PasswordChangeView`,
  65. :class:`~django.contrib.auth.views.PasswordChangeDoneView`,
  66. :class:`~django.contrib.auth.views.PasswordResetView`,
  67. :class:`~django.contrib.auth.views.PasswordResetDoneView`,
  68. :class:`~django.contrib.auth.views.PasswordResetConfirmView`, and
  69. :class:`~django.contrib.auth.views.PasswordResetCompleteView` class-based
  70. views supersede the deprecated ``password_change()``,
  71. ``password_change_done()``, ``password_reset()``, ``password_reset_done()``,
  72. ``password_reset_confirm()``, and ``password_reset_complete()`` function-based
  73. views.
  74. * The new ``post_reset_login`` attribute for
  75. :class:`~django.contrib.auth.views.PasswordResetConfirmView` allows
  76. automatically logging in a user after a successful password reset.
  77. * :func:`~django.contrib.auth.update_session_auth_hash` now rotates the session
  78. key to allow a password change to invalidate stolen session cookies.
  79. * The new ``success_url_allowed_hosts`` attribute for
  80. :class:`~django.contrib.auth.views.LoginView` and
  81. :class:`~django.contrib.auth.views.LogoutView` allows specifying a set of
  82. hosts that are safe for redirecting after login and logout.
  83. * Added password validators ``help_text`` to
  84. :class:`~django.contrib.auth.forms.UserCreationForm`.
  85. * The ``HttpRequest`` is now passed to :func:`~django.contrib.auth.authenticate`
  86. which in turn passes it to the authentication backend if it accepts a
  87. ``request`` argument.
  88. * The :func:`~django.contrib.auth.signals.user_login_failed` signal now
  89. receives a ``request`` argument.
  90. * :class:`~django.contrib.auth.forms.PasswordResetForm` supports custom user
  91. models that use an email field named something other than ``'email'``.
  92. Set :attr:`CustomUser.EMAIL_FIELD
  93. <django.contrib.auth.models.CustomUser.EMAIL_FIELD>` to the name of the field.
  94. :mod:`django.contrib.contenttypes`
  95. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  96. * When stale content types are detected in the
  97. :djadmin:`remove_stale_contenttypes` command, there's now a list of related
  98. objects such as ``auth.Permission``\s that will also be deleted. Previously,
  99. only the content types were listed (and this prompt was after ``migrate``
  100. rather than in a separate command).
  101. :mod:`django.contrib.gis`
  102. ~~~~~~~~~~~~~~~~~~~~~~~~~
  103. * The new :meth:`.GEOSGeometry.from_gml` and :meth:`.OGRGeometry.from_gml`
  104. methods allow creating geometries from GML.
  105. * Added support for the :lookup:`dwithin` lookup on SpatiaLite.
  106. * The OpenLayers-based form widgets now use ``OpenLayers.js`` from
  107. ``https://cdnjs.cloudflare.com`` which is more suitable for production use
  108. than the the old ``http://openlayers.org`` source.
  109. * PostGIS migrations can now change field dimensions.
  110. :mod:`django.contrib.messages`
  111. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  112. * ...
  113. :mod:`django.contrib.postgres`
  114. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  115. * The new ``distinct`` argument for
  116. :class:`~django.contrib.postgres.aggregates.StringAgg` determines if
  117. concatenated values will be distinct.
  118. * The new :class:`~django.contrib.postgres.indexes.GinIndex` class allows
  119. creating gin indexes in the database.
  120. * :class:`~django.contrib.postgres.fields.JSONField` accepts a new ``encoder``
  121. parameter to specify a custom class to encode data types not supported by the
  122. standard encoder.
  123. * The new :class:`~django.contrib.postgres.fields.CITextField` and
  124. :class:`~django.contrib.postgres.operations.CITextExtension` migration
  125. operation allow using PostgreSQL's ``citext`` extension for case-insensitive
  126. lookups.
  127. * The new :class:`~django.contrib.postgres.aggregates.JsonAgg` allows
  128. aggregating values as a JSON array.
  129. :mod:`django.contrib.redirects`
  130. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  131. * ...
  132. :mod:`django.contrib.sessions`
  133. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  134. * ...
  135. :mod:`django.contrib.sitemaps`
  136. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  137. * ...
  138. :mod:`django.contrib.sites`
  139. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  140. * ...
  141. :mod:`django.contrib.staticfiles`
  142. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  143. * ...
  144. :mod:`django.contrib.syndication`
  145. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  146. * ...
  147. Cache
  148. ~~~~~
  149. * Memcached backends now pass the contents of :setting:`OPTIONS <CACHES-OPTIONS>`
  150. as keyword arguments to the client constructors, allowing for more advanced
  151. control of client behavior. See the :ref:`cache arguments <cache_arguments>`
  152. documentation for examples.
  153. * Memcached backends now allow defining multiple servers as a comma-delimited
  154. string in :setting:`LOCATION <CACHES-LOCATION>`, for convenience with
  155. third-party services that use such strings in environment variables.
  156. CSRF
  157. ~~~~
  158. * ...
  159. Database backends
  160. ~~~~~~~~~~~~~~~~~
  161. * Added the ``skip_locked`` argument to :meth:`.QuerySet.select_for_update()`
  162. on PostgreSQL 9.5+ and Oracle to execute queries with
  163. ``FOR UPDATE SKIP LOCKED``.
  164. * Added the :setting:`TEST['TEMPLATE'] <TEST_TEMPLATE>` setting to let
  165. PostgreSQL users specify a template for creating the test database.
  166. Email
  167. ~~~~~
  168. * Added the :setting:`EMAIL_USE_LOCALTIME` setting to allow sending SMTP date
  169. headers in the local time zone rather than in UTC.
  170. * ``EmailMessage.attach()`` and ``attach_file()`` now fall back to MIME type
  171. ``application/octet-stream`` when binary content that can't be decoded as
  172. UTF-8 is specified for a ``text/*`` attachment.
  173. File Storage
  174. ~~~~~~~~~~~~
  175. * To make it wrappable by :class:`io.TextIOWrapper`,
  176. :class:`~django.core.files.File` now has the ``readable()``, ``writable()``,
  177. and ``seekable()`` methods.
  178. File Uploads
  179. ~~~~~~~~~~~~
  180. * ...
  181. Forms
  182. ~~~~~
  183. * The new :attr:`CharField.empty_value <django.forms.CharField.empty_value>`
  184. attribute allows specifying the Python value to use to represent "empty".
  185. * The new :meth:`Form.get_initial_for_field()
  186. <django.forms.Form.get_initial_for_field>` method returns initial data for a
  187. form field.
  188. Generic Views
  189. ~~~~~~~~~~~~~
  190. * ...
  191. Internationalization
  192. ~~~~~~~~~~~~~~~~~~~~
  193. * Number formatting and the :setting:`NUMBER_GROUPING` setting support
  194. non-uniform digit grouping.
  195. Management Commands
  196. ~~~~~~~~~~~~~~~~~~~
  197. * The new :option:`loaddata --exclude` option allows excluding models and apps
  198. while loading data from fixtures.
  199. * The unused ``BaseCommand.can_import_settings`` attribute is removed.
  200. Migrations
  201. ~~~~~~~~~~
  202. * Added support for serialization of ``uuid.UUID`` objects.
  203. Models
  204. ~~~~~~
  205. * Added support for callable values in the ``defaults`` argument of
  206. :meth:`QuerySet.update_or_create()
  207. <django.db.models.query.QuerySet.update_or_create>` and
  208. :meth:`~django.db.models.query.QuerySet.get_or_create`.
  209. * :class:`~django.db.models.ImageField` now has a default
  210. :data:`~django.core.validators.validate_image_file_extension` validator.
  211. * Added support for time truncation to
  212. :class:`~django.db.models.functions.datetime.Trunc` functions.
  213. * Added the :class:`~django.db.models.functions.datetime.TruncTime` function
  214. to truncate :class:`~django.db.models.DateTimeField` to its time component
  215. and exposed it through the :lookup:`time` lookup.
  216. * Added support for expressions in :meth:`.QuerySet.values` and
  217. :meth:`~.QuerySet.values_list`.
  218. * Added support for query expressions on lookups that take multiple arguments,
  219. such as ``range``.
  220. * You can now use the ``unique=True`` option with
  221. :class:`~django.db.models.FileField`.
  222. Requests and Responses
  223. ~~~~~~~~~~~~~~~~~~~~~~
  224. * Added :meth:`QueryDict.fromkeys() <django.http.QueryDict.fromkeys>`.
  225. * :class:`~django.middleware.common.CommonMiddleware` now sets the
  226. ``Content-Length`` response header for non-streaming responses.
  227. * Added the :setting:`SECURE_HSTS_PRELOAD` setting to allow appending the
  228. ``preload`` directive to the ``Strict-Transport-Security`` header.
  229. * :class:`~django.middleware.http.ConditionalGetMiddleware` now adds the
  230. ``ETag`` header to responses.
  231. Serialization
  232. ~~~~~~~~~~~~~
  233. * The new ``django.core.serializers.base.Serializer.stream_class`` attribute
  234. allows subclasses to customize the default stream.
  235. * The encoder used by the :ref:`JSON serializer <serialization-formats-json>`
  236. can now be customized by passing a ``cls`` keyword argument to the
  237. ``serializers.serialize()`` function.
  238. * :class:`~django.core.serializers.json.DjangoJSONEncoder` now serializes
  239. :class:`~datetime.timedelta` objects (used by
  240. :class:`~django.db.models.DurationField`).
  241. Signals
  242. ~~~~~~~
  243. * ...
  244. Templates
  245. ~~~~~~~~~
  246. * :meth:`~django.utils.safestring.mark_safe` can now be used as a decorator.
  247. * The :class:`~django.template.backends.jinja2.Jinja2` template backend now
  248. supports context processors by setting the ``'context_processors'`` option in
  249. :setting:`OPTIONS <TEMPLATES-OPTIONS>`.
  250. * The :ttag:`regroup` tag now returns ``namedtuple``\s instead of dictionaries
  251. so you can unpack the group object directly in a loop, e.g.
  252. ``{% for grouper, list in regrouped %}``.
  253. * Added a :ttag:`resetcycle` template tag to allow resetting the sequence of
  254. the :ttag:`cycle` template tag.
  255. Tests
  256. ~~~~~
  257. * Added :meth:`.DiscoverRunner.get_test_runner_kwargs` to allow customizing the
  258. keyword arguments passed to the test runner.
  259. * Added the :option:`test --debug-mode` option to help troubleshoot test
  260. failures by setting the :setting:`DEBUG` setting to ``True``.
  261. * The new :func:`django.test.utils.setup_databases` (moved from
  262. ``django.test.runner``) and :func:`~django.test.utils.teardown_databases`
  263. functions make it easier to build custom test runners.
  264. * Added support for :meth:`python:unittest.TestCase.subTest`’s when using the
  265. :option:`test --parallel` option.
  266. URLs
  267. ~~~~
  268. * ...
  269. Validators
  270. ~~~~~~~~~~
  271. * Added :class:`~django.core.validators.FileExtensionValidator` to validate
  272. file extensions and
  273. :data:`~django.core.validators.validate_image_file_extension` to validate
  274. image files.
  275. .. _backwards-incompatible-1.11:
  276. Backwards incompatible changes in 1.11
  277. ======================================
  278. :mod:`django.contrib.gis`
  279. -------------------------
  280. * To simplify the codebase and because it's easier to install than when
  281. ``contrib.gis`` was first released, :ref:`gdalbuild` is now a required
  282. dependency for GeoDjango. In older versions, it's only required for SQLite.
  283. * ``contrib.gis.maps`` is removed as it interfaces with a retired version of
  284. the Google Maps API and seems to be unmaintained. If you're using it, `let
  285. us know <https://code.djangoproject.com/ticket/14284>`_.
  286. Database backend API
  287. --------------------
  288. * The ``DatabaseOperations.time_trunc_sql()`` method is added to support
  289. ``TimeField`` truncation. It accepts a ``lookup_type`` and ``field_name``
  290. arguments and returns the appropriate SQL to truncate the given time field
  291. ``field_name`` to a time object with only the given specificity. The
  292. ``lookup_type`` argument can be either ``'hour'``, ``'minute'``, or
  293. ``'second'``.
  294. * The ``DatabaseOperations.datetime_cast_time_sql()`` method is added to
  295. support the :lookup:`time` lookup. It accepts a ``field_name`` and ``tzname``
  296. arguments and returns the SQL necessary to cast a datetime value to time value.
  297. * To enable ``FOR UPDATE SKIP LOCKED`` support, set
  298. ``DatabaseFeatures.has_select_for_update_skip_locked = True``.
  299. * The new ``DatabaseFeatures.supports_index_column_ordering`` attribute
  300. specifies if a database allows defining ordering for columns in indexes. The
  301. default value is ``True`` and the ``DatabaseIntrospection.get_constraints()``
  302. method should include an ``'orders'`` key in each of the returned
  303. dictionaries with a list of ``'ASC'`` and/or ``'DESC'`` values corresponding
  304. to the the ordering of each column in the index.
  305. * :djadmin:`inspectdb` no longer calls ``DatabaseIntrospection.get_indexes()``
  306. which is deprecated. Custom database backends should ensure all types of
  307. indexes are returned by ``DatabaseIntrospection.get_constraints()``.
  308. Dropped support for PostgreSQL 9.2 and PostGIS 2.0
  309. --------------------------------------------------
  310. Upstream support for PostgreSQL 9.2 ends in September 2017. As a consequence,
  311. Django 1.11 sets PostgreSQL 9.3 as the minimum version it officially supports.
  312. Support for PostGIS 2.0 is also removed as PostgreSQL 9.2 is the last version
  313. to support it.
  314. ``LiveServerTestCase`` binds to port zero
  315. -----------------------------------------
  316. Rather than taking a port range and iterating to find a free port,
  317. ``LiveServerTestCase`` binds to port zero and relies on the operating system
  318. to assign a free port. The ``DJANGO_LIVE_TEST_SERVER_ADDRESS`` environment
  319. variable is no longer used, and as it's also no longer used, the
  320. ``manage.py test --liveserver`` option is removed.
  321. Protection against insecure redirects in :mod:`django.contrib.auth` and ``i18n`` views
  322. --------------------------------------------------------------------------------------
  323. ``LoginView``, ``LogoutView`` (and the deprecated function-based equivalents),
  324. and :func:`~django.views.i18n.set_language` protect users from being redirected
  325. to non-HTTPS ``next`` URLs when the app is running over HTTPS.
  326. ``QuerySet.get_or_create()`` and ``update_or_create()`` validate arguments
  327. --------------------------------------------------------------------------
  328. To prevent typos from passing silently,
  329. :meth:`~django.db.models.query.QuerySet.get_or_create` and
  330. :meth:`~django.db.models.query.QuerySet.update_or_create` check that their
  331. arguments are model fields. This should be backwards-incompatible only in the
  332. fact that it might expose a bug in your project.
  333. ``pytz`` is a required dependency and support for ``settings.TIME_ZONE = None`` is removed
  334. ------------------------------------------------------------------------------------------
  335. To simplify Django's timezone handling, ``pytz`` is now a required dependency.
  336. It's automatically installed along with Django.
  337. Support for ``settings.TIME_ZONE = None`` is removed as the behavior isn't
  338. commonly used and is questionably useful. If you want to automatically detect
  339. the timezone based on the system timezone, you can use `tzlocal
  340. <https://pypi.python.org/pypi/tzlocal>`_::
  341. from tzlocal import get_localzone
  342. TIME_ZONE = get_localzone().zone
  343. This works similar to ``settings.TIME_ZONE = None`` except that it also sets
  344. ``os.environ['TZ']``. `Let us know
  345. <https://groups.google.com/d/topic/django-developers/OAV3FChfuPM/discussion>`__
  346. if there's a use case where you find you can't adapt your code to set a
  347. ``TIME_ZONE``.
  348. Miscellaneous
  349. -------------
  350. * If no items in the feed have a ``pubdate`` or ``updateddate`` attribute,
  351. :meth:`SyndicationFeed.latest_post_date()
  352. <django.utils.feedgenerator.SyndicationFeed.latest_post_date>` now returns
  353. the current UTC date/time, instead of a datetime without any timezone
  354. information.
  355. * Support for SpatiaLite < 4.0 is dropped.
  356. * CSRF failures are logged to the ``django.security.csrf`` logger instead of
  357. ``django.request``.
  358. * :setting:`ALLOWED_HOSTS` validation is no longer disabled when running tests.
  359. If your application includes tests with custom host names, you must include
  360. those host names in :setting:`ALLOWED_HOSTS`. See
  361. :ref:`topics-testing-advanced-multiple-hosts`.
  362. * Using a foreign key's id (e.g. ``'field_id'``) in ``ModelAdmin.list_display``
  363. displays the related object's ID. Remove the ``_id`` suffix if you want the
  364. old behavior of the string representation of the object.
  365. * In model forms, :class:`~django.db.models.CharField` with ``null=True`` now
  366. saves ``NULL`` for blank values instead of empty strings.
  367. * On Oracle, :meth:`Model.validate_unique()
  368. <django.db.models.Model.validate_unique>` no longer checks empty strings for
  369. uniqueness as the database interprets the value as ``NULL``.
  370. * If you subclass :class:`.AbstractUser` and override ``clean()``, be sure it
  371. calls ``super()``. :meth:`.BaseUserManager.normalize_email` is called in a
  372. new :meth:`.AbstractUser.clean` method so that normalization is applied in
  373. cases like model form validation.
  374. * ``EmailField`` and ``URLField`` no longer accept the ``strip`` keyword
  375. argument. Remove it because it doesn't have an effect in older versions of
  376. Django as these fields alway strip whitespace.
  377. * The ``checked`` and ``selected`` attribute rendered by form widgets now uses
  378. HTML5 boolean syntax rather than XHTML's ``checked='checked'`` and
  379. ``selected='selected'``.
  380. * :meth:`RelatedManager.add()
  381. <django.db.models.fields.related.RelatedManager.add>`,
  382. :meth:`~django.db.models.fields.related.RelatedManager.remove`,
  383. :meth:`~django.db.models.fields.related.RelatedManager.clear`, and
  384. :meth:`~django.db.models.fields.related.RelatedManager.set` now
  385. clear the ``prefetch_related()`` cache.
  386. * To prevent possible loss of saved settings,
  387. :func:`~django.test.utils.setup_test_environment` now raises an exception if
  388. called a second time before calling
  389. :func:`~django.test.utils.teardown_test_environment`.
  390. * The undocumented ``DateTimeAwareJSONEncoder`` alias for
  391. :class:`~django.core.serializers.json.DjangoJSONEncoder` (renamed in Django
  392. 1.0) is removed.
  393. * The :class:`cached template loader <django.template.loaders.cached.Loader>`
  394. is now enabled if :setting:`DEBUG` is ``False`` and
  395. :setting:`OPTIONS['loaders'] <TEMPLATES-OPTIONS>` isn't specified. This could
  396. be backwards-incompatible if you have some :ref:`template tags that aren't
  397. thread safe <template_tag_thread_safety>`.
  398. * The prompt for stale content type deletion no longer occurs after running the
  399. ``migrate`` command. Use the new :djadmin:`remove_stale_contenttypes` command
  400. instead.
  401. * The admin's widget for ``IntegerField`` uses ``type="number"`` rather than
  402. ``type="text"``.
  403. * Conditional HTTP headers are now parsed and compared according to the
  404. :rfc:`7232` Conditional Requests specification rather than the older
  405. :rfc:`2616`.
  406. * :func:`~django.utils.cache.patch_response_headers` no longer adds a
  407. ``Last-Modified`` header. According to the :rfc:`7234#section-4.2.2`, this
  408. header is useless alongside other caching headers that provide an explicit
  409. expiration time, e.g. ``Expires`` or ``Cache-Control``.
  410. :class:`~django.middleware.cache.UpdateCacheMiddleware` and
  411. :func:`~django.utils.cache.add_never_cache_headers` call
  412. ``patch_response_headers()`` and therefore are also affected by this change.
  413. * In the admin templates, ``<p class="help">`` is replaced with a ``<div>`` tag
  414. to allow including lists inside help text.
  415. * :class:`~django.middleware.http.ConditionalGetMiddleware` no longer sets the
  416. ``Date`` header as Web servers set that header. It also no longer sets the
  417. ``Content-Length`` header as this is now done by
  418. :class:`~django.middleware.common.CommonMiddleware`.
  419. * :meth:`~django.apps.AppConfig.get_model` and
  420. :meth:`~django.apps.AppConfig.get_models` now raise
  421. :exc:`~django.core.exceptions.AppRegistryNotReady` if they're called before
  422. models of all applications have been loaded. Previously they only required
  423. the target application's models to be loaded and thus could return models
  424. without all their relations set up. If you need the old behavior of
  425. ``get_model()``, set the ``require_ready`` argument to ``False``.
  426. .. _deprecated-features-1.11:
  427. Features deprecated in 1.11
  428. ===========================
  429. ``models.permalink()`` decorator
  430. --------------------------------
  431. Use :func:`django.urls.reverse` instead. For example::
  432. from django.db import models
  433. class MyModel(models.Model):
  434. ...
  435. @models.permalink
  436. def url(self):
  437. return ('guitarist_detail', [self.slug])
  438. becomes::
  439. from django.db import models
  440. from django.urls import reverse
  441. class MyModel(models.Model):
  442. ...
  443. def url(self):
  444. return reverse('guitarist_detail', args=[self.slug])
  445. Miscellaneous
  446. -------------
  447. * ``contrib.auth``’s ``login()`` and ``logout()`` function-based views are
  448. deprecated in favor of new class-based views
  449. :class:`~django.contrib.auth.views.LoginView` and
  450. :class:`~django.contrib.auth.views.LogoutView`.
  451. * The unused ``extra_context`` parameter of
  452. ``contrib.auth.views.logout_then_login()`` is deprecated.
  453. * ``contrib.auth``’s ``password_change()``, ``password_change_done()``,
  454. ``password_reset()``, ``password_reset_done()``, ``password_reset_confirm()``,
  455. and ``password_reset_complete()`` function-based views are deprecated in favor
  456. of new class-based views
  457. :class:`~django.contrib.auth.views.PasswordChangeView`,
  458. :class:`~django.contrib.auth.views.PasswordChangeDoneView`,
  459. :class:`~django.contrib.auth.views.PasswordResetView`,
  460. :class:`~django.contrib.auth.views.PasswordResetDoneView`,
  461. :class:`~django.contrib.auth.views.PasswordResetConfirmView`, and
  462. :class:`~django.contrib.auth.views.PasswordResetCompleteView`.
  463. * ``django.test.runner.setup_databases()`` is moved to
  464. :func:`django.test.utils.setup_databases`. The old location is deprecated.
  465. * ``django.utils.translation.string_concat()`` is deprecated in
  466. favor of :func:`django.utils.text.format_lazy`. ``string_concat(*strings)``
  467. can be replaced by ``format_lazy('{}' * len(strings), *strings)``.
  468. * For the ``PyLibMCCache`` cache backend, passing ``pylibmc`` behavior settings
  469. as top-level attributes of ``OPTIONS`` is deprecated. Set them under a
  470. ``behaviors`` key within ``OPTIONS`` instead.
  471. * The ``host`` parameter of ``django.utils.http.is_safe_url()`` is deprecated
  472. in favor of the new ``allowed_hosts`` parameter.
  473. * Silencing exceptions raised while rendering the
  474. :ttag:`{% include %} <include>` template tag is deprecated as the behavior is
  475. often more confusing than helpful. In Django 2.1, the exception will be
  476. raised.
  477. * ``DatabaseIntrospection.get_indexes()`` is deprecated in favor of
  478. ``DatabaseIntrospection.get_constraints()``.
  479. * :func:`~django.contrib.auth.authenticate` now passes a ``request`` argument
  480. to the ``authenticate()`` method of authentication backends. Support for
  481. methods that don't accept ``request`` will be removed in Django 2.1.
  482. * The ``USE_ETAGS`` setting is deprecated in favor of
  483. :class:`~django.middleware.http.ConditionalGetMiddleware` which now adds the
  484. ``ETag`` header to responses regardless of the setting. ``CommonMiddleware``
  485. and ``django.utils.cache.patch_response_headers()`` will no longer set ETags
  486. when the deprecation ends.