'nonetype' Object Has No Attribute 'user' Django
When i submit form i get an AttributeError: 'NoneType' object has no attribute 'user' please help meto fix this problem My forms.py class resume_upload(forms.ModelForm): cv = f
Solution 1:
When you overwrite the save()
method in your ModelForm resume_upload(forms.ModelForm)
you need to return the object:
defsave(self, commit=False):
cvs = super(resume_upload, self).save(commit=False)
cvs.cv = self.cleaned_data['cv']
cvs.job_title = self.cleaned_data['job_title']
if commit:
cvs.save()
return cvs
Solution 2:
You are hiding your user field when you setting up fields that way, so they cant find attribute user in your form when you trying to pass request.user
to it
classMeta:
model = Cvfields= ('cv', 'job_title', 'user')
Post a Comment for "'nonetype' Object Has No Attribute 'user' Django"