6

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.

3 Answers3

2

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

mdc123
  • 196
  • 1
  • 10
  • +1, This works, thanks! And also, don't hesitate to answer just because some question is old, because a lot of people come from google too... – Datajack Jan 31 '22 at 05:06
0

Is there a way you can remove this? Yes, it is.

  1. ! This way will be not recommended ! but it works:

in settings.py delete all in the list AUTH_PASSWORD_VALIDATORS = []

OR

  1. My way: in .html file I have used this
<form method="post">
  {% csrf_token %}

  <label>{{ form.username.label }}</label>
  {{ form.username }}

  <label>{{ form.password1.label }}</label>
  {{ form.password1 }}

  <label>{{ form.password2.label }}</label>
  {{ form.password2 }}

  <input type="submit" value="Submit">
</form>
nukiska
  • 1
  • 2
-2
  password1 = forms.CharField(
            label='Password', widget=forms.PasswordInput())
        password2 = forms.CharField(
            label='Confirm Password(again)', widget=forms.PasswordInput())
Christopher Moore
  • 15,626
  • 10
  • 42
  • 52