Removing help_text from Django UserCreateForm

后端 未结 7 1277
感动是毒
感动是毒 2020-12-05 14:10

Probably a poor question, but I\'m using Django\'s UserCreationForm (slightly modified to include email), and I would like to remove the help_text that Django automatically

7条回答
  •  抹茶落季
    2020-12-05 14:25

    I had a similar issue. Based on one of the comments, here is the solution after reading the documentation.

    class UserCreateForm(UserCreationForm):
        password1 = forms.CharField(label='Enter password', 
                                    widget=forms.PasswordInput)
        password2 = forms.CharField(label='Confirm password', 
                                    widget=forms.PasswordInput)
        class Meta:
            model=User
            fields=("username","email","first_name",
                    "last_name","password1","password2")
            help_texts = {
                "username":None,
            }
    

    Basically what we are trying to do is over-ride the automated setting by re-creating the password fields for our new class form.

提交回复
热议问题