Monday, October 27, 2014

How to get rid of help text on a ModelForm?

Hi,
I have a ModelForm for creating users, but it shows some help text "Required. 30 characters..." next to the username field.
How do I get rid of this text?  I tried the following, but the text remains on the form:

class UserForm(forms.ModelForm):
    password = forms.CharField(widget=forms.PasswordInput())
    class Meta:
        model = User
        fields = ['username', 'email', 'password']
        def __init__(self, *args, **kwargs):
            super(UserForm, self).__init__(*args, **kwargs)
            for fieldname in self.fields:
                self.fields[fieldname].help_text = None

Any ideas?
Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e0cf5137-e64d-4f15-b133-4ea75d86e52c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment