Click here to Skip to main content
15,663,399 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got this error while running python makemigrations. I was using the attris in the right way as searched by me in google:

Form fields:
image = forms.ImageField(required=False, widget=forms.FileInput(attris={'class': 'form-control'})) 
    ethnicity = forms.ChoiceField(choices = ETHINIC_CHOICES, widget=forms.Select(attris={'class': 'nice-select rounded'}))
    date_birth = forms.DateField(required=True, widget=forms.FileInput(attris={'class': 'form-control', 'placeholder': 'Enter a date: '}))
    sex =  forms.ChoiceField(choices = SEX_CHOICES, widget=forms.Select(attris={'class': 'nice-select rounded'}))
    marital_status = forms.ChoiceField(choices = MARITAL_STATUS, widget=forms.Select(attris={'class': 'nice-select rounded'}))
    addressLine1 = forms.CharField(required=True, widget=forms.TextInput(attris={'class': 'form-control resume', 'placeholder': 'Enter Address Line 1'}))
    addressLine2 = forms.CharField(required=True, widget=forms.TextInput(attris={'class': 'form-control resume', 'placeholder': 'Enter Address Line 2'}))
    suburb = forms.CharField(required=True, widget=forms.TextInput(attris={'class': 'form-control resume', 'placeholder': 'Enter Suburb'}))
    city = forms.CharField(required=True, widget=forms.TextInput(attris={'class': 'form-control resume', 'placeholder': 'Enter City'}))
    province = forms.ChoiceField(choices = PROVINCE_CHOICES, widget=forms.Select(attris={'class': 'nice-select rounded'}))
    phoneNumber = forms.CharField(required=True, widget=forms.TextInput(attris={'class': 'form-control resume', 'placeholder': 'Enter Phone Number'}))
    cover_letter = forms.FileField(required=False, widget=forms.FileInput(attris={'class': 'form-control'}))
    cv = forms.FileField(required=False, widget=forms.FileInput(attris={'class': 'form-control'}))

I am getting in the image one but i would assume all are wrong since all are written in the same way

What I have tried:

I searched google and most common response I got was:
attrs is not an argument to the field, it's an argument to the widget.

file = forms.FileField(widget=forms.FileInput(attrs={'class': 'rounded_list'}))

Note that some browsers don't allow the styling of the file input.

Which I was already doing
Updated 9-Jul-22 5:35am
Richard MacCutchan 9-Jul-22 4:27am    
The error message is quite clear: the FileInput constructor does not have a parameter named attris.

1 solution

See Widgets | Django documentation | Django[^], the property is named attrs not attris, and is a property of the widget class.
Share this answer
Kavya Bhargava 9-Jul-22 17:17pm    
Thanks, I don't know how I did not see that

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900