1

I need to remove help text that appears on my template when I am creating a new user with the UserCreationForm.

I mean this help texts:

for the username field: Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.

and the password confirmation: Enter the same password as above, for verification.

Which comes from help_text parameter on field

Sardorbek Imomaliev
  • 14,861
  • 2
  • 51
  • 63
maudev
  • 974
  • 1
  • 14
  • 32
  • Possible duplicate of [Removing help\_text from Django UserCreateForm](https://stackoverflow.com/questions/13202845/removing-help-text-from-django-usercreateform) – Confusion Matrix Sep 21 '17 at 11:51

3 Answers3

4

You are probably rendering your template with something like {{ form.as_p }} which renders everything, labels, help_texts, errors and the field itself.

Instead you can do this:

{{ form.username.label }}
{{ form.username }}
....

Here are more details about manual rendering of forms: https://docs.djangoproject.com/en/dev/topics/forms/#rendering-fields-manually

Mihai Zamfir
  • 2,167
  • 4
  • 22
  • 37
3

with init you can set help_text None

class UserCreateForm(UserCreationForm):
    email = forms.EmailField(required=True)

    def __init__(self, *args, **kwargs):
        super(UserCreateForm, self).__init__(*args, **kwargs)
            self.fields['email'].help_text = ''
Sardorbek Imomaliev
  • 14,861
  • 2
  • 51
  • 63
Raja Simon
  • 10,126
  • 5
  • 43
  • 74
1

Made an asnwer, Actually you can do it like this

class UserCreateForm(UserCreationForm):
    email = forms.EmailField(required=True)
    email.help_text = ''
Sardorbek Imomaliev
  • 14,861
  • 2
  • 51
  • 63