Is there any way to create a widget that generates twitter bootstrap buttons? I am needing to put some buttons in the middle of the form. (or html that are not inputs)
Tried as follows:
class BootstrapButtonWidget(forms.Widget):
def render(self, value, attrs=None):
return '<a href="#" class="btn btn-danger delete">%s</a>' % (value,)
class BootstrapButton(forms.Field):
def __init__(self, value, *args, **kwargs):
if not kwargs:
kwargs = {}
kwargs["widget"] = BootstrapButtonWidget
super(BootstrapButton, self).__init__(*args, **kwargs)
def clean(self, value):
return value
But I could not pass values. He always spends a "value".
I need to render a button like this:
<button type="button" class="btn %s">%s</button> % (btn_type, btn_text)
Rendered:
<button type="button" class="btn btn-primary">Delete this</button>