1.7.txt 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489
  1. ============================================
  2. Django 1.7 release notes - UNDER DEVELOPMENT
  3. ============================================
  4. Welcome to Django 1.7!
  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.7>`, and we've `begun the
  9. deprecation process for some features`_.
  10. .. _`new features`: `What's new in Django 1.7`_
  11. .. _`backwards incompatible changes`: `Backwards incompatible changes in 1.7`_
  12. .. _`begun the deprecation process for some features`: `Features deprecated in 1.7`_
  13. Python compatibility
  14. ====================
  15. Django 1.7 requires Python 2.7 or above, though we **highly recommend**
  16. the latest minor release. Support for Python 2.6 has been dropped.
  17. This change should affect only a small number of Django users, as most
  18. operating-system vendors today are shipping Python 2.7 or newer as their default
  19. version. If you're still using Python 2.6, however, you'll need to stick to
  20. Django 1.6 until you can upgrade your Python version. Per :doc:`our support
  21. policy </internals/release-process>`, Django 1.6 will continue to receive
  22. security support until the release of Django 1.8.
  23. What's new in Django 1.7
  24. ========================
  25. Schema migrations
  26. ~~~~~~~~~~~~~~~~~
  27. Django now has built-in support for schema migrations. It allows models
  28. to be updated, changed, and deleted by creating migration files that represent
  29. the model changes and which can be run on any development, staging or production
  30. database.
  31. Migrations are covered in :doc:`their own documentation</topics/migrations>`,
  32. but a few of the key features are:
  33. * ``syncdb`` has been deprecated and replaced by ``migrate``. Don't worry -
  34. calls to ``syncdb`` will still work as before.
  35. * A new ``makemigrations`` command provides an easy way to autodetect changes
  36. to your models and make migrations for them.
  37. :data:`~django.db.models.signals.pre_syncdb` and
  38. :data:`~django.db.models.signals.post_syncdb` have been replaced by
  39. :data:`~django.db.models.signals.pre_migrate` and
  40. :data:`~django.db.models.signals.post_migrate` respectively. These new
  41. signals have slightly different arguments. Check the documentation for
  42. details.
  43. * The ``allow_syncdb`` method on database routers is now called ``allow_migrate``,
  44. but still performs the same function. Routers with ``allow_syncdb`` methods
  45. will still work, but that method name is deprecated and you should change
  46. it as soon as possible (nothing more than renaming is required).
  47. * ``initial_data`` fixtures are no longer loaded for apps with migrations; if
  48. you want to load initial data for an app, we suggest you do it in a migration.
  49. App-loading refactor
  50. ~~~~~~~~~~~~~~~~~~~~
  51. Historically, Django applications were tightly linked to models. A singleton
  52. known as the "app cache" dealt with both installed applications and models.
  53. The models module was used as an identifier for applications in many APIs.
  54. As the concept of :doc:`Django applications </ref/applications>` matured, this
  55. code showed some shortcomings. It has been refactored into an "app registry"
  56. where models modules no longer have a central role and where it's possible to
  57. attach configuration data to applications.
  58. Improvements thus far include:
  59. * Applications can run code at startup, before Django does anything else, with
  60. the :meth:`~django.apps.AppConfig.ready` method of their configuration.
  61. * Application labels are assigned correctly to models even when they're
  62. defined outside of ``models.py``. You don't have to set
  63. :attr:`~django.db.models.Options.app_label` explicitly any more.
  64. * It is possible to omit ``models.py`` entirely if an application doesn't
  65. have any models.
  66. * Applications can be relabeled with the :attr:`~django.apps.AppConfig.label`
  67. attribute of application configurations, to work around label conflicts.
  68. * The name of applications can be customized in the admin with the
  69. :attr:`~django.apps.AppConfig.verbose_name` of application configurations.
  70. * The admin automatically calls :func:`~django.contrib.admin.autodiscover()`
  71. when Django starts. You can consequently remove this line from your
  72. URLconf.
  73. * Django imports all application configurations and models as soon as it
  74. starts, through a deterministic and straightforward process. This should
  75. make it easier to diagnose import issues such as import loops.
  76. New method on Field subclasses
  77. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  78. To help power both schema migrations and composite keys, the :class:`~django.db.models.Field` API now
  79. has a new required method: ``deconstruct()``.
  80. This method takes no arguments, and returns a tuple of four items:
  81. * ``name``: The field's attribute name on its parent model, or None if it is not part of a model
  82. * ``path``: A dotted, Python path to the class of this field, including the class name.
  83. * ``args``: Positional arguments, as a list
  84. * ``kwargs``: Keyword arguments, as a dict
  85. These four values allow any field to be serialized into a file, as well as
  86. allowing the field to be copied safely, both essential parts of these new features.
  87. This change should not affect you unless you write custom Field subclasses;
  88. if you do, you may need to reimplement the ``deconstruct()`` method if your
  89. subclass changes the method signature of ``__init__`` in any way. If your
  90. field just inherits from a built-in Django field and doesn't override ``__init__``,
  91. no changes are necessary.
  92. If you do need to override ``deconstruct()``, a good place to start is the
  93. built-in Django fields (``django/db/models/fields/__init__.py``) as several
  94. fields, including ``DecimalField`` and ``DateField``, override it and show how
  95. to call the method on the superclass and simply add or remove extra arguments.
  96. Calling custom ``QuerySet`` methods from the ``Manager``
  97. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  98. Historically, the recommended way to make reusable model queries was to create
  99. methods on a custom ``Manager`` class. The problem with this approach was that
  100. after the first method call, you'd get back a ``QuerySet`` instance and
  101. couldn't call additional custom manager methods.
  102. Though not documented, it was common to work around this issue by creating a
  103. custom ``QuerySet`` so that custom methods could be chained; but the solution
  104. had a number of drawbacks:
  105. * The custom ``QuerySet`` and its custom methods were lost after the first
  106. call to ``values()`` or ``values_list()``.
  107. * Writing a custom ``Manager`` was still necessary to return the custom
  108. ``QuerySet`` class and all methods that were desired on the ``Manager``
  109. had to be proxied to the ``QuerySet``. The whole process went against
  110. the DRY principle.
  111. The :meth:`QuerySet.as_manager() <django.db.models.query.QuerySet.as_manager>`
  112. class method can now directly :ref:`create Manager with QuerySet methods
  113. <create-manager-with-queryset-methods>`::
  114. class FoodQuerySet(models.QuerySet):
  115. def pizzas(self):
  116. return self.filter(kind='pizza')
  117. def vegetarian(self):
  118. return self.filter(vegetarian=True)
  119. class Food(models.Model):
  120. kind = models.CharField(max_length=50)
  121. vegetarian = models.BooleanField()
  122. objects = FoodQuerySet.as_manager()
  123. Food.objects.pizzas().vegetarian()
  124. Using a custom manager when traversing reverse relations
  125. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  126. It is now possible to :ref:`specify a custom manager
  127. <using-custom-reverse-manager>` when traversing a reverse relationship::
  128. class Blog(models.Model):
  129. pass
  130. class Entry(models.Model):
  131. blog = models.ForeignKey(Blog)
  132. objects = models.Manager() # Default Manager
  133. entries = EntryManager() # Custom Manager
  134. b = Blog.objects.get(id=1)
  135. b.entry_set(manager='entries').all()
  136. New system check framework
  137. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  138. We've added a new :doc:`System check framework </ref/checks>` for
  139. detecting common problems (like invalid models) and providing hints for
  140. resolving those problems. The framework is extensible so you can add your
  141. own checks for your own apps and libraries.
  142. To perform system checks, you use the :djadmin:`check` management command.
  143. This command replaces the older :djadmin:`validate` management command.
  144. New ``Prefetch`` object for advanced ``prefetch_related`` operations.
  145. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  146. The new :class:`~django.db.models.Prefetch` object allows customizing
  147. prefetch operations.
  148. You can specify the ``QuerySet`` used to traverse a given relation
  149. or customize the storage location of prefetch results.
  150. This enables things like filtering prefetched relations, calling
  151. :meth:`~django.db.models.query.QuerySet.select_related()` from a prefetched
  152. relation, or prefetching the same relation multiple times with different
  153. querysets. See :meth:`~django.db.models.query.QuerySet.prefetch_related()`
  154. for more details.
  155. Admin shortcuts support time zones
  156. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  157. The "today" and "now" shortcuts next to date and time input widgets in the
  158. admin are now operating in the :ref:`current time zone
  159. <default-current-time-zone>`. Previously, they used the browser time zone,
  160. which could result in saving the wrong value when it didn't match the current
  161. time zone on the server.
  162. In addition, the widgets now display a help message when the browser and
  163. server time zone are different, to clarify how the value inserted in the field
  164. will be interpreted.
  165. Using database cursors as context managers
  166. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  167. Prior to Python 2.7, database cursors could be used as a context manager. The
  168. specific backend's cursor defined the behavior of the context manager. The
  169. behavior of magic method lookups was changed with Python 2.7 and cursors were
  170. no longer usable as context managers.
  171. Django 1.7 allows a cursor to be used as a context manager that is a shortcut
  172. for the following, instead of backend specific behavior.
  173. .. code-block:: python
  174. c = connection.cursor()
  175. try:
  176. c.execute(...)
  177. finally:
  178. c.close()
  179. Custom lookups
  180. ~~~~~~~~~~~~~~
  181. It is now possible to write custom lookups and transforms for the ORM.
  182. Custom lookups work just like Django's inbuilt lookups (e.g. ``lte``,
  183. ``icontains``) while transforms are a new concept.
  184. The :class:`django.db.models.Lookup` class provides a way to add lookup
  185. operators for model fields. As an example it is possible to add ``day_lte``
  186. operator for ``DateFields``.
  187. The :class:`django.db.models.Transform` class allows transformations of
  188. database values prior to the final lookup. For example it is possible to
  189. write a ``year`` transform that extracts year from the field's value.
  190. Transforms allow for chaining. After the ``year`` transform has been added
  191. to ``DateField`` it is possible to filter on the transformed value, for
  192. example ``qs.filter(author__birthdate__year__lte=1981)``.
  193. For more information about both custom lookups and transforms refer to
  194. :doc:`custom lookups </ref/models/custom-lookups>` documentation.
  195. Minor features
  196. ~~~~~~~~~~~~~~
  197. :mod:`django.contrib.admin`
  198. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  199. * You can now implement :attr:`~django.contrib.admin.AdminSite.site_header`,
  200. :attr:`~django.contrib.admin.AdminSite.site_title`, and
  201. :attr:`~django.contrib.admin.AdminSite.index_title` attributes on a custom
  202. :class:`~django.contrib.admin.AdminSite` in order to easily change the admin
  203. site's page title and header text. No more needing to override templates!
  204. * Buttons in :mod:`django.contrib.admin` now use the ``border-radius`` CSS
  205. property for rounded corners rather than GIF background images.
  206. * Some admin templates now have ``app-<app_name>`` and ``model-<model_name>``
  207. classes in their ``<body>`` tag to allow customizing the CSS per app or per
  208. model.
  209. * The admin changelist cells now have a ``field-<field_name>`` class in the
  210. HTML to enable style customizations.
  211. * The admin's search fields can now be customized per-request thanks to the new
  212. :meth:`django.contrib.admin.ModelAdmin.get_search_fields` method.
  213. * The :meth:`ModelAdmin.get_fields()
  214. <django.contrib.admin.ModelAdmin.get_fields>` method may be overridden to
  215. customize the value of :attr:`ModelAdmin.fields
  216. <django.contrib.admin.ModelAdmin.fields>`.
  217. * In addition to the existing ``admin.site.register`` syntax, you can use the
  218. new :func:`~django.contrib.admin.register` decorator to register a
  219. :class:`~django.contrib.admin.ModelAdmin`.
  220. * You may specify :meth:`ModelAdmin.list_display_links
  221. <django.contrib.admin.ModelAdmin.list_display_links>` ``= None`` to disable
  222. links on the change list page grid.
  223. * You may now specify :attr:`ModelAdmin.view_on_site
  224. <django.contrib.admin.ModelAdmin.view_on_site>` to control whether or not to
  225. display the "View on site" link.
  226. * You can specify a descending ordering for a :attr:`ModelAdmin.list_display
  227. <django.contrib.admin.ModelAdmin.list_display>` value by prefixing the
  228. ``admin_order_field`` value with a hyphen.
  229. * The :meth:`ModelAdmin.get_changeform_initial_data()
  230. <django.contrib.admin.ModelAdmin.get_changeform_initial_data>` method may be
  231. overridden to define custom behavior for setting initial change form data.
  232. :mod:`django.contrib.auth`
  233. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  234. * Any ``**kwargs`` passed to
  235. :meth:`~django.contrib.auth.models.User.email_user()` are passed to the
  236. underlying :meth:`~django.core.mail.send_mail()` call.
  237. * The :func:`~django.contrib.auth.decorators.permission_required` decorator can
  238. take a list of permissions as well as a single permission.
  239. * You can override the new :meth:`AuthenticationForm.confirm_login_allowed()
  240. <django.contrib.auth.forms.AuthenticationForm.confirm_login_allowed>` method
  241. to more easily customize the login policy.
  242. * :func:`django.contrib.auth.views.password_reset` takes an optional
  243. ``html_email_template_name`` parameter used to send a multipart HTML email
  244. for password resets.
  245. :mod:`django.contrib.formtools`
  246. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  247. * Calls to :meth:`WizardView.done()
  248. <django.contrib.formtools.wizard.views.WizardView.done>` now include a
  249. ``form_dict`` to allow easier access to forms by their step name.
  250. :mod:`django.contrib.gis`
  251. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  252. * The default OpenLayers library version included in widgets has been updated
  253. from 2.11 to 2.13.
  254. * Prepared geometries now also support the ``crosses``, ``disjoint``,
  255. ``overlaps``, ``touches`` and ``within`` predicates, if GEOS 3.3 or later is
  256. installed.
  257. :mod:`django.contrib.messages`
  258. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  259. * The backends for :mod:`django.contrib.messages` that use cookies, will now
  260. follow the :setting:`SESSION_COOKIE_SECURE` and
  261. :setting:`SESSION_COOKIE_HTTPONLY` settings.
  262. * The :ref:`messages context processor <message-displaying>` now adds a
  263. dictionary of default levels under the name ``DEFAULT_MESSAGE_LEVELS``.
  264. * :class:`~django.contrib.messages.storage.base.Message` objects now have a
  265. ``level_tag`` attribute that contains the string representation of the
  266. message level.
  267. :mod:`django.contrib.redirects`
  268. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  269. * :class:`~django.contrib.redirects.middleware.RedirectFallbackMiddleware`
  270. has two new attributes
  271. (:attr:`~django.contrib.redirects.middleware.RedirectFallbackMiddleware.response_gone_class`
  272. and
  273. :attr:`~django.contrib.redirects.middleware.RedirectFallbackMiddleware.response_redirect_class`)
  274. that specify the types of :class:`~django.http.HttpResponse` instances the
  275. middleware returns.
  276. :mod:`django.contrib.sessions`
  277. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  278. * The ``"django.contrib.sessions.backends.cached_db"`` session backend now
  279. respects :setting:`SESSION_CACHE_ALIAS`. In previous versions, it always used
  280. the `default` cache.
  281. :mod:`django.contrib.sitemaps`
  282. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  283. * The :mod:`sitemap framework<django.contrib.sitemaps>` now makes use of
  284. :attr:`~django.contrib.sitemaps.Sitemap.lastmod` to set a ``Last-Modified``
  285. header in the response. This makes it possible for the
  286. :class:`~django.middleware.http.ConditionalGetMiddleware` to handle
  287. conditional ``GET`` requests for sitemaps which set ``lastmod``.
  288. :mod:`django.contrib.sites`
  289. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  290. * The new :class:`django.contrib.sites.middleware.CurrentSiteMiddleware` allows
  291. setting the current site on each request.
  292. :mod:`django.contrib.staticfiles`
  293. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  294. * The :ref:`static files storage classes <staticfiles-storages>` may be
  295. subclassed to override the permissions that collected static files and
  296. directories receive by setting the
  297. :attr:`~django.core.files.storage.FileSystemStorage.file_permissions_mode`
  298. and :attr:`~django.core.files.storage.FileSystemStorage.directory_permissions_mode`
  299. parameters. See :djadmin:`collectstatic` for example usage.
  300. * The :class:`~django.contrib.staticfiles.storage.CachedStaticFilesStorage`
  301. backend gets a sibling class called
  302. :class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage`
  303. that doesn't use the cache system at all but instead a JSON file called
  304. ``staticfiles.json`` for storing the mapping between the original file name
  305. (e.g. ``css/styles.css``) and the hashed file name (e.g.
  306. ``css/styles.55e7cbb9ba48.css``. The ``staticfiles.json`` file is created
  307. when running the :djadmin:`collectstatic` management command and should
  308. be a less expensive alternative for remote storages such as Amazon S3.
  309. See the :class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage`
  310. docs for more information.
  311. * :djadmin:`findstatic` now accepts verbosity flag level 2, meaning it will
  312. show the relative paths of the directories it searched. See
  313. :djadmin:`findstatic` for example output.
  314. :mod:`django.contrib.syndication`
  315. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  316. * The :class:`~django.utils.feedgenerator.Atom1Feed` syndication feed's
  317. ``updated`` element now utilizes ``updateddate`` instead of ``pubdate``,
  318. allowing the ``published`` element to be included in the feed (which
  319. relies on ``pubdate``).
  320. Cache
  321. ^^^^^
  322. * Access to caches configured in :setting:`CACHES` is now available via
  323. :data:`django.core.cache.caches`. This dict-like object provides a different
  324. instance per thread. It supersedes :func:`django.core.cache.get_cache` which
  325. is now deprecated.
  326. * If you instantiate cache backends directly, be aware that they aren't
  327. thread-safe any more, as :data:`django.core.cache.caches` now yields
  328. different instances per thread.
  329. * Defining the :setting:`TIMEOUT <CACHES-TIMEOUT>` argument of the
  330. :setting:`CACHES` setting as ``None`` will set the cache keys as
  331. "non-expiring" by default. Previously, it was only possible to pass
  332. ``timeout=None` to the cache backend's ``set()`` method.
  333. Cross Site Request Forgery
  334. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  335. * The :setting:`CSRF_COOKIE_AGE` setting facilitates the use of session-based
  336. CSRF cookies.
  337. Email
  338. ^^^^^
  339. * :func:`~django.core.mail.send_mail` now accepts an ``html_message``
  340. parameter for sending a multipart ``text/plain`` and ``text/html`` email.
  341. * The SMTP :class:`~django.core.mail.backends.smtp.EmailBackend` now accepts a
  342. :attr:`~django.core.mail.backends.smtp.EmailBackend.timeout` parameter.
  343. File Storage
  344. ^^^^^^^^^^^^
  345. * File locking on Windows previously depended on the PyWin32 package; if it
  346. wasn't installed, file locking failed silently. That dependency has been
  347. removed, and file locking is now implemented natively on both Windows
  348. and Unix.
  349. File Uploads
  350. ^^^^^^^^^^^^
  351. * The new :attr:`UploadedFile.content_type_extra
  352. <django.core.files.uploadedfile.UploadedFile.content_type_extra>` attribute
  353. contains extra parameters passed to the ``content-type`` header on a file
  354. upload.
  355. * The new :setting:`FILE_UPLOAD_DIRECTORY_PERMISSIONS` setting controls
  356. the file system permissions of directories created during file upload, like
  357. :setting:`FILE_UPLOAD_PERMISSIONS` does for the files themselves.
  358. * The :attr:`FileField.upload_to <django.db.models.FileField.upload_to>`
  359. attribute is now optional. If it is omitted or given ``None`` or an empty
  360. string, a subdirectory won't be used for storing the uploaded files.
  361. Forms
  362. ^^^^^
  363. * The ``<label>`` and ``<input>`` tags rendered by
  364. :class:`~django.forms.RadioSelect` and
  365. :class:`~django.forms.CheckboxSelectMultiple` when looping over the radio
  366. buttons or checkboxes now include ``for`` and ``id`` attributes, respectively.
  367. Each radio button or checkbox includes an ``id_for_label`` attribute to
  368. output the element's ID.
  369. * The ``<textarea>`` tags rendered by :class:`~django.forms.Textarea` now
  370. include a ``maxlength`` attribute if the :class:`~django.db.models.TextField`
  371. model field has a ``max_length``.
  372. * :attr:`Field.choices<django.db.models.Field.choices>` now allows you to
  373. customize the "empty choice" label by including a tuple with an empty string
  374. or ``None`` for the key and the custom label as the value. The default blank
  375. option ``"----------"`` will be omitted in this case.
  376. * :class:`~django.forms.MultiValueField` allows optional subfields by setting
  377. the ``require_all_fields`` argument to ``False``. The ``required`` attribute
  378. for each individual field will be respected, and a new ``incomplete``
  379. validation error will be raised when any required fields are empty.
  380. * The :meth:`~django.forms.Form.clean` method on a form no longer needs to
  381. return ``self.cleaned_data``. If it does return a changed dictionary then
  382. that will still be used.
  383. * After a temporary regression in Django 1.6, it's now possible again to make
  384. :class:`~django.forms.TypedChoiceField` ``coerce`` method return an arbitrary
  385. value.
  386. * :attr:`SelectDateWidget.months
  387. <django.forms.extras.widgets.SelectDateWidget.months>` can be used to
  388. customize the wording of the months displayed in the select widget.
  389. * The ``min_num`` and ``validate_min`` parameters were added to
  390. :func:`~django.forms.formsets.formset_factory` to allow validating
  391. a minimum number of submitted forms.
  392. * The metaclasses used by ``Form`` and ``ModelForm`` have been reworked to
  393. support more inheritance scenarios. The previous limitation that prevented
  394. inheriting from both ``Form`` and ``ModelForm`` simultaneously have been
  395. removed as long as ``ModelForm`` appears first in the MRO.
  396. * It's now possible to opt-out from a ``Form`` field declared in a parent class
  397. by shadowing it with a non-``Field`` value.
  398. * The new :meth:`~django.forms.Form.add_error()` method allows adding errors
  399. to specific form fields.
  400. * The dict-like attribute :attr:`~django.forms.Form.errors` now has two new
  401. methods :meth:`~django.forms.Form.errors.as_data()` and
  402. :meth:`~django.forms.Form.errors.as_json()`. The former returns a ``dict``
  403. that maps fields to their original errors, complete with all metadata
  404. (error code and params), the latter returns the errors serialized as json.
  405. * It's now possible to customize the error messages for ``ModelForm``’s
  406. ``unique``, ``unique_for_date``, and ``unique_together`` constraints.
  407. In order to support ``unique_together`` or any other ``NON_FIELD_ERROR``,
  408. ``ModelForm`` now looks for the ``NON_FIELD_ERROR`` key in the
  409. ``error_messages`` dictionary of the ``ModelForm``’s inner ``Meta`` class.
  410. See :ref:`considerations regarding model's error_messages
  411. <considerations-regarding-model-errormessages>` for more details.
  412. Internationalization
  413. ^^^^^^^^^^^^^^^^^^^^
  414. * The :attr:`django.middleware.locale.LocaleMiddleware.response_redirect_class`
  415. attribute allows you to customize the redirects issued by the middleware.
  416. * The :class:`~django.middleware.locale.LocaleMiddleware` now stores the user's
  417. selected language with the session key ``_language``. This should only be
  418. accessed using the :data:`~django.utils.translation.LANGUAGE_SESSION_KEY`
  419. constant. Previously it was stored with the key ``django_language`` and the
  420. ``LANGUAGE_SESSION_KEY`` constant did not exist, but keys reserved for Django
  421. should start with an underscore. For backwards compatibility ``django_language``
  422. is still read from in 1.7. Sessions will be migrated to the new key
  423. as they are written.
  424. * The :ttag:`blocktrans` now supports a ``trimmed`` option. This
  425. option will remove newline characters from the beginning and the end of the
  426. content of the ``{% blocktrans %}`` tag, replace any whitespace at the
  427. beginning and end of a line and merge all lines into one using a space
  428. character to separate them. This is quite useful for indenting the content of
  429. a ``{% blocktrans %}`` tag without having the indentation characters end up
  430. in the corresponding entry in the PO file, which makes the translation
  431. process easier.
  432. * When you run :djadmin:`makemessages` from the root directory of your project,
  433. any extracted strings will now be automatically distributed to the proper
  434. app or project message file. See :ref:`how-to-create-language-files` for
  435. details.
  436. * The :djadmin:`makemessages` command now always adds the ``--previous``
  437. command line flag to the ``msgmerge`` command, keeping previously translated
  438. strings in po files for fuzzy strings.
  439. * The following settings to adjust the language cookie options were introduced:
  440. :setting:`LANGUAGE_COOKIE_AGE`, :setting:`LANGUAGE_COOKIE_DOMAIN`
  441. and :setting:`LANGUAGE_COOKIE_PATH`.
  442. * Added :ref:`format definitions <format-localization>` for Esperanto.
  443. Management Commands
  444. ^^^^^^^^^^^^^^^^^^^
  445. * The :djadminopt:`--no-color` option for ``django-admin.py`` allows you to
  446. disable the colorization of management command output.
  447. * The new :djadminopt:`--natural-foreign` and :djadminopt:`--natural-primary`
  448. options for :djadmin:`dumpdata`, and the new ``use_natural_foreign_keys`` and
  449. ``use_natural_primary_keys`` arguments for ``serializers.serialize()``, allow
  450. the use of natural primary keys when serializing.
  451. * It is no longer necessary to provide the cache table name or the
  452. :djadminopt:`--database` option for the :djadmin:`createcachetable` command.
  453. Django takes this information from your settings file. If you have configured
  454. multiple caches or multiple databases, all cache tables are created.
  455. * The :djadmin:`runserver` command received several improvements:
  456. * On Linux systems, if pyinotify_ is installed, the development server will
  457. reload immediately when a file is changed. Previously, it polled the
  458. filesystem for changes every second. That caused a small delay before
  459. reloads and reduced battery life on laptops.
  460. .. _pyinotify: https://pypi.python.org/pypi/pyinotify
  461. * In addition, the development server automatically reloads when a
  462. translation file is updated, i.e. after running
  463. :djadmin:`compilemessages`.
  464. * All HTTP requests are logged to the console, including requests for static
  465. files or ``favicon.ico`` that used to be filtered out.
  466. * Management commands can now produce syntax colored output under Windows if
  467. the ANSICON third-party tool is installed and active.
  468. * :djadmin:`collectstatic` command with symlink option is now supported on
  469. Windows NT 6 (Windows Vista and newer).
  470. Models
  471. ^^^^^^
  472. * The :meth:`QuerySet.update_or_create()
  473. <django.db.models.query.QuerySet.update_or_create>` method was added.
  474. * The new :attr:`~django.db.models.Options.default_permissions` model
  475. ``Meta`` option allows you to customize (or disable) creation of the default
  476. add, change, and delete permissions.
  477. * Explicit :class:`~django.db.models.OneToOneField` for
  478. :ref:`multi-table-inheritance` are now discovered in abstract classes.
  479. * Is it now possible to avoid creating a backward relation for
  480. :class:`~django.db.models.OneToOneField` by setting its
  481. :attr:`~django.db.models.ForeignKey.related_name` to
  482. ``'+'`` or ending it with ``'+'``.
  483. * :class:`F expressions <django.db.models.F>` support the power operator
  484. (``**``).
  485. * The ``remove()`` and ``clear()`` methods of the related managers created by
  486. ``ForeignKey`` and ``GenericForeignKey`` now accept the ``bulk`` keyword
  487. argument to control whether or not to perform operations in bulk
  488. (i.e. using ``QuerySet.update()``). Defaults to ``True``.
  489. * It is now possible to use ``None`` as a query value for the :lookup:`iexact`
  490. lookup.
  491. * It is now possible to pass a callable as value for the attribute
  492. :attr:`~django.db.models.ForeignKey.limit_choices_to` when defining a
  493. ``ForeignKey`` or ``ManyToManyField``.
  494. * Calling :meth:`only() <django.db.models.query.QuerySet.only>` and
  495. :meth:`defer() <django.db.models.query.QuerySet.defer>` on the result of
  496. :meth:`QuerySet.values() <django.db.models.query.QuerySet.values>` now raises
  497. an error (before that, it would either result in a database error or
  498. incorrect data).
  499. * You can use a single list for :attr:`~django.db.models.Options.index_together`
  500. (rather than a list of lists) when specifying a single set of fields.
  501. * Custom intermediate models having more than one foreign key to any of the
  502. models participating in a many-to-many relationship are now permitted,
  503. provided you explicitly specify which foreign keys should be used by setting
  504. the new :attr:`ManyToManyField.through_fields <django.db.models.ManyToManyField.through_fields>`
  505. argument.
  506. * Assigning a model instance to a non-relation field will now throw an error.
  507. Previously this used to work if the field accepted integers as input as it
  508. took the primary key.
  509. Signals
  510. ^^^^^^^
  511. * The ``enter`` argument was added to the
  512. :data:`~django.test.signals.setting_changed` signal.
  513. * The model signals can be now be connected to using a ``str`` of the
  514. ``'app_label.ModelName'`` form – just like related fields – to lazily
  515. reference their senders.
  516. Templates
  517. ^^^^^^^^^
  518. * The :meth:`Context.push() <django.template.Context.push>` method now returns
  519. a context manager which automatically calls :meth:`pop()
  520. <django.template.Context.pop>` upon exiting the ``with`` statement.
  521. Additionally, :meth:`push() <django.template.Context.push>` now accepts
  522. parameters that are passed to the ``dict`` constructor used to build the new
  523. context level.
  524. * The new :meth:`Context.flatten() <django.template.Context.flatten>` method
  525. returns a ``Context``'s stack as one flat dictionary.
  526. * ``Context`` objects can now be compared for equality (internally, this
  527. uses :meth:`Context.flatten() <django.template.Context.flatten>` so the
  528. internal structure of each ``Context``'s stack doesn't matter as long as their
  529. flattened version is identical).
  530. * The :ttag:`widthratio` template tag now accepts an "as" parameter to capture
  531. the result in a variable.
  532. * The :ttag:`include` template tag will now also accept anything with a
  533. ``render()`` method (such as a ``Template``) as an argument. String
  534. arguments will be looked up using
  535. :func:`~django.template.loader.get_template` as always.
  536. * It is now possible to :ttag:`include` templates recursively.
  537. * Template objects now have an origin attribute set when
  538. :setting:`TEMPLATE_DEBUG` is ``True``. This allows template origins to be
  539. inspected and logged outside of the ``django.template`` infrastructure.
  540. * ``TypeError`` exceptions are no longer silenced when raised during the
  541. rendering of a template.
  542. * The following functions now accept a ``dirs`` parameter which is a list or
  543. tuple to override :setting:`TEMPLATE_DIRS`:
  544. * :func:`django.template.loader.get_template()`
  545. * :func:`django.template.loader.select_template()`
  546. * :func:`django.shortcuts.render()`
  547. * :func:`django.shortcuts.render_to_response()`
  548. * The :tfilter:`time` filter now accepts timezone-related :ref:`format
  549. specifiers <date-and-time-formatting-specifiers>` ``'e'``, ``'O'`` , ``'T'``
  550. and ``'Z'`` and is able to digest :ref:`time-zone-aware
  551. <naive_vs_aware_datetimes>` ``datetime`` instances performing the expected
  552. rendering.
  553. * The :ttag:`cache` tag will now try to use the cache called
  554. "template_fragments" if it exists and fall back to using the default cache
  555. otherwise. It also now accepts an optional ``using`` keyword argument to
  556. control which cache it uses.
  557. * The new :tfilter:`truncatechars_html` filter truncates a string to be no
  558. longer than the specified number of characters, taking HTML into account.
  559. Requests and Responses
  560. ^^^^^^^^^^^^^^^^^^^^^^
  561. * The new :attr:`HttpRequest.scheme <django.http.HttpRequest.scheme>` attribute
  562. specifies the scheme of the request (``http`` or ``https`` normally).
  563. * The shortcut :func:`redirect() <django.shortcuts.redirect>` now supports
  564. relative URLs.
  565. * The new :class:`~django.http.JsonResponse` subclass of
  566. :class:`~django.http.HttpResponse` helps easily create JSON-encoded responses.
  567. Tests
  568. ^^^^^
  569. * :class:`~django.test.runner.DiscoverRunner` has two new attributes,
  570. :attr:`~django.test.runner.DiscoverRunner.test_suite` and
  571. :attr:`~django.test.runner.DiscoverRunner.test_runner`, which facilitate
  572. overriding the way tests are collected and run.
  573. * The ``fetch_redirect_response`` argument was added to
  574. :meth:`~django.test.SimpleTestCase.assertRedirects`. Since the test
  575. client can't fetch externals URLs, this allows you to use ``assertRedirects``
  576. with redirects that aren't part of your Django app.
  577. * Correct handling of scheme when making comparisons in
  578. :meth:`~django.test.SimpleTestCase.assertRedirects`.
  579. * The ``secure`` argument was added to all the request methods of
  580. :class:`~django.test.Client`. If ``True``, the request will be made
  581. through HTTPS.
  582. * Requests made with :meth:`Client.login() <django.test.Client.login>` and
  583. :meth:`Client.logout() <django.test.Client.logout>` respect defaults defined
  584. in :class:`~django.test.Client` instantiation and are processed through
  585. middleware.
  586. * :meth:`~django.test.TransactionTestCase.assertNumQueries` now prints
  587. out the list of executed queries if the assertion fails.
  588. * The ``WSGIRequest`` instance generated by the test handler is now attached to
  589. the :attr:`django.test.Response.wsgi_request` attribute.
  590. * The database settings for testing have been collected into a dictionary
  591. named :setting:`TEST <DATABASE-TEST>`.
  592. Validators
  593. ^^^^^^^^^^
  594. * :class:`~django.core.validators.RegexValidator` now accepts the optional
  595. :attr:`~django.core.validators.RegexValidator.flags` and
  596. Boolean :attr:`~django.core.validators.RegexValidator.inverse_match` arguments.
  597. The :attr:`~django.core.validators.RegexValidator.inverse_match` attribute
  598. determines if the :exc:`~django.core.exceptions.ValidationError` should
  599. be raised when the regular expression pattern matches (``True``) or does not
  600. match (``False``, by default) the provided ``value``. The
  601. :attr:`~django.core.validators.RegexValidator.flags` attribute sets the flags
  602. used when compiling a regular expression string.
  603. * :class:`~django.core.validators.URLValidator` now accepts an optional
  604. ``schemes`` argument which allows customization of the accepted URI schemes
  605. (instead of the defaults ``http(s)`` and ``ftp(s)``).
  606. * :func:`~django.core.validators.validate_email` now accepts addresses with
  607. IPv6 literals, like ``example@[2001:db8::1]``, as specified in RFC 5321.
  608. Backwards incompatible changes in 1.7
  609. =====================================
  610. .. warning::
  611. In addition to the changes outlined in this section, be sure to review the
  612. :doc:`deprecation plan </internals/deprecation>` for any features that
  613. have been removed. If you haven't updated your code within the
  614. deprecation timeline for a given feature, its removal may appear as a
  615. backwards incompatible change.
  616. allow_syncdb/allow_migrate
  617. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  618. While Django will still look at ``allow_syncdb`` methods even though they
  619. should be renamed to ``allow_migrate``, there is a subtle difference in which
  620. models get passed to these methods.
  621. For apps with migrations, ``allow_migrate`` will now get passed
  622. :ref:`historical models <historical-models>`, which are special versioned models
  623. without custom attributes, methods or managers. Make sure your ``allow_migrate``
  624. methods are only referring to fields or other items in ``model._meta``.
  625. initial_data
  626. ~~~~~~~~~~~~
  627. Apps with migrations will not load ``initial_data`` fixtures when they have
  628. finished migrating. Apps without migrations will continue to load these fixtures
  629. during the phase of ``migrate`` which emulates the old ``syncdb`` behavior,
  630. but any new apps will not have this support.
  631. Instead, you are encouraged to load initial data in migrations if you need it
  632. (using the ``RunPython`` operation and your model classes);
  633. this has the added advantage that your initial data will not need updating
  634. every time you change the schema.
  635. App-loading changes
  636. ~~~~~~~~~~~~~~~~~~~
  637. Start-up sequence
  638. ^^^^^^^^^^^^^^^^^
  639. Django 1.7 loads application configurations and models as soon as it starts.
  640. While this behavior is more straightforward and is believed to be more robust,
  641. regressions cannot be ruled out. You may encounter the following exceptions:
  642. * ``RuntimeError: App registry isn't ready yet.`` This happens when importing
  643. an application configuration or a models module triggers code that depends
  644. on the app registry.
  645. For example, :func:`~django.utils.translation.ugettext()` uses the app
  646. registry to look up translation catalogs in applications. To translate at
  647. import time, you need :func:`~django.utils.translation.ugettext_lazy()`
  648. instead. (Using :func:`~django.utils.translation.ugettext()` would be a bug,
  649. because the translation would happen at import time, rather than at each
  650. request depending on the active language.)
  651. Executing database queries with the ORM at import time in models modules
  652. will also trigger this exception. The ORM cannot function properly until all
  653. models are available.
  654. Another common culprit is :func:`django.contrib.auth.get_user_model()`. Use
  655. the :setting:`AUTH_USER_MODEL` setting to reference the User model at import
  656. time.
  657. * ``ImportError: cannot import name ...`` This happens if the import sequence
  658. ends up in a loop.
  659. To eliminate such problems, you should minimize dependencies between your
  660. models modules and do as little work as possible at import time. To avoid
  661. executing code at import time, you can move it into a function and cache its
  662. results. The code will be executed when you first need its results. This
  663. concept is known as "lazy evaluation".
  664. * ``django.contrib.admin`` will now automatically perform autodiscovery of
  665. ``admin`` modules in installed applications. To prevent it, change your
  666. :setting:`INSTALLED_APPS` to contain
  667. ``'django.contrib.admin.apps.SimpleAdminConfig'`` instead of
  668. ``'django.contrib.admin'``.
  669. Standalone scripts
  670. ^^^^^^^^^^^^^^^^^^
  671. If you're using Django in a plain Python script — rather than a management
  672. command — and you rely on the :envvar:`DJANGO_SETTINGS_MODULE` environment
  673. variable, you must now explicitly initialize Django at the beginning of your
  674. script with::
  675. >>> import django
  676. >>> django.setup()
  677. Otherwise, you will hit ``RuntimeError: App registry isn't ready yet.``
  678. App registry consistency
  679. ^^^^^^^^^^^^^^^^^^^^^^^^
  680. It is no longer possible to have multiple installed applications with the same
  681. label. In previous versions of Django, this didn't always work correctly, but
  682. didn't crash outright either.
  683. If you have two apps with the same label, you should create an
  684. :class:`~django.apps.AppConfig` for one of them and override its
  685. :class:`~django.apps.AppConfig.label` there. You should then adjust your code
  686. wherever it references this application or its models with the old label.
  687. It isn't possible to import the same model twice through different paths any
  688. more. As of Django 1.6, this may happen only if you're manually putting a
  689. directory and a subdirectory on :envvar:`PYTHONPATH`. Refer to the section on
  690. the new project layout in the :doc:`1.4 release notes </releases/1.4>` for
  691. migration instructions.
  692. You should make sure that:
  693. * All models are defined in applications that are listed in
  694. :setting:`INSTALLED_APPS` or have an explicit
  695. :attr:`~django.db.models.Options.app_label`.
  696. * Models aren't imported as a side-effect of loading their application.
  697. Specifically, you shouldn't import models in the root module of an
  698. application nor in the module that define its configuration class.
  699. Django will enforce these requirements as of version 1.9, after a deprecation
  700. period.
  701. Subclassing AppCommand
  702. ^^^^^^^^^^^^^^^^^^^^^^
  703. Subclasses of :class:`~django.core.management.AppCommand` must now implement a
  704. :meth:`~django.core.management.AppCommand.handle_app_config` method instead of
  705. ``handle_app()``. This method receives an :class:`~django.apps.AppConfig`
  706. instance instead of a models module.
  707. Introspecting applications
  708. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  709. Since :setting:`INSTALLED_APPS` now supports application configuration classes
  710. in addition to application modules, you should review code that accesses this
  711. setting directly and use the app registry (:attr:`django.apps.apps`) instead.
  712. The app registry has preserved some features of the old app cache. Even though
  713. the app cache was a private API, obsolete methods and arguments will be
  714. removed through a standard deprecation path, with the exception of the
  715. following changes that take effect immediately:
  716. * ``get_model`` raises :exc:`~exceptions.LookupError` instead of returning
  717. ``None`` when no model is found.
  718. * The ``only_installed`` argument of ``get_model`` and ``get_models`` no
  719. longer exists, nor does the ``seed_cache`` argument of ``get_model``.
  720. Management commands and order of :setting:`INSTALLED_APPS`
  721. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  722. When several applications provide management commands with the same name,
  723. Django loads the command from the application that comes first in
  724. :setting:`INSTALLED_APPS`. Previous versions loaded the command from the
  725. application that came last.
  726. This brings discovery of management commands in line with other parts of
  727. Django that rely on the order of :setting:`INSTALLED_APPS`, such as static
  728. files, templates, and translations.
  729. Behavior of ``LocMemCache`` regarding pickle errors
  730. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  731. An inconsistency existed in previous versions of Django regarding how pickle
  732. errors are handled by different cache backends.
  733. ``django.core.cache.backends.locmem.LocMemCache`` used to fail silently when
  734. such an error occurs, which is inconsistent with other backends and leads to
  735. cache-specific errors. This has been fixed in Django 1.7, see
  736. `Ticket #21200`_ for more details.
  737. .. _Ticket #21200: https://code.djangoproject.com/ticket/21200
  738. Cache keys are now generated from the request's absolute URL
  739. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  740. Previous versions of Django generated cache keys using a request's path and
  741. query string but not the scheme or host. If a Django application was serving
  742. multiple subdomains or domains, cache keys could collide. In Django 1.7, cache
  743. keys vary by the absolute URL of the request including scheme, host, path, and
  744. query string. For example, the URL portion of a cache key is now generated from
  745. ``http://www.example.com/path/to/?key=val`` rather than ``/path/to/?key=val``.
  746. The cache keys generated by Django 1.7 will be different from the keys
  747. generated by older versions of Django. After upgrading to Django 1.7, the first
  748. request to any previously cached URL will be a cache miss .
  749. Passing ``None`` to ``Manager.db_manager()``
  750. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  751. In previous versions of Django, it was possible to use
  752. ``db_manager(using=None)`` on a model manager instance to obtain a manager
  753. instance using default routing behavior, overriding any manually specified
  754. database routing. In Django 1.7, a value of ``None`` passed to db_manager will
  755. produce a router that *retains* any manually assigned database routing -- the
  756. manager will *not* be reset. This was necessary to resolve an inconsistency in
  757. the way routing information cascaded over joins. See `Ticket #13724`_ for more
  758. details.
  759. .. _Ticket #13724: https://code.djangoproject.com/ticket/13724
  760. pytz may be required
  761. ~~~~~~~~~~~~~~~~~~~~
  762. If your project handles datetimes before 1970 or after 2037 and Django raises
  763. a :exc:`~exceptions.ValueError` when encountering them, you will have to
  764. install pytz_. You may be affected by this problem if you use Django's time
  765. zone-related date formats or :mod:`django.contrib.syndication`.
  766. .. _pytz: https://pypi.python.org/pypi/pytz/
  767. ``remove()`` and ``clear()`` methods of related managers
  768. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  769. The ``remove()`` and ``clear()`` methods of the related managers created by
  770. ``ForeignKey``, ``GenericForeignKey``, and ``ManyToManyField`` suffered from a
  771. number of issues. Some operations ran multiple data modifying queries without
  772. wrapping them in a transaction, and some operations didn't respect default
  773. filtering when it was present (i.e. when the default manager on the related
  774. model implemented a custom ``get_queryset()``).
  775. Fixing the issues introduced some backward incompatible changes:
  776. - The default implementation of ``remove()`` for ``ForeignKey`` related managers
  777. changed from a series of ``Model.save()`` calls to a single
  778. ``QuerySet.update()`` call. The change means that ``pre_save`` and
  779. ``post_save`` signals aren't sent anymore. You can use the ``bulk=False``
  780. keyword argument to revert to the previous behavior.
  781. - The ``remove()`` and ``clear()`` methods for ``GenericForeignKey`` related
  782. managers now perform bulk delete. The ``Model.delete()`` method isn't called
  783. on each instance anymore. You can use the ``bulk=False`` keyword argument to
  784. revert to the previous behavior.
  785. - The ``remove()`` and ``clear()`` methods for ``ManyToManyField`` related
  786. managers perform nested queries when filtering is involved, which may or
  787. may not be an issue depending on your database and your data itself.
  788. See :ref:`this note <nested-queries-performance>` for more details.
  789. Admin login redirection strategy
  790. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  791. Historically, the Django admin site passed the request from an unauthorized or
  792. unauthenticated user directly to the login view, without HTTP redirection. In
  793. Django 1.7, this behavior changed to conform to a more traditional workflow
  794. where any unauthorized request to an admin page will be redirected (by HTTP
  795. status code 302) to the login page, with the ``next`` parameter set to the
  796. referring path. The user will be redirected there after a successful login.
  797. Note also that the admin login form has been updated to not contain the
  798. ``this_is_the_login_form`` field (now unused) and the ``ValidationError`` code
  799. has been set to the more regular ``invalid_login`` key.
  800. Miscellaneous
  801. ~~~~~~~~~~~~~
  802. * The :meth:`django.core.files.uploadhandler.FileUploadHandler.new_file()`
  803. method is now passed an additional ``content_type_extra`` parameter. If you
  804. have a custom :class:`~django.core.files.uploadhandler.FileUploadHandler`
  805. that implements ``new_file()``, be sure it accepts this new parameter.
  806. * :class:`ModelFormSet<django.forms.models.BaseModelFormSet>`\s no longer
  807. delete instances when ``save(commit=False)`` is called. See
  808. :attr:`~django.forms.formsets.BaseFormSet.can_delete` for instructions on how
  809. to manually delete objects from deleted forms.
  810. * Loading empty fixtures emits a ``RuntimeWarning`` rather than raising
  811. :class:`~django.core.management.CommandError`.
  812. * :func:`django.contrib.staticfiles.views.serve` will now raise an
  813. :exc:`~django.http.Http404` exception instead of
  814. :exc:`~django.core.exceptions.ImproperlyConfigured` when :setting:`DEBUG`
  815. is ``False``. This change removes the need to conditionally add the view to
  816. your root URLconf, which in turn makes it safe to reverse by name. It also
  817. removes the ability for visitors to generate spurious HTTP 500 errors by
  818. requesting static files that don't exist or haven't been collected yet.
  819. * The :meth:`django.db.models.Model.__eq__` method is now defined in a
  820. way where instances of a proxy model and its base model are considered
  821. equal when primary keys match. Previously only instances of exact same
  822. class were considered equal on primary key match.
  823. * The :meth:`django.db.models.Model.__eq__` method has changed such that
  824. two ``Model`` instances without primary key values won't be considered
  825. equal (unless they are the same instance).
  826. * The :meth:`django.db.models.Model.__hash__` will now raise ``TypeError``
  827. when called on an instance without a primary key value. This is done to
  828. avoid mutable ``__hash__`` values in containers.
  829. * :class:`~django.db.models.AutoField` columns in SQLite databases will now be
  830. created using the ``AUTOINCREMENT`` option, which guarantees monotonic
  831. increments. This will cause primary key numbering behavior to change on
  832. SQLite, becoming consistent with most other SQL databases. This will only
  833. apply to newly created tables. If you have a database created with an older
  834. version of Django, you will need to migrate it to take advantage of this
  835. feature. For example, you could do the following:
  836. #) Use :djadmin:`dumpdata` to save your data.
  837. #) Rename the existing database file (keep it as a backup).
  838. #) Run :djadmin:`migrate` to create the updated schema.
  839. #) Use :djadmin:`loaddata` to import the fixtures you exported in (1).
  840. * ``django.contrib.auth.models.AbstractUser`` no longer defines a
  841. :meth:`~django.db.models.Model.get_absolute_url()` method. The old definition
  842. returned ``"/users/%s/" % urlquote(self.username)`` which was arbitrary
  843. since applications may or may not define such a url in ``urlpatterns``.
  844. Define a ``get_absolute_url()`` method on your own custom user object or use
  845. :setting:`ABSOLUTE_URL_OVERRIDES` if you want a URL for your user.
  846. * The static asset-serving functionality of the
  847. :class:`django.test.LiveServerTestCase` class has been simplified: Now it's
  848. only able to serve content already present in :setting:`STATIC_ROOT` when
  849. tests are run. The ability to transparently serve all the static assets
  850. (similarly to what one gets with :setting:`DEBUG = True <DEBUG>` at
  851. development-time) has been moved to a new class that lives in the
  852. ``staticfiles`` application (the one actually in charge of such feature):
  853. :class:`django.contrib.staticfiles.testing.StaticLiveServerCase`. In other
  854. words, ``LiveServerTestCase`` itself is less powerful but at the same time
  855. has less magic.
  856. Rationale behind this is removal of dependency of non-contrib code on
  857. contrib applications.
  858. * The old cache URI syntax (e.g. ``"locmem://"``) is no longer supported. It
  859. still worked, even though it was not documented or officially supported. If
  860. you're still using it, please update to the current :setting:`CACHES` syntax.
  861. * The default ordering of ``Form`` fields in case of inheritance has changed to
  862. follow normal Python MRO. Fields are now discovered by iterating through the
  863. MRO in reverse with the topmost class coming last. This only affects you if
  864. you relied on the default field ordering while having fields defined on both
  865. the current class *and* on a parent ``Form``.
  866. * The ``required`` argument of
  867. :class:`~django.forms.extras.widgets.SelectDateWidget` has been removed.
  868. This widget now respects the form field's ``is_required`` attribute like
  869. other widgets.
  870. * ``Widget.is_hidden`` is now a read-only property, getting its value by
  871. introspecting the presence of ``input_type == 'hidden'``.
  872. * :meth:`~django.db.models.query.QuerySet.select_related` now chains in the
  873. same way as other similar calls like ``prefetch_related``. That is,
  874. ``select_related('foo', 'bar')`` is equivalent to
  875. ``select_related('foo').select_related('bar')``. Previously the latter would
  876. have been equivalent to ``select_related('bar')``.
  877. * GeoDjango dropped support for GEOS < 3.1.
  878. * The ``init_connection_state`` method of database backends now executes in
  879. autocommit mode (unless you set :setting:`AUTOCOMMIT <DATABASE-AUTOCOMMIT>`
  880. to ``False``). If you maintain a custom database backend, you should check
  881. that method.
  882. * The ``django.db.backends.BaseDatabaseFeatures.allows_primary_key_0``
  883. attribute has been renamed to ``allows_auto_pk_0`` to better describe it.
  884. It's ``True`` for all database backends included with Django except MySQL
  885. which does allow primary keys with value 0. It only forbids *autoincrement*
  886. primary keys with value 0.
  887. * Shadowing model fields defined in a parent model has been forbidden as this
  888. creates ambiguity in the expected model behavior. In addition, any clashing
  889. fields in the model inheritance hierarchy results in a system check error.
  890. For example, if you use multi-inheritance, you need to define custom primary
  891. key fields on parent models, otherwise the default ``id`` fields will clash.
  892. * ``django.utils.translation.parse_accept_lang_header()`` now returns
  893. lowercase locales, instead of the case as it was provided. As locales should
  894. be treated case-insensitive this allows us to speed up locale detection.
  895. * ``django.utils.translation.get_language_from_path()`` and
  896. ``django.utils.translation.trans_real.get_supported_language_variant()``
  897. now no longer have a ``supported`` argument.
  898. * The ``shortcut`` view in ``django.contrib.contenttypes.views`` now supports
  899. protocol-relative URLs (e.g. ``//example.com``).
  900. * :class:`~django.contrib.contenttypes.fields.GenericRelation` now supports an
  901. optional ``related_query_name`` argument. Setting ``related_query_name`` adds
  902. a relation from the related object back to the content type for filtering,
  903. ordering and other query operations.
  904. * When a model field's :attr:`~django.db.models.Field.validators` contains
  905. a :class:`~django.core.validators.RegexValidator`, the regular expression
  906. must now be passed as a regular expression string. You can no longer use a
  907. pre-compiled regular expression in this case, as it is not serializable.
  908. The :attr:`~django.core.validators.RegexValidator.flags` attribute was added
  909. to :class:`~django.core.validators.RegexValidator` to simplify this change.
  910. .. _deprecated-features-1.7:
  911. Features deprecated in 1.7
  912. ==========================
  913. ``django.core.cache.get_cache``
  914. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  915. :func:`django.core.cache.get_cache` has been supplanted by
  916. :data:`django.core.cache.caches`.
  917. ``django.utils.dictconfig``/``django.utils.importlib``
  918. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  919. ``django.utils.dictconfig`` and ``django.utils.importlib`` were copies of
  920. respectively :mod:`logging.config` and :mod:`importlib` provided for Python
  921. versions prior to 2.7. They have been deprecated.
  922. ``django.utils.module_loading.import_by_path``
  923. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  924. The current :meth:`~django.utils.module_loading.import_by_path` function
  925. catches ``AttributeError``, ``ImportError`` and ``ValueError`` exceptions,
  926. and re-raises :exc:`~django.core.exceptions.ImproperlyConfigured`. Such
  927. exception masking makes it needlessly hard to diagnose circular import
  928. problems, because it makes it look like the problem comes from inside Django.
  929. It has been deprecated in favor of
  930. :meth:`~django.utils.module_loading.import_string`.
  931. ``django.utils.tzinfo``
  932. ~~~~~~~~~~~~~~~~~~~~~~~
  933. ``django.utils.tzinfo`` provided two :class:`~datetime.tzinfo` subclasses,
  934. ``LocalTimezone`` and ``FixedOffset``. They've been deprecated in favor of
  935. more correct alternatives provided by :mod:`django.utils.timezone`,
  936. :func:`django.utils.timezone.get_default_timezone` and
  937. :func:`django.utils.timezone.get_fixed_timezone`.
  938. ``django.utils.unittest``
  939. ~~~~~~~~~~~~~~~~~~~~~~~~~
  940. ``django.utils.unittest`` provided uniform access to the ``unittest2`` library
  941. on all Python versions. Since ``unittest2`` became the standard library's
  942. :mod:`unittest` module in Python 2.7, and Django 1.7 drops support for older
  943. Python versions, this module isn't useful anymore. It has been deprecated. Use
  944. :mod:`unittest` instead.
  945. ``django.utils.datastructures.SortedDict``
  946. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  947. As :class:`~collections.OrderedDict` was added to the standard library in
  948. Python 2.7, :class:`~django.utils.datastructures.SortedDict` is no longer
  949. needed and has been deprecated.
  950. Custom SQL location for models package
  951. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  952. Previously, if models were organized in a package (``myapp/models/``) rather
  953. than simply ``myapp/models.py``, Django would look for :ref:`initial SQL data
  954. <initial-sql>` in ``myapp/models/sql/``. This bug has been fixed so that Django
  955. will search ``myapp/sql/`` as documented. The old location will continue to
  956. work until Django 1.9.
  957. Reorganization of ``django.contrib.sites``
  958. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  959. ``django.contrib.sites`` provides reduced functionality when it isn't in
  960. :setting:`INSTALLED_APPS`. The app-loading refactor adds some constraints in
  961. that situation. As a consequence, two objects were moved, and the old
  962. locations are deprecated:
  963. * :class:`~django.contrib.sites.requests.RequestSite` now lives in
  964. ``django.contrib.sites.requests``.
  965. * :func:`~django.contrib.sites.shortcuts.get_current_site` now lives in
  966. ``django.contrib.sites.shortcuts``.
  967. ``declared_fieldsets`` attribute on ``ModelAdmin``
  968. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  969. ``ModelAdmin.declared_fieldsets`` has been deprecated. Despite being a private
  970. API, it will go through a regular deprecation path. This attribute was mostly
  971. used by methods that bypassed ``ModelAdmin.get_fieldsets()`` but this was
  972. considered a bug and has been addressed.
  973. Reorganization of ``django.contrib.contenttypes``
  974. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  975. Since ``django.contrib.contenttypes.generic`` defined both admin and model
  976. related objects an import of this module could trigger unexpected side effects.
  977. As a consequence, its contents were split into :mod:`~django.contrib.contenttypes`
  978. submodules and the ``django.contrib.contenttypes.generic`` module is deprecated:
  979. * :class:`~django.contrib.contenttypes.fields.GenericForeignKey` and
  980. :class:`~django.contrib.contenttypes.fields.GenericRelation` now live in
  981. :mod:`~django.contrib.contenttypes.fields`.
  982. * :class:`~django.contrib.contenttypes.forms.BaseGenericInlineFormSet` and
  983. :func:`~django.contrib.contenttypes.forms.generic_inlineformset_factory` now
  984. live in :mod:`~django.contrib.contenttypes.forms`.
  985. * :class:`~django.contrib.contenttypes.admin.GenericInlineModelAdmin`,
  986. :class:`~django.contrib.contenttypes.admin.GenericStackedInline` and
  987. :class:`~django.contrib.contenttypes.admin.GenericTabularInline` now live in
  988. :mod:`~django.contrib.contenttypes.admin`.
  989. ``syncdb``
  990. ~~~~~~~~~~
  991. The :djadmin:`syncdb` command has been deprecated in favor of the new :djadmin:`migrate`
  992. command. ``migrate`` takes the same arguments as ``syncdb`` used to plus a few
  993. more, so it's safe to just change the name you're calling and nothing else.
  994. ``util`` modules renamed to ``utils``
  995. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  996. The following instances of ``util.py`` in the Django codebase have been renamed
  997. to ``utils.py`` in an effort to unify all util and utils references:
  998. * ``django.contrib.admin.util``
  999. * ``django.contrib.gis.db.backends.util``
  1000. * ``django.db.backends.util``
  1001. * ``django.forms.util``
  1002. ``get_formsets`` method on ``ModelAdmin``
  1003. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1004. ``ModelAdmin.get_formsets`` has been deprecated in favor of the new
  1005. :meth:`~django.contrib.admin.ModelAdmin.get_formsets_with_inlines`, in order to
  1006. better handle the case of selecting showing inlines on a ``ModelAdmin``.
  1007. ``IPAddressField``
  1008. ~~~~~~~~~~~~~~~~~~
  1009. The :class:`django.db.models.IPAddressField` and
  1010. :class:`django.forms.IPAddressField` fields have been deprecated in favor of
  1011. :class:`django.db.models.GenericIPAddressField` and
  1012. :class:`django.forms.GenericIPAddressField`.
  1013. ``BaseMemcachedCache._get_memcache_timeout`` method
  1014. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1015. The ``BaseMemcachedCache._get_memcache_timeout()`` method has been renamed to
  1016. ``get_backend_timeout()``. Despite being a private API, it will go through the
  1017. normal deprecation.
  1018. Natural key serialization options
  1019. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1020. The ``--natural`` and ``-n`` options for :djadmin:`dumpdata` have been
  1021. deprecated. Use :djadminopt:`--natural-foreign` instead.
  1022. Similarly, the ``use_natural_keys`` argument for ``serializers.serialize()``
  1023. has been deprecated. Use ``use_natural_foreign_keys`` instead.
  1024. Merging of ``POST`` and ``GET`` arguments into ``WSGIRequest.REQUEST``
  1025. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1026. It was already strongly suggested that you use ``GET`` and ``POST`` instead of
  1027. ``REQUEST``, because the former are more explicit. The property ``REQUEST`` is
  1028. deprecated and will be removed in Django 1.9.
  1029. ``django.utils.datastructures.MergeDict`` class
  1030. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1031. ``MergeDict`` exists primarily to support merging ``POST`` and ``GET``
  1032. arguments into a ``REQUEST`` property on ``WSGIRequest``. To merge
  1033. dictionaries, use ``dict.update()`` instead. The class ``MergeDict`` is
  1034. deprecated and will be removed in Django 1.9.
  1035. Language codes ``zh-cn``, ``zh-tw`` and ``fy-nl``
  1036. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1037. The currently used language codes for Simplified Chinese ``zh-cn``,
  1038. Traditional Chinese ``zh-tw`` and (Western) Frysian ``fy-nl`` are deprecated
  1039. and should be replaced by the language codes ``zh-hans``, ``zh-hant`` and
  1040. ``fy`` respectively. If you use these language codes, you should rename the
  1041. locale directories and update your settings to reflect these changes. The
  1042. deprecated language codes will be removed in Django 1.9.
  1043. ``django.utils.functional.memoize`` function
  1044. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1045. The function ``memoize`` is deprecated and should be replaced by the
  1046. ``functools.lru_cache`` decorator (available from Python 3.2 onwards).
  1047. Django ships a backport of this decorator for older Python versions and it's
  1048. available at ``django.utils.lru_cache.lru_cache``. The deprecated function will
  1049. be removed in Django 1.9.
  1050. Geo Sitemaps
  1051. ~~~~~~~~~~~~
  1052. Google has retired support for the Geo Sitemaps format. Hence Django support
  1053. for Geo Sitemaps is deprecated and will be removed in Django 1.8.
  1054. Passing callable arguments to queryset methods
  1055. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1056. Callable arguments for querysets were an undocumented feature that was
  1057. unreliable. It's been deprecated and will be removed in Django 1.9.
  1058. Callable arguments were evaluated when a queryset was constructed rather than
  1059. when it was evaluated, thus this feature didn't offer any benefit compared to
  1060. evaluating arguments before passing them to queryset and created confusion that
  1061. the arguments may have been evaluated at query time.
  1062. ``ADMIN_FOR`` setting
  1063. ~~~~~~~~~~~~~~~~~~~~~
  1064. The ``ADMIN_FOR`` feature, part of the admindocs, has been removed. You can
  1065. remove the setting from your configuration at your convenience.
  1066. ``SplitDateTimeWidget`` with ``DateTimeField``
  1067. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1068. ``SplitDateTimeWidget`` support in :class:`~django.forms.DateTimeField` is
  1069. deprecated, use ``SplitDateTimeWidget`` with
  1070. :class:`~django.forms.SplitDateTimeField` instead.
  1071. ``validate``
  1072. ~~~~~~~~~~~~
  1073. :djadmin:`validate` command is deprecated in favor of :djadmin:`check` command.
  1074. ``django.core.management.BaseCommand``
  1075. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1076. ``requires_model_validation`` is deprecated in favor of a new
  1077. ``requires_system_checks`` flag. If the latter flag is missing, then the
  1078. value of the former flag is used. Defining both ``requires_system_checks`` and
  1079. ``requires_model_validation`` results in an error.
  1080. The ``check()`` method has replaced the old ``validate()`` method.
  1081. ``ModelAdmin.validator``
  1082. ~~~~~~~~~~~~~~~~~~~~~~~~
  1083. ``ModelAdmin.validator`` is deprecated in favor of new ``checks`` attribute.
  1084. ``django.db.backends.DatabaseValidation.validate_field``
  1085. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1086. This method is deprecated in favor of a new ``check_field`` method.
  1087. The functionality required by ``check_field()`` is the same as that provided
  1088. by ``validate_field()``, but the output format is different. Third-party database
  1089. backends needing this functionality should modify their backends to provide an
  1090. implementation of ``check_field()``.
  1091. Loading ``ssi`` and ``url`` template tags from ``future`` library
  1092. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1093. Django 1.3 introduced ``{% load ssi from future %}`` and
  1094. ``{% load url from future %}`` syntax for forward compatibility of the
  1095. :ttag:`ssi` and :ttag:`url` template tags. This syntax is now deprecated and
  1096. will be removed in Django 1.9. You can simply remove the
  1097. ``{% load ... from future %}`` tags.
  1098. ``django.utils.text.javascript_quote``
  1099. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1100. ``javascript_quote()`` was an undocumented function present in ``django.utils.text``.
  1101. It was used internally in the :ref:`javascript_catalog view <javascript_catalog-view>`
  1102. whose implementation was changed to make use of ``json.dumps()`` instead.
  1103. If you were relying on this function to provide safe output from untrusted
  1104. strings, you should use ``django.utils.html.escapejs`` or the
  1105. :tfilter:`escapejs` template filter.
  1106. If all you need is to generate valid javascript strings, you can simply use
  1107. ``json.dumps()``.
  1108. ``fix_ampersands`` utils method and template filter
  1109. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1110. The ``django.utils.html.fix_ampersands`` method and the ``fix_ampersands``
  1111. template filter are deprecated, as the escaping of ampersands is already taken care
  1112. of by Django's standard HTML escaping features. Combining this with ``fix_ampersands``
  1113. would either result in double escaping, or, if the output is assumed to be safe,
  1114. a risk of introducing XSS vulnerabilities. Along with ``fix_ampersands``,
  1115. ``django.utils.html.clean_html`` is deprecated, an undocumented function that calls
  1116. ``fix_ampersands``.
  1117. As this is an accelerated deprecation, ``fix_ampersands`` and ``clean_html``
  1118. will be removed in Django 1.8.
  1119. Reorganization of database test settings
  1120. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1121. All database settings with a `TEST_` prefix have been deprecated in favor of
  1122. entries in a :setting:`TEST <DATABASE-TEST>` dictionary in the database
  1123. settings. The old settings will be supported until Django 1.9.