1.11.txt 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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. Minor features
  36. --------------
  37. :mod:`django.contrib.admin`
  38. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  39. * :attr:`.ModelAdmin.date_hierarchy` can now reference fields across relations.
  40. :mod:`django.contrib.admindocs`
  41. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  42. * ...
  43. :mod:`django.contrib.auth`
  44. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  45. * The default iteration count for the PBKDF2 password hasher is increased by
  46. 20%.
  47. * The :class:`~django.contrib.auth.views.LoginView` and
  48. :class:`~django.contrib.auth.views.LogoutView` class-based views supersede the
  49. deprecated ``login()`` and ``logout()`` function-based views.
  50. * The :class:`~django.contrib.auth.views.PasswordChangeView`,
  51. :class:`~django.contrib.auth.views.PasswordChangeDoneView`,
  52. :class:`~django.contrib.auth.views.PasswordResetView`,
  53. :class:`~django.contrib.auth.views.PasswordResetDoneView`,
  54. :class:`~django.contrib.auth.views.PasswordResetConfirmView`, and
  55. :class:`~django.contrib.auth.views.PasswordResetCompleteView` class-based
  56. views supersede the deprecated ``password_change()``,
  57. ``password_change_done()``, ``password_reset()``, ``password_reset_done()``,
  58. ``password_reset_confirm()``, and ``password_reset_complete()`` function-based
  59. views.
  60. :mod:`django.contrib.contenttypes`
  61. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  62. * When stale content types are detected during a management command, there is
  63. now an expansive list of objects that will be deleted. Previously, only
  64. the content type objects themselves were listed, even if there were objects
  65. with foreign keys towards the content types that would be deleted also.
  66. :mod:`django.contrib.gis`
  67. ~~~~~~~~~~~~~~~~~~~~~~~~~
  68. * The new :meth:`.GEOSGeometry.from_gml` and :meth:`.OGRGeometry.from_gml`
  69. methods allow creating geometries from GML.
  70. :mod:`django.contrib.messages`
  71. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  72. * ...
  73. :mod:`django.contrib.postgres`
  74. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  75. * The new ``distinct`` argument for
  76. :class:`~django.contrib.postgres.aggregates.StringAgg` determines if
  77. concatenated values will be distinct.
  78. :mod:`django.contrib.redirects`
  79. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80. * ...
  81. :mod:`django.contrib.sessions`
  82. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  83. * ...
  84. :mod:`django.contrib.sitemaps`
  85. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  86. * ...
  87. :mod:`django.contrib.sites`
  88. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  89. * ...
  90. :mod:`django.contrib.staticfiles`
  91. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  92. * ...
  93. :mod:`django.contrib.syndication`
  94. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  95. * ...
  96. Cache
  97. ~~~~~
  98. * ...
  99. CSRF
  100. ~~~~
  101. * ...
  102. Database backends
  103. ~~~~~~~~~~~~~~~~~
  104. * Added the ``skip_locked`` argument to :meth:`.QuerySet.select_for_update()`
  105. on PostgreSQL 9.5+ and Oracle to execute queries with
  106. ``FOR UPDATE SKIP LOCKED``.
  107. Email
  108. ~~~~~
  109. * Added the :setting:`EMAIL_USE_LOCALTIME` setting to allow sending SMTP date
  110. headers in the local time zone rather than in UTC.
  111. File Storage
  112. ~~~~~~~~~~~~
  113. * To make it wrappable by :class:`io.TextIOWrapper`,
  114. :class:`~django.core.files.File` now has the ``readable()``, ``writable()``,
  115. and ``seekable()`` methods.
  116. File Uploads
  117. ~~~~~~~~~~~~
  118. * ...
  119. Forms
  120. ~~~~~
  121. * The new :attr:`CharField.empty_value <django.forms.CharField.empty_value>`
  122. attribute allows specifying the Python value to use to represent "empty".
  123. Generic Views
  124. ~~~~~~~~~~~~~
  125. * ...
  126. Internationalization
  127. ~~~~~~~~~~~~~~~~~~~~
  128. * Number formatting and the :setting:`NUMBER_GROUPING` setting support
  129. non-uniform digit grouping.
  130. Management Commands
  131. ~~~~~~~~~~~~~~~~~~~
  132. * The new :option:`loaddata --exclude` option allows excluding models and apps
  133. while loading data from fixtures.
  134. Migrations
  135. ~~~~~~~~~~
  136. * ...
  137. Models
  138. ~~~~~~
  139. * Added support for callable values in the ``defaults`` argument of
  140. :meth:`QuerySet.update_or_create()
  141. <django.db.models.query.QuerySet.update_or_create>` and
  142. :meth:`~django.db.models.query.QuerySet.get_or_create`.
  143. * :class:`~django.db.models.ImageField` now has a default
  144. :data:`~django.core.validators.validate_image_file_extension` validator.
  145. * Added support for time truncation to
  146. :class:`~django.db.models.functions.datetime.Trunc` functions.
  147. * Added the :class:`~django.db.models.functions.datetime.TruncTime` function
  148. to truncate :class:`~django.db.models.DateTimeField` to its time component
  149. and exposed it through the :lookup:`time` lookup.
  150. Requests and Responses
  151. ~~~~~~~~~~~~~~~~~~~~~~
  152. * Added :meth:`QueryDict.fromkeys() <django.http.QueryDict.fromkeys>`.
  153. * :class:`~django.middleware.common.CommonMiddleware` now sets the
  154. ``Content-Length`` response header for non-streaming responses.
  155. Serialization
  156. ~~~~~~~~~~~~~
  157. * The new ``django.core.serializers.base.Serializer.stream_class`` attribute
  158. allows subclasses to customize the default stream.
  159. * The encoder used by the :ref:`JSON serializer <serialization-formats-json>`
  160. can now be customized by passing a ``cls`` keyword argument to the
  161. ``serializers.serialize()`` function.
  162. * :class:`~django.core.serializers.json.DjangoJSONEncoder` now serializes
  163. :class:`~datetime.timedelta` objects (used by
  164. :class:`~django.db.models.DurationField`).
  165. Signals
  166. ~~~~~~~
  167. * ...
  168. Templates
  169. ~~~~~~~~~
  170. * :meth:`~django.utils.safestring.mark_safe` can now be used as a decorator.
  171. * The :class:`~django.template.backends.jinja2.Jinja2` template backend now
  172. supports context processors by setting the ``'context_processors'`` option in
  173. :setting:`OPTIONS <TEMPLATES-OPTIONS>`.
  174. Tests
  175. ~~~~~
  176. * Added :meth:`.DiscoverRunner.get_test_runner_kwargs` to allow customizing the
  177. keyword arguments passed to the test runner.
  178. * Added the ``debug_mode`` keyword argument to
  179. :class:`~django.test.runner.DiscoverRunner` to make it easier to customize
  180. the :setting:`DEBUG` setting when running tests.
  181. URLs
  182. ~~~~
  183. * ...
  184. Validators
  185. ~~~~~~~~~~
  186. * Added :class:`~django.core.validators.FileExtensionValidator` to validate
  187. file extensions and
  188. :data:`~django.core.validators.validate_image_file_extension` to validate
  189. image files.
  190. .. _backwards-incompatible-1.11:
  191. Backwards incompatible changes in 1.11
  192. ======================================
  193. :mod:`django.contrib.gis`
  194. -------------------------
  195. * To simplify the codebase and because it's easier to install than when
  196. ``contrib.gis`` was first released, :ref:`gdalbuild` is now a required
  197. dependency for GeoDjango. In older versions, it's only required for SQLite.
  198. Database backend API
  199. --------------------
  200. * The ``DatabaseOperations.time_trunc_sql()`` method is added to support
  201. ``TimeField`` truncation. It accepts a ``lookup_type`` and ``field_name``
  202. arguments and returns the appropriate SQL to truncate the given time field
  203. ``field_name`` to a time object with only the given specificity. The
  204. ``lookup_type`` argument can be either ``'hour'``, ``'minute'``, or
  205. ``'second'``.
  206. * The ``DatabaseOperations.datetime_cast_time_sql()`` method is added to
  207. support the :lookup:`time` lookup. It accepts a ``field_name`` and ``tzname``
  208. arguments and returns the SQL necessary to cast a datetime value to time value.
  209. * To enable ``FOR UPDATE SKIP LOCKED`` support, set
  210. ``DatabaseFeatures.has_select_for_update_skip_locked = True``.
  211. Dropped support for PostgreSQL 9.2 and PostGIS 2.0
  212. --------------------------------------------------
  213. Upstream support for PostgreSQL 9.2 ends in September 2017. As a consequence,
  214. Django 1.11 sets PostgreSQL 9.3 as the minimum version it officially supports.
  215. Support for PostGIS 2.0 is also removed as PostgreSQL 9.2 is the last version
  216. to support it.
  217. ``LiveServerTestCase`` binds to port zero
  218. -----------------------------------------
  219. Rather than taking a port range and iterating to find a free port,
  220. ``LiveServerTestCase`` binds to port zero and relies on the operating system
  221. to assign a free port. The ``DJANGO_LIVE_TEST_SERVER_ADDRESS`` environment
  222. variable is no longer used, and as it's also no longer used, the
  223. ``manage.py test --liveserver`` option is removed.
  224. Miscellaneous
  225. -------------
  226. * If no items in the feed have a ``pubdate`` or ``updateddate`` attribute,
  227. :meth:`SyndicationFeed.latest_post_date()
  228. <django.utils.feedgenerator.SyndicationFeed.latest_post_date>` now returns
  229. the current UTC date/time, instead of a datetime without any timezone
  230. information.
  231. * Support for SpatiaLite < 4.0 is dropped.
  232. * CSRF failures are logged to the ``django.security.csrf`` logger instead of
  233. ``django.request``.
  234. * :setting:`ALLOWED_HOSTS` validation is no longer disabled when running tests.
  235. If your application includes tests with custom host names, you must include
  236. those host names in :setting:`ALLOWED_HOSTS`. See
  237. :ref:`topics-testing-advanced-multiple-hosts`.
  238. * Using a foreign key's id (e.g. ``'field_id'``) in ``ModelAdmin.list_display``
  239. displays the related object's ID. Remove the ``_id`` suffix if you want the
  240. old behavior of the string representation of the object.
  241. * In model forms, :class:`~django.db.models.CharField` with ``null=True`` now
  242. saves ``NULL`` for blank values instead of empty strings.
  243. * On Oracle, :meth:`Model.validate_unique()
  244. <django.db.models.Model.validate_unique>` no longer checks empty strings for
  245. uniqueness as the database interprets the value as ``NULL``.
  246. * If you subclass :class:`.AbstractUser` and override ``clean()``, be sure it
  247. calls ``super()``. :meth:`.BaseUserManager.normalize_email` is called in a
  248. new :meth:`.AbstractUser.clean` method so that normalization is applied in
  249. cases like model form validation.
  250. * ``EmailField`` and ``URLField`` no longer accept the ``strip`` keyword
  251. argument. Remove it because it doesn't have an effect in older versions of
  252. Django as these fields alway strip whitespace.
  253. * The ``checked`` attribute rendered by form widgets now uses HTML5 boolean
  254. syntax rather than XHTML's ``checked='checked'``.
  255. * :meth:`RelatedManager.add()
  256. <django.db.models.fields.related.RelatedManager.add>`,
  257. :meth:`~django.db.models.fields.related.RelatedManager.remove`,
  258. :meth:`~django.db.models.fields.related.RelatedManager.clear`, and
  259. :meth:`~django.db.models.fields.related.RelatedManager.set` now
  260. clear the ``prefetch_related()`` cache.
  261. * To prevent possible loss of saved settings,
  262. :func:`~django.test.utils.setup_test_environment` now raises an exception if
  263. called a second time before calling
  264. :func:`~django.test.utils.teardown_test_environment`.
  265. * The :djadmin:`makemessages` command now requires configured settings, like
  266. most other commands.
  267. .. _deprecated-features-1.11:
  268. Features deprecated in 1.11
  269. ===========================
  270. Miscellaneous
  271. -------------
  272. * ``contrib.auth``’s ``login()`` and ``logout()`` function-based views are
  273. deprecated in favor of new class-based views
  274. :class:`~django.contrib.auth.views.LoginView` and
  275. :class:`~django.contrib.auth.views.LogoutView`.
  276. * The unused ``extra_context`` parameter of
  277. ``contrib.auth.views.logout_then_login()`` is deprecated.
  278. * ``contrib.auth``’s ``password_change()``, ``password_change_done()``,
  279. ``password_reset()``, ``password_reset_done()``, ``password_reset_confirm()``,
  280. and ``password_reset_complete()`` function-based views are deprecated in favor
  281. of new class-based views
  282. :class:`~django.contrib.auth.views.PasswordChangeView`,
  283. :class:`~django.contrib.auth.views.PasswordChangeDoneView`,
  284. :class:`~django.contrib.auth.views.PasswordResetView`,
  285. :class:`~django.contrib.auth.views.PasswordResetDoneView`,
  286. :class:`~django.contrib.auth.views.PasswordResetConfirmView`, and
  287. :class:`~django.contrib.auth.views.PasswordResetCompleteView`.