Add css class on RelatedField dropdown?


I am using built in Django Admin Template, I am trying customize the change_form.html and fieldset.html file.

I am trying to add “form-control” bootstrap class on each field, for that I have created the filter template tag.

def css_class(field, classname='form-control'):
Add css class to widget
css = field.field.widget.attrs.get('class', '')
field.field.widget.attrs['class'] = css + ' form-control'
return field

by using this " {{ field.field|css_class }} " class is being applied on all fields except RelatedField drop-down, also see the attached screenshot

please guide me how can I achieve this on each field