S
Size: a a a
S
S
AU
К
AU
К
A
A
class ToggleWidget(forms.widgets.CheckboxInput):
class Media:
css = {'all': (
"https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css", )}
js = ("https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js",)
def __init__(self, attrs=None, *args, **kwargs):
attrs = attrs or {}
default_options = {
'toggle': 'toggle',
'offstyle': 'danger'
}
options = kwargs.get('options', {})
default_options.update(options)
for key, val in default_options.items():
attrs['data-' + key] = val
super().__init__(attrs)
A
A
A
this will append the custom media for the ToggleWidget. Will wrap css to link tags, and js to script tags every where we use the ToggleWidget widget. For further information, read the documentation.
...A
AG
A
AG
AG
A
AG
A
{{ widget.media }}
?AG
{{ widget.media }}
?