1.8.txt 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. ============================================
  2. Django 1.8 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. Welcome to Django 1.8!
  5. These release notes cover the `new features`_, as well as some `backwards
  6. incompatible changes`_ you'll want to be aware of when upgrading from Django
  7. 1.6 or older versions. We've also dropped some features, which are detailed in
  8. :ref:`our deprecation plan <deprecation-removed-in-1.8>`, and we've `begun the
  9. deprecation process for some features`_.
  10. .. _`new features`: `What's new in Django 1.8`_
  11. .. _`backwards incompatible changes`: `Backwards incompatible changes in 1.8`_
  12. .. _`begun the deprecation process for some features`: `Features deprecated in 1.8`_
  13. Python compatibility
  14. ====================
  15. Like Django 1.7, Django 1.8 requires Python 2.7 or above, though we
  16. **highly recommend** the latest minor release.
  17. What's new in Django 1.8
  18. ========================
  19. Security enhancements
  20. ~~~~~~~~~~~~~~~~~~~~~
  21. Several features of the django-secure_ third-party library have been
  22. integrated into Django. :class:`django.middleware.security.SecurityMiddleware`
  23. provides several security enhancements to the request/response cycle. The new
  24. :djadminopt:`--deploy` option of the :djadmin:`check` command allows you to
  25. check your production settings file for ways to increase the security of your
  26. site.
  27. .. _django-secure: https://pypi.python.org/pypi/django-secure
  28. New data types
  29. ~~~~~~~~~~~~~~
  30. * Django now has a :class:`~django.db.models.UUIDField` for storing
  31. universally unique identifiers. There is a corresponding :class:`form field
  32. <django.forms.UUIDField>`. It is stored as the native ``uuid`` data type on
  33. PostgreSQL and as a fixed length character field on other backends.
  34. Minor features
  35. ~~~~~~~~~~~~~~
  36. :mod:`django.contrib.admin`
  37. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  38. * :class:`~django.contrib.admin.ModelAdmin` now has a
  39. :meth:`~django.contrib.admin.ModelAdmin.has_module_permission`
  40. method to allow limiting access to the module on the admin index page.
  41. * :class:`~django.contrib.admin.InlineModelAdmin` now has an attribute
  42. :attr:`~django.contrib.admin.InlineModelAdmin.show_change_link` that
  43. supports showing a link to an inline object's change form.
  44. * Use the new ``django.contrib.admin.RelatedOnlyFieldListFilter`` in
  45. :attr:`ModelAdmin.list_filter <django.contrib.admin.ModelAdmin.list_filter>`
  46. to limit the ``list_filter`` choices to foreign objects which are attached to
  47. those from the ``ModelAdmin``.
  48. * The :meth:`ModelAdmin.delete_view()
  49. <django.contrib.admin.ModelAdmin.delete_view>` displays a summary of objects
  50. to be deleted on the deletion confirmation page.
  51. * The jQuery library embedded in the admin has been upgraded to version 1.11.1.
  52. * You can now specify :attr:`AdminSite.site_url
  53. <django.contrib.admin.AdminSite.site_url>` in order to display a link to the
  54. front-end site.
  55. * You can now specify :attr:`ModelAdmin.show_full_result_count
  56. <django.contrib.admin.ModelAdmin.show_full_result_count>` to control whether
  57. or not the full count of objects should be displayed on a filtered admin page.
  58. :mod:`django.contrib.auth`
  59. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  60. * Authorization backends can now raise
  61. :class:`~django.core.exceptions.PermissionDenied` in
  62. :meth:`~django.contrib.auth.models.User.has_perm`
  63. and :meth:`~django.contrib.auth.models.User.has_module_perms`
  64. to short-circuit permission checking.
  65. * :class:`~django.contrib.auth.forms.PasswordResetForm` now
  66. has a method :meth:`~django.contrib.auth.forms.PasswordResetForm.send_email`
  67. that can be overridden to customize the mail to be sent.
  68. * The ``max_length`` of :attr:`Permission.name
  69. <django.contrib.auth.models.Permission.name>` has been increased from 50 to
  70. 255 characters. Please run the database migration.
  71. * :attr:`~django.contrib.auth.models.CustomUser.USERNAME_FIELD` and
  72. :attr:`~django.contrib.auth.models.CustomUser.REQUIRED_FIELDS` now supports
  73. :class:`~django.db.models.ForeignKey`\s.
  74. :mod:`django.contrib.formtools`
  75. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  76. * A :doc:`form wizard </ref/contrib/formtools/form-wizard>` using the
  77. :class:`~django.contrib.formtools.wizard.views.CookieWizardView` will now ignore
  78. an invalid cookie, and the wizard will restart from the first step. An invalid
  79. cookie can occur in cases of intentional manipulation, but also after a secret
  80. key change. Previously, this would raise ``WizardViewCookieModified``, a
  81. ``SuspiciousOperation``, causing an exception for any user with an invalid cookie
  82. upon every request to the wizard, until the cookie is removed.
  83. :mod:`django.contrib.gis`
  84. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  85. * Compatibility shims for ``SpatialRefSys`` and ``GeometryColumns`` changed in
  86. Django 1.2 have been removed.
  87. * The Spatialite backend now supports ``Collect`` and ``Extent`` aggregates
  88. when the database version is 3.0 or later.
  89. :mod:`django.contrib.messages`
  90. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  91. * ...
  92. :mod:`django.contrib.redirects`
  93. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  94. * ...
  95. :mod:`django.contrib.sessions`
  96. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  97. * Session cookie is now deleted after
  98. :meth:`~django.contrib.sessions.backends.base.SessionBase.flush()` is called.
  99. :mod:`django.contrib.sitemaps`
  100. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  101. * The new :attr:`Sitemap.i18n <django.contrib.sitemaps.Sitemap.i18n>` attribute
  102. allows you to generate a sitemap based on the :setting:`LANGUAGES` setting.
  103. :mod:`django.contrib.sites`
  104. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  105. * :func:`~django.contrib.sites.shortcuts.get_current_site` will now lookup
  106. the current site based on :meth:`request.get_host()
  107. <django.http.HttpRequest.get_host>` if the :setting:`SITE_ID` setting is not
  108. defined.
  109. :mod:`django.contrib.staticfiles`
  110. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  111. * ...
  112. :mod:`django.contrib.syndication`
  113. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  114. * ...
  115. Cache
  116. ^^^^^
  117. * The ``incr()`` method of the
  118. ``django.core.cache.backends.locmem.LocMemCache`` backend is now thread-safe.
  119. Email
  120. ^^^^^
  121. * :ref:`Email backends <topic-email-backends>` now support the context manager
  122. protocol for opening and closing connections.
  123. * The SMTP email backend now supports ``keyfile`` and ``certfile``
  124. authentication with the :setting:`EMAIL_SSL_CERTFILE` and
  125. :setting:`EMAIL_SSL_KEYFILE` settings.
  126. * The SMTP :class:`~django.core.mail.backends.smtp.EmailBackend` now supports
  127. setting the ``timeout`` parameter with the :setting:`EMAIL_TIMEOUT` setting.
  128. File Storage
  129. ^^^^^^^^^^^^
  130. * ...
  131. File Uploads
  132. ^^^^^^^^^^^^
  133. * ...
  134. Forms
  135. ^^^^^
  136. * Form widgets now render attributes with a value of ``True`` or ``False``
  137. as HTML5 boolean attributes.
  138. * The new :meth:`~django.forms.Form.has_error()` method allows checking
  139. if a specific error has happened.
  140. * If :attr:`~django.forms.Form.required_css_class` is defined on a form, then
  141. the ``<label>`` tags for required fields will have this class present in its
  142. attributes.
  143. * The rendering of non-field errors in unordered lists (``<ul>``) now includes
  144. ``nonfield`` in its list of classes to distinguish them from field-specific
  145. errors.
  146. * :class:`~django.forms.Field` now accepts a
  147. :attr:`~django.forms.Field.label_suffix` argument, which will override the
  148. form's :attr:`~django.forms.Form.label_suffix`. This enables customizing the
  149. suffix on a per-field basis — previously it wasn't possible to override
  150. a form's :attr:`~django.forms.Form.label_suffix` while using shortcuts such
  151. as ``{{ form.as_p }}`` in templates.
  152. * :class:`~django.forms.extras.widgets.SelectDateWidget` now accepts an
  153. :attr:`~django.forms.extras.widgets.SelectDateWidget.empty_label` argument, which will
  154. override the top list choice label when :class:`~django.forms.DateField` is not required.
  155. * After an :class:`~django.forms.ImageField` has been cleaned and validated, the
  156. ``UploadedFile`` object will have an additional ``image`` attribute containing
  157. the Pillow ``Image`` instance used to check if the file was a valid image. It
  158. will also update ``UploadedFile.content_type`` with the image's content type
  159. as determined by Pillow.
  160. Generic Views
  161. ^^^^^^^^^^^^^
  162. * Generic views that use :class:`~django.views.generic.list.MultipleObjectMixin`
  163. may now specify the ordering applied to the
  164. :attr:`~django.views.generic.list.MultipleObjectMixin.queryset` by setting
  165. :attr:`~django.views.generic.list.MultipleObjectMixin.ordering` or overriding
  166. :meth:`~django.views.generic.list.MultipleObjectMixin.get_ordering()`.
  167. * The new :attr:`SingleObjectMixin.query_pk_and_slug
  168. <django.views.generic.detail.SingleObjectMixin.query_pk_and_slug>`
  169. attribute allows changing the behavior of
  170. :meth:`~django.views.generic.detail.SingleObjectMixin.get_object()`
  171. so that it'll perform its lookup using both the primary key and the slug.
  172. Internationalization
  173. ^^^^^^^^^^^^^^^^^^^^
  174. * :setting:`FORMAT_MODULE_PATH` can now be a list of strings representing
  175. module paths. This allows importing several format modules from different
  176. reusable apps. It also allows overriding those custom formats in your main
  177. Django project.
  178. Management Commands
  179. ^^^^^^^^^^^^^^^^^^^
  180. * :djadmin:`dumpdata` now has the option :djadminopt:`--output` which allows
  181. specifying the file to which the serialized data is written.
  182. * :djadmin:`makemessages` and :djadmin:`compilemessages` now have the option
  183. :djadminopt:`--exclude` which allows exclusion of specific locales from
  184. processing.
  185. * The :djadminopt:`--ignorenonexistent` option of the :djadmin:`loaddata`
  186. management command now ignores data for models that no longer exist.
  187. * :djadmin:`runserver` now uses daemon threads for faster reloading.
  188. * :djadmin:`inspectdb` now outputs ``Meta.unique_together``.
  189. * When calling management commands from code through :ref:`call_command
  190. <call-command>` and passing options, the option name can match the command
  191. line option name (without the initial dashes) or the final option destination
  192. variable name, but in either case, the resulting option received by the
  193. command is now always the ``dest`` name specified in the command option
  194. definition (as long as the command uses the new :py:mod:`argparse` module).
  195. * The :djadmin:`dbshell` command now supports MySQL's optional SSL certificate
  196. authority setting (``--ssl-ca``).
  197. * The :djadminopt:`--name` option for :djadmin:`makemigrations` allows you to
  198. to give the migration(s) a custom name instead of a generated one.
  199. Migrations
  200. ^^^^^^^^^^
  201. * The :class:`~django.db.migrations.operations.RunSQL` operation can now handle
  202. parameters passed to the SQL statements.
  203. * It is now possible to have migrations (most probably :ref:`data migrations
  204. <data-migrations>`) for applications without models.
  205. Models
  206. ^^^^^^
  207. * Django now logs at most 9000 queries in ``connections.queries``, in order
  208. to prevent excessive memory usage in long-running processes in debug mode.
  209. * There is now a model ``Meta`` option to define a
  210. :attr:`default related name <django.db.models.Options.default_related_name>`
  211. for all relational fields of a model.
  212. * Pickling models and querysets across different versions of Django isn't
  213. officially supported (it may work, but there's no guarantee). An extra
  214. variable that specifies the current Django version is now added to the
  215. pickled state of models and querysets, and Django raises a ``RuntimeWarning``
  216. when these objects are unpickled in a different version than the one in
  217. which they were pickled.
  218. * Added :meth:`Model.from_db() <django.db.models.Model.from_db()>` which
  219. Django uses whenever objects are loaded using the ORM. The method allows
  220. customizing model loading behavior.
  221. * ``extra(select={...})`` now allows you to escape a literal ``%s`` sequence
  222. using ``%%s``.
  223. * :doc:`Custom Lookups</howto/custom-lookups>` can now be registered using
  224. a decorator pattern.
  225. * The new :attr:`Transform.bilateral <django.db.models.Transform.bilateral>`
  226. attribute allows creating bilateral transformations. These transformations
  227. are applied to both ``lhs`` and ``rhs`` when used in a lookup expression,
  228. providing opportunities for more sophisticated lookups.
  229. Signals
  230. ^^^^^^^
  231. * Exceptions from the ``(receiver, exception)`` tuples returned by
  232. :meth:`Signal.send_robust() <django.dispatch.Signal.send_robust>` now have
  233. their traceback attached as a ``__traceback__`` attribute.
  234. * The ``environ`` argument, which contains the WSGI environment structure from
  235. the request, was added to the :data:`~django.core.signals.request_started`
  236. signal.
  237. Templates
  238. ^^^^^^^^^
  239. * :tfilter:`urlize` now supports domain-only links that include characters after
  240. the top-level domain (e.g. ``djangoproject.com/`` and
  241. ``djangoproject.com/download/``).
  242. Requests and Responses
  243. ^^^^^^^^^^^^^^^^^^^^^^
  244. * ``WSGIRequest`` now respects paths starting with ``//``.
  245. * The :meth:`HttpRequest.build_absolute_uri()
  246. <django.http.HttpRequest.build_absolute_uri>` method now handles paths
  247. starting with ``//`` correctly.
  248. * If :setting:`DEBUG` is ``True`` and a request raises a
  249. :exc:`~django.core.exceptions.SuspiciousOperation`, the response will be
  250. rendered with a detailed error page.
  251. * The ``query_string`` argument of :class:`~django.http.QueryDict` is now
  252. optional, defaulting to ``None``, so a blank ``QueryDict`` can now be
  253. instantiated with ``QueryDict()`` instead of ``QueryDict(None)`` or
  254. ``QueryDict('')``.
  255. * The ``GET`` and ``POST`` attributes of an :class:`~django.http.HttpRequest`
  256. object are now :class:`~django.http.QueryDict`\s rather than dictionaries,
  257. and the ``FILES`` attribute is now a ``MultiValueDict``.
  258. This brings this class into line with the documentation and with
  259. ``WSGIRequest``.
  260. * The :attr:`HttpResponse.charset <django.http.HttpResponse.charset>` attribute
  261. was added.
  262. * ``WSGIRequestHandler`` now follows RFC in converting URI to IRI, using
  263. ``uri_to_iri()``.
  264. Tests
  265. ^^^^^
  266. * The ``count`` argument was added to
  267. :meth:`~django.test.SimpleTestCase.assertTemplateUsed`. This allows you to
  268. assert that a template was rendered a specific number of times.
  269. * The new :meth:`~django.test.SimpleTestCase.assertJSONNotEqual` assertion
  270. allows you to test that two JSON fragments are not equal.
  271. * Added the ability to preserve the test database by adding the
  272. :djadminopt:`--keepdb` flag.
  273. * Added the :attr:`~django.test.Response.resolver_match` attribute to test
  274. client responses.
  275. * Added several settings that allow customization of test tablespace parameters
  276. for Oracle: :setting:`DATAFILE`, :setting:`DATAFILE_TMP`,
  277. :setting:`DATAFILE_MAXSIZE` and :setting:`DATAFILE_TMP_MAXSIZE`.
  278. Validators
  279. ^^^^^^^^^^
  280. * ...
  281. Backwards incompatible changes in 1.8
  282. =====================================
  283. .. warning::
  284. In addition to the changes outlined in this section, be sure to review the
  285. :ref:`deprecation plan <deprecation-removed-in-1.8>` for any features that
  286. have been removed. If you haven't updated your code within the
  287. deprecation timeline for a given feature, its removal may appear as a
  288. backwards incompatible change.
  289. Related object operations are run in a transaction
  290. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  291. Some operations on related objects such as
  292. :meth:`~django.db.models.fields.related.RelatedManager.add()` or
  293. :ref:`direct assignment<direct-assignment>` ran multiple data modifying
  294. queries without wrapping them in transactions. To reduce the risk of data
  295. corruption, all data modifying methods that affect multiple related objects
  296. (i.e. ``add()``, ``remove()``, ``clear()``, and :ref:`direct assignment
  297. <direct-assignment>`) now perform their data modifying queries from within a
  298. transaction, provided your database supports transactions.
  299. This has one backwards incompatible side effect, signal handlers triggered from
  300. these methods are now executed within the method's transaction and any
  301. exception in a signal handler will prevent the whole operation.
  302. Assigning unsaved objects to relations raises an error
  303. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  304. Assigning unsaved objects to a :class:`~django.db.models.ForeignKey`,
  305. :class:`~django.contrib.contenttypes.fields.GenericForeignKey`, and
  306. :class:`~django.db.models.OneToOneField` now raises a :exc:`ValueError`.
  307. Previously, the assignment of an unsaved object would be silently ignored.
  308. For example::
  309. >>> book = Book.objects.create(name="Django")
  310. >>> book.author = Author(name="John")
  311. >>> book.author.save()
  312. >>> book.save()
  313. >>> Book.objects.get(name="Django")
  314. >>> book.author
  315. >>>
  316. Now, an error will be raised to prevent data loss::
  317. >>> book.author = Author(name="john")
  318. Traceback (most recent call last):
  319. ...
  320. ValueError: Cannot assign "<Author: John>": "Author" instance isn't saved in the database.
  321. Management commands that only accept positional arguments
  322. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  323. If you have written a custom management command that only accepts positional
  324. arguments and you didn't specify the
  325. :attr:`~django.core.management.BaseCommand.args` command variable, you might
  326. get an error like ``Error: unrecognized arguments: ...``, as variable parsing
  327. is now based on :py:mod:`argparse` which doesn't implicitly accept positional
  328. arguments. You can make your command backwards compatible by simply setting the
  329. :attr:`~django.core.management.BaseCommand.args` class variable. However, if
  330. you don't have to keep compatibility with older Django versions, it's better to
  331. implement the new :meth:`~django.core.management.BaseCommand.add_arguments`
  332. method as described in :doc:`/howto/custom-management-commands`.
  333. Custom test management command arguments through test runner
  334. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  335. The method to add custom arguments to the `test` management command through the
  336. test runner has changed. Previously, you could provide an `option_list` class
  337. variable on the test runner to add more arguments (à la :py:mod:`optparse`).
  338. Now to implement the same behavior, you have to create an
  339. ``add_arguments(cls, parser)`` class method on the test runner and call
  340. ``parser.add_argument`` to add any custom arguments, as parser is now an
  341. :py:class:`argparse.ArgumentParser` instance.
  342. Model check ensures auto-generated column names are within limits specified by database
  343. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  344. A field name that's longer than the column name length supported by a database
  345. can create problems. For example, with MySQL you'll get an exception trying to
  346. create the column, and with PostgreSQL the column name is truncated by the
  347. database (you may see a warning in the PostgreSQL logs).
  348. A model check has been introduced to better alert users to this scenario before
  349. the actual creation of database tables.
  350. If you have an existing model where this check seems to be a false positive,
  351. for example on PostgreSQL where the name was already being truncated, simply
  352. use :attr:`~django.db.models.Field.db_column` to specify the name that's being
  353. used.
  354. The check also applies to the columns generated in an implicit
  355. ``ManyToManyField.through`` model. If you run into an issue there, use
  356. :attr:`~django.db.models.ManyToManyField.through` to create an explicit model
  357. and then specify :attr:`~django.db.models.Field.db_column` on its column(s)
  358. as needed.
  359. Query relation lookups now check object types
  360. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  361. Querying for model lookups now checks if the object passed is of correct type
  362. and raises a :exc:`ValueError` if not. Previously, Django didn't care if the
  363. object was of correct type; it just used the object's related field attribute
  364. (e.g. ``id``) for the lookup. Now, an error is raised to prevent incorrect
  365. lookups::
  366. >>> book = Book.objects.create(name="Django")
  367. >>> book = Book.objects.filter(author=book)
  368. Traceback (most recent call last):
  369. ...
  370. ValueError: Cannot query "<Book: Django>": Must be "Author" instance.
  371. Default ``EmailField.max_length`` increased to 254
  372. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  373. The old default 75 character ``max_length`` was not capable of storing all
  374. possible RFC3696/5321-compliant email addresses. In order to store all
  375. possible valid email addresses, the ``max_length`` has been increased to 254
  376. characters. You will need to generate and apply database migrations for your
  377. affected models (or add ``max_length=75`` if you wish to keep the length on
  378. your current fields). A migration for
  379. :attr:`django.contrib.auth.models.User.email` is included.
  380. Support for PostgreSQL versions older than 9.0
  381. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  382. The end of upstream support periods was reached in July 2014 for PostgreSQL 8.4.
  383. As a consequence, Django 1.8 sets 9.0 as the minimum PostgreSQL version it
  384. officially supports.
  385. This also includes dropping support for PostGIS 1.3 and 1.4 as these versions
  386. are not supported on versions of PostgreSQL later than 8.4.
  387. Django also now requires the use of Psycopg2 version 2.0.9 or higher.
  388. Support for MySQL versions older than 5.5
  389. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  390. The end of upstream support periods was reached in January 2012 for MySQL 5.0
  391. and December 2013 for MySQL 5.1. As a consequence, Django 1.8 sets 5.5 as the
  392. minimum MySQL version it officially supports.
  393. Support for Oracle versions older than 11.1
  394. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  395. The end of upstream support periods was reached in July 2010 for Oracle 9.2,
  396. January 2012 for Oracle 10.1, and July 2013 for Oracle 10.2. As a consequence,
  397. Django 1.8 sets 11.1 as the minimum Oracle version it officially supports.
  398. Specific privileges used instead of roles for tests on Oracle
  399. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  400. Earlier versions of Django granted the CONNECT and RESOURCE roles to the test
  401. user on Oracle. These roles have been deprecated, so Django 1.8 uses the
  402. specific underlying privileges instead. This changes the privileges required
  403. of the main user for running tests (unless the project is configured to avoid
  404. creating a test user). The exact privileges required now are detailed in
  405. :ref:`Oracle notes <oracle-notes>`.
  406. ``AbstractUser.last_login`` allows null values
  407. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  408. The :attr:`AbstractUser.last_login <django.contrib.auth.models.User.last_login>`
  409. field now allows null values. Previously, it defaulted to the time when the user
  410. was created which was misleading if the user never logged in. Please run the
  411. database migration. If your custom user inherits from ``AbstractUser`` and you
  412. wish to set ``last_login`` to ``NULL`` for users who haven't logged in, you can
  413. run this query::
  414. from django.db import models
  415. from django.contrib.auth import get_user_model
  416. from django.contrib.auth.models import AbstractBaseUser
  417. UserModel = get_user_model()
  418. if issubclass(UserModel, AbstractBaseUser):
  419. UserModel._default_manager.filter(
  420. last_login=models.F('date_joined')
  421. ).update(last_login=None)
  422. :mod:`django.contrib.gis`
  423. ~~~~~~~~~~~~~~~~~~~~~~~~~
  424. * Support for GEOS 3.1 and GDAL 1.6 has been dropped.
  425. * Support for SpatiaLite < 2.4 has been dropped.
  426. * GIS-specific lookups have been refactored to use the
  427. :class:`django.db.models.Lookup` API.
  428. * The default ``str`` representation of
  429. :class:`~django.contrib.gis.geos.GEOSGeometry` objects has been changed from
  430. WKT to EWKT format (including the SRID). As this representation is used in
  431. the serialization framework, that means that ``dumpdata`` output will now
  432. contain the SRID value of geometry objects.
  433. Miscellaneous
  434. ~~~~~~~~~~~~~
  435. * ``connections.queries`` is now a read-only attribute.
  436. * Database connections are considered equal only if they're the same object.
  437. They aren't hashable any more.
  438. * :class:`~django.middleware.gzip.GZipMiddleware` used to disable compression
  439. for some content types when the request is from Internet Explorer, in order
  440. to work around a bug in IE6 and earlier. This behavior could affect
  441. performance on IE7 and later. It was removed.
  442. * ``URLField.to_python`` no longer adds a trailing slash to pathless URLs.
  443. * The :tfilter:`length` template filter now returns ``0`` for an undefined
  444. variable, rather than an empty string.
  445. * ``ForeignKey.default_error_message['invalid']`` has been changed from
  446. ``'%(model)s instance with pk %(pk)r does not exist.'`` to
  447. ``'%(model)s instance with %(field)s %(value)r does not exist.'`` If you are
  448. using this message in your own code, please update the list of interpolated
  449. parameters. Internally, Django will continue to provide the
  450. ``pk`` parameter in ``params`` for backwards compatibility.
  451. * ``UserCreationForm.errors_messages['duplicate_username']`` is no longer used.
  452. If you wish to customize that error message, :ref:`override it on the form
  453. <modelforms-overriding-default-fields>` using the ``'unique'`` key in
  454. ``Meta.errors_messages['username']`` or, if you have a custom form field for
  455. ``'username'``, using the the ``'unique'`` key in its
  456. :attr:`~django.forms.Field.error_messages` argument.
  457. * ``AdminSite`` no longer takes an ``app_name`` argument and its ``app_name``
  458. attribute has been removed. The application name is always ``admin`` (as
  459. opposed to the instance name which you can still customize using
  460. ``AdminSite(name="...")``.
  461. * Internal changes were made to the :class:`~django.forms.ClearableFileInput`
  462. widget to allow more customization. The undocumented ``url_markup_template``
  463. attribute was removed in favor of ``template_with_initial``.
  464. * For consistency with other major vendors, the ``en_GB`` locale now has Monday
  465. as the first day of the week.
  466. * Seconds have been removed from any locales that had them in ``TIME_FORMAT``,
  467. ``DATETIME_FORMAT``, or ``SHORT_DATETIME_FORMAT``.
  468. * The default max size of the Oracle test tablespace has increased from 200M
  469. to 500M.
  470. * :func:`~django.core.urlresolvers.reverse` and
  471. :func:`~django.core.urlresolvers.reverse_lazy` now return Unicode strings
  472. instead of byte strings.
  473. * The ``CacheClass`` shim has been removed from all cache backends.
  474. These aliases were provided for backwards compatibility with Django 1.3.
  475. If you are still using them, please update your project to use the real
  476. class name found in the :setting:`BACKEND <CACHES-BACKEND>` key of the
  477. :setting:`CACHES` setting.
  478. * By default, :ref:`call_command <call-command>` now always skips the check
  479. framework (unless you pass it ``skip_checks=False``).
  480. .. _deprecated-features-1.8:
  481. Features deprecated in 1.8
  482. ==========================
  483. Loading ``cycle`` and ``firstof`` template tags from ``future`` library
  484. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  485. Django 1.6 introduced ``{% load cycle from future %}`` and
  486. ``{% load firstof from future %}`` syntax for forward compatibility of the
  487. :ttag:`cycle` and :ttag:`firstof` template tags. This syntax is now deprecated
  488. and will be removed in Django 2.0. You can simply remove the
  489. ``{% load ... from future %}`` tags.
  490. ``django.conf.urls.patterns()``
  491. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  492. In the olden days of Django, it was encouraged to reference views as strings
  493. in ``urlpatterns``::
  494. urlpatterns = patterns('',
  495. url('^$', 'myapp.views.myview'),
  496. )
  497. and Django would magically import ``myapp.views.myview`` internally and turn
  498. the string into a real function reference. In order to reduce repetition when
  499. referencing many views from the same module, the ``patterns()`` function takes
  500. a required initial ``prefix`` argument which is prepended to all
  501. views-as-strings in that set of ``urlpatterns``::
  502. urlpatterns = patterns('myapp.views',
  503. url('^$', 'myview'),
  504. url('^other/$', 'otherview'),
  505. )
  506. In the modern era, we have updated the tutorial to instead recommend importing
  507. your views module and referencing your view functions (or classes) directly.
  508. This has a number of advantages, all deriving from the fact that we are using
  509. normal Python in place of "Django String Magic": the errors when you mistype a
  510. view name are less obscure, IDEs can help with autocompletion of view names,
  511. etc.
  512. So these days, the above use of the ``prefix`` arg is much more likely to be
  513. written (and is better written) as::
  514. from myapp import views
  515. urlpatterns = patterns('',
  516. url('^$', views.myview),
  517. url('^other/$', views.otherview),
  518. )
  519. Thus ``patterns()`` serves little purpose and is a burden when teaching new users
  520. (answering the newbie's question "why do I need this empty string as the first
  521. argument to ``patterns()``?"). For these reasons, we are deprecating it.
  522. Updating your code is as simple as ensuring that ``urlpatterns`` is a list of
  523. :func:`django.conf.urls.url` instances. For example::
  524. from django.conf.urls import url
  525. from myapp import views
  526. urlpatterns = [
  527. url('^$', views.myview),
  528. url('^other/$', views.otherview),
  529. ]
  530. Passing a string as ``view`` to :func:`~django.conf.urls.url`
  531. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  532. Related to the previous item, referencing views as strings in the ``url()``
  533. function is deprecated. Pass the callable view as described in the previous
  534. section instead.
  535. ``django.test.SimpleTestCase.urls``
  536. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  537. The attribute :attr:`SimpleTestCase.urls <django.test.SimpleTestCase.urls>`
  538. for specifying URLconf configuration in tests has been deprecated and will be
  539. removed in Django 2.0. Use :func:`@override_settings(ROOT_URLCONF=...)
  540. <django.test.override_settings>` instead.
  541. ``prefix`` argument to :func:`~django.conf.urls.i18n.i18n_patterns`
  542. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  543. Related to the previous item, the ``prefix`` argument to
  544. :func:`django.conf.urls.i18n.i18n_patterns` has been deprecated. Simply pass a
  545. list of :func:`django.conf.urls.url` instances instead.
  546. Using an incorrect count of unpacked values in the :ttag:`for` template tag
  547. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  548. Using an incorrect count of unpacked values in :ttag:`for` tag will raise an
  549. exception rather than fail silently in Django 2.0.
  550. Passing a dotted path to :func:`~django.core.urlresolvers.reverse()` and :ttag:`url`
  551. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  552. Reversing URLs by Python path is an expensive operation as it causes the
  553. path being reversed to be imported. This behavior has also resulted in a
  554. `security issue`_. Use :ref:`named URL patterns <naming-url-patterns>`
  555. for reversing instead.
  556. If you are using :mod:`django.contrib.sitemaps`, add the ``name`` argument to
  557. the ``url`` that references :func:`django.contrib.sitemaps.views.sitemap`::
  558. from django.contrib.sitemaps.views import sitemap
  559. url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},
  560. name='django.contrib.sitemaps.views.sitemap')
  561. to ensure compatibility when reversing by Python path is removed in Django 2.0.
  562. Similarly for GIS sitemaps, add ``name='django.contrib.gis.sitemaps.views.kml'``
  563. or ``name='django.contrib.gis.sitemaps.views.kmz'``.
  564. .. _security issue: https://www.djangoproject.com/weblog/2014/apr/21/security/#s-issue-unexpected-code-execution-using-reverse
  565. Extending management command arguments through ``Command.option_list``
  566. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  567. Management commands now use :py:mod:`argparse` instead of :py:mod:`optparse` to
  568. parse command-line arguments passed to commands. This also means that the way
  569. to add custom arguments to commands has changed: instead of extending the
  570. ``option_list`` class list, you should now override the
  571. :meth:`~django.core.management.BaseCommand.add_arguments` method and add
  572. arguments through ``argparse.add_argument()``. See
  573. :ref:`this example <custom-commands-options>` for more details.
  574. ``django.core.management.NoArgsCommand``
  575. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  576. The class :class:`~django.core.management.NoArgsCommand` is now deprecated and
  577. will be removed in Django 2.0. Use :class:`~django.core.management.BaseCommand`
  578. instead, which takes no arguments by default.
  579. ``cache_choices`` option of ``ModelChoiceField`` and ``ModelMultipleChoiceField``
  580. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  581. :class:`~django.forms.ModelChoiceField` and
  582. :class:`~django.forms.ModelMultipleChoiceField` took an undocumented, untested
  583. option ``cache_choices``. This cached querysets between multiple renderings of
  584. the same ``Form`` object. This option is subject to an accelerated deprecation
  585. and will be removed in Django 1.9.
  586. ``django.template.resolve_variable()``
  587. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  588. The function has been informally marked as "Deprecated" for some time. Replace
  589. ``resolve_variable(path, context)`` with
  590. ``django.template.Variable(path).resolve(context)``.
  591. ``django.contrib.webdesign``
  592. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  593. It provided the :ttag:`lorem` template tag which is now included in the
  594. built-in tags. Simply remove ``'django.contrib.webdesign'`` from
  595. :setting:`INSTALLED_APPS` and ``{% load webdesign %}`` from your templates.
  596. ``error_message`` argument to ``django.forms.RegexField``
  597. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  598. It provided backwards compatibility for pre-1.0 code, but its functionality is
  599. redundant. Use ``Field.error_messages['invalid']`` instead.
  600. Old :tfilter:`unordered_list` syntax
  601. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  602. An older (pre-1.0), more restrictive and verbose input format for the
  603. :tfilter:`unordered_list` template filter has been deprecated::
  604. ``['States', [['Kansas', [['Lawrence', []], ['Topeka', []]]], ['Illinois', []]]]``
  605. Using the new syntax, this becomes::
  606. ``['States', ['Kansas', ['Lawrence', 'Topeka'], 'Illinois']]``
  607. ``django.forms.Field._has_changed()``
  608. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  609. Rename this method to :meth:`~django.forms.Field.has_changed` by removing the
  610. leading underscore. The old name will still work until Django 2.0.
  611. ``django.utils.html.remove_tags()`` and ``removetags`` template filter
  612. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  613. ``django.utils.html.remove_tags()`` as well as the template filter
  614. ``removetags`` have been deprecated as they cannot guarantee safe output. Their
  615. existence is likely to lead to their use in security-sensitive contexts where
  616. they are not actually safe.
  617. The unused and undocumented ``django.utils.html.strip_entities()`` function has
  618. also been deprecated.
  619. ``is_admin_site`` argument to ``django.contrib.auth.views.password_reset()``
  620. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  621. It's a legacy option that should no longer be necessary.
  622. ``SubfieldBase``
  623. ~~~~~~~~~~~~~~~~
  624. ``django.db.models.fields.subclassing.SubfieldBase`` has been deprecated and
  625. will be removed in Django 2.0. Historically, it was used to handle fields where
  626. type conversion was needed when loading from the database, but it was not used
  627. in ``.values()`` calls or in aggregates. It has been replaced with
  628. :meth:`~django.db.models.Field.from_db_value`. Note that the new approach does
  629. not call the :meth:`~django.db.models.Field.to_python` method on assignment
  630. as was the case with ``SubfieldBase``.
  631. ``django.utils.checksums``
  632. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  633. The ``django.utils.checksums`` module has been deprecated and will be removed
  634. in Django 2.0. The functionality it provided (validating checksum using the
  635. Luhn algorithm) was undocumented and not used in Django. The module has been
  636. moved to the `django-localflavor`_ package (version 1.1+).
  637. .. _django-localflavor: https://pypi.python.org/pypi/django-localflavor
  638. ``django.contrib.admin.helpers.InlineAdminForm.original_content_type_id``
  639. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  640. The ``original_content_type_id`` attribute on ``InlineAdminForm`` has been
  641. deprecated and will be removed in Django 2.0. Historically, it was used
  642. to construct the "view on site" URL. This URL is now accessible using the
  643. ``absolute_url`` attribute of the form.