Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed a bunch of code examples in the form media documentation.

Backport from trunk (r14594).

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14596 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f58d17db7495ce56acb9029ae4ebeab00cba085a 1 parent 17d0c7a
Jannis Leidel authored November 17, 2010

Showing 1 changed file with 32 additions and 32 deletions. Show diff stats Hide diff stats

  1. 64  docs/topics/forms/media.txt
64  docs/topics/forms/media.txt
@@ -131,12 +131,12 @@ media associated with the parent widget. This occurs regardless of how the
131 131
 parent defines its media requirements. For example, if we were to extend our
132 132
 basic Calendar widget from the example above::
133 133
 
134  
-    class FancyCalendarWidget(CalendarWidget):
135  
-        class Media:
136  
-            css = {
137  
-                'all': ('fancy.css',)
138  
-            }
139  
-            js = ('whizbang.js',)
  134
+    >>> class FancyCalendarWidget(CalendarWidget):
  135
+            class Media:
  136
+                css = {
  137
+                    'all': ('fancy.css',)
  138
+                }
  139
+                js = ('whizbang.js',)
140 140
 
141 141
     >>> w = FancyCalendarWidget()
142 142
     >>> print w.media
@@ -150,13 +150,13 @@ The FancyCalendar widget inherits all the media from it's parent widget. If
150 150
 you don't want media to be inherited in this way, add an ``extend=False``
151 151
 declaration to the media declaration::
152 152
 
153  
-    class FancyCalendarWidget(CalendarWidget):
154  
-        class Media:
155  
-            extend = False
156  
-            css = {
157  
-                'all': ('fancy.css',)
158  
-            }
159  
-            js = ('whizbang.js',)
  153
+    >>> class FancyCalendarWidget(CalendarWidget):
  154
+            class Media:
  155
+                extend = False
  156
+                css = {
  157
+                    'all': ('fancy.css',)
  158
+                }
  159
+                js = ('whizbang.js',)
160 160
 
161 161
     >>> w = FancyCalendarWidget()
162 162
     >>> print w.media
@@ -246,16 +246,16 @@ Combining media objects
246 246
 Media objects can also be added together. When two media objects are added,
247 247
 the resulting Media object contains the union of the media from both files::
248 248
 
249  
-    class CalendarWidget(forms.TextInput):
250  
-        class Media:
251  
-            css = {
252  
-                'all': ('pretty.css',)
253  
-            }
254  
-            js = ('animations.js', 'actions.js')
  249
+    >>> class CalendarWidget(forms.TextInput):
  250
+            class Media:
  251
+                css = {
  252
+                    'all': ('pretty.css',)
  253
+                }
  254
+                js = ('animations.js', 'actions.js')
255 255
 
256  
-    class OtherWidget(forms.TextInput):
257  
-        class Media:
258  
-            js = ('whizbang.js',)
  256
+    >>> class OtherWidget(forms.TextInput):
  257
+            class Media:
  258
+                js = ('whizbang.js',)
259 259
 
260 260
     >>> w1 = CalendarWidget()
261 261
     >>> w2 = OtherWidget()
@@ -277,9 +277,9 @@ Regardless of whether you define a media declaration, *all* Form objects
277 277
 have a media property. The default value for this property is the result
278 278
 of adding the media definitions for all widgets that are part of the form::
279 279
 
280  
-    class ContactForm(forms.Form):
281  
-        date = DateField(widget=CalendarWidget)
282  
-        name = CharField(max_length=40, widget=OtherWidget)
  280
+    >>> class ContactForm(forms.Form):
  281
+            date = DateField(widget=CalendarWidget)
  282
+            name = CharField(max_length=40, widget=OtherWidget)
283 283
 
284 284
     >>> f = ContactForm()
285 285
     >>> f.media
@@ -291,14 +291,14 @@ of adding the media definitions for all widgets that are part of the form::
291 291
 If you want to associate additional media with a form -- for example, CSS for form
292 292
 layout -- simply add a media declaration to the form::
293 293
 
294  
-    class ContactForm(forms.Form):
295  
-        date = DateField(widget=CalendarWidget)
296  
-        name = CharField(max_length=40, widget=OtherWidget)
  294
+    >>> class ContactForm(forms.Form):
  295
+            date = DateField(widget=CalendarWidget)
  296
+            name = CharField(max_length=40, widget=OtherWidget)
297 297
 
298  
-        class Media:
299  
-            css = {
300  
-                'all': ('layout.css',)
301  
-            }
  298
+            class Media:
  299
+                css = {
  300
+                    'all': ('layout.css',)
  301
+                }
302 302
 
303 303
     >>> f = ContactForm()
304 304
     >>> f.media

0 notes on commit f58d17d

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