1.8.txt 44 KB

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