1.7.txt 50 KB

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