1.9.txt 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. ============================================
  2. Django 1.9 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. Welcome to Django 1.9!
  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.8 or older versions. We've :ref:`dropped some features
  8. <deprecation-removed-in-1.9>` that have reached the end of their deprecation
  9. cycle, and we've `begun the deprecation process for some features`_.
  10. .. _`new features`: `What's new in Django 1.9`_
  11. .. _`backwards incompatible changes`: `Backwards incompatible changes in 1.9`_
  12. .. _`dropped some features`: `Features removed in 1.9`_
  13. .. _`begun the deprecation process for some features`: `Features deprecated in 1.9`_
  14. Python compatibility
  15. ====================
  16. Like Django 1.8, Django 1.9 requires Python 2.7 or above, though we
  17. **highly recommend** the latest minor release. We've dropped support for
  18. Python 3.2 and added support for Python 3.5.
  19. What's new in Django 1.9
  20. ========================
  21. ...
  22. Minor features
  23. ~~~~~~~~~~~~~~
  24. :mod:`django.contrib.admin`
  25. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  26. * Admin views now have ``model_admin`` or ``admin_site`` attributes.
  27. * The URL of the admin change view has been changed (was at
  28. ``/admin/<app>/<model>/<pk>/`` by default and is now at
  29. ``/admin/<app>/<model>/<pk>/change/``). This should not affect your
  30. application unless you have hardcoded admin URLs. In that case, replace those
  31. links by :ref:`reversing admin URLs <admin-reverse-urls>` instead. Note that
  32. the old URL still redirects to the new one for backwards compatibility, but
  33. it may be removed in a future version.
  34. * :meth:`ModelAdmin.get_list_select_related()
  35. <django.contrib.admin.ModelAdmin.get_list_select_related>` was added to allow
  36. changing the ``select_related()`` values used in the admin's changelist query
  37. based on the request.
  38. * The ``available_apps`` context variable, which lists the available
  39. applications for the current user, has been added to the
  40. :meth:`AdminSite.each_context() <django.contrib.admin.AdminSite.each_context>`
  41. method.
  42. * :attr:`AdminSite.empty_value_display
  43. <django.contrib.admin.AdminSite.empty_value_display>` and
  44. :attr:`ModelAdmin.empty_value_display
  45. <django.contrib.admin.ModelAdmin.empty_value_display>` were added to override
  46. the display of empty values in admin change list. You can also customize the
  47. value for each field.
  48. :mod:`django.contrib.auth`
  49. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  50. * The default iteration count for the PBKDF2 password hasher has been increased
  51. by 20%. This backwards compatible change will not affect users who have
  52. subclassed ``django.contrib.auth.hashers.PBKDF2PasswordHasher`` to change the
  53. default value.
  54. * The ``BCryptSHA256PasswordHasher`` will now update passwords if its
  55. ``rounds`` attribute is changed.
  56. * ``AbstractBaseUser`` and ``BaseUserManager`` were moved to a new
  57. ``django.contrib.auth.base_user`` module so that they can be imported without
  58. including ``django.contrib.auth`` in :setting:`INSTALLED_APPS` (this raised
  59. a deprecation warning in older versions and is no longer supported in
  60. Django 1.9).
  61. :mod:`django.contrib.gis`
  62. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  63. * All ``GeoQuerySet`` methods have been deprecated and replaced by
  64. :doc:`equivalent database functions </ref/contrib/gis/functions>`. As soon
  65. as the legacy methods have been replaced in your code, you should even be
  66. able to remove the special ``GeoManager`` from your GIS-enabled classes.
  67. * The GDAL interface now supports instantiating file-based and in-memory
  68. :ref:`GDALRaster objects <raster-data-source-objects>` from raw data.
  69. Setters for raster properties such as projection or pixel values have
  70. been added.
  71. :mod:`django.contrib.messages`
  72. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  73. * ...
  74. :mod:`django.contrib.postgres`
  75. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  76. * Added support for the :lookup:`rangefield.contained_by` lookup for some built
  77. in fields which correspond to the range fields.
  78. * Added :class:`~django.contrib.postgres.fields.JSONField`.
  79. * Added :doc:`/ref/contrib/postgres/aggregates`.
  80. * Fixed serialization of
  81. :class:`~django.contrib.postgres.fields.DateRangeField` and
  82. :class:`~django.contrib.postgres.fields.DateTimeRangeField`.
  83. :mod:`django.contrib.redirects`
  84. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  85. * ...
  86. :mod:`django.contrib.sessions`
  87. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  88. * ...
  89. :mod:`django.contrib.sitemaps`
  90. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  91. * ...
  92. :mod:`django.contrib.sites`
  93. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  94. * ...
  95. :mod:`django.contrib.staticfiles`
  96. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  97. * ...
  98. :mod:`django.contrib.syndication`
  99. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  100. * ...
  101. Cache
  102. ^^^^^
  103. * ``django.core.cache.backends.base.BaseCache`` now has a ``get_or_set()``
  104. method.
  105. * :func:`django.views.decorators.cache.never_cache` now sends more persuasive
  106. headers (added ``no-cache, no-store, must-revalidate`` to ``Cache-Control``)
  107. to better prevent caching.
  108. Email
  109. ^^^^^
  110. * ...
  111. File Storage
  112. ^^^^^^^^^^^^
  113. * :meth:`Storage.get_valid_name()
  114. <django.core.files.storage.Storage.get_valid_name>` is now called when
  115. the :attr:`~django.db.models.FileField.upload_to` is a callable.
  116. File Uploads
  117. ^^^^^^^^^^^^
  118. * ...
  119. Forms
  120. ^^^^^
  121. * :class:`~django.forms.ModelForm` accepts the new ``Meta`` option
  122. ``field_classes`` to customize the type of the fields. See
  123. :ref:`modelforms-overriding-default-fields` for details.
  124. * You can now specify the order in which form fields are rendered with the
  125. :attr:`~django.forms.Form.field_order` attribute, the ``field_order``
  126. constructor argument , or the :meth:`~django.forms.Form.order_fields` method.
  127. * A form prefix can be specified inside a form class, not only when
  128. instantiating a form. See :ref:`form-prefix` for details.
  129. * You can now :ref:`specify keyword arguments <custom-formset-form-kwargs>`
  130. that you want to pass to the constructor of forms in a formset.
  131. Generic Views
  132. ^^^^^^^^^^^^^
  133. * Class based views generated using ``as_view()`` now have ``view_class``
  134. and ``view_initkwargs`` attributes.
  135. Internationalization
  136. ^^^^^^^^^^^^^^^^^^^^
  137. * The :func:`django.views.i18n.set_language` view now properly redirects to
  138. :ref:`translated URLs <url-internationalization>`, when available.
  139. * The :func:`django.views.i18n.javascript_catalog` view now works correctly
  140. if used multiple times with different configurations on the same page.
  141. * The :func:`django.utils.timezone.make_aware` function gained an ``is_dst``
  142. argument to help resolve ambiguous times during DST transitions.
  143. * You can now use locale variants supported by gettext. These are usually used
  144. for languages which can be written in different scripts, for example Latin
  145. and Cyrillic (e.g. ``be@latin``).
  146. * Added the ``name_translated`` attribute to the object returned by the
  147. :ttag:`get_language_info` template tag. Also added a corresponding template
  148. filter: :tfilter:`language_name_translated`.
  149. * You can now run :djadmin:`compilemessages` from the root directory of your
  150. project and it will find all the app message files that were created by
  151. :djadmin:`makemessages`.
  152. Management Commands
  153. ^^^^^^^^^^^^^^^^^^^
  154. * The new :djadmin:`sendtestemail` command lets you send a test email to
  155. easily confirm that email sending through Django is working.
  156. * To increase the readability of the SQL code generated by
  157. :djadmin:`sqlmigrate`, the SQL code generated for each migration operation is
  158. preceded by the operation's description.
  159. * The :djadmin:`dumpdata` command output is now deterministically ordered.
  160. * The :djadmin:`createcachetable` command now has a ``--dry-run`` flag to
  161. print out the SQL rather than execute it.
  162. Models
  163. ^^^^^^
  164. * Database configuration gained a :setting:`TIME_ZONE <DATABASE-TIME_ZONE>`
  165. option for interacting with databases that store datetimes in local time and
  166. don't support time zones when :setting:`USE_TZ` is ``True``.
  167. * Added the :meth:`RelatedManager.set()
  168. <django.db.models.fields.related.RelatedManager.set()>` method to the related
  169. managers created by ``ForeignKey``, ``GenericForeignKey``, and
  170. ``ManyToManyField``.
  171. * Added the ``keep_parents`` parameter to :meth:`Model.delete()
  172. <django.db.models.Model.delete>` to allow deleting only a child's data in a
  173. model that uses multi-table inheritance.
  174. * :meth:`Model.delete() <django.db.models.Model.delete>`
  175. and :meth:`QuerySet.delete() <django.db.models.query.QuerySet.delete>` return
  176. the number of objects deleted.
  177. * Added a system check to prevent defining both ``Meta.ordering`` and
  178. ``order_with_respect_to`` on the same model.
  179. * :lookup:`Date and time <year>` lookups can be chained with other lookups
  180. (such as :lookup:`exact`, :lookup:`gt`, :lookup:`lt`, etc.). For example:
  181. ``Entry.objects.filter(pub_date__month__gt=6)``.
  182. * Time lookups (hour, minute, second) are now supported by
  183. :class:`~django.db.models.TimeField` for all database backends. Support for
  184. backends other than SQLite was added but undocumented in Django 1.7.
  185. * You can specify the ``output_field`` parameter of the
  186. :class:`~django.db.models.Avg` aggregate in order to aggregate over
  187. non-numeric columns, such as ``DurationField``.
  188. * Added the :lookup:`date` lookup to :class:`~django.db.models.DateTimeField`
  189. to allow querying the field by only the date portion.
  190. * Added the :class:`~django.db.models.functions.Greatest` and
  191. :class:`~django.db.models.functions.Least` database functions.
  192. * Added the :class:`~django.db.models.functions.Now` database function, which
  193. returns the current date and time.
  194. CSRF
  195. ^^^^
  196. * The request header's name used for CSRF authentication can be customized
  197. with :setting:`CSRF_HEADER_NAME`.
  198. Signals
  199. ^^^^^^^
  200. * ...
  201. Templates
  202. ^^^^^^^^^
  203. * Template tags created with the :meth:`~django.template.Library.simple_tag`
  204. helper can now store results in a template variable by using the ``as``
  205. argument.
  206. * Added a :meth:`Context.setdefault() <django.template.Context.setdefault>`
  207. method.
  208. * A warning will now be logged for missing context variables. These messages
  209. will be logged to the :ref:`django.template <django-template-logger>` logger.
  210. * The :ttag:`firstof` template tag supports storing the output in a variable
  211. using 'as'.
  212. * :meth:`Context.update() <django.template.Context.update>` can now be used as
  213. a context manager.
  214. * Django template loaders can now extend templates recursively.
  215. * The debug page template postmortem now include output from each engine that
  216. is installed.
  217. * :ref:`Debug page integration <template-debug-integration>` for custom
  218. template engines was added.
  219. * The :class:`~django.template.backends.django.DjangoTemplates` backend gained
  220. the ability to register libraries and builtins explicitly through the
  221. template :setting:`OPTIONS <TEMPLATES-OPTIONS>`.
  222. * The ``timesince`` and ``timeuntil`` filters were improved to deal with leap
  223. years when given large time spans.
  224. * The ``include`` tag now caches parsed templates objects during template
  225. rendering, speeding up reuse in places such as for loops.
  226. Requests and Responses
  227. ^^^^^^^^^^^^^^^^^^^^^^
  228. * Unless :attr:`HttpResponse.reason_phrase
  229. <django.http.HttpResponse.reason_phrase>` is explicitly set, it now is
  230. determined by the current value of :attr:`HttpResponse.status_code
  231. <django.http.HttpResponse.status_code>`. Modifying the value of
  232. ``status_code`` outside of the constructor will also modify the value of
  233. ``reason_phrase``.
  234. * The debug view now shows details of chained exceptions on Python 3.
  235. * The default 40x error views now accept a second positional parameter, the
  236. exception that triggered the view.
  237. Tests
  238. ^^^^^
  239. * Added the :meth:`json() <django.test.Response.json>` method to test client
  240. responses to give access to the response body as JSON.
  241. URLs
  242. ^^^^
  243. * Regular expression lookaround assertions are now allowed in URL patterns.
  244. Validators
  245. ^^^^^^^^^^
  246. * Added :func:`django.core.validators.int_list_validator` to generate
  247. validators of strings containing integers separated with a custom character.
  248. * :class:`~django.core.validators.EmailValidator` now limits the length of
  249. domain name labels to 63 characters per :rfc:`1034`.
  250. Backwards incompatible changes in 1.9
  251. =====================================
  252. .. warning::
  253. In addition to the changes outlined in this section, be sure to review the
  254. :doc:`deprecation timeline </internals/deprecation>` for any features that
  255. have been removed. If you haven't updated your code within the
  256. deprecation timeline for a given feature, its removal may appear as a
  257. backwards incompatible change.
  258. Database backend API
  259. ~~~~~~~~~~~~~~~~~~~~
  260. * A couple of new tests rely on the ability of the backend to introspect column
  261. defaults (returning the result as ``Field.default``). You can set the
  262. ``can_introspect_default`` database feature to ``False`` if your backend
  263. doesn't implement this. You may want to review the implementation on the
  264. backends that Django includes for reference (:ticket:`24245`).
  265. * Registering a global adapter or converter at the level of the DB-API module
  266. to handle time zone information of :class:`~datetime.datetime` values passed
  267. as query parameters or returned as query results on databases that don't
  268. support time zones is discouraged. It can conflict with other libraries.
  269. The recommended way to add a time zone to :class:`~datetime.datetime` values
  270. fetched from the database is to register a converter for ``DateTimeField``
  271. in ``DatabaseOperations.get_db_converters()``.
  272. The ``needs_datetime_string_cast`` database feature was removed. Database
  273. backends that set it must register a converter instead, as explained above.
  274. * The ``DatabaseOperations.value_to_db_<type>()`` methods were renamed to
  275. ``adapt_<type>field_value()`` to mirror the ``convert_<type>field_value()``
  276. methods.
  277. * To use the new ``date`` lookup, third-party database backends may need to
  278. implement the ``DatabaseOperations.datetime_cast_date_sql()`` method.
  279. * The ``DatabaseOperations.time_extract_sql()`` method was added. It calls the
  280. existing ``date_extract_sql()`` method. This method is overridden by the
  281. SQLite backend to add time lookups (hour, minute, second) to
  282. :class:`~django.db.models.TimeField`, and may be needed by third-party
  283. database backends.
  284. Default settings that were tuples are now lists
  285. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  286. The default settings in ``django.conf.global_settings`` were a combination of
  287. lists and tuples. All settings that were formerly tuples are now lists.
  288. ``is_usable`` attribute on template loaders is removed
  289. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  290. Django template loaders previously required an ``is_usable`` attribute to be
  291. defined. If a loader was configured in the template settings and this attribute
  292. was ``False``, the loader would be silently ignored. In practice, this was only
  293. used by the egg loader to detect if setuptools was installed. The ``is_usable``
  294. attribute is now removed and the egg loader instead fails at runtime if
  295. setuptools is not installed.
  296. Related set direct assignment
  297. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  298. :ref:`Direct assignment <direct-assignment>`) used to perform a ``clear()``
  299. followed by a call to ``add()``. This caused needlessly large data changes
  300. and prevented using the :data:`~django.db.models.signals.m2m_changed` signal
  301. to track individual changes in many-to-many relations.
  302. Direct assignment now relies on the the new
  303. :meth:`django.db.models.fields.related.RelatedManager.set()` method on
  304. related managers which by default only processes changes between the
  305. existing related set and the one that's newly assigned. The previous behavior
  306. can be restored by replacing direct assignment by a call to ``set()`` with
  307. the keyword argument ``clear=True``.
  308. ``ModelForm``, and therefore ``ModelAdmin``, internally rely on direct
  309. assignment for many-to-many relations and as a consequence now use the new
  310. behavior.
  311. Filesystem-based template loaders catch more specific exceptions
  312. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  313. When using the :class:`filesystem.Loader <django.template.loaders.filesystem.Loader>`
  314. or :class:`app_directories.Loader <django.template.loaders.app_directories.Loader>`
  315. template loaders, earlier versions of Django raised a
  316. :exc:`~django.template.TemplateDoesNotExist` error if a template source existed
  317. but was unreadable. This could happen under many circumstances, such as if
  318. Django didn't have permissions to open the file, or if the template source was
  319. a directory. Now, Django only silences the exception if the template source
  320. does not exist. All other situations result in the original ``IOError`` being
  321. raised.
  322. HTTP redirects no longer forced to absolute URIs
  323. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  324. Relative redirects are no longer converted to absolute URIs. :rfc:`2616`
  325. required the ``Location`` header in redirect responses to be an absolute URI,
  326. but it has been superseded by :rfc:`7231` which allows relative URIs in
  327. ``Location``, recognizing the actual practice of user agents, almost all of
  328. which support them.
  329. Consequently, the expected URLs passed to ``assertRedirects`` should generally
  330. no longer include the scheme and domain part of the URLs. For example,
  331. ``self.assertRedirects(response, 'http://testserver/some-url/')`` should be
  332. replaced by ``self.assertRedirects(response, '/some-url/')`` (unless the
  333. redirection specifically contained an absolute URL, of course).
  334. Dropped support for PostgreSQL 9.0
  335. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  336. Upstream support for PostgreSQL 9.0 ended in September 2015. As a consequence,
  337. Django 1.9 sets 9.1 as the minimum PostgreSQL version it officially supports.
  338. Template ``LoaderOrigin`` and ``StringOrigin`` are removed
  339. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  340. In previous versions of Django, when a template engine was initialized with
  341. debug as ``True``, an instance of ``django.template.loader.LoaderOrigin`` or
  342. ``django.template.base.StringOrigin`` was set as the origin attribute on the
  343. template object. These classes have been combined into
  344. :class:`~django.template.base.Origin` and is now always set regardless of the
  345. engine debug setting.
  346. .. _default-logging-changes-19:
  347. Changes to the default logging configuration
  348. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  349. To make it easier to write custom logging configurations, Django's default
  350. logging configuration no longer defines 'django.request' and 'django.security'
  351. loggers. Instead, it defines a single 'django' logger with two handlers:
  352. * 'console': filtered at the ``INFO`` level and only active if ``DEBUG=True``.
  353. * 'mail_admins': filtered at the ``ERROR`` level and only active if
  354. ``DEBUG=False``.
  355. If you aren't overriding Django's default logging, you should see minimal
  356. changes in behavior, but you might see some new logging to the ``runserver``
  357. console, for example.
  358. If you are overriding Django's default logging, you should check to see how
  359. your configuration merges with the new defaults.
  360. Removal of time zone aware global adapters and converters for datetimes
  361. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  362. Django no longer registers global adapters and converters for managing time
  363. zone information on :class:`~datetime.datetime` values sent to the database as
  364. query parameters or read from the database in query results. This change
  365. affects projects that meet all the following conditions:
  366. * The :setting:`USE_TZ` setting is ``True``.
  367. * The database is SQLite, MySQL, Oracle, or a third-party database that
  368. doesn't support time zones. In doubt, you can check the value of
  369. ``connection.features.supports_timezones``.
  370. * The code queries the database outside of the ORM, typically with
  371. ``cursor.execute(sql, params)``.
  372. If you're passing aware :class:`~datetime.datetime` parameters to such
  373. queries, you should turn them into naive datetimes in UTC::
  374. from django.utils import timezone
  375. param = timezone.make_naive(param, timezone.utc)
  376. If you fail to do so, Django 1.9 and 2.0 will perform the conversion like
  377. earlier versions but emit a deprecation warning. Django 2.1 won't perform any
  378. conversion, which may result in data corruption.
  379. If you're reading :class:`~datetime.datetime` values from the results, they
  380. will be naive instead of aware. You can compensate as follows::
  381. from django.utils import timezone
  382. value = timezone.make_aware(value, timezone.utc)
  383. You don't need any of this if you're querying the database through the ORM,
  384. even if you're using :meth:`raw() <django.db.models.query.QuerySet.raw>`
  385. queries. The ORM takes care of managing time zone information.
  386. Template tag modules are imported when templates are configured
  387. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  388. The :class:`~django.template.backends.django.DjangoTemplates` backend now
  389. performs discovery on installed template tag modules when instantiated. This
  390. update enables libraries to be provided explicitly via the ``'libraries'``
  391. key of :setting:`OPTIONS <TEMPLATES-OPTIONS>` when defining a
  392. :class:`~django.template.backends.django.DjangoTemplates` backend. Import
  393. or syntax errors in template tag modules now fail early at instantiation time
  394. rather than when a template with a :ttag:`{% load %}<load>` tag is first
  395. compiled.
  396. ``django.template.base.add_to_builtins()`` is removed
  397. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  398. Although it was a private API, projects commonly used ``add_to_builtins()`` to
  399. make template tags and filters available without using the
  400. :ttag:`{% load %}<load>` tag. This API has been formalized. Projects should now
  401. define built-in libraries via the ``'builtins'`` key of :setting:`OPTIONS
  402. <TEMPLATES-OPTIONS>` when defining a
  403. :class:`~django.template.backends.django.DjangoTemplates` backend.
  404. Miscellaneous
  405. ~~~~~~~~~~~~~
  406. * CSS and images in ``contrib.admin`` to support Internet Explorer 6 & 7 have
  407. been removed as these browsers have reached end-of-life.
  408. * The text displayed for null columns in the admin changelist ``list_display``
  409. cells has changed from ``(None)`` (or its translated equivalent) to ``-``.
  410. * ``django.http.responses.REASON_PHRASES`` and
  411. ``django.core.handlers.wsgi.STATUS_CODE_TEXT`` have been removed. Use
  412. Python's stdlib instead: :data:`http.client.responses` for Python 3 and
  413. `httplib.responses`_ for Python 2.
  414. .. _`httplib.responses`: https://docs.python.org/2/library/httplib.html#httplib.responses
  415. * ``ValuesQuerySet`` and ``ValuesListQuerySet`` have been removed.
  416. * The ``admin/base.html`` template no longer sets
  417. ``window.__admin_media_prefix__``. Image references in JavaScript that used
  418. that value to construct absolute URLs have been moved to CSS for easier
  419. customization.
  420. * ``CommaSeparatedIntegerField`` validation has been refined to forbid values
  421. like ``','``, ``',1'``, and ``'1,,2'``.
  422. * Form initialization was moved from the :meth:`ProcessFormView.get()
  423. <django.views.generic.edit.ProcessFormView.get>` method to the new
  424. :meth:`FormMixin.get_context_data()
  425. <django.views.generic.edit.FormMixin.get_context_data>` method. This may be
  426. backwards incompatible if you have overridden the ``get_context_data()``
  427. method without calling ``super()``.
  428. * Support for PostGIS 1.5 has been dropped.
  429. * The ``django.contrib.sites.models.Site.domain`` field was changed to be
  430. :attr:`~django.db.models.Field.unique`.
  431. * In order to enforce test isolation, database queries are not allowed
  432. by default in :class:`~django.test.SimpleTestCase` tests anymore. You
  433. can disable this behavior by setting the
  434. :attr:`~django.test.SimpleTestCase.allow_database_queries` class attribute
  435. to ``True`` on your test class.
  436. * :attr:`ResolverMatch.app_name
  437. <django.core.urlresolvers.ResolverMatch.app_name>` was changed to contain
  438. the full namespace path in the case of nested namespaces. For consistency
  439. with :attr:`ResolverMatch.namespace
  440. <django.core.urlresolvers.ResolverMatch.namespace>`, the empty value is now
  441. an empty string instead of ``None``.
  442. .. _deprecated-features-1.9:
  443. Features deprecated in 1.9
  444. ==========================
  445. ``assignment_tag()``
  446. ~~~~~~~~~~~~~~~~~~~~
  447. Django 1.4 added the ``assignment_tag`` helper to ease the creation of
  448. template tags that store results in a template variable. The
  449. :meth:`~django.template.Library.simple_tag` helper has gained this same
  450. ability, making the ``assignment_tag`` obsolete. Tags that use
  451. ``assignment_tag`` should be updated to use ``simple_tag``.
  452. ``{% cycle %}`` syntax with comma-separated arguments
  453. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  454. The :ttag:`cycle` tag supports an inferior old syntax from previous Django
  455. versions:
  456. .. code-block:: html+django
  457. {% cycle row1,row2,row3 %}
  458. Its parsing caused bugs with the current syntax, so support for the old syntax
  459. will be removed in Django 2.0 following an accelerated deprecation.
  460. ``Field.rel`` changes
  461. ~~~~~~~~~~~~~~~~~~~~~
  462. ``Field.rel`` and its methods and attributes have changed to match the related
  463. fields API. The ``Field.rel`` attribute is renamed to ``remote_field`` and many
  464. of its methods and attributes are either changed or renamed.
  465. The aim of these changes is to provide a documented API for relation fields.
  466. ``GeoManager`` and ``GeoQuerySet`` custom methods
  467. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  468. All custom ``GeoQuerySet`` methods (``area()``, ``distance()``, ``gml()``, ...)
  469. have been replaced by equivalent geographic expressions in annotations (see in
  470. new features). Hence the need to set a custom ``GeoManager`` to GIS-enabled
  471. models is now obsolete. As soon as your code doesn't call any of the deprecated
  472. methods, you can simply remove the ``objects = GeoManager()`` lines from your
  473. models.
  474. Template loader APIs have changed
  475. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  476. Django template loaders have been updated to allow recursive template
  477. extending. This change necessitated a new template loader API. The old
  478. ``load_template()`` and ``load_template_sources()`` methods are now deprecated.
  479. Details about the new API can be found :ref:`in the template loader
  480. documentation <custom-template-loaders>`.
  481. Miscellaneous
  482. ~~~~~~~~~~~~~
  483. * The ``weak`` argument to ``django.dispatch.signals.Signal.disconnect()`` has
  484. been deprecated as it has no effect.
  485. * The ``check_aggregate_support()`` method of
  486. ``django.db.backends.base.BaseDatabaseOperations`` has been deprecated and
  487. will be removed in Django 2.1. The more general ``check_expression_support()``
  488. should be used instead.
  489. * ``django.forms.extras`` is deprecated. You can find
  490. :class:`~django.forms.SelectDateWidget` in ``django.forms.widgets``
  491. (or simply ``django.forms``) instead.
  492. * Private API ``django.db.models.fields.add_lazy_relation()`` is deprecated.
  493. * The ``django.contrib.auth.tests.utils.skipIfCustomUser()`` decorator is
  494. deprecated. With the test discovery changes in Django 1.6, the tests for
  495. ``django.contrib`` apps are no longer run as part of the user's project.
  496. Therefore, the ``@skipIfCustomUser`` decorator is no longer needed to
  497. decorate tests in ``django.contrib.auth``.
  498. * If you customized some :ref:`error handlers <error-views>`, the view
  499. signatures with only one request parameter are deprecated. The views should
  500. now also accept a second ``exception`` positional parameter.
  501. * The ``django.utils.feedgenerator.Atom1Feed.mime_type`` and
  502. ``django.utils.feedgenerator.RssFeed.mime_type`` attributes are deprecated in
  503. favor of ``content_type``.
  504. .. removed-features-1.9:
  505. Features removed in 1.9
  506. =======================
  507. These features have reached the end of their deprecation cycle and so have been
  508. removed in Django 1.9 (please see the :ref:`deprecation timeline
  509. <deprecation-removed-in-1.9>` for more details):
  510. * ``django.utils.dictconfig`` is removed.
  511. * ``django.utils.importlib`` is removed.
  512. * ``django.utils.tzinfo`` is removed.
  513. * ``django.utils.unittest`` is removed.
  514. * The ``syncdb`` command is removed.
  515. * ``django.db.models.signals.pre_syncdb`` and
  516. ``django.db.models.signals.post_syncdb`` is removed.
  517. * Support for ``allow_syncdb`` on database routers is removed.
  518. * The legacy method of syncing apps without migrations is removed,
  519. and migrations are compulsory for all apps. This includes automatic
  520. loading of ``initial_data`` fixtures and support for initial SQL data.
  521. * All models need to be defined inside an installed application or declare an
  522. explicit :attr:`~django.db.models.Options.app_label`. Furthermore, it isn't
  523. possible to import them before their application is loaded. In particular, it
  524. isn't possible to import models inside the root package of an application.
  525. * The model and form ``IPAddressField`` is removed. A stub field remains for
  526. compatibility with historical migrations.
  527. * ``AppCommand.handle_app()`` is no longer be supported.
  528. * ``RequestSite`` and ``get_current_site()`` are no longer importable from
  529. ``django.contrib.sites.models``.
  530. * FastCGI support via the ``runfcgi`` management command is removed.
  531. * ``django.utils.datastructures.SortedDict`` is removed.
  532. * ``ModelAdmin.declared_fieldsets`` is removed.
  533. * The ``util`` modules that provided backwards compatibility are removed:
  534. * ``django.contrib.admin.util``
  535. * ``django.contrib.gis.db.backends.util``
  536. * ``django.db.backends.util``
  537. * ``django.forms.util``
  538. * ``ModelAdmin.get_formsets`` is removed.
  539. * The backward compatible shims introduced to rename the
  540. ``BaseMemcachedCache._get_memcache_timeout()`` method to
  541. ``get_backend_timeout()`` is removed.
  542. * The ``--natural`` and ``-n`` options for :djadmin:`dumpdata` are removed.
  543. * The ``use_natural_keys`` argument for ``serializers.serialize()`` is removed.
  544. * Private API ``django.forms.forms.get_declared_fields()`` is removed.
  545. * The ability to use a ``SplitDateTimeWidget`` with ``DateTimeField`` is
  546. removed.
  547. * The ``WSGIRequest.REQUEST`` property is removed.
  548. * The class ``django.utils.datastructures.MergeDict`` is removed.
  549. * The ``zh-cn`` and ``zh-tw`` language codes are removed.
  550. * The internal ``django.utils.functional.memoize()`` is removed.
  551. * ``django.core.cache.get_cache`` is removed.
  552. * ``django.db.models.loading`` is removed.
  553. * Passing callable arguments to querysets is no longer possible.
  554. * ``BaseCommand.requires_model_validation`` is removed in favor of
  555. ``requires_system_checks``. Admin validators is replaced by admin checks.
  556. * The ``ModelAdmin.validator_class`` and ``default_validator_class`` attributes
  557. are removed.
  558. * ``ModelAdmin.validate()`` is removed.
  559. * ``django.db.backends.DatabaseValidation.validate_field`` is removed in
  560. favor of the ``check_field`` method.
  561. * The ``validate`` management command is removed.
  562. * ``django.utils.module_loading.import_by_path`` is removed in favor of
  563. ``django.utils.module_loading.import_string``.
  564. * ``ssi`` and ``url`` template tags are removed from the ``future`` template
  565. tag library.
  566. * ``django.utils.text.javascript_quote()`` is removed.
  567. * Database test settings as independent entries in the database settings,
  568. prefixed by ``TEST_``, are no longer supported.
  569. * The `cache_choices` option to :class:`~django.forms.ModelChoiceField` and
  570. :class:`~django.forms.ModelMultipleChoiceField` is removed.
  571. * The default value of the
  572. :attr:`RedirectView.permanent <django.views.generic.base.RedirectView.permanent>`
  573. attribute has changed from ``True`` to ``False``.
  574. * ``django.contrib.sitemaps.FlatPageSitemap`` is removed in favor of
  575. ``django.contrib.flatpages.sitemaps.FlatPageSitemap``.
  576. * Private API ``django.test.utils.TestTemplateLoader`` is removed.
  577. * The ``django.contrib.contenttypes.generic`` module is removed.