Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit UserCreationForm password help text?

When I create a registration form that inherits from UserCreationForm, the text "Your password can't be too similar to your other personal information. Your password must contain at least 8 characters. Your password can't be a commonly used password. Your password can't be entirely numeric." appears under the password input fields and takes up quite a bit of space. Is there a way I can remove this?

I know the username help text can be removed with:

 help_texts = {
        'username': None
    }

but

help_texts = {
        'password1': None,
        'password2': None,
    }

does not work.

like image 893
Justin O'Brien Avatar asked Nov 26 '22 02:11

Justin O'Brien


1 Answers

a bit old but still:

class SignUpForm(UserCreationForm):

    class Meta:
        model = User

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['password1'].help_text = None
        self.fields['password2'].help_text = None

Those "None" could be edited by whatever text you wish

like image 73
mdc123 Avatar answered Feb 15 '23 07:02

mdc123