问题
forms.py
class ImportExcelForm(Form):
file = forms.FileField(attrs={'class':'rounded_list',})
I am trying to add css class to my filefield in forms.I am getting this error "__init__() got an unexpected keyword argument 'attrs'"
What i did wrong.
Thanks
回答1:
attrs is not an argument to the field, it's an argument to the widget.
file = forms.FieldField(widget=forms.FileInput(attrs={'class': 'rounded_list'}))
Note that some browsers don't allow styling of the file input.
来源:https://stackoverflow.com/questions/16482432/init-got-an-unexpected-keyword-argument-attrs