code: def add_bootstrap_class(field):
      
      if not isinstance(field.field.widget, (
          django.forms.widgets.CheckboxInput,
          django.forms.widgets.CheckboxSelectMultiple,
          django.forms.widgets.RadioSelect,
          django.forms.widgets.FileInput,
          str
      )):
          field_classes = set(field.field.widget.attrs.get('class', '').split())
          field_classes.add('form-control')
          field.field.widget.attrs['class'] = ' '.join(field_classes)
      return field
docs: Add a "form-control" CSS class to the field's widget.
  
      This is so that Bootstrap styles it properly.