1.8.txt 75 KB

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