1.8.txt 75 KB

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