1.8.txt 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596
  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.7 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. ``Model._meta`` API
  25. ~~~~~~~~~~~~~~~~~~~
  26. Django now has a formalized API for :doc:`Model._meta </ref/models/meta>`,
  27. providing an officially supported way to :ref:`retrieve fields
  28. <model-meta-field-api>` and filter fields based on their :ref:`attributes
  29. <model-field-attributes>`.
  30. The ``Model._meta`` object has been part of Django since the days of pre-0.96
  31. "Magic Removal" -- it just wasn't an official, stable API. In recognition of
  32. this, we've endeavored to maintain backwards-compatibility with the old
  33. API endpoint where possible. However, API endpoints that aren't part of the
  34. new official API have been deprecated and will eventually be removed. A
  35. :ref:`guide to migrating from the old API to the new API
  36. <migrating-old-meta-api>` has been provided.
  37. Multiple template engines
  38. ~~~~~~~~~~~~~~~~~~~~~~~~~
  39. Django 1.8 defines a stable API for integrating template backends. It includes
  40. built-in support for the Django template language and for Jinja2_. It supports
  41. rendering templates with multiple engines within the same project. Learn more
  42. about the new features in the :doc:`topic guide </topics/templates>` and check
  43. the :doc:`upgrade instructions </ref/templates/upgrading>` for details.
  44. .. _Jinja2: http://jinja.pocoo.org/
  45. Security enhancements
  46. ~~~~~~~~~~~~~~~~~~~~~
  47. Several features of the django-secure_ third-party library have been
  48. integrated into Django. :class:`django.middleware.security.SecurityMiddleware`
  49. provides several security enhancements to the request/response cycle. The new
  50. :djadminopt:`--deploy` option of the :djadmin:`check` command allows you to
  51. check your production settings file for ways to increase the security of your
  52. site.
  53. .. _django-secure: https://pypi.python.org/pypi/django-secure
  54. New PostgreSQL specific functionality
  55. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  56. Django now has a module with extensions for PostgreSQL specific features, such
  57. as :class:`~django.contrib.postgres.fields.ArrayField`,
  58. :class:`~django.contrib.postgres.fields.HStoreField`, :ref:`range-fields`, and
  59. :lookup:`unaccent` lookup. A full breakdown of the features is available
  60. :doc:`in the documentation </ref/contrib/postgres/index>`.
  61. New data types
  62. ~~~~~~~~~~~~~~
  63. * Django now has a :class:`~django.db.models.UUIDField` for storing
  64. universally unique identifiers. It is stored as the native ``uuid`` data type
  65. on PostgreSQL and as a fixed length character field on other backends. There
  66. is a corresponding :class:`form field <django.forms.UUIDField>`.
  67. * Django now has a :class:`~django.db.models.DurationField` for storing periods
  68. of time - modeled in Python by :class:`~python:datetime.timedelta`. It is
  69. stored in the native ``interval`` data type on PostgreSQL, as a ``INTERVAL
  70. DAY(9) TO SECOND(6)`` on Oracle, and as a ``bigint`` of microseconds on other
  71. backends. Date and time related arithmetic has also been improved on all
  72. backends. There is a corresponding :class:`form field
  73. <django.forms.DurationField>`.
  74. Query Expressions and Database Functions
  75. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  76. :doc:`Query Expressions </ref/models/expressions>` allow users to create,
  77. customize, and compose complex SQL expressions. This has enabled annotate
  78. to accept expressions other than aggregates. Aggregates are now able to
  79. reference multiple fields, as well as perform arithmetic, similar to ``F()``
  80. objects.
  81. A collection of :doc:`database functions </ref/models/database-functions>` is
  82. also included with functionality such as
  83. :class:`~django.db.models.functions.Coalesce`,
  84. :class:`~django.db.models.functions.Concat`, and
  85. :class:`~django.db.models.functions.Substr`.
  86. ``TestCase`` data setup
  87. ~~~~~~~~~~~~~~~~~~~~~~~
  88. :class:`~django.test.TestCase` has been refactored to allow for data
  89. initialization at the class level using transactions and savepoints. Database
  90. backends which do not support transactions, like MySQL with the MyISAM storage
  91. engine, will still be able to run these tests but won't benefit from the
  92. improvements. Tests are now run within two nested
  93. :func:`~django.db.transaction.atomic()` blocks: one for the whole class and one
  94. for each test.
  95. * The class method
  96. :meth:`TestCase.setUpTestData() <django.test.TestCase.setUpTestData>` adds
  97. the ability to setup test data at the class level. Using this technique can
  98. speed up the tests as compared to using ``setUp()``.
  99. * Fixture loading within ``TestCase`` is now performed once for the whole
  100. ``TestCase``.
  101. Minor features
  102. ~~~~~~~~~~~~~~
  103. :mod:`django.contrib.admin`
  104. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  105. * :class:`~django.contrib.admin.ModelAdmin` now has a
  106. :meth:`~django.contrib.admin.ModelAdmin.has_module_permission`
  107. method to allow limiting access to the module on the admin index page.
  108. * :class:`~django.contrib.admin.InlineModelAdmin` now has an attribute
  109. :attr:`~django.contrib.admin.InlineModelAdmin.show_change_link` that
  110. supports showing a link to an inline object's change form.
  111. * Use the new ``django.contrib.admin.RelatedOnlyFieldListFilter`` in
  112. :attr:`ModelAdmin.list_filter <django.contrib.admin.ModelAdmin.list_filter>`
  113. to limit the ``list_filter`` choices to foreign objects which are attached to
  114. those from the ``ModelAdmin``.
  115. * The :meth:`ModelAdmin.delete_view()
  116. <django.contrib.admin.ModelAdmin.delete_view>` displays a summary of objects
  117. to be deleted on the deletion confirmation page.
  118. * The jQuery library embedded in the admin has been upgraded to version 1.11.2.
  119. * You can now specify :attr:`AdminSite.site_url
  120. <django.contrib.admin.AdminSite.site_url>` in order to display a link to the
  121. front-end site.
  122. * You can now specify :attr:`ModelAdmin.show_full_result_count
  123. <django.contrib.admin.ModelAdmin.show_full_result_count>` to control whether
  124. or not the full count of objects should be displayed on a filtered admin page.
  125. * The ``AdminSite.password_change()`` method now has an ``extra_context``
  126. parameter.
  127. * You can now control who may login to the admin site by overriding only
  128. :meth:`AdminSite.has_permission()
  129. <django.contrib.admin.AdminSite.has_permission>` and
  130. :attr:`AdminSite.login_form <django.contrib.admin.AdminSite.login_form>`.
  131. The ``base.html`` template has a new block ``usertools`` which contains the
  132. user-specific header. A new context variable ``has_permission``, which gets
  133. its value from :meth:`~django.contrib.admin.AdminSite.has_permission`,
  134. indicates whether the user may access the site.
  135. * Foreign key dropdowns now have buttons for changing or deleting related
  136. objects using a popup.
  137. :mod:`django.contrib.admindocs`
  138. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  139. * reStructuredText is now parsed in model docstrings.
  140. :mod:`django.contrib.auth`
  141. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  142. * Authorization backends can now raise
  143. :class:`~django.core.exceptions.PermissionDenied` in
  144. :meth:`~django.contrib.auth.models.User.has_perm`
  145. and :meth:`~django.contrib.auth.models.User.has_module_perms`
  146. to short-circuit permission checking.
  147. * :class:`~django.contrib.auth.forms.PasswordResetForm` now
  148. has a method :meth:`~django.contrib.auth.forms.PasswordResetForm.send_email`
  149. that can be overridden to customize the mail to be sent.
  150. * The ``max_length`` of :attr:`Permission.name
  151. <django.contrib.auth.models.Permission.name>` has been increased from 50 to
  152. 255 characters. Please run the database migration.
  153. * :attr:`~django.contrib.auth.models.CustomUser.USERNAME_FIELD` and
  154. :attr:`~django.contrib.auth.models.CustomUser.REQUIRED_FIELDS` now supports
  155. :class:`~django.db.models.ForeignKey`\s.
  156. * The default iteration count for the PBKDF2 password hasher has been
  157. increased by 33%. This backwards compatible change will not affect users who
  158. have subclassed ``django.contrib.auth.hashers.PBKDF2PasswordHasher`` to
  159. change the default value.
  160. :mod:`django.contrib.gis`
  161. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  162. * A new :doc:`GeoJSON serializer </ref/contrib/gis/serializers>` is now
  163. available.
  164. * The Spatialite backend now supports ``Collect`` and ``Extent`` aggregates
  165. when the database version is 3.0 or later.
  166. * The PostGIS 2 ``CREATE EXTENSION postgis`` and the Spatialite
  167. ``SELECT InitSpatialMetaData`` initialization commands are now automatically
  168. run by :djadmin:`migrate`.
  169. * The GDAL interface now supports retrieving properties of
  170. :ref:`raster (image) data file <raster-data-source-objects>`.
  171. * Compatibility shims for ``SpatialRefSys`` and ``GeometryColumns`` changed in
  172. Django 1.2 have been removed.
  173. * All GDAL-related exceptions are now raised with ``GDALException``. The former
  174. ``OGRException`` has been kept for backwards compatibility but should not be
  175. used any longer.
  176. :mod:`django.contrib.messages`
  177. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  178. * ...
  179. :mod:`django.contrib.redirects`
  180. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  181. * ...
  182. :mod:`django.contrib.sessions`
  183. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  184. * Session cookie is now deleted after
  185. :meth:`~django.contrib.sessions.backends.base.SessionBase.flush()` is called.
  186. :mod:`django.contrib.sitemaps`
  187. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  188. * The new :attr:`Sitemap.i18n <django.contrib.sitemaps.Sitemap.i18n>` attribute
  189. allows you to generate a sitemap based on the :setting:`LANGUAGES` setting.
  190. :mod:`django.contrib.sites`
  191. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  192. * :func:`~django.contrib.sites.shortcuts.get_current_site` will now lookup
  193. the current site based on :meth:`request.get_host()
  194. <django.http.HttpRequest.get_host>` if the :setting:`SITE_ID` setting is not
  195. defined.
  196. * The default :class:`~django.contrib.sites.models.Site` created when running
  197. ``migrate`` now respects the :setting:`SITE_ID` setting (instead of always
  198. using ``pk=1``).
  199. :mod:`django.contrib.staticfiles`
  200. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  201. * ...
  202. :mod:`django.contrib.syndication`
  203. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  204. * ...
  205. Cache
  206. ^^^^^
  207. * The ``incr()`` method of the
  208. ``django.core.cache.backends.locmem.LocMemCache`` backend is now thread-safe.
  209. Cryptography
  210. ^^^^^^^^^^^^
  211. * The ``max_age`` parameter of the
  212. :meth:`django.core.signing.TimestampSigner.unsign` method now also accept a
  213. :py:class:`datetime.timedelta` object.
  214. Database backends
  215. ^^^^^^^^^^^^^^^^^
  216. * The MySQL backend no longer strips microseconds from ``datetime`` values as
  217. MySQL 5.6.4 and up supports fractional seconds depending on the declaration
  218. of the datetime field (when ``DATETIME`` includes fractional precision greater
  219. than 0). New datetime database columns created with Django 1.8 and MySQL 5.6.4
  220. and up will support microseconds. See the :ref:`MySQL database notes
  221. <mysql-fractional-seconds>` for more details.
  222. * The MySQL backend no longer creates explicit indexes for foreign keys when
  223. using the InnoDB storage engine, as MySQL already creates them automatically.
  224. Email
  225. ^^^^^
  226. * :ref:`Email backends <topic-email-backends>` now support the context manager
  227. protocol for opening and closing connections.
  228. * The SMTP email backend now supports ``keyfile`` and ``certfile``
  229. authentication with the :setting:`EMAIL_SSL_CERTFILE` and
  230. :setting:`EMAIL_SSL_KEYFILE` settings.
  231. * The SMTP :class:`~django.core.mail.backends.smtp.EmailBackend` now supports
  232. setting the ``timeout`` parameter with the :setting:`EMAIL_TIMEOUT` setting.
  233. * :class:`~django.core.mail.EmailMessage` and ``EmailMultiAlternatives`` now
  234. support the ``reply_to`` parameter.
  235. File Storage
  236. ^^^^^^^^^^^^
  237. * :meth:`Storage.get_available_name()
  238. <django.core.files.storage.Storage.get_available_name>` and
  239. :meth:`Storage.save() <django.core.files.storage.Storage.save>`
  240. now take a ``max_length`` argument to implement storage-level maximum
  241. filename length constraints. Filenames exceeding this argument will get
  242. truncated. This prevents a database error when appending a unique suffix to a
  243. long filename that already exists on the storage. See the :ref:`deprecation
  244. note <storage-max-length-update>` about adding this argument to your custom
  245. storage classes.
  246. File Uploads
  247. ^^^^^^^^^^^^
  248. * ...
  249. Forms
  250. ^^^^^
  251. * Form widgets now render attributes with a value of ``True`` or ``False``
  252. as HTML5 boolean attributes.
  253. * The new :meth:`~django.forms.Form.has_error()` method allows checking
  254. if a specific error has happened.
  255. * If :attr:`~django.forms.Form.required_css_class` is defined on a form, then
  256. the ``<label>`` tags for required fields will have this class present in its
  257. attributes.
  258. * The rendering of non-field errors in unordered lists (``<ul>``) now includes
  259. ``nonfield`` in its list of classes to distinguish them from field-specific
  260. errors.
  261. * :class:`~django.forms.Field` now accepts a
  262. :attr:`~django.forms.Field.label_suffix` argument, which will override the
  263. form's :attr:`~django.forms.Form.label_suffix`. This enables customizing the
  264. suffix on a per-field basis — previously it wasn't possible to override
  265. a form's :attr:`~django.forms.Form.label_suffix` while using shortcuts such
  266. as ``{{ form.as_p }}`` in templates.
  267. * :class:`~django.forms.extras.widgets.SelectDateWidget` now accepts an
  268. :attr:`~django.forms.extras.widgets.SelectDateWidget.empty_label` argument, which will
  269. override the top list choice label when :class:`~django.forms.DateField` is not required.
  270. * After an :class:`~django.forms.ImageField` has been cleaned and validated, the
  271. ``UploadedFile`` object will have an additional ``image`` attribute containing
  272. the Pillow ``Image`` instance used to check if the file was a valid image. It
  273. will also update ``UploadedFile.content_type`` with the image's content type
  274. as determined by Pillow.
  275. * You can now pass a callable that returns an iterable of choices when
  276. instantiating a :class:`~django.forms.ChoiceField`.
  277. Generic Views
  278. ^^^^^^^^^^^^^
  279. * Generic views that use :class:`~django.views.generic.list.MultipleObjectMixin`
  280. may now specify the ordering applied to the
  281. :attr:`~django.views.generic.list.MultipleObjectMixin.queryset` by setting
  282. :attr:`~django.views.generic.list.MultipleObjectMixin.ordering` or overriding
  283. :meth:`~django.views.generic.list.MultipleObjectMixin.get_ordering()`.
  284. * The new :attr:`SingleObjectMixin.query_pk_and_slug
  285. <django.views.generic.detail.SingleObjectMixin.query_pk_and_slug>`
  286. attribute allows changing the behavior of
  287. :meth:`~django.views.generic.detail.SingleObjectMixin.get_object()`
  288. so that it'll perform its lookup using both the primary key and the slug.
  289. * The :meth:`~django.views.generic.edit.FormMixin.get_form()` method doesn't
  290. require a ``form_class`` to be provided anymore. If not provided ``form_class``
  291. defaults to :meth:`~django.views.generic.edit.FormMixin.get_form_class()`.
  292. Internationalization
  293. ^^^^^^^^^^^^^^^^^^^^
  294. * :setting:`FORMAT_MODULE_PATH` can now be a list of strings representing
  295. module paths. This allows importing several format modules from different
  296. reusable apps. It also allows overriding those custom formats in your main
  297. Django project.
  298. Logging
  299. ^^^^^^^
  300. * The :class:`django.utils.log.AdminEmailHandler` class now has a
  301. :meth:`~django.utils.log.AdminEmailHandler.send_mail` method to make it more
  302. subclass friendly.
  303. Management Commands
  304. ^^^^^^^^^^^^^^^^^^^
  305. * Database connections are now always closed after a management command called
  306. from the command line has finished doing its job.
  307. * Commands from alternate package formats like eggs are now also discovered.
  308. * :djadmin:`dumpdata` now has the option :djadminopt:`--output` which allows
  309. specifying the file to which the serialized data is written.
  310. * :djadmin:`makemessages` and :djadmin:`compilemessages` now have the option
  311. :djadminopt:`--exclude` which allows exclusion of specific locales from
  312. processing.
  313. * :djadmin:`compilemessages` now has a ``--use-fuzzy`` or ``-f`` option which
  314. includes fuzzy translations into compiled files.
  315. * The :djadminopt:`--ignorenonexistent` option of the :djadmin:`loaddata`
  316. management command now ignores data for models that no longer exist.
  317. * :djadmin:`runserver` now uses daemon threads for faster reloading.
  318. * :djadmin:`inspectdb` now outputs ``Meta.unique_together``. It is also able to
  319. introspect :class:`~django.db.models.AutoField` for MySQL and PostgreSQL
  320. databases.
  321. * When calling management commands from code through :ref:`call_command
  322. <call-command>` and passing options, the option name can match the command
  323. line option name (without the initial dashes) or the final option destination
  324. variable name, but in either case, the resulting option received by the
  325. command is now always the ``dest`` name specified in the command option
  326. definition (as long as the command uses the new :py:mod:`argparse` module).
  327. * The :djadmin:`dbshell` command now supports MySQL's optional SSL certificate
  328. authority setting (``--ssl-ca``).
  329. * The :djadminopt:`--name` option for :djadmin:`makemigrations` allows you to
  330. to give the migration(s) a custom name instead of a generated one.
  331. * The :djadmin:`loaddata` command now prevents repeated fixture loading. If
  332. :setting:`FIXTURE_DIRS` contains duplicates or a default fixture directory
  333. path (``app_name/fixtures``), an exception is raised.
  334. * :djadmin:`makemigrations` now supports an :djadminopt:`--exit` option to
  335. exit with an error code if no migrations are created.
  336. * The new :djadmin:`showmigrations` command allows listing all migrations and
  337. their dependencies in a project.
  338. Middleware
  339. ^^^^^^^^^^
  340. * The :attr:`CommonMiddleware.response_redirect_class
  341. <django.middleware.common.CommonMiddleware.response_redirect_class>`
  342. attribute allows you to customize the redirects issued by the middleware.
  343. * A debug message will be logged to the ``django.request`` logger when a
  344. middleware raises a :exc:`~django.core.exceptions.MiddlewareNotUsed` exception
  345. in :setting:`DEBUG` mode.
  346. Migrations
  347. ^^^^^^^^^^
  348. * The :class:`~django.db.migrations.operations.RunSQL` operation can now handle
  349. parameters passed to the SQL statements.
  350. * It is now possible to have migrations (most probably :ref:`data migrations
  351. <data-migrations>`) for applications without models.
  352. * Migrations can now :ref:`serialize model managers
  353. <using-managers-in-migrations>` as part of the model state.
  354. * A :ref:`generic mechanism to handle the deprecation of model fields
  355. <migrations-removing-model-fields>` was added.
  356. * The :attr:`RunPython.noop <django.db.migrations.operations.RunPython.noop>`
  357. and :meth:`RunSQL.noop() <django.db.migrations.operations.RunSQL.noop>` class
  358. attribute/method were added to ease in making ``RunPython`` and ``RunSQL``
  359. operations reversible.
  360. * The :class:`~django.db.migrations.operations.RunPython` and
  361. :class:`~django.db.migrations.operations.RunSQL` operations now accept a
  362. ``hints`` parameter that will be passed to :meth:`allow_migrate`. To take
  363. advantage of this feature you must ensure that the ``allow_migrate()`` method
  364. of all your routers accept ``**hints``.
  365. Models
  366. ^^^^^^
  367. * Django now logs at most 9000 queries in ``connections.queries``, in order
  368. to prevent excessive memory usage in long-running processes in debug mode.
  369. * There is now a model ``Meta`` option to define a
  370. :attr:`default related name <django.db.models.Options.default_related_name>`
  371. for all relational fields of a model.
  372. * Pickling models and querysets across different versions of Django isn't
  373. officially supported (it may work, but there's no guarantee). An extra
  374. variable that specifies the current Django version is now added to the
  375. pickled state of models and querysets, and Django raises a ``RuntimeWarning``
  376. when these objects are unpickled in a different version than the one in
  377. which they were pickled.
  378. * Added :meth:`Model.from_db() <django.db.models.Model.from_db()>` which
  379. Django uses whenever objects are loaded using the ORM. The method allows
  380. customizing model loading behavior.
  381. * ``extra(select={...})`` now allows you to escape a literal ``%s`` sequence
  382. using ``%%s``.
  383. * :doc:`Custom Lookups</howto/custom-lookups>` can now be registered using
  384. a decorator pattern.
  385. * The new :attr:`Transform.bilateral <django.db.models.Transform.bilateral>`
  386. attribute allows creating bilateral transformations. These transformations
  387. are applied to both ``lhs`` and ``rhs`` when used in a lookup expression,
  388. providing opportunities for more sophisticated lookups.
  389. * SQL special characters (\, %, _) are now escaped properly when a pattern
  390. lookup (e.g. ``contains``, ``startswith``, etc.) is used with an ``F()``
  391. expression as the right-hand side. In those cases, the escaping is performed
  392. by the database, which can lead to somewhat complex queries involving nested
  393. ``REPLACE`` function calls.
  394. * You can now refresh model instances by using :meth:`Model.refresh_from_db()
  395. <django.db.models.Model.refresh_from_db>`.
  396. * You can now get the set of deferred fields for a model using
  397. :meth:`Model.get_deferred_fields() <django.db.models.Model.get_deferred_fields>`.
  398. Signals
  399. ^^^^^^^
  400. * Exceptions from the ``(receiver, exception)`` tuples returned by
  401. :meth:`Signal.send_robust() <django.dispatch.Signal.send_robust>` now have
  402. their traceback attached as a ``__traceback__`` attribute.
  403. * The ``environ`` argument, which contains the WSGI environment structure from
  404. the request, was added to the :data:`~django.core.signals.request_started`
  405. signal.
  406. * You can now import the :func:`~django.test.signals.setting_changed` signal
  407. from ``django.core.signals`` to avoid loading ``django.test`` in non-test
  408. situations. Django no longer does so itself.
  409. System Check Framework
  410. ^^^^^^^^^^^^^^^^^^^^^^
  411. * :attr:`~django.core.checks.register` can now be used as a function.
  412. Templates
  413. ^^^^^^^^^
  414. * :tfilter:`urlize` now supports domain-only links that include characters after
  415. the top-level domain (e.g. ``djangoproject.com/`` and
  416. ``djangoproject.com/download/``).
  417. * :tfilter:`urlize` doesn't treat exclamation marks at the end of a domain or
  418. its query string as part of the URL (the URL in e.g. ``'djangoproject.com!``
  419. is ``djangoproject.com``)
  420. * Added a :class:`locmem.Loader <django.template.loaders.locmem.Loader>`
  421. class that loads Django templates from a Python dictionary.
  422. * The :ttag:`now` tag can now store its output in a context variable with the
  423. usual syntax: ``{% now 'j n Y' as varname %}``.
  424. Requests and Responses
  425. ^^^^^^^^^^^^^^^^^^^^^^
  426. * ``WSGIRequest`` now respects paths starting with ``//``.
  427. * The :meth:`HttpRequest.build_absolute_uri()
  428. <django.http.HttpRequest.build_absolute_uri>` method now handles paths
  429. starting with ``//`` correctly.
  430. * If :setting:`DEBUG` is ``True`` and a request raises a
  431. :exc:`~django.core.exceptions.SuspiciousOperation`, the response will be
  432. rendered with a detailed error page.
  433. * The ``query_string`` argument of :class:`~django.http.QueryDict` is now
  434. optional, defaulting to ``None``, so a blank ``QueryDict`` can now be
  435. instantiated with ``QueryDict()`` instead of ``QueryDict(None)`` or
  436. ``QueryDict('')``.
  437. * The ``GET`` and ``POST`` attributes of an :class:`~django.http.HttpRequest`
  438. object are now :class:`~django.http.QueryDict`\s rather than dictionaries,
  439. and the ``FILES`` attribute is now a ``MultiValueDict``.
  440. This brings this class into line with the documentation and with
  441. ``WSGIRequest``.
  442. * The :attr:`HttpResponse.charset <django.http.HttpResponse.charset>` attribute
  443. was added.
  444. * ``WSGIRequestHandler`` now follows RFC in converting URI to IRI, using
  445. ``uri_to_iri()``.
  446. * The :meth:`HttpRequest.get_full_path()
  447. <django.http.HttpRequest.get_full_path>` method now escapes unsafe characters
  448. from the path portion of a Uniform Resource Identifier (URI) properly.
  449. * :class:`~django.http.HttpResponse` now implements a few additional methods
  450. like :meth:`~django.http.HttpResponse.getvalue` so that instances can be used
  451. as stream objects.
  452. * The new :meth:`HttpResponse.setdefault()
  453. <django.http.HttpResponse.setdefault>` method allows setting a header unless
  454. it has already been set.
  455. * You can use the new :class:`~django.http.FileResponse` to stream files.
  456. * The :func:`~django.views.decorators.http.condition` decorator for
  457. conditional view processing now supports the ``If-unmodified-since`` header.
  458. Tests
  459. ^^^^^
  460. * The :class:`RequestFactory.trace() <django.test.RequestFactory>`
  461. and :class:`Client.trace() <django.test.Client.trace>` methods were
  462. implemented, allowing you to create ``TRACE`` requests in your tests.
  463. * The ``count`` argument was added to
  464. :meth:`~django.test.SimpleTestCase.assertTemplateUsed`. This allows you to
  465. assert that a template was rendered a specific number of times.
  466. * The new :meth:`~django.test.SimpleTestCase.assertJSONNotEqual` assertion
  467. allows you to test that two JSON fragments are not equal.
  468. * Added options to the :djadmin:`test` command to preserve the test database
  469. (:djadminopt:`--keepdb`), to run the test cases in reverse order
  470. (:djadminopt:`--reverse`), and to enable SQL logging for failing tests
  471. (:djadminopt:`--debug-sql`).
  472. * Added the :attr:`~django.test.Response.resolver_match` attribute to test
  473. client responses.
  474. * Added several settings that allow customization of test tablespace parameters
  475. for Oracle: :setting:`DATAFILE`, :setting:`DATAFILE_TMP`,
  476. :setting:`DATAFILE_MAXSIZE` and :setting:`DATAFILE_TMP_MAXSIZE`.
  477. * The :func:`~django.test.override_settings` decorator can now affect the
  478. master router in :setting:`DATABASE_ROUTERS`.
  479. * Added test client support for file uploads with file-like objects.
  480. * A shared cache is now used when testing with a SQLite in-memory database when
  481. using Python 3.4+ and SQLite 3.7.13+. This allows sharing the database
  482. between threads.
  483. Validators
  484. ^^^^^^^^^^
  485. * :class:`~django.core.validators.URLValidator` now supports IPv6 addresses,
  486. unicode domains, and URLs containing authentication data.
  487. Backwards incompatible changes in 1.8
  488. =====================================
  489. .. warning::
  490. In addition to the changes outlined in this section, be sure to review the
  491. :ref:`deprecation plan <deprecation-removed-in-1.8>` for any features that
  492. have been removed. If you haven't updated your code within the
  493. deprecation timeline for a given feature, its removal may appear as a
  494. backwards incompatible change.
  495. Related object operations are run in a transaction
  496. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  497. Some operations on related objects such as
  498. :meth:`~django.db.models.fields.related.RelatedManager.add()` or
  499. :ref:`direct assignment<direct-assignment>` ran multiple data modifying
  500. queries without wrapping them in transactions. To reduce the risk of data
  501. corruption, all data modifying methods that affect multiple related objects
  502. (i.e. ``add()``, ``remove()``, ``clear()``, and :ref:`direct assignment
  503. <direct-assignment>`) now perform their data modifying queries from within a
  504. transaction, provided your database supports transactions.
  505. This has one backwards incompatible side effect, signal handlers triggered from
  506. these methods are now executed within the method's transaction and any
  507. exception in a signal handler will prevent the whole operation.
  508. Assigning unsaved objects to relations raises an error
  509. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  510. Assigning unsaved objects to a :class:`~django.db.models.ForeignKey`,
  511. :class:`~django.contrib.contenttypes.fields.GenericForeignKey`, and
  512. :class:`~django.db.models.OneToOneField` now raises a :exc:`ValueError`.
  513. Previously, the assignment of an unsaved object would be silently ignored.
  514. For example::
  515. >>> book = Book.objects.create(name="Django")
  516. >>> book.author = Author(name="John")
  517. >>> book.author.save()
  518. >>> book.save()
  519. >>> Book.objects.get(name="Django")
  520. >>> book.author
  521. >>>
  522. Now, an error will be raised to prevent data loss::
  523. >>> book.author = Author(name="john")
  524. Traceback (most recent call last):
  525. ...
  526. ValueError: Cannot assign "<Author: John>": "Author" instance isn't saved in the database.
  527. Management commands that only accept positional arguments
  528. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  529. If you have written a custom management command that only accepts positional
  530. arguments and you didn't specify the
  531. :attr:`~django.core.management.BaseCommand.args` command variable, you might
  532. get an error like ``Error: unrecognized arguments: ...``, as variable parsing
  533. is now based on :py:mod:`argparse` which doesn't implicitly accept positional
  534. arguments. You can make your command backwards compatible by simply setting the
  535. :attr:`~django.core.management.BaseCommand.args` class variable. However, if
  536. you don't have to keep compatibility with older Django versions, it's better to
  537. implement the new :meth:`~django.core.management.BaseCommand.add_arguments`
  538. method as described in :doc:`/howto/custom-management-commands`.
  539. Custom test management command arguments through test runner
  540. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  541. The method to add custom arguments to the `test` management command through the
  542. test runner has changed. Previously, you could provide an `option_list` class
  543. variable on the test runner to add more arguments (à la :py:mod:`optparse`).
  544. Now to implement the same behavior, you have to create an
  545. ``add_arguments(cls, parser)`` class method on the test runner and call
  546. ``parser.add_argument`` to add any custom arguments, as parser is now an
  547. :py:class:`argparse.ArgumentParser` instance.
  548. Model check ensures auto-generated column names are within limits specified by database
  549. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  550. A field name that's longer than the column name length supported by a database
  551. can create problems. For example, with MySQL you'll get an exception trying to
  552. create the column, and with PostgreSQL the column name is truncated by the
  553. database (you may see a warning in the PostgreSQL logs).
  554. A model check has been introduced to better alert users to this scenario before
  555. the actual creation of database tables.
  556. If you have an existing model where this check seems to be a false positive,
  557. for example on PostgreSQL where the name was already being truncated, simply
  558. use :attr:`~django.db.models.Field.db_column` to specify the name that's being
  559. used.
  560. The check also applies to the columns generated in an implicit
  561. ``ManyToManyField.through`` model. If you run into an issue there, use
  562. :attr:`~django.db.models.ManyToManyField.through` to create an explicit model
  563. and then specify :attr:`~django.db.models.Field.db_column` on its column(s)
  564. as needed.
  565. Query relation lookups now check object types
  566. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  567. Querying for model lookups now checks if the object passed is of correct type
  568. and raises a :exc:`ValueError` if not. Previously, Django didn't care if the
  569. object was of correct type; it just used the object's related field attribute
  570. (e.g. ``id``) for the lookup. Now, an error is raised to prevent incorrect
  571. lookups::
  572. >>> book = Book.objects.create(name="Django")
  573. >>> book = Book.objects.filter(author=book)
  574. Traceback (most recent call last):
  575. ...
  576. ValueError: Cannot query "<Book: Django>": Must be "Author" instance.
  577. ``select_related()`` now checks given fields
  578. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  579. ``select_related()`` now validates that the given fields actually exist.
  580. Previously, nonexistent fields were silently ignored. Now, an error is raised::
  581. >>> book = Book.objects.select_related('nonexistent_field')
  582. Traceback (most recent call last):
  583. ...
  584. FieldError: Invalid field name(s) given in select_related: 'nonexistent_field'
  585. The validation also makes sure that the given field is relational::
  586. >>> book = Book.objects.select_related('name')
  587. Traceback (most recent call last):
  588. ...
  589. FieldError: Non-relational field given in select_related: 'name'
  590. Default ``EmailField.max_length`` increased to 254
  591. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  592. The old default 75 character ``max_length`` was not capable of storing all
  593. possible RFC3696/5321-compliant email addresses. In order to store all
  594. possible valid email addresses, the ``max_length`` has been increased to 254
  595. characters. You will need to generate and apply database migrations for your
  596. affected models (or add ``max_length=75`` if you wish to keep the length on
  597. your current fields). A migration for
  598. :attr:`django.contrib.auth.models.User.email` is included.
  599. Support for PostgreSQL versions older than 9.0
  600. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  601. The end of upstream support periods was reached in July 2014 for PostgreSQL 8.4.
  602. As a consequence, Django 1.8 sets 9.0 as the minimum PostgreSQL version it
  603. officially supports.
  604. This also includes dropping support for PostGIS 1.3 and 1.4 as these versions
  605. are not supported on versions of PostgreSQL later than 8.4.
  606. Django also now requires the use of Psycopg2 version 2.0.9 or higher.
  607. Support for MySQL versions older than 5.5
  608. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  609. The end of upstream support periods was reached in January 2012 for MySQL 5.0
  610. and December 2013 for MySQL 5.1. As a consequence, Django 1.8 sets 5.5 as the
  611. minimum MySQL version it officially supports.
  612. Support for Oracle versions older than 11.1
  613. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  614. The end of upstream support periods was reached in July 2010 for Oracle 9.2,
  615. January 2012 for Oracle 10.1, and July 2013 for Oracle 10.2. As a consequence,
  616. Django 1.8 sets 11.1 as the minimum Oracle version it officially supports.
  617. Specific privileges used instead of roles for tests on Oracle
  618. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  619. Earlier versions of Django granted the CONNECT and RESOURCE roles to the test
  620. user on Oracle. These roles have been deprecated, so Django 1.8 uses the
  621. specific underlying privileges instead. This changes the privileges required
  622. of the main user for running tests (unless the project is configured to avoid
  623. creating a test user). The exact privileges required now are detailed in
  624. :ref:`Oracle notes <oracle-notes>`.
  625. ``AbstractUser.last_login`` allows null values
  626. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  627. The :attr:`AbstractUser.last_login <django.contrib.auth.models.User.last_login>`
  628. field now allows null values. Previously, it defaulted to the time when the user
  629. was created which was misleading if the user never logged in. Please run the
  630. database migration. If your custom user inherits from ``AbstractUser`` and you
  631. wish to set ``last_login`` to ``NULL`` for users who haven't logged in, you can
  632. run this query::
  633. from django.db import models
  634. from django.contrib.auth import get_user_model
  635. from django.contrib.auth.models import AbstractBaseUser
  636. UserModel = get_user_model()
  637. if issubclass(UserModel, AbstractBaseUser):
  638. UserModel._default_manager.filter(
  639. last_login=models.F('date_joined')
  640. ).update(last_login=None)
  641. :mod:`django.contrib.gis`
  642. ~~~~~~~~~~~~~~~~~~~~~~~~~
  643. * Support for GEOS 3.1 and GDAL 1.6 has been dropped.
  644. * Support for SpatiaLite < 2.4 has been dropped.
  645. * GIS-specific lookups have been refactored to use the
  646. :class:`django.db.models.Lookup` API.
  647. * The default ``str`` representation of
  648. :class:`~django.contrib.gis.geos.GEOSGeometry` objects has been changed from
  649. WKT to EWKT format (including the SRID). As this representation is used in
  650. the serialization framework, that means that ``dumpdata`` output will now
  651. contain the SRID value of geometry objects.
  652. Priority of context processors for ``TemplateResponse`` brought in line with ``render``
  653. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  654. The :class:`~django.template.response.TemplateResponse` constructor is designed to be a
  655. drop-in replacement for the :func:`~django.shortcuts.render` function. However,
  656. it had a slight incompatibility, in that for ``TemplateResponse``, context data
  657. from the passed in context dictionary could be shadowed by context data returned
  658. from context processors, whereas for ``render`` it was the other way
  659. around. This was a bug, and the behavior of ``render`` is more appropriate,
  660. since it allows the globally defined context processors to be overridden locally
  661. in the view. If you were relying on the fact context data in a
  662. ``TemplateResponse`` could be overridden using a context processor, you will
  663. need to change your code.
  664. Overriding ``setUpClass`` / ``tearDownClass`` in test cases
  665. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  666. The decorators :func:`~django.test.override_settings` and
  667. :func:`~django.test.modify_settings` now act at the class level when used as
  668. class decorators. As a consequence, when overriding ``setUpClass()`` or
  669. ``tearDownClass()``, the ``super`` implementation should always be called.
  670. Removal of ``django.contrib.formtools``
  671. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  672. The formtools contrib app has been moved into a separate package.
  673. ``django.contrib.formtools`` itself has been removed. The docs provide
  674. :ref:`migration instructions <formtools-how-to-migrate>`.
  675. The new package is available `on Github`_ and on PyPI.
  676. .. _on GitHub: https://github.com/django/django-formtools/
  677. Database connection reloading between tests
  678. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  679. Django previously closed database connections between each test within a
  680. ``TestCase``. This is no longer the case as Django now wraps the whole
  681. ``TestCase`` within a transaction. If some of your tests relied on the old
  682. behavior, you should have them inherit from ``TransactionTestCase`` instead.
  683. Cleanup of the ``django.template`` namespace
  684. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  685. If you've been relying on private APIs exposed in the ``django.template``
  686. module, you may have to import them from ``django.template.base`` instead.
  687. Also private APIs ``django.template.base.compile_string()``,
  688. ``django.template.loader.find_template()``, and
  689. ``django.template.loader.get_template_from_string()`` were removed.
  690. Database backend API
  691. ~~~~~~~~~~~~~~~~~~~~
  692. The following changes to the database backend API are documented to assist
  693. those writing third-party backends in updating their code:
  694. * The ``data_types``, ``data_types_suffix``, and
  695. ``data_type_check_constraints`` attributes have moved from the
  696. ``DatabaseCreation`` class to ``DatabaseWrapper``.
  697. :mod:`django.contrib.admin`
  698. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  699. * ``AdminSite`` no longer takes an ``app_name`` argument and its ``app_name``
  700. attribute has been removed. The application name is always ``admin`` (as
  701. opposed to the instance name which you can still customize using
  702. ``AdminSite(name="...")``.
  703. * The ``ModelAdmin.get_object()`` method (private API) now takes a third
  704. argument named ``from_field`` in order to specify which field should match
  705. the provided ``object_id``.
  706. * The :meth:`ModelAdmin.response_delete()
  707. <django.contrib.admin.ModelAdmin.response_delete>` method
  708. now takes a second argument named ``obj_id`` which is the serialized
  709. identifier used to retrieve the object before deletion.
  710. Miscellaneous
  711. ~~~~~~~~~~~~~
  712. * ``connections.queries`` is now a read-only attribute.
  713. * Database connections are considered equal only if they're the same object.
  714. They aren't hashable any more.
  715. * :class:`~django.middleware.gzip.GZipMiddleware` used to disable compression
  716. for some content types when the request is from Internet Explorer, in order
  717. to work around a bug in IE6 and earlier. This behavior could affect
  718. performance on IE7 and later. It was removed.
  719. * ``URLField.to_python`` no longer adds a trailing slash to pathless URLs.
  720. * The :tfilter:`length` template filter now returns ``0`` for an undefined
  721. variable, rather than an empty string.
  722. * ``ForeignKey.default_error_message['invalid']`` has been changed from
  723. ``'%(model)s instance with pk %(pk)r does not exist.'`` to
  724. ``'%(model)s instance with %(field)s %(value)r does not exist.'`` If you are
  725. using this message in your own code, please update the list of interpolated
  726. parameters. Internally, Django will continue to provide the
  727. ``pk`` parameter in ``params`` for backwards compatibility.
  728. * ``UserCreationForm.errors_messages['duplicate_username']`` is no longer used.
  729. If you wish to customize that error message, :ref:`override it on the form
  730. <modelforms-overriding-default-fields>` using the ``'unique'`` key in
  731. ``Meta.errors_messages['username']`` or, if you have a custom form field for
  732. ``'username'``, using the the ``'unique'`` key in its
  733. :attr:`~django.forms.Field.error_messages` argument.
  734. * The block ``usertools`` in the ``base.html`` template of
  735. :mod:`django.contrib.admin` now requires the ``has_permission`` context
  736. variable to be set. If you have any custom admin views that use this
  737. template, update them to pass :meth:`AdminSite.has_permission()
  738. <django.contrib.admin.AdminSite.has_permission>` as this new variable's
  739. value or simply include :meth:`AdminSite.each_context(request)
  740. <django.contrib.admin.AdminSite.each_context>` in the context.
  741. * Internal changes were made to the :class:`~django.forms.ClearableFileInput`
  742. widget to allow more customization. The undocumented ``url_markup_template``
  743. attribute was removed in favor of ``template_with_initial``.
  744. * For consistency with other major vendors, the ``en_GB`` locale now has Monday
  745. as the first day of the week.
  746. * Seconds have been removed from any locales that had them in ``TIME_FORMAT``,
  747. ``DATETIME_FORMAT``, or ``SHORT_DATETIME_FORMAT``.
  748. * The default max size of the Oracle test tablespace has increased from 300M
  749. (or 200M, before 1.7.2) to 500M.
  750. * :func:`~django.core.urlresolvers.reverse` and
  751. :func:`~django.core.urlresolvers.reverse_lazy` now return Unicode strings
  752. instead of byte strings.
  753. * The ``CacheClass`` shim has been removed from all cache backends.
  754. These aliases were provided for backwards compatibility with Django 1.3.
  755. If you are still using them, please update your project to use the real
  756. class name found in the :setting:`BACKEND <CACHES-BACKEND>` key of the
  757. :setting:`CACHES` setting.
  758. * By default, :ref:`call_command <call-command>` now always skips the check
  759. framework (unless you pass it ``skip_checks=False``).
  760. * When iterating over lines, :class:`~django.core.files.File` now uses
  761. `universal newlines`_. The following are recognized as ending a line: the
  762. Unix end-of-line convention ``'\n'``, the Windows convention ``'\r\n'``, and
  763. the old Macintosh convention ``'\r'``.
  764. .. _universal newlines: https://www.python.org/dev/peps/pep-0278
  765. * The Memcached cache backends ``MemcachedCache`` and ``PyLibMCCache`` will
  766. delete a key if ``set()`` fails. This is necessary to ensure the ``cache_db``
  767. session store always fetches the most current session data.
  768. * Private APIs ``override_template_loaders`` and ``override_with_test_loader``
  769. in ``django.test.utils`` were removed. Override ``TEMPLATES`` with
  770. ``override_settings`` instead.
  771. * Warnings from the MySQL database backend are no longer converted to
  772. exceptions when :setting:`DEBUG` is ``True``.
  773. * :class:`~django.http.HttpRequest` now has a simplified ``repr`` (e.g.
  774. ``<WSGIRequest: GET '/somepath/'>``). This won't change the behavior of
  775. the :class:`~django.views.debug.SafeExceptionReporterFilter` class.
  776. * Class-based views that use :class:`~django.views.generic.edit.ModelFormMixin`
  777. will raise an :exc:`~django.core.exceptions.ImproperlyConfigured` exception
  778. when both the ``fields`` and ``form_class`` attributes are specified.
  779. Previously, ``fields`` was silently ignored.
  780. * When following redirects, the test client now raises
  781. :exc:`~django.test.client.RedirectCycleError` if it detects a loop or hits a
  782. maximum redirect limit (rather than passing silently).
  783. * Translatable strings set as the ``default`` parameter of the field are cast
  784. to concrete strings later, so the return type of ``Field.get_default()`` is
  785. different in some cases. There is no change to default values which are the
  786. result of a callable.
  787. * ``GenericIPAddressField.empty_strings_allowed`` is now ``False``. Database
  788. backends that interpret empty strings as null (only Oracle among the backends
  789. that Django includes) will no longer convert null values back to an empty
  790. string. This is consistent with other backends.
  791. * When the :attr:`~django.core.management.BaseCommand.leave_locale_alone`
  792. attribute is ``False``, translations are now deactivated instead of forcing
  793. the "en-us" locale. In the case your models contained non-English strings and
  794. you counted on English translations to be activated in management commands,
  795. this will not happen any longer. It might be that new database migrations are
  796. generated (once) after migrating to 1.8.
  797. * :func:`django.utils.translation.get_language()` now returns ``None`` instead
  798. of :setting:`LANGUAGE_CODE` when translations are temporarily deactivated.
  799. * The migration operations :class:`~django.db.migrations.operations.RunPython`
  800. and :class:`~django.db.migrations.operations.RunSQL` now call the
  801. :meth:`allow_migrate` method of database routers. In these cases the
  802. ``model`` argument of ``allow_migrate()`` is set to ``None``, so the router
  803. must properly handle this value. This is most useful when used together with
  804. the newly introduced ``hints`` parameter for these operations, but it can
  805. also be used to disable migrations from running on a particular database.
  806. .. _deprecated-features-1.8:
  807. Features deprecated in 1.8
  808. ==========================
  809. Selected methods in ``django.db.models.options.Options``
  810. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  811. As part of the formalization of the ``Model._meta`` API (from the
  812. :class:`django.db.models.options.Options` class), a number of methods have been
  813. deprecated and will be removed in Django 2.0:
  814. * ``get_all_field_names()``
  815. * ``get_all_related_objects()``
  816. * ``get_all_related_objects_with_model()``
  817. * ``get_all_related_many_to_many_objects()``
  818. * ``get_all_related_m2m_objects_with_model()``
  819. * ``get_concrete_fields_with_model()``
  820. * ``get_field_by_name()``
  821. * ``get_fields_with_model()``
  822. * ``get_m2m_with_model()``
  823. A :ref:`migration guide <migrating-old-meta-api>` has been provided to assist
  824. in converting your code from the old API to the new, official API.
  825. Loading ``cycle`` and ``firstof`` template tags from ``future`` library
  826. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  827. Django 1.6 introduced ``{% load cycle from future %}`` and
  828. ``{% load firstof from future %}`` syntax for forward compatibility of the
  829. :ttag:`cycle` and :ttag:`firstof` template tags. This syntax is now deprecated
  830. and will be removed in Django 2.0. You can simply remove the
  831. ``{% load ... from future %}`` tags.
  832. ``django.conf.urls.patterns()``
  833. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  834. In the olden days of Django, it was encouraged to reference views as strings
  835. in ``urlpatterns``::
  836. urlpatterns = patterns('',
  837. url('^$', 'myapp.views.myview'),
  838. )
  839. and Django would magically import ``myapp.views.myview`` internally and turn
  840. the string into a real function reference. In order to reduce repetition when
  841. referencing many views from the same module, the ``patterns()`` function takes
  842. a required initial ``prefix`` argument which is prepended to all
  843. views-as-strings in that set of ``urlpatterns``::
  844. urlpatterns = patterns('myapp.views',
  845. url('^$', 'myview'),
  846. url('^other/$', 'otherview'),
  847. )
  848. In the modern era, we have updated the tutorial to instead recommend importing
  849. your views module and referencing your view functions (or classes) directly.
  850. This has a number of advantages, all deriving from the fact that we are using
  851. normal Python in place of "Django String Magic": the errors when you mistype a
  852. view name are less obscure, IDEs can help with autocompletion of view names,
  853. etc.
  854. So these days, the above use of the ``prefix`` arg is much more likely to be
  855. written (and is better written) as::
  856. from myapp import views
  857. urlpatterns = patterns('',
  858. url('^$', views.myview),
  859. url('^other/$', views.otherview),
  860. )
  861. Thus ``patterns()`` serves little purpose and is a burden when teaching new users
  862. (answering the newbie's question "why do I need this empty string as the first
  863. argument to ``patterns()``?"). For these reasons, we are deprecating it.
  864. Updating your code is as simple as ensuring that ``urlpatterns`` is a list of
  865. :func:`django.conf.urls.url` instances. For example::
  866. from django.conf.urls import url
  867. from myapp import views
  868. urlpatterns = [
  869. url('^$', views.myview),
  870. url('^other/$', views.otherview),
  871. ]
  872. Passing a string as ``view`` to :func:`~django.conf.urls.url`
  873. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  874. Related to the previous item, referencing views as strings in the ``url()``
  875. function is deprecated. Pass the callable view as described in the previous
  876. section instead.
  877. Template-related settings
  878. ~~~~~~~~~~~~~~~~~~~~~~~~~
  879. As a consequence of the multiple template engines refactor, several settings
  880. are deprecated in favor of :setting:`TEMPLATES`:
  881. * ``ALLOWED_INCLUDE_ROOTS``
  882. * ``TEMPLATE_CONTEXT_PROCESSORS``
  883. * ``TEMPLATE_DIRS``
  884. * ``TEMPLATE_LOADERS``
  885. * ``TEMPLATE_STRING_IF_INVALID``
  886. ``django.core.context_processors``
  887. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  888. Built-in template context processors have been moved to
  889. ``django.template.context_processors``.
  890. ``django.test.SimpleTestCase.urls``
  891. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  892. The attribute :attr:`SimpleTestCase.urls <django.test.SimpleTestCase.urls>`
  893. for specifying URLconf configuration in tests has been deprecated and will be
  894. removed in Django 2.0. Use :func:`@override_settings(ROOT_URLCONF=...)
  895. <django.test.override_settings>` instead.
  896. ``prefix`` argument to :func:`~django.conf.urls.i18n.i18n_patterns`
  897. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  898. Related to the previous item, the ``prefix`` argument to
  899. :func:`django.conf.urls.i18n.i18n_patterns` has been deprecated. Simply pass a
  900. list of :func:`django.conf.urls.url` instances instead.
  901. Using an incorrect count of unpacked values in the :ttag:`for` template tag
  902. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  903. Using an incorrect count of unpacked values in :ttag:`for` tag will raise an
  904. exception rather than fail silently in Django 2.0.
  905. Passing a dotted path to :func:`~django.core.urlresolvers.reverse()` and :ttag:`url`
  906. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  907. Reversing URLs by Python path is an expensive operation as it causes the
  908. path being reversed to be imported. This behavior has also resulted in a
  909. `security issue`_. Use :ref:`named URL patterns <naming-url-patterns>`
  910. for reversing instead.
  911. If you are using :mod:`django.contrib.sitemaps`, add the ``name`` argument to
  912. the ``url`` that references :func:`django.contrib.sitemaps.views.sitemap`::
  913. from django.contrib.sitemaps.views import sitemap
  914. url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},
  915. name='django.contrib.sitemaps.views.sitemap')
  916. to ensure compatibility when reversing by Python path is removed in Django 2.0.
  917. Similarly for GIS sitemaps, add ``name='django.contrib.gis.sitemaps.views.kml'``
  918. or ``name='django.contrib.gis.sitemaps.views.kmz'``.
  919. .. _security issue: https://www.djangoproject.com/weblog/2014/apr/21/security/#s-issue-unexpected-code-execution-using-reverse
  920. Aggregate methods and modules
  921. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  922. The ``django.db.models.sql.aggregates`` and
  923. ``django.contrib.gis.db.models.sql.aggregates`` modules (both private API), have
  924. been deprecated as ``django.db.models.aggregates`` and
  925. ``django.contrib.gis.db.models.aggregates`` are now also responsible
  926. for SQL generation. The old modules will be removed in Django 2.0.
  927. If you were using the old modules, see :doc:`Query Expressions
  928. </ref/models/expressions>` for instructions on rewriting custom aggregates
  929. using the new stable API.
  930. The following methods and properties of ``django.db.models.sql.query.Query``
  931. have also been deprecated and the backwards compatibility shims will be removed
  932. in Django 2.0:
  933. * ``Query.aggregates``, replaced by ``annotations``.
  934. * ``Query.aggregate_select``, replaced by ``annotation_select``.
  935. * ``Query.add_aggregate()``, replaced by ``add_annotation()``.
  936. * ``Query.set_aggregate_mask()``, replaced by ``set_annotation_mask()``.
  937. * ``Query.append_aggregate_mask()``, replaced by ``append_annotation_mask()``.
  938. Extending management command arguments through ``Command.option_list``
  939. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  940. Management commands now use :py:mod:`argparse` instead of :py:mod:`optparse` to
  941. parse command-line arguments passed to commands. This also means that the way
  942. to add custom arguments to commands has changed: instead of extending the
  943. ``option_list`` class list, you should now override the
  944. :meth:`~django.core.management.BaseCommand.add_arguments` method and add
  945. arguments through ``argparse.add_argument()``. See
  946. :ref:`this example <custom-commands-options>` for more details.
  947. ``django.core.management.NoArgsCommand``
  948. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  949. The class :class:`~django.core.management.NoArgsCommand` is now deprecated and
  950. will be removed in Django 2.0. Use :class:`~django.core.management.BaseCommand`
  951. instead, which takes no arguments by default.
  952. Listing all migrations in a project
  953. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  954. The ``--list`` option of the :djadmin:`migrate` management command is
  955. deprecated and will be removed in Django 2.0. Use :djadmin:`showmigrations`
  956. instead.
  957. ``cache_choices`` option of ``ModelChoiceField`` and ``ModelMultipleChoiceField``
  958. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  959. :class:`~django.forms.ModelChoiceField` and
  960. :class:`~django.forms.ModelMultipleChoiceField` took an undocumented, untested
  961. option ``cache_choices``. This cached querysets between multiple renderings of
  962. the same ``Form`` object. This option is subject to an accelerated deprecation
  963. and will be removed in Django 1.9.
  964. ``django.template.resolve_variable()``
  965. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  966. The function has been informally marked as "Deprecated" for some time. Replace
  967. ``resolve_variable(path, context)`` with
  968. ``django.template.Variable(path).resolve(context)``.
  969. ``django.contrib.webdesign``
  970. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  971. It provided the :ttag:`lorem` template tag which is now included in the
  972. built-in tags. Simply remove ``'django.contrib.webdesign'`` from
  973. :setting:`INSTALLED_APPS` and ``{% load webdesign %}`` from your templates.
  974. ``error_message`` argument to ``django.forms.RegexField``
  975. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  976. It provided backwards compatibility for pre-1.0 code, but its functionality is
  977. redundant. Use ``Field.error_messages['invalid']`` instead.
  978. Old :tfilter:`unordered_list` syntax
  979. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  980. An older (pre-1.0), more restrictive and verbose input format for the
  981. :tfilter:`unordered_list` template filter has been deprecated::
  982. ``['States', [['Kansas', [['Lawrence', []], ['Topeka', []]]], ['Illinois', []]]]``
  983. Using the new syntax, this becomes::
  984. ``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``
  985. ``django.forms.Field._has_changed()``
  986. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  987. Rename this method to :meth:`~django.forms.Field.has_changed` by removing the
  988. leading underscore. The old name will still work until Django 2.0.
  989. ``django.utils.html.remove_tags()`` and ``removetags`` template filter
  990. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  991. ``django.utils.html.remove_tags()`` as well as the template filter
  992. ``removetags`` have been deprecated as they cannot guarantee safe output. Their
  993. existence is likely to lead to their use in security-sensitive contexts where
  994. they are not actually safe.
  995. The unused and undocumented ``django.utils.html.strip_entities()`` function has
  996. also been deprecated.
  997. ``is_admin_site`` argument to ``django.contrib.auth.views.password_reset()``
  998. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  999. It's a legacy option that should no longer be necessary.
  1000. ``SubfieldBase``
  1001. ~~~~~~~~~~~~~~~~
  1002. ``django.db.models.fields.subclassing.SubfieldBase`` has been deprecated and
  1003. will be removed in Django 2.0. Historically, it was used to handle fields where
  1004. type conversion was needed when loading from the database, but it was not used
  1005. in ``.values()`` calls or in aggregates. It has been replaced with
  1006. :meth:`~django.db.models.Field.from_db_value`. Note that the new approach does
  1007. not call the :meth:`~django.db.models.Field.to_python` method on assignment
  1008. as was the case with ``SubfieldBase``.
  1009. ``django.utils.checksums``
  1010. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1011. The ``django.utils.checksums`` module has been deprecated and will be removed
  1012. in Django 2.0. The functionality it provided (validating checksum using the
  1013. Luhn algorithm) was undocumented and not used in Django. The module has been
  1014. moved to the `django-localflavor`_ package (version 1.1+).
  1015. .. _django-localflavor: https://pypi.python.org/pypi/django-localflavor
  1016. ``django.contrib.admin.helpers.InlineAdminForm.original_content_type_id``
  1017. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1018. The ``original_content_type_id`` attribute on ``InlineAdminForm`` has been
  1019. deprecated and will be removed in Django 2.0. Historically, it was used
  1020. to construct the "view on site" URL. This URL is now accessible using the
  1021. ``absolute_url`` attribute of the form.
  1022. ``django.views.generic.edit.FormMixin.get_form()``’s ``form_class`` argument
  1023. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1024. ``FormMixin`` subclasses that override the ``get_form()`` method should make
  1025. sure to provide a default value for the ``form_class`` argument since it's
  1026. now optional.
  1027. ``current_app`` argument of template-related APIs
  1028. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1029. The following functions and classes will no longer accept a ``current_app``
  1030. parameter to set an URL namespace in Django 2.0:
  1031. * ``django.shortcuts.render()``
  1032. * ``django.template.Context()``
  1033. * ``django.template.RequestContext()``
  1034. * ``django.template.response.TemplateResponse()``
  1035. Set ``request.current_app`` instead, where ``request`` is the first argument
  1036. to these functions or classes. If you're using a plain ``Context``, use a
  1037. ``RequestContext`` instead.
  1038. ``dictionary`` and ``context_instance`` arguments of rendering functions
  1039. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1040. The following functions will no longer accept the ``dictionary`` and
  1041. ``context_instance`` parameters in Django 2.0:
  1042. * ``django.shortcuts.render()``
  1043. * ``django.shortcuts.render_to_response()``
  1044. * ``django.template.loader.render_to_string()``
  1045. Use the ``context`` parameter instead. When ``dictionary`` is passed as a
  1046. positional argument, which is the most common idiom, no changes are needed.
  1047. If you're passing a :class:`~django.template.Context` in ``context_instance``,
  1048. pass a :class:`dict` in the ``context`` parameter instead. If you're passing a
  1049. :class:`~django.template.RequestContext`, pass the request separately in the
  1050. ``request`` parameter.
  1051. ``dirs`` argument of template-finding functions
  1052. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1053. The following functions will no longer accept a ``dirs`` parameter to override
  1054. ``TEMPLATE_DIRS`` in Django 2.0:
  1055. * :func:`django.template.loader.get_template()`
  1056. * :func:`django.template.loader.select_template()`
  1057. * :func:`django.shortcuts.render()`
  1058. * :func:`django.shortcuts.render_to_response()`
  1059. The parameter didn't work consistently across different template loaders and
  1060. didn't work for included templates.
  1061. ``django.template.loader.BaseLoader``
  1062. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1063. ``django.template.loader.BaseLoader`` was renamed to
  1064. ``django.template.loaders.base.Loader``. If you've written a custom template
  1065. loader that inherits ``BaseLoader``, you must inherit ``Loader`` instead.
  1066. ``django.test.utils.TestTemplateLoader``
  1067. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1068. Private API ``django.test.utils.TestTemplateLoader`` is deprecated in favor of
  1069. ``django.template.loaders.locmem.Loader``.
  1070. .. _storage-max-length-update:
  1071. Support for the ``max_length`` argument on custom ``Storage`` classes
  1072. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1073. ``Storage`` subclasses should add ``max_length=None`` as a parameter to
  1074. :meth:`~django.core.files.storage.Storage.get_available_name` and/or
  1075. :meth:`~django.core.files.storage.Storage.save` if they override either method.
  1076. Support for storages that do not accept this argument will be removed in
  1077. Django 2.0.
  1078. ``qn`` replaced by ``compiler``
  1079. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1080. In previous Django versions, various internal ORM methods (mostly ``as_sql``
  1081. methods) accepted a ``qn`` (for "quote name") argument, which was a reference
  1082. to a function that quoted identifiers for sending to the database. In Django
  1083. 1.8, that argument has been renamed to ``compiler`` and is now a full
  1084. ``SQLCompiler`` instance. For backwards-compatibility, calling a
  1085. ``SQLCompiler`` instance performs the same name-quoting that the ``qn``
  1086. function used to. However, this backwards-compatibility shim is immediately
  1087. deprecated: you should rename your ``qn`` arguments to ``compiler``, and call
  1088. ``compiler.quote_name_unless_alias(...)`` where you previously called
  1089. ``qn(...)``.
  1090. Default value of ``RedirectView.permanent``
  1091. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1092. The default value of the
  1093. :attr:`RedirectView.permanent <django.views.generic.base.RedirectView.permanent>`
  1094. attribute will change from ``True`` to ``False`` in Django 1.9.
  1095. Using ``AuthenticationMiddleware`` without ``SessionAuthenticationMiddleware``
  1096. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1097. :class:`django.contrib.auth.middleware.SessionAuthenticationMiddleware` was
  1098. added in Django 1.7. In Django 1.7.2, its functionality was moved to
  1099. ``auth.get_user()`` and, for backwards compatibility, enabled only if
  1100. ``'django.contrib.auth.middleware.SessionAuthenticationMiddleware'`` appears in
  1101. :setting:`MIDDLEWARE_CLASSES`.
  1102. In Django 2.0, session verification will be enabled regardless of whether or not
  1103. ``SessionAuthenticationMiddleware`` is enabled (at which point
  1104. ``SessionAuthenticationMiddleware`` will have no significance). You can add it
  1105. to your ``MIDDLEWARE_CLASSES`` sometime before then to opt-in. Please read the
  1106. :ref:`upgrade considerations <session-invalidation-on-password-change>` first.
  1107. ``django.contrib.sitemaps.FlatPageSitemap``
  1108. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1109. ``django.contrib.sitemaps.FlatPageSitemap`` has moved to
  1110. ``django.contrib.flatpages.sitemaps.FlatPageSitemap``. The old import location
  1111. is deprecated and will be removed in Django 1.9.
  1112. Model ``Field.related``
  1113. ~~~~~~~~~~~~~~~~~~~~~~~
  1114. Private attribute ``django.db.models.Field.related`` is deprecated in favor
  1115. of ``Field.rel``. The latter is an instance of
  1116. ``django.db.models.fields.related.ForeignObjectRel`` which replaces
  1117. ``django.db.models.related.RelatedObject``. The ``django.db.models.related``
  1118. module has been removed and the ``Field.related`` attribute will be removed in
  1119. Django 2.0.
  1120. ``ssi`` template tag
  1121. ~~~~~~~~~~~~~~~~~~~~
  1122. The :ttag:`ssi` template tag allows files to be included in a template by
  1123. absolute path. This is of limited use in most deployment situations, and
  1124. the :ttag:`include` tag often makes more sense. This tag is now deprecated and
  1125. will be removed in Django 2.0.
  1126. ``=`` as comparison operator in ``if`` template tag
  1127. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1128. Using a single equals sign with the ``{% if %}`` template tag for equality
  1129. testing was undocumented and untested. It's now deprecated in favor of ``==``.
  1130. .. removed-features-1.8:
  1131. Features removed in 1.8
  1132. =======================
  1133. These features have reached the end of their deprecation cycle and so have been
  1134. removed in Django 1.8 (please see the :ref:`deprecation timeline
  1135. <deprecation-removed-in-1.8>` for more details):
  1136. * ``django.contrib.comments`` is removed.
  1137. * The following transaction management APIs are removed:
  1138. - ``TransactionMiddleware``
  1139. - the decorators and context managers ``autocommit``, ``commit_on_success``,
  1140. and ``commit_manually``, defined in ``django.db.transaction``
  1141. - the functions ``commit_unless_managed`` and ``rollback_unless_managed``,
  1142. also defined in ``django.db.transaction``
  1143. - the ``TRANSACTIONS_MANAGED`` setting
  1144. * The :ttag:`cycle` and :ttag:`firstof` template tags auto-escape their
  1145. arguments.
  1146. * The ``SEND_BROKEN_LINK_EMAILS`` setting is removed.
  1147. * ``django.middleware.doc.XViewMiddleware`` is removed.
  1148. * The ``Model._meta.module_name`` alias is removed.
  1149. * The backward compatible shims introduced to rename ``get_query_set``
  1150. and similar queryset methods are removed. This affects the following classes:
  1151. ``BaseModelAdmin``, ``ChangeList``, ``BaseCommentNode``,
  1152. ``GenericForeignKey``, ``Manager``, ``SingleRelatedObjectDescriptor`` and
  1153. ``ReverseSingleRelatedObjectDescriptor``.
  1154. * The backward compatible shims introduced to rename the attributes
  1155. ``ChangeList.root_query_set`` and ``ChangeList.query_set`` are removed.
  1156. * ``django.views.defaults.shortcut`` and ``django.conf.urls.shortcut`` are
  1157. removed.
  1158. * Support for the Python Imaging Library (PIL) module is removed.
  1159. * The following private APIs are removed:
  1160. - ``django.db.backend``
  1161. - ``django.db.close_connection()``
  1162. - ``django.db.backends.creation.BaseDatabaseCreation.set_autocommit()``
  1163. - ``django.db.transaction.is_managed()``
  1164. - ``django.db.transaction.managed()``
  1165. * ``django.forms.widgets.RadioInput`` is removed.
  1166. * The module ``django.test.simple`` and the class
  1167. ``django.test.simple.DjangoTestSuiteRunner`` are removed.
  1168. * The module ``django.test._doctest`` is removed.
  1169. * The ``CACHE_MIDDLEWARE_ANONYMOUS_ONLY`` setting is removed.
  1170. * Usage of the hard-coded *Hold down "Control", or "Command" on a Mac, to select
  1171. more than one.* string to override or append to user-provided ``help_text`` in
  1172. forms for ``ManyToMany`` model fields is not be performed by Django anymore
  1173. either at the model or forms layer.
  1174. * The ``Model._meta.get_(add|change|delete)_permission`` methods are removed.
  1175. * The session key ``django_language`` is no longer read for backwards
  1176. compatibility.
  1177. * Geographic Sitemaps are removed
  1178. (``django.contrib.gis.sitemaps.views.index`` and
  1179. ``django.contrib.gis.sitemaps.views.sitemap``).
  1180. * ``django.utils.html.fix_ampersands``, the ``fix_ampersands`` template filter,
  1181. and ``django.utils.html.clean_html`` are removed.