2๐
โ
(Updated according to the comment โ the same principle still applies: subclass the form and override.)
Subclass the form and override the clean method for the particular field:
from django import forms
from django.contrib.auth.forms import PasswordChangeForm
class MyPasswordChangeForm(PasswordChangeForm):
def clean_old_password(self):
try:
return super(MyPasswordChangeForm, self).clean_old_password():
except forms.ValidationError:
raise forms.ValidationError("Booh, the password was not correct!")
โฆ then use MyPasswordChangeForm
instead of PasswordChangeForm in your views.
๐คandreaspelme
Source:stackexchange.com