Fixed a bunch of code examples in the form media documentation.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14594 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
96af304747
commit
d7ad02ff72
|
@ -131,12 +131,12 @@ media associated with the parent widget. This occurs regardless of how the
|
||||||
parent defines its media requirements. For example, if we were to extend our
|
parent defines its media requirements. For example, if we were to extend our
|
||||||
basic Calendar widget from the example above::
|
basic Calendar widget from the example above::
|
||||||
|
|
||||||
class FancyCalendarWidget(CalendarWidget):
|
>>> class FancyCalendarWidget(CalendarWidget):
|
||||||
class Media:
|
class Media:
|
||||||
css = {
|
css = {
|
||||||
'all': ('fancy.css',)
|
'all': ('fancy.css',)
|
||||||
}
|
}
|
||||||
js = ('whizbang.js',)
|
js = ('whizbang.js',)
|
||||||
|
|
||||||
>>> w = FancyCalendarWidget()
|
>>> w = FancyCalendarWidget()
|
||||||
>>> print w.media
|
>>> print w.media
|
||||||
|
@ -150,13 +150,13 @@ The FancyCalendar widget inherits all the media from it's parent widget. If
|
||||||
you don't want media to be inherited in this way, add an ``extend=False``
|
you don't want media to be inherited in this way, add an ``extend=False``
|
||||||
declaration to the media declaration::
|
declaration to the media declaration::
|
||||||
|
|
||||||
class FancyCalendarWidget(CalendarWidget):
|
>>> class FancyCalendarWidget(CalendarWidget):
|
||||||
class Media:
|
class Media:
|
||||||
extend = False
|
extend = False
|
||||||
css = {
|
css = {
|
||||||
'all': ('fancy.css',)
|
'all': ('fancy.css',)
|
||||||
}
|
}
|
||||||
js = ('whizbang.js',)
|
js = ('whizbang.js',)
|
||||||
|
|
||||||
>>> w = FancyCalendarWidget()
|
>>> w = FancyCalendarWidget()
|
||||||
>>> print w.media
|
>>> print w.media
|
||||||
|
@ -269,16 +269,16 @@ Combining media objects
|
||||||
Media objects can also be added together. When two media objects are added,
|
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::
|
the resulting Media object contains the union of the media from both files::
|
||||||
|
|
||||||
class CalendarWidget(forms.TextInput):
|
>>> class CalendarWidget(forms.TextInput):
|
||||||
class Media:
|
class Media:
|
||||||
css = {
|
css = {
|
||||||
'all': ('pretty.css',)
|
'all': ('pretty.css',)
|
||||||
}
|
}
|
||||||
js = ('animations.js', 'actions.js')
|
js = ('animations.js', 'actions.js')
|
||||||
|
|
||||||
class OtherWidget(forms.TextInput):
|
>>> class OtherWidget(forms.TextInput):
|
||||||
class Media:
|
class Media:
|
||||||
js = ('whizbang.js',)
|
js = ('whizbang.js',)
|
||||||
|
|
||||||
>>> w1 = CalendarWidget()
|
>>> w1 = CalendarWidget()
|
||||||
>>> w2 = OtherWidget()
|
>>> w2 = OtherWidget()
|
||||||
|
@ -300,9 +300,9 @@ Regardless of whether you define a media declaration, *all* Form objects
|
||||||
have a media property. The default value for this property is the result
|
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::
|
of adding the media definitions for all widgets that are part of the form::
|
||||||
|
|
||||||
class ContactForm(forms.Form):
|
>>> class ContactForm(forms.Form):
|
||||||
date = DateField(widget=CalendarWidget)
|
date = DateField(widget=CalendarWidget)
|
||||||
name = CharField(max_length=40, widget=OtherWidget)
|
name = CharField(max_length=40, widget=OtherWidget)
|
||||||
|
|
||||||
>>> f = ContactForm()
|
>>> f = ContactForm()
|
||||||
>>> f.media
|
>>> f.media
|
||||||
|
@ -314,14 +314,14 @@ of adding the media definitions for all widgets that are part of the form::
|
||||||
If you want to associate additional media with a form -- for example, CSS for form
|
If you want to associate additional media with a form -- for example, CSS for form
|
||||||
layout -- simply add a media declaration to the form::
|
layout -- simply add a media declaration to the form::
|
||||||
|
|
||||||
class ContactForm(forms.Form):
|
>>> class ContactForm(forms.Form):
|
||||||
date = DateField(widget=CalendarWidget)
|
date = DateField(widget=CalendarWidget)
|
||||||
name = CharField(max_length=40, widget=OtherWidget)
|
name = CharField(max_length=40, widget=OtherWidget)
|
||||||
|
|
||||||
class Media:
|
class Media:
|
||||||
css = {
|
css = {
|
||||||
'all': ('layout.css',)
|
'all': ('layout.css',)
|
||||||
}
|
}
|
||||||
|
|
||||||
>>> f = ContactForm()
|
>>> f = ContactForm()
|
||||||
>>> f.media
|
>>> f.media
|
||||||
|
|
Loading…
Reference in New Issue