3👍
✅
Clean
should return dict
. You need to rewrite clean
method:
def clean(self):
cleaned_data = super(ResetActivatioKey, self).clean()
try:
user = User.objects.get(email__iexact=self.cleaned_data['email'])
return cleaned_data
except:
raise forms.ValidationError('User with this email does not exist!')
3👍
Your clean()
method is returning a string with the email you just entered in it. You may need to call super()
on your method to get the cleaned_data as dict
and return the same to the view.
You need to edit your clean()
method in your form,
def clean(self):
cleaned_data = super(ResetActvatioKey, self).clean()
try:
user = User.objects.get(email__iexact=self.cleaned_data['email'])
return cleaned_data
except:
raise forms.ValidationError('User with that email does not exist!')
- [Django]-Build When Case query in for loop django
- [Django]-Accessing models by variable model name in django
- [Django]-Understanding Model.from_db() in Django
- [Django]-Django rest framework custom Response middleware
Source:stackexchange.com