Author: jezdez
Date: 2010-11-17 09:45:15 -0600 (Wed, 17 Nov 2010)
New Revision: 14596
Modified:
django/branches/releases/1.2.X/docs/topics/forms/media.txt
Log:
[1.2.X] Fixed a bunch of code examples in the form media documentation.
Backport from trunk (r14594).
Modified: django/branches/releases/1.2.X/docs/topics/forms/media.txt
===================================================================
--- django/branches/releases/1.2.X/docs/topics/forms/media.txt 2010-11-17
15:37:33 UTC (rev 14595)
+++ django/branches/releases/1.2.X/docs/topics/forms/media.txt 2010-11-17
15:45:15 UTC (rev 14596)
@@ -131,12 +131,12 @@
parent defines its media requirements. For example, if we were to extend our
basic Calendar widget from the example above::
- class FancyCalendarWidget(CalendarWidget):
- class Media:
- css = {
- 'all': ('fancy.css',)
- }
- js = ('whizbang.js',)
+ >>> class FancyCalendarWidget(CalendarWidget):
+ class Media:
+ css = {
+ 'all': ('fancy.css',)
+ }
+ js = ('whizbang.js',)
>>> w = FancyCalendarWidget()
>>> print w.media
@@ -150,13 +150,13 @@
you don't want media to be inherited in this way, add an ``extend=False``
declaration to the media declaration::
- class FancyCalendarWidget(CalendarWidget):
- class Media:
- extend = False
- css = {
- 'all': ('fancy.css',)
- }
- js = ('whizbang.js',)
+ >>> class FancyCalendarWidget(CalendarWidget):
+ class Media:
+ extend = False
+ css = {
+ 'all': ('fancy.css',)
+ }
+ js = ('whizbang.js',)
>>> w = FancyCalendarWidget()
>>> print w.media
@@ -246,16 +246,16 @@
Media objects can also be added together. When two media objects are added,
the resulting Media object contains the union of the media from both files::
- class CalendarWidget(forms.TextInput):
- class Media:
- css = {
- 'all': ('pretty.css',)
- }
- js = ('animations.js', 'actions.js')
+ >>> class CalendarWidget(forms.TextInput):
+ class Media:
+ css = {
+ 'all': ('pretty.css',)
+ }
+ js = ('animations.js', 'actions.js')
- class OtherWidget(forms.TextInput):
- class Media:
- js = ('whizbang.js',)
+ >>> class OtherWidget(forms.TextInput):
+ class Media:
+ js = ('whizbang.js',)
>>> w1 = CalendarWidget()
>>> w2 = OtherWidget()
@@ -277,9 +277,9 @@
have a media property. The default value for this property is the result
of adding the media definitions for all widgets that are part of the form::
- class ContactForm(forms.Form):
- date = DateField(widget=CalendarWidget)
- name = CharField(max_length=40, widget=OtherWidget)
+ >>> class ContactForm(forms.Form):
+ date = DateField(widget=CalendarWidget)
+ name = CharField(max_length=40, widget=OtherWidget)
>>> f = ContactForm()
>>> f.media
@@ -291,14 +291,14 @@
If you want to associate additional media with a form -- for example, CSS for
form
layout -- simply add a media declaration to the form::
- class ContactForm(forms.Form):
- date = DateField(widget=CalendarWidget)
- name = CharField(max_length=40, widget=OtherWidget)
+ >>> class ContactForm(forms.Form):
+ date = DateField(widget=CalendarWidget)
+ name = CharField(max_length=40, widget=OtherWidget)
- class Media:
- css = {
- 'all': ('layout.css',)
- }
+ class Media:
+ css = {
+ 'all': ('layout.css',)
+ }
>>> f = ContactForm()
>>> f.media
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.