I am using a bootstrap form mixin which includes code similar to this
class BootstrapForm(object):
def __init__(self, *args, **kwargs):
super(BootstrapForm, self).__init__(*args, **kwargs)
for bfield in self:
field = self.fields[bfield.name]
classes = ['form-control']
if 'class' in field.widget.attrs:
classes.append(field.widget.attrs['class'])
field.widget.attrs.update(
{'class' : ' '.join(classes)}
)
It depends on the value of field.widget.attrs['class'] being propagated to the rendered widget.
One could argue that Django should be doing the combining for us, but it doesn't, for now this works, and I don't believe will cause any other issues.
I am using a bootstrap form mixin which includes code similar to this
It depends on the value of field.widget.attrs['class'] being propagated to the rendered widget.
One could argue that Django should be doing the combining for us, but it doesn't, for now this works, and I don't believe will cause any other issues.