1.7.txt 68 KB

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