Removing help_text from Django UserCreateForm

后端 未结 7 1281
感动是毒
感动是毒 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:36

    Another, cleaner option is to use help_texts dictionary in class Meta. Example:

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

    More info in here: https://docs.djangoproject.com/en/1.11/topics/forms/modelforms/#overriding-the-default-fields

    Works perfect for username and email, but doesn't work for password2. No idea why.

提交回复
热议问题