1.8.txt 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  1. ============================================
  2. Django 1.8 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. Welcome to Django 1.8!
  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.6 or older versions. We've also `begun the deprecation process for some
  8. features`_, and some features have reached the end of their deprecation process
  9. and `have been removed`_.
  10. Django 1.8 has been designated as Django's second :ref:`"Long-Term Support"
  11. (LTS) <lts-releases>` release. It will receive security updates for at least
  12. three years after its release. Support for the previous LTS, Django 1.4, will
  13. end 6 months from the release date of Django 1.8.
  14. .. _`new features`: `What's new in Django 1.8`_
  15. .. _`backwards incompatible changes`: `Backwards incompatible changes in 1.8`_
  16. .. _`begun the deprecation process for some features`: `Features deprecated in 1.8`_
  17. .. _`have been removed`: `Features removed in 1.8`_
  18. Python compatibility
  19. ====================
  20. Like Django 1.7, Django 1.8 requires Python 2.7 or above, though we
  21. **highly recommend** the latest minor release.
  22. What's new in Django 1.8
  23. ========================
  24. Security enhancements
  25. ~~~~~~~~~~~~~~~~~~~~~
  26. Several features of the django-secure_ third-party library have been
  27. integrated into Django. :class:`django.middleware.security.SecurityMiddleware`
  28. provides several security enhancements to the request/response cycle. The new
  29. :djadminopt:`--deploy` option of the :djadmin:`check` command allows you to
  30. check your production settings file for ways to increase the security of your
  31. site.
  32. .. _django-secure: https://pypi.python.org/pypi/django-secure
  33. New PostgreSQL specific functionality
  34. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. Django now has a module with extensions for PostgreSQL specific features, such
  36. as :class:`~django.contrib.postgres.fields.ArrayField` and
  37. :class:`~django.contrib.postgres.fields.HStoreField`. A full breakdown of the
  38. features is available :doc:`in the documentation</ref/contrib/postgres/index>`.
  39. New data types
  40. ~~~~~~~~~~~~~~
  41. * Django now has a :class:`~django.db.models.UUIDField` for storing
  42. universally unique identifiers. There is a corresponding :class:`form field
  43. <django.forms.UUIDField>`. It is stored as the native ``uuid`` data type on
  44. PostgreSQL and as a fixed length character field on other backends.
  45. Query Expressions
  46. ~~~~~~~~~~~~~~~~~
  47. :doc:`Query Expressions </ref/models/expressions>` allow users to create,
  48. customize, and compose complex SQL expressions. This has enabled annotate
  49. to accept expressions other than aggregates. Aggregates are now able to
  50. reference multiple fields, as well as perform arithmetic, similar to ``F()``
  51. objects.
  52. Minor features
  53. ~~~~~~~~~~~~~~
  54. :mod:`django.contrib.admin`
  55. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  56. * :class:`~django.contrib.admin.ModelAdmin` now has a
  57. :meth:`~django.contrib.admin.ModelAdmin.has_module_permission`
  58. method to allow limiting access to the module on the admin index page.
  59. * :class:`~django.contrib.admin.InlineModelAdmin` now has an attribute
  60. :attr:`~django.contrib.admin.InlineModelAdmin.show_change_link` that
  61. supports showing a link to an inline object's change form.
  62. * Use the new ``django.contrib.admin.RelatedOnlyFieldListFilter`` in
  63. :attr:`ModelAdmin.list_filter <django.contrib.admin.ModelAdmin.list_filter>`
  64. to limit the ``list_filter`` choices to foreign objects which are attached to
  65. those from the ``ModelAdmin``.
  66. * The :meth:`ModelAdmin.delete_view()
  67. <django.contrib.admin.ModelAdmin.delete_view>` displays a summary of objects
  68. to be deleted on the deletion confirmation page.
  69. * The jQuery library embedded in the admin has been upgraded to version 1.11.1.
  70. * You can now specify :attr:`AdminSite.site_url
  71. <django.contrib.admin.AdminSite.site_url>` in order to display a link to the
  72. front-end site.
  73. * You can now specify :attr:`ModelAdmin.show_full_result_count
  74. <django.contrib.admin.ModelAdmin.show_full_result_count>` to control whether
  75. or not the full count of objects should be displayed on a filtered admin page.
  76. :mod:`django.contrib.admindocs`
  77. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  78. * reStructuredText is now parsed in model docstrings.
  79. :mod:`django.contrib.auth`
  80. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  81. * Authorization backends can now raise
  82. :class:`~django.core.exceptions.PermissionDenied` in
  83. :meth:`~django.contrib.auth.models.User.has_perm`
  84. and :meth:`~django.contrib.auth.models.User.has_module_perms`
  85. to short-circuit permission checking.
  86. * :class:`~django.contrib.auth.forms.PasswordResetForm` now
  87. has a method :meth:`~django.contrib.auth.forms.PasswordResetForm.send_email`
  88. that can be overridden to customize the mail to be sent.
  89. * The ``max_length`` of :attr:`Permission.name
  90. <django.contrib.auth.models.Permission.name>` has been increased from 50 to
  91. 255 characters. Please run the database migration.
  92. * :attr:`~django.contrib.auth.models.CustomUser.USERNAME_FIELD` and
  93. :attr:`~django.contrib.auth.models.CustomUser.REQUIRED_FIELDS` now supports
  94. :class:`~django.db.models.ForeignKey`\s.
  95. :mod:`django.contrib.formtools`
  96. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  97. * A :doc:`form wizard </ref/contrib/formtools/form-wizard>` using the
  98. :class:`~django.contrib.formtools.wizard.views.CookieWizardView` will now ignore
  99. an invalid cookie, and the wizard will restart from the first step. An invalid
  100. cookie can occur in cases of intentional manipulation, but also after a secret
  101. key change. Previously, this would raise ``WizardViewCookieModified``, a
  102. ``SuspiciousOperation``, causing an exception for any user with an invalid cookie
  103. upon every request to the wizard, until the cookie is removed.
  104. :mod:`django.contrib.gis`
  105. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  106. * A new :doc:`GeoJSON serializer </ref/contrib/gis/serializers>` is now
  107. available.
  108. * The Spatialite backend now supports ``Collect`` and ``Extent`` aggregates
  109. when the database version is 3.0 or later.
  110. * Compatibility shims for ``SpatialRefSys`` and ``GeometryColumns`` changed in
  111. Django 1.2 have been removed.
  112. :mod:`django.contrib.messages`
  113. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  114. * ...
  115. :mod:`django.contrib.redirects`
  116. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  117. * ...
  118. :mod:`django.contrib.sessions`
  119. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  120. * Session cookie is now deleted after
  121. :meth:`~django.contrib.sessions.backends.base.SessionBase.flush()` is called.
  122. :mod:`django.contrib.sitemaps`
  123. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  124. * The new :attr:`Sitemap.i18n <django.contrib.sitemaps.Sitemap.i18n>` attribute
  125. allows you to generate a sitemap based on the :setting:`LANGUAGES` setting.
  126. :mod:`django.contrib.sites`
  127. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  128. * :func:`~django.contrib.sites.shortcuts.get_current_site` will now lookup
  129. the current site based on :meth:`request.get_host()
  130. <django.http.HttpRequest.get_host>` if the :setting:`SITE_ID` setting is not
  131. defined.
  132. :mod:`django.contrib.staticfiles`
  133. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  134. * ...
  135. :mod:`django.contrib.syndication`
  136. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  137. * ...
  138. Cache
  139. ^^^^^
  140. * The ``incr()`` method of the
  141. ``django.core.cache.backends.locmem.LocMemCache`` backend is now thread-safe.
  142. Cryptography
  143. ^^^^^^^^^^^^
  144. * The ``max_age`` parameter of the
  145. :meth:`django.core.signing.TimestampSigner.unsign` method now also accept a
  146. :py:class:`datetime.timedelta` object.
  147. Database backends
  148. ^^^^^^^^^^^^^^^^^
  149. * The MySQL backend no longer strips microseconds from ``datetime`` values as
  150. MySQL 5.6.4 and up supports fractional seconds depending on the declaration
  151. of the datetime field (when ``DATETIME`` includes fractional precision greater
  152. than 0). New datetime database columns created with Django 1.8 and MySQL 5.6.4
  153. and up will support microseconds. See the :ref:`MySQL database notes
  154. <mysql-fractional-seconds>` for more details.
  155. Email
  156. ^^^^^
  157. * :ref:`Email backends <topic-email-backends>` now support the context manager
  158. protocol for opening and closing connections.
  159. * The SMTP email backend now supports ``keyfile`` and ``certfile``
  160. authentication with the :setting:`EMAIL_SSL_CERTFILE` and
  161. :setting:`EMAIL_SSL_KEYFILE` settings.
  162. * The SMTP :class:`~django.core.mail.backends.smtp.EmailBackend` now supports
  163. setting the ``timeout`` parameter with the :setting:`EMAIL_TIMEOUT` setting.
  164. File Storage
  165. ^^^^^^^^^^^^
  166. * ...
  167. File Uploads
  168. ^^^^^^^^^^^^
  169. * ...
  170. Forms
  171. ^^^^^
  172. * Form widgets now render attributes with a value of ``True`` or ``False``
  173. as HTML5 boolean attributes.
  174. * The new :meth:`~django.forms.Form.has_error()` method allows checking
  175. if a specific error has happened.
  176. * If :attr:`~django.forms.Form.required_css_class` is defined on a form, then
  177. the ``<label>`` tags for required fields will have this class present in its
  178. attributes.
  179. * The rendering of non-field errors in unordered lists (``<ul>``) now includes
  180. ``nonfield`` in its list of classes to distinguish them from field-specific
  181. errors.
  182. * :class:`~django.forms.Field` now accepts a
  183. :attr:`~django.forms.Field.label_suffix` argument, which will override the
  184. form's :attr:`~django.forms.Form.label_suffix`. This enables customizing the
  185. suffix on a per-field basis — previously it wasn't possible to override
  186. a form's :attr:`~django.forms.Form.label_suffix` while using shortcuts such
  187. as ``{{ form.as_p }}`` in templates.
  188. * :class:`~django.forms.extras.widgets.SelectDateWidget` now accepts an
  189. :attr:`~django.forms.extras.widgets.SelectDateWidget.empty_label` argument, which will
  190. override the top list choice label when :class:`~django.forms.DateField` is not required.
  191. * After an :class:`~django.forms.ImageField` has been cleaned and validated, the
  192. ``UploadedFile`` object will have an additional ``image`` attribute containing
  193. the Pillow ``Image`` instance used to check if the file was a valid image. It
  194. will also update ``UploadedFile.content_type`` with the image's content type
  195. as determined by Pillow.
  196. * You can now pass a callable that returns an iterable of choices when
  197. instantiating a :class:`~django.forms.ChoiceField`.
  198. Generic Views
  199. ^^^^^^^^^^^^^
  200. * Generic views that use :class:`~django.views.generic.list.MultipleObjectMixin`
  201. may now specify the ordering applied to the
  202. :attr:`~django.views.generic.list.MultipleObjectMixin.queryset` by setting
  203. :attr:`~django.views.generic.list.MultipleObjectMixin.ordering` or overriding
  204. :meth:`~django.views.generic.list.MultipleObjectMixin.get_ordering()`.
  205. * The new :attr:`SingleObjectMixin.query_pk_and_slug
  206. <django.views.generic.detail.SingleObjectMixin.query_pk_and_slug>`
  207. attribute allows changing the behavior of
  208. :meth:`~django.views.generic.detail.SingleObjectMixin.get_object()`
  209. so that it'll perform its lookup using both the primary key and the slug.
  210. * The :meth:`~django.views.generic.edit.FormMixin.get_form()` method doesn't
  211. require a ``form_class`` to be provided anymore. If not provided ``form_class``
  212. defaults to :meth:`~django.views.generic.edit.FormMixin.get_form_class()`.
  213. Internationalization
  214. ^^^^^^^^^^^^^^^^^^^^
  215. * :setting:`FORMAT_MODULE_PATH` can now be a list of strings representing
  216. module paths. This allows importing several format modules from different
  217. reusable apps. It also allows overriding those custom formats in your main
  218. Django project.
  219. Logging
  220. ^^^^^^^
  221. * The :class:`django.utils.log.AdminEmailHandler` class now has a
  222. :meth:`~django.utils.log.AdminEmailHandler.send_mail` method to make it more
  223. subclass friendly.
  224. Management Commands
  225. ^^^^^^^^^^^^^^^^^^^
  226. * :djadmin:`dumpdata` now has the option :djadminopt:`--output` which allows
  227. specifying the file to which the serialized data is written.
  228. * :djadmin:`makemessages` and :djadmin:`compilemessages` now have the option
  229. :djadminopt:`--exclude` which allows exclusion of specific locales from
  230. processing.
  231. * :djadmin:`compilemessages` now has a ``--use-fuzzy`` or ``-f`` option which
  232. includes fuzzy translations into compiled files.
  233. * The :djadminopt:`--ignorenonexistent` option of the :djadmin:`loaddata`
  234. management command now ignores data for models that no longer exist.
  235. * :djadmin:`runserver` now uses daemon threads for faster reloading.
  236. * :djadmin:`inspectdb` now outputs ``Meta.unique_together``. It is also able to
  237. introspect :class:`~django.db.models.AutoField` for MySQL and PostgreSQL
  238. databases.
  239. * When calling management commands from code through :ref:`call_command
  240. <call-command>` and passing options, the option name can match the command
  241. line option name (without the initial dashes) or the final option destination
  242. variable name, but in either case, the resulting option received by the
  243. command is now always the ``dest`` name specified in the command option
  244. definition (as long as the command uses the new :py:mod:`argparse` module).
  245. * The :djadmin:`dbshell` command now supports MySQL's optional SSL certificate
  246. authority setting (``--ssl-ca``).
  247. * The :djadminopt:`--name` option for :djadmin:`makemigrations` allows you to
  248. to give the migration(s) a custom name instead of a generated one.
  249. * The :djadmin:`loaddata` command now prevents repeated fixture loading. If
  250. :setting:`FIXTURE_DIRS` contains duplicates or a default fixture directory
  251. path (``app_name/fixtures``), an exception is raised.
  252. Middleware
  253. ^^^^^^^^^^
  254. * The :attr:`CommonMiddleware.response_redirect_class
  255. <django.middleware.common.CommonMiddleware.response_redirect_class>`
  256. attribute allows you to customize the redirects issued by the middleware.
  257. Migrations
  258. ^^^^^^^^^^
  259. * The :class:`~django.db.migrations.operations.RunSQL` operation can now handle
  260. parameters passed to the SQL statements.
  261. * It is now possible to have migrations (most probably :ref:`data migrations
  262. <data-migrations>`) for applications without models.
  263. Models
  264. ^^^^^^
  265. * Django now logs at most 9000 queries in ``connections.queries``, in order
  266. to prevent excessive memory usage in long-running processes in debug mode.
  267. * There is now a model ``Meta`` option to define a
  268. :attr:`default related name <django.db.models.Options.default_related_name>`
  269. for all relational fields of a model.
  270. * Pickling models and querysets across different versions of Django isn't
  271. officially supported (it may work, but there's no guarantee). An extra
  272. variable that specifies the current Django version is now added to the
  273. pickled state of models and querysets, and Django raises a ``RuntimeWarning``
  274. when these objects are unpickled in a different version than the one in
  275. which they were pickled.
  276. * Added :meth:`Model.from_db() <django.db.models.Model.from_db()>` which
  277. Django uses whenever objects are loaded using the ORM. The method allows
  278. customizing model loading behavior.
  279. * ``extra(select={...})`` now allows you to escape a literal ``%s`` sequence
  280. using ``%%s``.
  281. * :doc:`Custom Lookups</howto/custom-lookups>` can now be registered using
  282. a decorator pattern.
  283. * The new :attr:`Transform.bilateral <django.db.models.Transform.bilateral>`
  284. attribute allows creating bilateral transformations. These transformations
  285. are applied to both ``lhs`` and ``rhs`` when used in a lookup expression,
  286. providing opportunities for more sophisticated lookups.
  287. Signals
  288. ^^^^^^^
  289. * Exceptions from the ``(receiver, exception)`` tuples returned by
  290. :meth:`Signal.send_robust() <django.dispatch.Signal.send_robust>` now have
  291. their traceback attached as a ``__traceback__`` attribute.
  292. * The ``environ`` argument, which contains the WSGI environment structure from
  293. the request, was added to the :data:`~django.core.signals.request_started`
  294. signal.
  295. System Check Framework
  296. ^^^^^^^^^^^^^^^^^^^^^^
  297. * :attr:`~django.core.checks.register` can now be used as a function.
  298. Templates
  299. ^^^^^^^^^
  300. * :tfilter:`urlize` now supports domain-only links that include characters after
  301. the top-level domain (e.g. ``djangoproject.com/`` and
  302. ``djangoproject.com/download/``).
  303. * :tfilter:`urlize` doesn't treat exclamation marks at the end of a domain or
  304. its query string as part of the URL (the URL in e.g. ``'djangoproject.com!``
  305. is ``djangoproject.com``)
  306. * Added a :class:`locmem.Loader <django.template.loaders.locmem.Loader>`
  307. class that loads Django templates from a Python dictionary.
  308. Requests and Responses
  309. ^^^^^^^^^^^^^^^^^^^^^^
  310. * ``WSGIRequest`` now respects paths starting with ``//``.
  311. * The :meth:`HttpRequest.build_absolute_uri()
  312. <django.http.HttpRequest.build_absolute_uri>` method now handles paths
  313. starting with ``//`` correctly.
  314. * If :setting:`DEBUG` is ``True`` and a request raises a
  315. :exc:`~django.core.exceptions.SuspiciousOperation`, the response will be
  316. rendered with a detailed error page.
  317. * The ``query_string`` argument of :class:`~django.http.QueryDict` is now
  318. optional, defaulting to ``None``, so a blank ``QueryDict`` can now be
  319. instantiated with ``QueryDict()`` instead of ``QueryDict(None)`` or
  320. ``QueryDict('')``.
  321. * The ``GET`` and ``POST`` attributes of an :class:`~django.http.HttpRequest`
  322. object are now :class:`~django.http.QueryDict`\s rather than dictionaries,
  323. and the ``FILES`` attribute is now a ``MultiValueDict``.
  324. This brings this class into line with the documentation and with
  325. ``WSGIRequest``.
  326. * The :attr:`HttpResponse.charset <django.http.HttpResponse.charset>` attribute
  327. was added.
  328. * ``WSGIRequestHandler`` now follows RFC in converting URI to IRI, using
  329. ``uri_to_iri()``.
  330. * The :meth:`HttpRequest.get_full_path()
  331. <django.http.HttpRequest.get_full_path>` method now escapes unsafe characters
  332. from the path portion of a Uniform Resource Identifier (URI) properly.
  333. * :class:`~django.http.HttpResponse` now implements a few additional methods
  334. like :meth:`~django.http.HttpResponse.getvalue` so that instances can be used
  335. as stream objects.
  336. Tests
  337. ^^^^^
  338. * The :class:`RequestFactory.trace() <django.test.RequestFactory>`
  339. and :class:`Client.trace() <django.test.Client.trace>` methods were
  340. implemented, allowing you to create ``TRACE`` requests in your tests.
  341. * The ``count`` argument was added to
  342. :meth:`~django.test.SimpleTestCase.assertTemplateUsed`. This allows you to
  343. assert that a template was rendered a specific number of times.
  344. * The new :meth:`~django.test.SimpleTestCase.assertJSONNotEqual` assertion
  345. allows you to test that two JSON fragments are not equal.
  346. * Added options to the :djadmin:`test` command to preserve the test database
  347. (:djadminopt:`--keepdb`) and to run the test cases in reverse order
  348. (:djadminopt:`--reverse`).
  349. * Added the :attr:`~django.test.Response.resolver_match` attribute to test
  350. client responses.
  351. * Added several settings that allow customization of test tablespace parameters
  352. for Oracle: :setting:`DATAFILE`, :setting:`DATAFILE_TMP`,
  353. :setting:`DATAFILE_MAXSIZE` and :setting:`DATAFILE_TMP_MAXSIZE`.
  354. Validators
  355. ^^^^^^^^^^
  356. * ...
  357. Backwards incompatible changes in 1.8
  358. =====================================
  359. .. warning::
  360. In addition to the changes outlined in this section, be sure to review the
  361. :ref:`deprecation plan <deprecation-removed-in-1.8>` for any features that
  362. have been removed. If you haven't updated your code within the
  363. deprecation timeline for a given feature, its removal may appear as a
  364. backwards incompatible change.
  365. Related object operations are run in a transaction
  366. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  367. Some operations on related objects such as
  368. :meth:`~django.db.models.fields.related.RelatedManager.add()` or
  369. :ref:`direct assignment<direct-assignment>` ran multiple data modifying
  370. queries without wrapping them in transactions. To reduce the risk of data
  371. corruption, all data modifying methods that affect multiple related objects
  372. (i.e. ``add()``, ``remove()``, ``clear()``, and :ref:`direct assignment
  373. <direct-assignment>`) now perform their data modifying queries from within a
  374. transaction, provided your database supports transactions.
  375. This has one backwards incompatible side effect, signal handlers triggered from
  376. these methods are now executed within the method's transaction and any
  377. exception in a signal handler will prevent the whole operation.
  378. Assigning unsaved objects to relations raises an error
  379. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  380. Assigning unsaved objects to a :class:`~django.db.models.ForeignKey`,
  381. :class:`~django.contrib.contenttypes.fields.GenericForeignKey`, and
  382. :class:`~django.db.models.OneToOneField` now raises a :exc:`ValueError`.
  383. Previously, the assignment of an unsaved object would be silently ignored.
  384. For example::
  385. >>> book = Book.objects.create(name="Django")
  386. >>> book.author = Author(name="John")
  387. >>> book.author.save()
  388. >>> book.save()
  389. >>> Book.objects.get(name="Django")
  390. >>> book.author
  391. >>>
  392. Now, an error will be raised to prevent data loss::
  393. >>> book.author = Author(name="john")
  394. Traceback (most recent call last):
  395. ...
  396. ValueError: Cannot assign "<Author: John>": "Author" instance isn't saved in the database.
  397. Management commands that only accept positional arguments
  398. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  399. If you have written a custom management command that only accepts positional
  400. arguments and you didn't specify the
  401. :attr:`~django.core.management.BaseCommand.args` command variable, you might
  402. get an error like ``Error: unrecognized arguments: ...``, as variable parsing
  403. is now based on :py:mod:`argparse` which doesn't implicitly accept positional
  404. arguments. You can make your command backwards compatible by simply setting the
  405. :attr:`~django.core.management.BaseCommand.args` class variable. However, if
  406. you don't have to keep compatibility with older Django versions, it's better to
  407. implement the new :meth:`~django.core.management.BaseCommand.add_arguments`
  408. method as described in :doc:`/howto/custom-management-commands`.
  409. Custom test management command arguments through test runner
  410. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  411. The method to add custom arguments to the `test` management command through the
  412. test runner has changed. Previously, you could provide an `option_list` class
  413. variable on the test runner to add more arguments (à la :py:mod:`optparse`).
  414. Now to implement the same behavior, you have to create an
  415. ``add_arguments(cls, parser)`` class method on the test runner and call
  416. ``parser.add_argument`` to add any custom arguments, as parser is now an
  417. :py:class:`argparse.ArgumentParser` instance.
  418. Model check ensures auto-generated column names are within limits specified by database
  419. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  420. A field name that's longer than the column name length supported by a database
  421. can create problems. For example, with MySQL you'll get an exception trying to
  422. create the column, and with PostgreSQL the column name is truncated by the
  423. database (you may see a warning in the PostgreSQL logs).
  424. A model check has been introduced to better alert users to this scenario before
  425. the actual creation of database tables.
  426. If you have an existing model where this check seems to be a false positive,
  427. for example on PostgreSQL where the name was already being truncated, simply
  428. use :attr:`~django.db.models.Field.db_column` to specify the name that's being
  429. used.
  430. The check also applies to the columns generated in an implicit
  431. ``ManyToManyField.through`` model. If you run into an issue there, use
  432. :attr:`~django.db.models.ManyToManyField.through` to create an explicit model
  433. and then specify :attr:`~django.db.models.Field.db_column` on its column(s)
  434. as needed.
  435. Query relation lookups now check object types
  436. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  437. Querying for model lookups now checks if the object passed is of correct type
  438. and raises a :exc:`ValueError` if not. Previously, Django didn't care if the
  439. object was of correct type; it just used the object's related field attribute
  440. (e.g. ``id``) for the lookup. Now, an error is raised to prevent incorrect
  441. lookups::
  442. >>> book = Book.objects.create(name="Django")
  443. >>> book = Book.objects.filter(author=book)
  444. Traceback (most recent call last):
  445. ...
  446. ValueError: Cannot query "<Book: Django>": Must be "Author" instance.
  447. Default ``EmailField.max_length`` increased to 254
  448. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  449. The old default 75 character ``max_length`` was not capable of storing all
  450. possible RFC3696/5321-compliant email addresses. In order to store all
  451. possible valid email addresses, the ``max_length`` has been increased to 254
  452. characters. You will need to generate and apply database migrations for your
  453. affected models (or add ``max_length=75`` if you wish to keep the length on
  454. your current fields). A migration for
  455. :attr:`django.contrib.auth.models.User.email` is included.
  456. Support for PostgreSQL versions older than 9.0
  457. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  458. The end of upstream support periods was reached in July 2014 for PostgreSQL 8.4.
  459. As a consequence, Django 1.8 sets 9.0 as the minimum PostgreSQL version it
  460. officially supports.
  461. This also includes dropping support for PostGIS 1.3 and 1.4 as these versions
  462. are not supported on versions of PostgreSQL later than 8.4.
  463. Django also now requires the use of Psycopg2 version 2.0.9 or higher.
  464. Support for MySQL versions older than 5.5
  465. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  466. The end of upstream support periods was reached in January 2012 for MySQL 5.0
  467. and December 2013 for MySQL 5.1. As a consequence, Django 1.8 sets 5.5 as the
  468. minimum MySQL version it officially supports.
  469. Support for Oracle versions older than 11.1
  470. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  471. The end of upstream support periods was reached in July 2010 for Oracle 9.2,
  472. January 2012 for Oracle 10.1, and July 2013 for Oracle 10.2. As a consequence,
  473. Django 1.8 sets 11.1 as the minimum Oracle version it officially supports.
  474. Specific privileges used instead of roles for tests on Oracle
  475. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  476. Earlier versions of Django granted the CONNECT and RESOURCE roles to the test
  477. user on Oracle. These roles have been deprecated, so Django 1.8 uses the
  478. specific underlying privileges instead. This changes the privileges required
  479. of the main user for running tests (unless the project is configured to avoid
  480. creating a test user). The exact privileges required now are detailed in
  481. :ref:`Oracle notes <oracle-notes>`.
  482. ``AbstractUser.last_login`` allows null values
  483. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  484. The :attr:`AbstractUser.last_login <django.contrib.auth.models.User.last_login>`
  485. field now allows null values. Previously, it defaulted to the time when the user
  486. was created which was misleading if the user never logged in. Please run the
  487. database migration. If your custom user inherits from ``AbstractUser`` and you
  488. wish to set ``last_login`` to ``NULL`` for users who haven't logged in, you can
  489. run this query::
  490. from django.db import models
  491. from django.contrib.auth import get_user_model
  492. from django.contrib.auth.models import AbstractBaseUser
  493. UserModel = get_user_model()
  494. if issubclass(UserModel, AbstractBaseUser):
  495. UserModel._default_manager.filter(
  496. last_login=models.F('date_joined')
  497. ).update(last_login=None)
  498. :mod:`django.contrib.gis`
  499. ~~~~~~~~~~~~~~~~~~~~~~~~~
  500. * Support for GEOS 3.1 and GDAL 1.6 has been dropped.
  501. * Support for SpatiaLite < 2.4 has been dropped.
  502. * GIS-specific lookups have been refactored to use the
  503. :class:`django.db.models.Lookup` API.
  504. * The default ``str`` representation of
  505. :class:`~django.contrib.gis.geos.GEOSGeometry` objects has been changed from
  506. WKT to EWKT format (including the SRID). As this representation is used in
  507. the serialization framework, that means that ``dumpdata`` output will now
  508. contain the SRID value of geometry objects.
  509. Priority of context processors for ``TemplateResponse`` brought in line with ``render``
  510. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  511. The :class:`~django.template.response.TemplateResponse` constructor is designed to be a
  512. drop-in replacement for the :func:`~django.shortcuts.render` function. However,
  513. it had a slight incompatibility, in that for ``TemplateResponse``, context data
  514. from the passed in context dictionary could be shadowed by context data returned
  515. from context processors, whereas for ``render`` it was the other way
  516. around. This was a bug, and the behavior of ``render`` is more appropriate,
  517. since it allows the globally defined context processors to be overridden locally
  518. in the view. If you were relying on the fact context data in a
  519. ``TemplateResponse`` could be overridden using a context processor, you will
  520. need to change your code.
  521. Overriding ``setUpClass`` / ``tearDownClass`` in test cases
  522. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  523. The decorators :func:`~django.test.override_settings` and
  524. :func:`~django.test.modify_settings` now act at the class level when used as
  525. class decorators. As a consequence, when overriding ``setUpClass()`` or
  526. ``tearDownClass()``, the ``super`` implementation should always be called.
  527. Miscellaneous
  528. ~~~~~~~~~~~~~
  529. * ``connections.queries`` is now a read-only attribute.
  530. * Database connections are considered equal only if they're the same object.
  531. They aren't hashable any more.
  532. * :class:`~django.middleware.gzip.GZipMiddleware` used to disable compression
  533. for some content types when the request is from Internet Explorer, in order
  534. to work around a bug in IE6 and earlier. This behavior could affect
  535. performance on IE7 and later. It was removed.
  536. * ``URLField.to_python`` no longer adds a trailing slash to pathless URLs.
  537. * The :tfilter:`length` template filter now returns ``0`` for an undefined
  538. variable, rather than an empty string.
  539. * ``ForeignKey.default_error_message['invalid']`` has been changed from
  540. ``'%(model)s instance with pk %(pk)r does not exist.'`` to
  541. ``'%(model)s instance with %(field)s %(value)r does not exist.'`` If you are
  542. using this message in your own code, please update the list of interpolated
  543. parameters. Internally, Django will continue to provide the
  544. ``pk`` parameter in ``params`` for backwards compatibility.
  545. * ``UserCreationForm.errors_messages['duplicate_username']`` is no longer used.
  546. If you wish to customize that error message, :ref:`override it on the form
  547. <modelforms-overriding-default-fields>` using the ``'unique'`` key in
  548. ``Meta.errors_messages['username']`` or, if you have a custom form field for
  549. ``'username'``, using the the ``'unique'`` key in its
  550. :attr:`~django.forms.Field.error_messages` argument.
  551. * ``AdminSite`` no longer takes an ``app_name`` argument and its ``app_name``
  552. attribute has been removed. The application name is always ``admin`` (as
  553. opposed to the instance name which you can still customize using
  554. ``AdminSite(name="...")``.
  555. * Internal changes were made to the :class:`~django.forms.ClearableFileInput`
  556. widget to allow more customization. The undocumented ``url_markup_template``
  557. attribute was removed in favor of ``template_with_initial``.
  558. * For consistency with other major vendors, the ``en_GB`` locale now has Monday
  559. as the first day of the week.
  560. * Seconds have been removed from any locales that had them in ``TIME_FORMAT``,
  561. ``DATETIME_FORMAT``, or ``SHORT_DATETIME_FORMAT``.
  562. * The default max size of the Oracle test tablespace has increased from 200M
  563. to 500M.
  564. * :func:`~django.core.urlresolvers.reverse` and
  565. :func:`~django.core.urlresolvers.reverse_lazy` now return Unicode strings
  566. instead of byte strings.
  567. * The ``CacheClass`` shim has been removed from all cache backends.
  568. These aliases were provided for backwards compatibility with Django 1.3.
  569. If you are still using them, please update your project to use the real
  570. class name found in the :setting:`BACKEND <CACHES-BACKEND>` key of the
  571. :setting:`CACHES` setting.
  572. * By default, :ref:`call_command <call-command>` now always skips the check
  573. framework (unless you pass it ``skip_checks=False``).
  574. * When iterating over lines, :class:`~django.core.files.File` now uses
  575. `universal newlines`_. The following are recognized as ending a line: the
  576. Unix end-of-line convention ``'\n'``, the Windows convention ``'\r\n'``, and
  577. the old Macintosh convention ``'\r'``.
  578. .. _universal newlines: http://www.python.org/dev/peps/pep-0278
  579. * The Memcached cache backends ``MemcachedCache`` and ``PyLibMCCache`` will
  580. delete a key if ``set()`` fails. This is necessary to ensure the ``cache_db``
  581. session store always fetches the most current session data.
  582. * Private API ``django.template.compile_string`` was removed.
  583. * Private APIs ``override_template_loaders`` and ``override_with_test_loader``
  584. in ``django.test.utils`` were removed. Override ``TEMPLATE_LOADERS`` with
  585. ``override_settings`` instead.
  586. * Warnings from the MySQL database backend are no longer converted to
  587. exceptions when :setting:`DEBUG` is ``True``.
  588. * :class:`~django.http.HttpRequest` now has a simplified ``repr`` (e.g.
  589. ``<WSGIRequest: GET '/somepath/'>``). This won't change the behavior of
  590. the :class:`~django.views.debug.SafeExceptionReporterFilter` class.
  591. * Class-based views that use :class:`~django.views.generic.edit.ModelFormMixin`
  592. will raise an :exc:`~django.core.exceptions.ImproperlyConfigured` exception
  593. when both the ``fields`` and ``form_class`` attributes are specified.
  594. Previously, ``fields`` was silently ignored.
  595. .. _deprecated-features-1.8:
  596. Features deprecated in 1.8
  597. ==========================
  598. Loading ``cycle`` and ``firstof`` template tags from ``future`` library
  599. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  600. Django 1.6 introduced ``{% load cycle from future %}`` and
  601. ``{% load firstof from future %}`` syntax for forward compatibility of the
  602. :ttag:`cycle` and :ttag:`firstof` template tags. This syntax is now deprecated
  603. and will be removed in Django 2.0. You can simply remove the
  604. ``{% load ... from future %}`` tags.
  605. ``django.conf.urls.patterns()``
  606. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  607. In the olden days of Django, it was encouraged to reference views as strings
  608. in ``urlpatterns``::
  609. urlpatterns = patterns('',
  610. url('^$', 'myapp.views.myview'),
  611. )
  612. and Django would magically import ``myapp.views.myview`` internally and turn
  613. the string into a real function reference. In order to reduce repetition when
  614. referencing many views from the same module, the ``patterns()`` function takes
  615. a required initial ``prefix`` argument which is prepended to all
  616. views-as-strings in that set of ``urlpatterns``::
  617. urlpatterns = patterns('myapp.views',
  618. url('^$', 'myview'),
  619. url('^other/$', 'otherview'),
  620. )
  621. In the modern era, we have updated the tutorial to instead recommend importing
  622. your views module and referencing your view functions (or classes) directly.
  623. This has a number of advantages, all deriving from the fact that we are using
  624. normal Python in place of "Django String Magic": the errors when you mistype a
  625. view name are less obscure, IDEs can help with autocompletion of view names,
  626. etc.
  627. So these days, the above use of the ``prefix`` arg is much more likely to be
  628. written (and is better written) as::
  629. from myapp import views
  630. urlpatterns = patterns('',
  631. url('^$', views.myview),
  632. url('^other/$', views.otherview),
  633. )
  634. Thus ``patterns()`` serves little purpose and is a burden when teaching new users
  635. (answering the newbie's question "why do I need this empty string as the first
  636. argument to ``patterns()``?"). For these reasons, we are deprecating it.
  637. Updating your code is as simple as ensuring that ``urlpatterns`` is a list of
  638. :func:`django.conf.urls.url` instances. For example::
  639. from django.conf.urls import url
  640. from myapp import views
  641. urlpatterns = [
  642. url('^$', views.myview),
  643. url('^other/$', views.otherview),
  644. ]
  645. Passing a string as ``view`` to :func:`~django.conf.urls.url`
  646. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  647. Related to the previous item, referencing views as strings in the ``url()``
  648. function is deprecated. Pass the callable view as described in the previous
  649. section instead.
  650. ``django.test.SimpleTestCase.urls``
  651. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  652. The attribute :attr:`SimpleTestCase.urls <django.test.SimpleTestCase.urls>`
  653. for specifying URLconf configuration in tests has been deprecated and will be
  654. removed in Django 2.0. Use :func:`@override_settings(ROOT_URLCONF=...)
  655. <django.test.override_settings>` instead.
  656. ``prefix`` argument to :func:`~django.conf.urls.i18n.i18n_patterns`
  657. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  658. Related to the previous item, the ``prefix`` argument to
  659. :func:`django.conf.urls.i18n.i18n_patterns` has been deprecated. Simply pass a
  660. list of :func:`django.conf.urls.url` instances instead.
  661. Using an incorrect count of unpacked values in the :ttag:`for` template tag
  662. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  663. Using an incorrect count of unpacked values in :ttag:`for` tag will raise an
  664. exception rather than fail silently in Django 2.0.
  665. Passing a dotted path to :func:`~django.core.urlresolvers.reverse()` and :ttag:`url`
  666. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  667. Reversing URLs by Python path is an expensive operation as it causes the
  668. path being reversed to be imported. This behavior has also resulted in a
  669. `security issue`_. Use :ref:`named URL patterns <naming-url-patterns>`
  670. for reversing instead.
  671. If you are using :mod:`django.contrib.sitemaps`, add the ``name`` argument to
  672. the ``url`` that references :func:`django.contrib.sitemaps.views.sitemap`::
  673. from django.contrib.sitemaps.views import sitemap
  674. url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},
  675. name='django.contrib.sitemaps.views.sitemap')
  676. to ensure compatibility when reversing by Python path is removed in Django 2.0.
  677. Similarly for GIS sitemaps, add ``name='django.contrib.gis.sitemaps.views.kml'``
  678. or ``name='django.contrib.gis.sitemaps.views.kmz'``.
  679. .. _security issue: https://www.djangoproject.com/weblog/2014/apr/21/security/#s-issue-unexpected-code-execution-using-reverse
  680. Aggregate methods and modules
  681. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  682. The ``django.db.models.sql.aggregates`` and
  683. ``django.contrib.gis.db.models.sql.aggregates`` modules (both private API), have
  684. been deprecated as ``django.db.models.aggregates`` and
  685. ``django.contrib.gis.db.models.aggregates`` are now also responsible
  686. for SQL generation. The old modules will be removed in Django 2.0.
  687. If you were using the old modules, see :doc:`Query Expressions
  688. </ref/models/expressions>` for instructions on rewriting custom aggregates
  689. using the new stable API.
  690. The following methods and properties of ``django.db.models.sql.query.Query``
  691. have also been deprecated and the backwards compatibility shims will be removed
  692. in Django 2.0:
  693. * ``Query.aggregates``, replaced by ``annotations``.
  694. * ``Query.aggregate_select``, replaced by ``annotation_select``.
  695. * ``Query.add_aggregate()``, replaced by ``add_annotation()``.
  696. * ``Query.set_aggregate_mask()``, replaced by ``set_annotation_mask()``.
  697. * ``Query.append_aggregate_mask()``, replaced by ``append_annotation_mask()``.
  698. Extending management command arguments through ``Command.option_list``
  699. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  700. Management commands now use :py:mod:`argparse` instead of :py:mod:`optparse` to
  701. parse command-line arguments passed to commands. This also means that the way
  702. to add custom arguments to commands has changed: instead of extending the
  703. ``option_list`` class list, you should now override the
  704. :meth:`~django.core.management.BaseCommand.add_arguments` method and add
  705. arguments through ``argparse.add_argument()``. See
  706. :ref:`this example <custom-commands-options>` for more details.
  707. ``django.core.management.NoArgsCommand``
  708. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  709. The class :class:`~django.core.management.NoArgsCommand` is now deprecated and
  710. will be removed in Django 2.0. Use :class:`~django.core.management.BaseCommand`
  711. instead, which takes no arguments by default.
  712. ``cache_choices`` option of ``ModelChoiceField`` and ``ModelMultipleChoiceField``
  713. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  714. :class:`~django.forms.ModelChoiceField` and
  715. :class:`~django.forms.ModelMultipleChoiceField` took an undocumented, untested
  716. option ``cache_choices``. This cached querysets between multiple renderings of
  717. the same ``Form`` object. This option is subject to an accelerated deprecation
  718. and will be removed in Django 1.9.
  719. ``django.template.resolve_variable()``
  720. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  721. The function has been informally marked as "Deprecated" for some time. Replace
  722. ``resolve_variable(path, context)`` with
  723. ``django.template.Variable(path).resolve(context)``.
  724. ``django.contrib.webdesign``
  725. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  726. It provided the :ttag:`lorem` template tag which is now included in the
  727. built-in tags. Simply remove ``'django.contrib.webdesign'`` from
  728. :setting:`INSTALLED_APPS` and ``{% load webdesign %}`` from your templates.
  729. ``error_message`` argument to ``django.forms.RegexField``
  730. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  731. It provided backwards compatibility for pre-1.0 code, but its functionality is
  732. redundant. Use ``Field.error_messages['invalid']`` instead.
  733. Old :tfilter:`unordered_list` syntax
  734. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  735. An older (pre-1.0), more restrictive and verbose input format for the
  736. :tfilter:`unordered_list` template filter has been deprecated::
  737. ``['States', [['Kansas', [['Lawrence', []], ['Topeka', []]]], ['Illinois', []]]]``
  738. Using the new syntax, this becomes::
  739. ``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``
  740. ``django.forms.Field._has_changed()``
  741. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  742. Rename this method to :meth:`~django.forms.Field.has_changed` by removing the
  743. leading underscore. The old name will still work until Django 2.0.
  744. ``django.utils.html.remove_tags()`` and ``removetags`` template filter
  745. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  746. ``django.utils.html.remove_tags()`` as well as the template filter
  747. ``removetags`` have been deprecated as they cannot guarantee safe output. Their
  748. existence is likely to lead to their use in security-sensitive contexts where
  749. they are not actually safe.
  750. The unused and undocumented ``django.utils.html.strip_entities()`` function has
  751. also been deprecated.
  752. ``is_admin_site`` argument to ``django.contrib.auth.views.password_reset()``
  753. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  754. It's a legacy option that should no longer be necessary.
  755. ``SubfieldBase``
  756. ~~~~~~~~~~~~~~~~
  757. ``django.db.models.fields.subclassing.SubfieldBase`` has been deprecated and
  758. will be removed in Django 2.0. Historically, it was used to handle fields where
  759. type conversion was needed when loading from the database, but it was not used
  760. in ``.values()`` calls or in aggregates. It has been replaced with
  761. :meth:`~django.db.models.Field.from_db_value`. Note that the new approach does
  762. not call the :meth:`~django.db.models.Field.to_python` method on assignment
  763. as was the case with ``SubfieldBase``.
  764. ``django.utils.checksums``
  765. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  766. The ``django.utils.checksums`` module has been deprecated and will be removed
  767. in Django 2.0. The functionality it provided (validating checksum using the
  768. Luhn algorithm) was undocumented and not used in Django. The module has been
  769. moved to the `django-localflavor`_ package (version 1.1+).
  770. .. _django-localflavor: https://pypi.python.org/pypi/django-localflavor
  771. ``django.contrib.admin.helpers.InlineAdminForm.original_content_type_id``
  772. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  773. The ``original_content_type_id`` attribute on ``InlineAdminForm`` has been
  774. deprecated and will be removed in Django 2.0. Historically, it was used
  775. to construct the "view on site" URL. This URL is now accessible using the
  776. ``absolute_url`` attribute of the form.
  777. ``django.views.generic.edit.FormMixin.get_form()``’s ``form_class`` argument
  778. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  779. ``FormMixin`` subclasses that override the ``get_form()`` method should make
  780. sure to provide a default value for the ``form_class`` argument since it's
  781. now optional.
  782. ``dirs`` argument of template-finding functions
  783. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  784. The following functions will no longer accept a ``dirs`` parameter to override
  785. :setting:`TEMPLATE_DIRS` in Django 2.0:
  786. * :func:`django.template.loader.get_template()`
  787. * :func:`django.template.loader.select_template()`
  788. * :func:`django.shortcuts.render()`
  789. * :func:`django.shortcuts.render_to_response()`
  790. The parameter didn't work consistently across different template loaders and
  791. didn't work for included templates.
  792. ``django.template.loader.BaseLoader``
  793. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  794. ``django.template.loader.BaseLoader`` was renamed to
  795. ``django.template.loaders.base.Loader``. If you've written a custom template
  796. loader that inherits ``BaseLoader``, you must inherit ``Loader`` instead.
  797. ``django.test.utils.TestTemplateLoader``
  798. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  799. Private API ``django.test.utils.TestTemplateLoader`` is deprecated in favor of
  800. ``django.template.loaders.locmem.Loader``.
  801. ``qn`` replaced by ``compiler``
  802. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  803. In previous Django versions, various internal ORM methods (mostly ``as_sql``
  804. methods) accepted a ``qn`` (for "quote name") argument, which was a reference
  805. to a function that quoted identifiers for sending to the database. In Django
  806. 1.8, that argument has been renamed to ``compiler`` and is now a full
  807. ``SQLCompiler`` instance. For backwards-compatibility, calling a
  808. ``SQLCompiler`` instance performs the same name-quoting that the ``qn``
  809. function used to. However, this backwards-compatibility shim is immediately
  810. deprecated: you should rename your ``qn`` arguments to ``compiler``, and call
  811. ``compiler.quote_name_unless_alias(...)`` where you previously called
  812. ``qn(...)``.
  813. .. removed-features-1.8:
  814. Features removed in 1.8
  815. =======================
  816. These features have reached the end of their deprecation cycle and so have been
  817. removed in Django 1.8 (please see the :ref:`deprecation timeline
  818. <deprecation-removed-in-1.8>` for more details):
  819. * ``django.contrib.comments`` is removed.
  820. * The following transaction management APIs are removed:
  821. - ``TransactionMiddleware``
  822. - the decorators and context managers ``autocommit``, ``commit_on_success``,
  823. and ``commit_manually``, defined in ``django.db.transaction``
  824. - the functions ``commit_unless_managed`` and ``rollback_unless_managed``,
  825. also defined in ``django.db.transaction``
  826. - the ``TRANSACTIONS_MANAGED`` setting
  827. * The :ttag:`cycle` and :ttag:`firstof` template tags auto-escape their
  828. arguments.
  829. * The ``SEND_BROKEN_LINK_EMAILS`` setting is removed.
  830. * ``django.middleware.doc.XViewMiddleware`` is removed.
  831. * The ``Model._meta.module_name`` alias is removed.
  832. * The backward compatible shims introduced to rename ``get_query_set``
  833. and similar queryset methods are removed. This affects the following classes:
  834. ``BaseModelAdmin``, ``ChangeList``, ``BaseCommentNode``,
  835. ``GenericForeignKey``, ``Manager``, ``SingleRelatedObjectDescriptor`` and
  836. ``ReverseSingleRelatedObjectDescriptor``.
  837. * The backward compatible shims introduced to rename the attributes
  838. ``ChangeList.root_query_set`` and ``ChangeList.query_set`` are removed.
  839. * ``django.views.defaults.shortcut`` and ``django.conf.urls.shortcut`` are
  840. removed.
  841. * Support for the Python Imaging Library (PIL) module is removed.
  842. * The following private APIs are removed:
  843. - ``django.db.backend``
  844. - ``django.db.close_connection()``
  845. - ``django.db.backends.creation.BaseDatabaseCreation.set_autocommit()``
  846. - ``django.db.transaction.is_managed()``
  847. - ``django.db.transaction.managed()``
  848. * ``django.forms.widgets.RadioInput`` is removed.
  849. * The module ``django.test.simple`` and the class
  850. ``django.test.simple.DjangoTestSuiteRunner`` are removed.
  851. * The module ``django.test._doctest`` is removed.
  852. * The ``CACHE_MIDDLEWARE_ANONYMOUS_ONLY`` setting is removed.
  853. * Usage of the hard-coded *Hold down "Control", or "Command" on a Mac, to select
  854. more than one.* string to override or append to user-provided ``help_text`` in
  855. forms for ``ManyToMany`` model fields is not be performed by Django anymore
  856. either at the model or forms layer.
  857. * The ``Model._meta.get_(add|change|delete)_permission`` methods are removed.
  858. * The session key ``django_language`` is no longer read for backwards
  859. compatibility.
  860. * Geographic Sitemaps are removed
  861. (``django.contrib.gis.sitemaps.views.index`` and
  862. ``django.contrib.gis.sitemaps.views.sitemap``).
  863. * ``django.utils.html.fix_ampersands``, the ``fix_ampersands`` template filter,
  864. and ``django.utils.html.clean_html`` are removed.