|
@@ -74,9 +74,9 @@ can be retrieved through this property:
|
|
|
|
|
|
>>> w = CalendarWidget()
|
|
|
>>> print(w.media)
|
|
|
- <link href="http://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
- <script src="http://static.example.com/animations.js"></script>
|
|
|
- <script src="http://static.example.com/actions.js"></script>
|
|
|
+ <link href="https://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
+ <script src="https://static.example.com/animations.js"></script>
|
|
|
+ <script src="https://static.example.com/actions.js"></script>
|
|
|
|
|
|
Here's a list of all possible ``Media`` options. There are no required options.
|
|
|
|
|
@@ -119,9 +119,9 @@ If this last CSS definition were to be rendered, it would become the following H
|
|
|
|
|
|
.. code-block:: html+django
|
|
|
|
|
|
- <link href="http://static.example.com/pretty.css" media="screen" rel="stylesheet">
|
|
|
- <link href="http://static.example.com/lo_res.css" media="tv,projector" rel="stylesheet">
|
|
|
- <link href="http://static.example.com/newspaper.css" media="print" rel="stylesheet">
|
|
|
+ <link href="https://static.example.com/pretty.css" media="screen" rel="stylesheet">
|
|
|
+ <link href="https://static.example.com/lo_res.css" media="tv,projector" rel="stylesheet">
|
|
|
+ <link href="https://static.example.com/newspaper.css" media="print" rel="stylesheet">
|
|
|
|
|
|
``js``
|
|
|
------
|
|
@@ -153,11 +153,11 @@ example above:
|
|
|
|
|
|
>>> w = FancyCalendarWidget()
|
|
|
>>> print(w.media)
|
|
|
- <link href="http://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
- <link href="http://static.example.com/fancy.css" media="all" rel="stylesheet">
|
|
|
- <script src="http://static.example.com/animations.js"></script>
|
|
|
- <script src="http://static.example.com/actions.js"></script>
|
|
|
- <script src="http://static.example.com/whizbang.js"></script>
|
|
|
+ <link href="https://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
+ <link href="https://static.example.com/fancy.css" media="all" rel="stylesheet">
|
|
|
+ <script src="https://static.example.com/animations.js"></script>
|
|
|
+ <script src="https://static.example.com/actions.js"></script>
|
|
|
+ <script src="https://static.example.com/whizbang.js"></script>
|
|
|
|
|
|
The FancyCalendar widget inherits all the assets from its parent
|
|
|
widget. If you don't want ``Media`` to be inherited in this way, add
|
|
@@ -176,8 +176,8 @@ an ``extend=False`` declaration to the ``Media`` declaration:
|
|
|
|
|
|
>>> w = FancyCalendarWidget()
|
|
|
>>> print(w.media)
|
|
|
- <link href="http://static.example.com/fancy.css" media="all" rel="stylesheet">
|
|
|
- <script src="http://static.example.com/whizbang.js"></script>
|
|
|
+ <link href="https://static.example.com/fancy.css" media="all" rel="stylesheet">
|
|
|
+ <script src="https://static.example.com/whizbang.js"></script>
|
|
|
|
|
|
If you require even more control over inheritance, define your assets using a
|
|
|
:ref:`dynamic property <dynamic-property>`. Dynamic properties give you
|
|
@@ -230,7 +230,7 @@ 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
|
|
|
to using :setting:`MEDIA_URL`. For example, if the :setting:`MEDIA_URL` for
|
|
|
-your site was ``'http://uploads.example.com/'`` and :setting:`STATIC_URL`
|
|
|
+your site was ``'https://uploads.example.com/'`` and :setting:`STATIC_URL`
|
|
|
was ``None``:
|
|
|
|
|
|
.. code-block:: pycon
|
|
@@ -241,24 +241,24 @@ was ``None``:
|
|
|
... css = {
|
|
|
... "all": ["/css/pretty.css"],
|
|
|
... }
|
|
|
- ... js = ["animations.js", "http://othersite.com/actions.js"]
|
|
|
+ ... js = ["animations.js", "https://othersite.com/actions.js"]
|
|
|
...
|
|
|
|
|
|
>>> w = CalendarWidget()
|
|
|
>>> print(w.media)
|
|
|
<link href="/css/pretty.css" media="all" rel="stylesheet">
|
|
|
- <script src="http://uploads.example.com/animations.js"></script>
|
|
|
- <script src="http://othersite.com/actions.js"></script>
|
|
|
+ <script src="https://uploads.example.com/animations.js"></script>
|
|
|
+ <script src="https://othersite.com/actions.js"></script>
|
|
|
|
|
|
-But if :setting:`STATIC_URL` is ``'http://static.example.com/'``:
|
|
|
+But if :setting:`STATIC_URL` is ``'https://static.example.com/'``:
|
|
|
|
|
|
.. code-block:: pycon
|
|
|
|
|
|
>>> w = CalendarWidget()
|
|
|
>>> print(w.media)
|
|
|
<link href="/css/pretty.css" media="all" rel="stylesheet">
|
|
|
- <script src="http://static.example.com/animations.js"></script>
|
|
|
- <script src="http://othersite.com/actions.js"></script>
|
|
|
+ <script src="https://static.example.com/animations.js"></script>
|
|
|
+ <script src="https://othersite.com/actions.js"></script>
|
|
|
|
|
|
Or if :mod:`~django.contrib.staticfiles` is configured using the
|
|
|
:class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage`:
|
|
@@ -269,7 +269,7 @@ Or if :mod:`~django.contrib.staticfiles` is configured using the
|
|
|
>>> print(w.media)
|
|
|
<link href="/css/pretty.css" media="all" rel="stylesheet">
|
|
|
<script src="https://static.example.com/animations.27e20196a850.js"></script>
|
|
|
- <script src="http://othersite.com/actions.js"></script>
|
|
|
+ <script src="https://othersite.com/actions.js"></script>
|
|
|
|
|
|
Paths as objects
|
|
|
----------------
|
|
@@ -316,12 +316,12 @@ operator to filter out a medium of interest. For example:
|
|
|
|
|
|
>>> w = CalendarWidget()
|
|
|
>>> print(w.media)
|
|
|
- <link href="http://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
- <script src="http://static.example.com/animations.js"></script>
|
|
|
- <script src="http://static.example.com/actions.js"></script>
|
|
|
+ <link href="https://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
+ <script src="https://static.example.com/animations.js"></script>
|
|
|
+ <script src="https://static.example.com/actions.js"></script>
|
|
|
|
|
|
>>> print(w.media["css"])
|
|
|
- <link href="http://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
+ <link href="https://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
|
|
|
When you use the subscript operator, the value that is returned is a
|
|
|
new ``Media`` object -- but one that only contains the media of interest.
|
|
@@ -352,10 +352,10 @@ specified by both:
|
|
|
>>> w1 = CalendarWidget()
|
|
|
>>> w2 = OtherWidget()
|
|
|
>>> print(w1.media + w2.media)
|
|
|
- <link href="http://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
- <script src="http://static.example.com/animations.js"></script>
|
|
|
- <script src="http://static.example.com/actions.js"></script>
|
|
|
- <script src="http://static.example.com/whizbang.js"></script>
|
|
|
+ <link href="https://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
+ <script src="https://static.example.com/animations.js"></script>
|
|
|
+ <script src="https://static.example.com/actions.js"></script>
|
|
|
+ <script src="https://static.example.com/whizbang.js"></script>
|
|
|
|
|
|
.. _form-media-asset-order:
|
|
|
|
|
@@ -383,10 +383,10 @@ For example:
|
|
|
>>> w1 = CalendarWidget()
|
|
|
>>> w2 = TimeWidget()
|
|
|
>>> print(w1.media + w2.media)
|
|
|
- <script src="http://static.example.com/jQuery.js"></script>
|
|
|
- <script src="http://static.example.com/calendar.js"></script>
|
|
|
- <script src="http://static.example.com/time.js"></script>
|
|
|
- <script src="http://static.example.com/noConflict.js"></script>
|
|
|
+ <script src="https://static.example.com/jQuery.js"></script>
|
|
|
+ <script src="https://static.example.com/calendar.js"></script>
|
|
|
+ <script src="https://static.example.com/time.js"></script>
|
|
|
+ <script src="https://static.example.com/noConflict.js"></script>
|
|
|
|
|
|
Combining ``Media`` objects with assets in a conflicting order results in a
|
|
|
``MediaOrderConflictWarning``.
|
|
@@ -415,10 +415,10 @@ are part of the form:
|
|
|
|
|
|
>>> f = ContactForm()
|
|
|
>>> f.media
|
|
|
- <link href="http://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
- <script src="http://static.example.com/animations.js"></script>
|
|
|
- <script src="http://static.example.com/actions.js"></script>
|
|
|
- <script src="http://static.example.com/whizbang.js"></script>
|
|
|
+ <link href="https://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
+ <script src="https://static.example.com/animations.js"></script>
|
|
|
+ <script src="https://static.example.com/actions.js"></script>
|
|
|
+ <script src="https://static.example.com/whizbang.js"></script>
|
|
|
|
|
|
If you want to associate additional assets with a form -- for example,
|
|
|
CSS for form layout -- add a ``Media`` declaration to the form:
|
|
@@ -436,8 +436,8 @@ CSS for form layout -- add a ``Media`` declaration to the form:
|
|
|
|
|
|
>>> f = ContactForm()
|
|
|
>>> f.media
|
|
|
- <link href="http://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
- <link href="http://static.example.com/layout.css" media="all" rel="stylesheet">
|
|
|
- <script src="http://static.example.com/animations.js"></script>
|
|
|
- <script src="http://static.example.com/actions.js"></script>
|
|
|
- <script src="http://static.example.com/whizbang.js"></script>
|
|
|
+ <link href="https://static.example.com/pretty.css" media="all" rel="stylesheet">
|
|
|
+ <link href="https://static.example.com/layout.css" media="all" rel="stylesheet">
|
|
|
+ <script src="https://static.example.com/animations.js"></script>
|
|
|
+ <script src="https://static.example.com/actions.js"></script>
|
|
|
+ <script src="https://static.example.com/whizbang.js"></script>
|