Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #5211 -- Added paths starting with '/' to the list of paths tha…

…t are preserved as-is by the widget media framework.

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5986 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 88987ed0ac6c29b78e2321e6f6687cb1385510fc 1 parent c49f2d2
Russell Keith-Magee authored August 20, 2007
5  django/newforms/widgets.py
@@ -14,6 +14,7 @@
14 14
 from django.utils.translation import ugettext
15 15
 from django.utils.encoding import StrAndUnicode, force_unicode
16 16
 from util import flatatt
  17
+from urlparse import urljoin
17 18
 
18 19
 __all__ = (
19 20
     'Media', 'Widget', 'TextInput', 'PasswordInput',
@@ -62,7 +63,9 @@ def render_css(self):
62 63
                 for medium in media])
63 64
         
64 65
     def absolute_path(self, path):
65  
-        return (path.startswith(u'http://') or path.startswith(u'https://')) and path or u''.join([settings.MEDIA_URL,path])
  66
+        if path.startswith(u'http://') or path.startswith(u'https://') or path.startswith(u'/'):
  67
+            return path
  68
+        return urljoin(settings.MEDIA_URL,path)
66 69
 
67 70
     def __getitem__(self, name):
68 71
         "Returns a Media object that only contains media of the given type"
6  docs/newforms.txt
@@ -2139,17 +2139,21 @@ Paths in media definitions
2139 2139
 --------------------------
2140 2140
 
2141 2141
 Paths used to specify media can be either relative or absolute. If a path 
2142  
-starts with 'http://' or 'https://', it will be interpreted as an absolute
  2142
+starts with '/', 'http://' or 'https://', it will be interpreted as an absolute
2143 2143
 path, and left as-is. All other paths will be prepended with the value of
2144 2144
 ``settings.MEDIA_URL``. For example, if the MEDIA_URL for your site was
2145 2145
 ``http://media.example.com/``::
2146 2146
 
2147 2147
     class CalendarWidget(forms.TextInput):
2148 2148
         class Media:
  2149
+            css = {
  2150
+                'all': ('/css/pretty.css',),
  2151
+            }
2149 2152
             js = ('animations.js', 'http://othersite.com/actions.js')
2150 2153
 
2151 2154
     >>> w = CalendarWidget()
2152 2155
     >>> print w.media
  2156
+    <link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet" />
2153 2157
     <script type="text/javascript" src="http://media.example.com/animations.js"></script>
2154 2158
     <script type="text/javascript" src="http://othersite.com/actions.js"></script>
2155 2159
 
