60π
You can set help_text
of fields to None in __init__
from django.contrib.auth.forms import UserCreationForm
from django import forms
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True)
def __init__(self, *args, **kwargs):
super(UserCreateForm, self).__init__(*args, **kwargs)
for fieldname in ['username', 'password1', 'password2']:
self.fields[fieldname].help_text = None
print UserCreateForm()
output:
<tr><th><label for="id_username">Username:</label></th><td><input id="id_username" type="text" name="username" maxlength="30" /></td></tr>
<tr><th><label for="id_password1">Password:</label></th><td><input type="password" name="password1" id="id_password1" /></td></tr>
<tr><th><label for="id_password2">Password confirmation:</label></th><td><input type="password" name="password2" id="id_password2" /></td></tr>
<tr><th><label for="id_email">Email:</label></th><td><input type="text" name="email" id="id_email" /></td></tr>
If you are doing too many changes, in such cases it is better to just override the fields e.g.
class UserCreateForm(UserCreationForm):
password2 = forms.CharField(label=_("Whatever"), widget=MyPasswordInput
but in your case my solution will work very well.
22π
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/stable/topics/forms/modelforms/#overriding-the-default-fields
Works perfect for username and email, but doesnβt work for password2. No idea why.
- [Django]-How can I get access to a Django Model field verbose name dynamically?
- [Django]-Setting DEBUG = False causes 500 Error
- [Django]-Django submit two different forms with one submit button
8π
You can add css class to registration_form.html file like this.
<style>
.helptext{
visibility: hidden;
}
</style>
- [Django]-Auth_user error with Django 1.8 and syncdb / migrate
- [Django]-How do I match the question mark character in a Django URL?
- [Django]-Django: How do I add arbitrary html attributes to input fields on a form?
6π
Simple CSS solution.
<style>
#hint_id_username, #hint_id_password1 {
display: none;
}
</style>
When the forms render inspect the page source code and you will see an id for each help text. Such as hint_id_username
for each form field. Use the above CSS to hide the text.
- [Django]-How do I render jinja2 output to a file in Python instead of a Browser
- [Django]-Project design / FS layout for large django projects
- [Django]-Access request in django custom template tags
4π
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.
- [Django]-Django Admin: how to display fields from two different models in same view?
- [Django]-Having trouble with user.is_authenticated in django template
- [Django]-Django download a file
1π
Or just iterate through form fields and omit to ouput "field.help_text"
{% for field in form %}
<div class="fieldWrapper">
{{ field.errors }}
{{ field.label_tag }} {{ field }}
<!--
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
-->
</div>
{% endfor %}
Django doc:
https://docs.djangoproject.com/en/3.0/topics/forms/#looping-over-the-form-s-fields
- [Django]-This QueryDict instance is immutable
- [Django]-Django and postgresql schemas
- [Django]-Serializer call is showing an TypeError: Object of type 'ListSerializer' is not JSON serializable?
1π
For those who want to change the default text for a password 1 and 2 without having to recreate your default model, can try doing like i did. Just add this init function right under your class meta.
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['password1'].help_text='Your text'
self.fields['password2'].help_text='Your text'
- [Django]-Django 1.4 timezone.now() vs datetime.datetime.now()
- [Django]-Open the file in universal-newline mode using the CSV Django module
- [Django]-Django template: check for empty query set
0π
Just go to UserCreationForm and make the required changes.
very simple hold control button on your keyboard and ckick on UserCreationForm you will get the UserCreationForm make the required changes as per your need and save it. as i did it for me in the below example i commented the Help Content.
error_messages = {
'password_mismatch': _("The two password fields didn't match."),
}
password1 = forms.CharField(
label=_("Password"),
strip=False,
widget=forms.PasswordInput,
# help_text=password_validation.password_validators_help_text_html(),
)
password2 = forms.CharField(
label=_("Password confirmation"),
widget=forms.PasswordInput,
strip=False,
help_text=_("Enter the same password as before, for verification."),
)
- [Django]-Get list item dynamically in django templates
- [Django]-Django: Validate file type of uploaded file
- [Django]-What is the purpose of NGINX and Gunicorn running in parallel?
0π
Just override the fieldβs help_text property.
For example
username = forms.CharField(help_text=None)
You donβt need to change any other parameters. It will work fine.
- [Django]-In the Django admin interface, is there a way to duplicate an item?
- [Django]-How to view database and schema of django sqlite3 db
- [Django]-Django: create Index: non-unique, multiple column
0π
If you want to remove the help text from the fields in your custom SignUpForm, you can override the init method and set the help_text attribute of each field to an empty string. Hereβs how you can do it:
Remove help text for all fields
for field_name in self.fields:
self.fields[field_name].help_text = ''
- [Django]-How to upgrade django?
- [Django]-Model not showing up in django admin
- [Django]-Is the Lift framework as "easy" as Ruby on Rails or Django?
-1π
Add this CSS in order to remove help text.
<style>
.helptext {
visibility: hidden;
}
body > main > form > ul > li{
display: none;
}
</style>
- [Django]-Django removing object from ManyToMany relationship
- [Django]-How to make a PATCH request using DJANGO REST framework
- [Django]-No Module named django.core