1.8.txt 75 KB

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