Skip to content

Instantly share code, notes, and snippets.

@rmoch
rmoch / gist:6364899
Last active April 22, 2016 17:47
- Django form widget for bootstrap switch HTML widget - http://www.bootstrap-switch.org/ - https://github.com/nostalgiaz/bootstrap-switch
class CheckBoxBootstrapSwitch(CheckboxInput):
"""Django widget for bootstrap switch HTML widget: http://www.bootstrap-switch.org/
Options can be provided through 'switch' argument:
switch = forms.BooleanField(required=False, label=_(u"bootstrap switch"),
widget=CheckBoxBootstrapSwitch(switch={'size': 'small', 'on': 'warning', 'text-label': 'Switch Me'}))
"""
def __init__(self, switch=None, *args, **kwargs):
self.switch = switch or {}
super(CheckBoxBootstrapSwitch, self).__init__(*args, **kwargs)