diff options
| author | Johannes Hoppe <info@johanneshoppe.com> | 2015-11-07 12:24:38 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-12-10 14:30:19 -0500 |
| commit | cf546e11ac76c8dec527e39ff8ce8249a195ab42 (patch) | |
| tree | c86d039e94099e47382bbeaf4361fef22bbcf55e /docs/topics/forms | |
| parent | 6be9589eb34f79914666c9d9e1e15bdb7fc44df2 (diff) | |
Fixed #21221 -- Made form Media and static template tag use staticfiles if installed.
Diffstat (limited to 'docs/topics/forms')
| -rw-r--r-- | docs/topics/forms/media.txt | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/docs/topics/forms/media.txt b/docs/topics/forms/media.txt index a7975b4bce..180cd92995 100644 --- a/docs/topics/forms/media.txt +++ b/docs/topics/forms/media.txt @@ -203,12 +203,13 @@ Paths in asset definitions Paths used to specify assets can be either relative or absolute. If a path starts with ``/``, ``http://`` or ``https://``, it will be interpreted as an absolute path, and left as-is. All other paths will -be prepended with the value of the appropriate prefix. +be prepended with the value of the appropriate prefix. If the +:mod:`django.contrib.staticfiles` app is installed, it will be used to serve +assets. -As part of the introduction of the -:doc:`staticfiles app </ref/contrib/staticfiles>` two new settings were added -to refer to "static files" (images, CSS, JavaScript, etc.) that are needed -to render a complete web page: :setting:`STATIC_URL` and :setting:`STATIC_ROOT`. +Whether or not you use :mod:`django.contrib.staticfiles`, the +:setting:`STATIC_URL` and :setting:`STATIC_ROOT` settings are required to +render a complete web page. To find the appropriate prefix to use, Django will check if the :setting:`STATIC_URL` setting is not ``None`` and automatically fall back @@ -238,6 +239,18 @@ But if :setting:`STATIC_URL` is ``'http://static.example.com/'``:: <script type="text/javascript" src="http://static.example.com/animations.js"></script> <script type="text/javascript" src="http://othersite.com/actions.js"></script> +Or if :mod:`~django.contrib.staticfiles` is configured using the +`~django.contib.staticfiles.ManifestStaticFilesStorage`:: + + >>> w = CalendarWidget() + >>> print(w.media) + <link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet" /> + <script type="text/javascript" src="https://static.example.com/animations.27e20196a850.js"></script> + <script type="text/javascript" src="http://othersite.com/actions.js"></script> + +.. versionchanged:: 1.10 + + Older versions didn't serve assets using :mod:`django.contrib.staticfiles`. ``Media`` objects ----------------- |
