1.8.txt 75 KB

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