dilmeet padda
dilmeet padda

Reputation: 53

how to remove these usercreation forms instruction in django

class Driver_SignUpForm(UserCreationForm):
    class Meta(UserCreationForm.Meta):
        fields = ("username", "email", "password1", "password2")
        model = User
        help_texts = {
            'username': None,
            'email': None,
            'password1': None,
            'password2': None,
        }

this is the code i already use the help text none but not working properly here is image of that

how to remove password instructions

Upvotes: 2

Views: 451

Answers (1)

dirkgroten
dirkgroten

Reputation: 20702

password1 and password2 aren't fields of the User model, so adding them to the fields list and trying to override the help texts in Meta doesn't do anything. That only works when you want to override model fields.

You should just redefine them at the top of your form, copying them from the django.contrib.auth.forms.UserCreationForm and removing the help texts.

class DriverSignUpForm(UserCreationForm):

    password1 = forms.CharField(
        label=_("Password"),
        strip=False,
        widget=forms.PasswordInput,
    )
    password2 = forms.CharField(
        label=_("Password confirmation"),
        widget=forms.PasswordInput,
        strip=False,
    )
    class Meta(UserCreationForm.Meta):
        fields = ("username", "email")

Upvotes: 4

Related Questions