Usuwanie help_text z Django UserCreateForm
Prawdopodobnie jest to kiepskie pytanie, ale używam Django UserCreationForm (nieco zmodyfikowany, aby zawierał e-mail) i chciałbym usunąć tekst help_text, który Django automatycznie wyświetla na stronie HTML.
W części Zarejestruj moją stronę HTML zawiera pola Nazwa użytkownika, E-mail, Hasło1 i Hasło2. Ale pod nazwą użytkownika jest „Wymagane. 30 znaków lub mniej. Tylko litery, cyfry i @ ...”. W polu Potwierdzenie hasła (hasło 2) pojawia się komunikat „Wprowadź to samo hasło, co powyżej w celu weryfikacji”.
Jak je usunąć?
#models.py
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True)
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data['email']
if commit:
user.save()
return user
class Meta:
model = User
fields = ("username", "email", "password1", "password2")
exclude = ('username.help_text')
#views.py
def index(request):
r = Movie.objects.all().order_by('-pub_date')
form = UserCreateForm()
return render_to_response('qanda/index.html', {'latest_movie_list': r, 'form':form}, context_instance = RequestContext(request))
#index.html
<form action = "/home/register/" method = "post" id = "register">{% csrf_token %}
<h6> Create an account </h6>
{{ form.as_p }}
<input type = "submit" value = "Create!">
<input type = "hidden" name = "next" value = "{{ next|escape }}" />
</form>