194  tests/regressiontests/forms/media.py
@@ -4,35 +4,35 @@
4 4
 media_tests = r"""
5 5
 >>> from django.newforms import TextInput, Media, TextInput, CharField, Form, MultiWidget
6 6
 >>> from django.conf import settings
7  
->>> settings.MEDIA_URL = 'http://media.example.com'
  7
+>>> settings.MEDIA_URL = 'http://media.example.com/media/'
8 8
 
9 9
 # Check construction of media objects
10  
->>> m = Media(css={'all': ('/path/to/css1','/path/to/css2')}, js=('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3'))
  10
+>>> m = Media(css={'all': ('path/to/css1','/path/to/css2')}, js=('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3'))
11 11
 >>> print m
12  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
13  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
14  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  12
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  13
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  14
+<script type="text/javascript" src="/path/to/js1"></script>
15 15
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
16 16
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
17 17
 
18 18
 >>> class Foo:
19 19
 ...     css = {
20  
-...        'all': ('/path/to/css1','/path/to/css2')
  20
+...        'all': ('path/to/css1','/path/to/css2')
21 21
 ...     }
22 22
 ...     js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3')
23 23
 >>> m3 = Media(Foo)
24 24
 >>> print m3
25  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
26  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
27  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  25
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  26
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  27
+<script type="text/javascript" src="/path/to/js1"></script>
28 28
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
29 29
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
30 30
 
31 31
 >>> m3 = Media(Foo)
32 32
 >>> print m3
33  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
34  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
35  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  33
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  34
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  35
+<script type="text/javascript" src="/path/to/js1"></script>
36 36
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
37 37
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
38 38
 
@@ -54,25 +54,25 @@
54 54
 >>> class MyWidget1(TextInput):
55 55
 ...     class Media:
56 56
 ...         css = {
57  
-...            'all': ('/path/to/css1','/path/to/css2')
  57
+...            'all': ('path/to/css1','/path/to/css2')
58 58
 ...         }
59 59
 ...         js = ('/path/to/js1','http://media.other.com/path/to/js2','https://secure.other.com/path/to/js3')
60 60
 
61 61
 >>> w1 = MyWidget1()
62 62
 >>> print w1.media
63  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
64  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
65  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  63
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  64
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  65
+<script type="text/javascript" src="/path/to/js1"></script>
66 66
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
67 67
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
68 68
 
69 69
 # Media objects can be interrogated by media type
70 70
 >>> print w1.media['css']
71  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
72  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  71
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  72
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
73 73
 
74 74
 >>> print w1.media['js']
75  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  75
+<script type="text/javascript" src="/path/to/js1"></script>
76 76
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
77 77
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
78 78
 
@@ -88,26 +88,26 @@
88 88
 >>> class MyWidget3(TextInput):
89 89
 ...     class Media:
90 90
 ...         css = {
91  
-...            'all': ('/path/to/css3','/path/to/css1')
  91
+...            'all': ('/path/to/css3','path/to/css1')
92 92
 ...         }
93 93
 ...         js = ('/path/to/js1','/path/to/js4')
94 94
 
95 95
 >>> w2 = MyWidget2()
96 96
 >>> w3 = MyWidget3()
97 97
 >>> print w1.media + w2.media + w3.media
98  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
99  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
100  
-<link href="http://media.example.com/path/to/css3" type="text/css" media="all" rel="stylesheet" />
101  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  98
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  99
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  100
+<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" />
  101
+<script type="text/javascript" src="/path/to/js1"></script>
102 102
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
103 103
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
104  
-<script type="text/javascript" src="http://media.example.com/path/to/js4"></script>
  104
+<script type="text/javascript" src="/path/to/js4"></script>
105 105
 
106 106
 # Check that media addition hasn't affected the original objects
107 107
 >>> print w1.media
108  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
109  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
110  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  108
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  109
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  110
+<script type="text/javascript" src="/path/to/js1"></script>
111 111
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
112 112
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
113 113
 
@@ -123,8 +123,8 @@
123 123
 
124 124
 >>> w4 = MyWidget4()
125 125
 >>> print w4.media
126  
-<link href="http://media.example.com/some/path" type="text/css" media="all" rel="stylesheet" />
127  
-<script type="text/javascript" src="http://media.example.com/some/js"></script>
  126
+<link href="/some/path" type="text/css" media="all" rel="stylesheet" />
  127
+<script type="text/javascript" src="/some/js"></script>
128 128
 
129 129
 # Media properties can reference the media of their parents
130 130
 >>> class MyWidget5(MyWidget4):
@@ -134,10 +134,10 @@
134 134
 
135 135
 >>> w5 = MyWidget5()
136 136
 >>> print w5.media
137  
-<link href="http://media.example.com/some/path" type="text/css" media="all" rel="stylesheet" />
138  
-<link href="http://media.example.com/other/path" type="text/css" media="all" rel="stylesheet" />
139  
-<script type="text/javascript" src="http://media.example.com/some/js"></script>
140  
-<script type="text/javascript" src="http://media.example.com/other/js"></script>
  137
+<link href="/some/path" type="text/css" media="all" rel="stylesheet" />
  138
+<link href="/other/path" type="text/css" media="all" rel="stylesheet" />
  139
+<script type="text/javascript" src="/some/js"></script>
  140
+<script type="text/javascript" src="/other/js"></script>
141 141
 
142 142
 # Media properties can reference the media of their parents,
143 143
 # even if the parent media was defined using a class
@@ -148,13 +148,13 @@
148 148
 
149 149
 >>> w6 = MyWidget6()
150 150
 >>> print w6.media
151  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
152  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
153  
-<link href="http://media.example.com/other/path" type="text/css" media="all" rel="stylesheet" />
154  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  151
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  152
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  153
+<link href="/other/path" type="text/css" media="all" rel="stylesheet" />
  154
+<script type="text/javascript" src="/path/to/js1"></script>
155 155
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
156 156
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
157  
-<script type="text/javascript" src="http://media.example.com/other/js"></script>
  157
+<script type="text/javascript" src="/other/js"></script>
158 158
 
159 159
 ###############################################################
160 160
 # Inheritance of media
@@ -166,9 +166,9 @@
166 166
 
167 167
 >>> w7 = MyWidget7()
168 168
 >>> print w7.media
169  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
170  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
171  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  169
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  170
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  171
+<script type="text/javascript" src="/path/to/js1"></script>
172 172
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
173 173
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
174 174
 
@@ -176,19 +176,19 @@
176 176
 >>> class MyWidget8(MyWidget1):
177 177
 ...     class Media:
178 178
 ...         css = {
179  
-...            'all': ('/path/to/css3','/path/to/css1')
  179
+...            'all': ('/path/to/css3','path/to/css1')
180 180
 ...         }
181 181
 ...         js = ('/path/to/js1','/path/to/js4')
182 182
 
183 183
 >>> w8 = MyWidget8()
184 184
 >>> print w8.media
185  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
186  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
187  
-<link href="http://media.example.com/path/to/css3" type="text/css" media="all" rel="stylesheet" />
188  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  185
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  186
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  187
+<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" />
  188
+<script type="text/javascript" src="/path/to/js1"></script>
189 189
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
190 190
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
191  
-<script type="text/javascript" src="http://media.example.com/path/to/js4"></script>
  191
+<script type="text/javascript" src="/path/to/js4"></script>
192 192
 
193 193
 # If a widget extends another but defines media, it extends the parents widget's media,
194 194
 # even if the parent defined media using a property.
@@ -201,62 +201,62 @@
201 201
 
202 202
 >>> w9 = MyWidget9()
203 203
 >>> print w9.media
204  
-<link href="http://media.example.com/some/path" type="text/css" media="all" rel="stylesheet" />
205  
-<link href="http://media.example.com/other/path" type="text/css" media="all" rel="stylesheet" />
206  
-<script type="text/javascript" src="http://media.example.com/some/js"></script>
207  
-<script type="text/javascript" src="http://media.example.com/other/js"></script>
  204
+<link href="/some/path" type="text/css" media="all" rel="stylesheet" />
  205
+<link href="/other/path" type="text/css" media="all" rel="stylesheet" />
  206
+<script type="text/javascript" src="/some/js"></script>
  207
+<script type="text/javascript" src="/other/js"></script>
208 208
 
209 209
 # A widget can disable media inheritance by specifying 'extend=False'
210 210
 >>> class MyWidget10(MyWidget1):
211 211
 ...     class Media:
212 212
 ...         extend = False
213 213
 ...         css = {
214  
-...            'all': ('/path/to/css3','/path/to/css1')
  214
+...            'all': ('/path/to/css3','path/to/css1')
215 215
 ...         }
216 216
 ...         js = ('/path/to/js1','/path/to/js4')
217 217
 
218 218
 >>> w10 = MyWidget10()
219 219
 >>> print w10.media
220  
-<link href="http://media.example.com/path/to/css3" type="text/css" media="all" rel="stylesheet" />
221  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
222  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
223  
-<script type="text/javascript" src="http://media.example.com/path/to/js4"></script>
  220
+<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" />
  221
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  222
+<script type="text/javascript" src="/path/to/js1"></script>
  223
+<script type="text/javascript" src="/path/to/js4"></script>
224 224
 
225 225
 # A widget can explicitly enable full media inheritance by specifying 'extend=True'
226 226
 >>> class MyWidget11(MyWidget1):
227 227
 ...     class Media:
228 228
 ...         extend = True
229 229
 ...         css = {
230  
-...            'all': ('/path/to/css3','/path/to/css1')
  230
+...            'all': ('/path/to/css3','path/to/css1')
231 231
 ...         }
232 232
 ...         js = ('/path/to/js1','/path/to/js4')
233 233
 
234 234
 >>> w11 = MyWidget11()
235 235
 >>> print w11.media
236  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
237  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
238  
-<link href="http://media.example.com/path/to/css3" type="text/css" media="all" rel="stylesheet" />
239  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  236
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  237
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  238
+<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" />
  239
+<script type="text/javascript" src="/path/to/js1"></script>
240 240
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
241 241
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
242  
-<script type="text/javascript" src="http://media.example.com/path/to/js4"></script>
  242
+<script type="text/javascript" src="/path/to/js4"></script>
243 243
 
244 244
 # A widget can enable inheritance of one media type by specifying extend as a tuple
245 245
 >>> class MyWidget12(MyWidget1):
246 246
 ...     class Media:
247 247
 ...         extend = ('css',)
248 248
 ...         css = {
249  
-...            'all': ('/path/to/css3','/path/to/css1')
  249
+...            'all': ('/path/to/css3','path/to/css1')
250 250
 ...         }
251 251
 ...         js = ('/path/to/js1','/path/to/js4')
252 252
 
253 253
 >>> w12 = MyWidget12()
254 254
 >>> print w12.media
255  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
256  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
257  
-<link href="http://media.example.com/path/to/css3" type="text/css" media="all" rel="stylesheet" />
258  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
259  
-<script type="text/javascript" src="http://media.example.com/path/to/js4"></script>
  255
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  256
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  257
+<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" />
  258
+<script type="text/javascript" src="/path/to/js1"></script>
  259
+<script type="text/javascript" src="/path/to/js4"></script>
260 260
 
261 261
 ###############################################################
262 262
 # Multi-media handling for CSS
@@ -274,12 +274,12 @@
274 274
 
275 275
 >>> multimedia = MultimediaWidget()
276 276
 >>> print multimedia.media
277  
-<link href="http://media.example.com/file4" type="text/css" media="print" rel="stylesheet" />
278  
-<link href="http://media.example.com/file3" type="text/css" media="screen" rel="stylesheet" />
279  
-<link href="http://media.example.com/file1" type="text/css" media="screen, print" rel="stylesheet" />
280  
-<link href="http://media.example.com/file2" type="text/css" media="screen, print" rel="stylesheet" />
281  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
282  
-<script type="text/javascript" src="http://media.example.com/path/to/js4"></script>
  277
+<link href="/file4" type="text/css" media="print" rel="stylesheet" />
  278
+<link href="/file3" type="text/css" media="screen" rel="stylesheet" />
  279
+<link href="/file1" type="text/css" media="screen, print" rel="stylesheet" />
  280
+<link href="/file2" type="text/css" media="screen, print" rel="stylesheet" />
  281
+<script type="text/javascript" src="/path/to/js1"></script>
  282
+<script type="text/javascript" src="/path/to/js4"></script>
283 283
 
284 284
 ###############################################################
285 285
 # Multiwidget media handling
@@ -294,13 +294,13 @@
294 294
             
295 295
 >>> mymulti = MyMultiWidget()
296 296
 >>> print mymulti.media   
297  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
298  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
299  
-<link href="http://media.example.com/path/to/css3" type="text/css" media="all" rel="stylesheet" />
300  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  297
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  298
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  299
+<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" />
  300
+<script type="text/javascript" src="/path/to/js1"></script>
301 301
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
302 302
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
303  
-<script type="text/javascript" src="http://media.example.com/path/to/js4"></script>
  303
+<script type="text/javascript" src="/path/to/js4"></script>
304 304
 
305 305
 ###############################################################
306 306
 # Media processing for forms
@@ -312,26 +312,26 @@
312 312
 ...     field2 = CharField(max_length=20, widget=MyWidget2())
313 313
 >>> f1 = MyForm()
314 314
 >>> print f1.media
315  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
316  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
317  
-<link href="http://media.example.com/path/to/css3" type="text/css" media="all" rel="stylesheet" />
318  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  315
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  316
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  317
+<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" />
  318
+<script type="text/javascript" src="/path/to/js1"></script>
319 319
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
320 320
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
321  
-<script type="text/javascript" src="http://media.example.com/path/to/js4"></script>
  321
+<script type="text/javascript" src="/path/to/js4"></script>
322 322
 
323 323
 # Form media can be combined to produce a single media definition.
324 324
 >>> class AnotherForm(Form):
325 325
 ...     field3 = CharField(max_length=20, widget=MyWidget3())
326 326
 >>> f2 = AnotherForm()
327 327
 >>> print f1.media + f2.media
328  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
329  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
330  
-<link href="http://media.example.com/path/to/css3" type="text/css" media="all" rel="stylesheet" />
331  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  328
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  329
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  330
+<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" />
  331
+<script type="text/javascript" src="/path/to/js1"></script>
332 332
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
333 333
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
334  
-<script type="text/javascript" src="http://media.example.com/path/to/js4"></script>
  334
+<script type="text/javascript" src="/path/to/js4"></script>
335 335
 
336 336
 # Forms can also define media, following the same rules as widgets.
337 337
 >>> class FormWithMedia(Form):
@@ -344,14 +344,14 @@
344 344
 ...         }
345 345
 >>> f3 = FormWithMedia()
346 346
 >>> print f3.media
347  
-<link href="http://media.example.com/path/to/css1" type="text/css" media="all" rel="stylesheet" />
348  
-<link href="http://media.example.com/path/to/css2" type="text/css" media="all" rel="stylesheet" />
349  
-<link href="http://media.example.com/path/to/css3" type="text/css" media="all" rel="stylesheet" />
350  
-<link href="http://media.example.com/some/form/css" type="text/css" media="all" rel="stylesheet" />
351  
-<script type="text/javascript" src="http://media.example.com/path/to/js1"></script>
  347
+<link href="http://media.example.com/media/path/to/css1" type="text/css" media="all" rel="stylesheet" />
  348
+<link href="/path/to/css2" type="text/css" media="all" rel="stylesheet" />
  349
+<link href="/path/to/css3" type="text/css" media="all" rel="stylesheet" />
  350
+<link href="/some/form/css" type="text/css" media="all" rel="stylesheet" />
  351
+<script type="text/javascript" src="/path/to/js1"></script>
352 352
 <script type="text/javascript" src="http://media.other.com/path/to/js2"></script>
353 353
 <script type="text/javascript" src="https://secure.other.com/path/to/js3"></script>
354  
-<script type="text/javascript" src="http://media.example.com/path/to/js4"></script>
355  
-<script type="text/javascript" src="http://media.example.com/some/form/javascript"></script>
  354
+<script type="text/javascript" src="/path/to/js4"></script>
  355
+<script type="text/javascript" src="/some/form/javascript"></script>
356 356
 
357 357
 """

0 notes on commit 88987ed

Please sign in to comment.
Something went wrong with that request. Please try again.