My problem is that I am trying to modify the Django default UserCreationForm and its default messages, but it does not work. I also heard that some of the checks and initial messages are defined separately and should be customized separately, but I did not find a lot on that. I tried to search around, but most of what I found was either old and not working for current django version or did just modify the fields and not the error messages.
I am importing the UserCreationForm in forms.py like this:
from django.contrib.auth.forms import UserCreationForm
And then I tried to modify it like this: The fields and everything is completely functional just the messages are still the default and not the custom I was trying to set.
class UserSignUpForm(UserCreationForm):
username = forms.CharField(label="custom",
error_messages={'required': 'custom.',
'unique': 'custom.'})
password1 = forms.CharField(label="custom", widget=forms.PasswordInput,
error_messages={'required': 'custom.'})
password2 = forms.CharField(label="Potvrďte custom", widget=forms.PasswordInput,
error_messages={'required': 'custom.',
'password_mismatch': 'custom.'})
class Meta(UserCreationForm.Meta):
model = User
fields = UserCreationForm.Meta.fields
error_messages = {
'password_mismatch': {"password_mismatch": "custom"},
'password_too_short': {"password_too_short": "custom"},
'password_common': {"password_common": "custom"},
'password_entirely_numeric': {"password_entirely_numeric": "custom"},
}
If someone knows how to solve this, please let me know. I would appreciate any feedback.