1.7.txt 66 KB

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