[英]Remove help_text from django UserCreationForm
我正在制作注冊頁面,但我不喜歡用戶名下的文本,例如: Required 150 characters or fewer. Letters, digits and @/./+/-/_ only
Required 150 characters or fewer. Letters, digits and @/./+/-/_ only
。 或在密碼下: Your password can't be too similar to your other personal information.
你明白了,請幫忙,謝謝
我試圖找到其他問題,但他們都從添加的字段中刪除了 help_text 作為電子郵件,但我需要從用戶名、密碼中刪除...
class UserRegisterForm(UserCreationForm):
email = forms.EmailField()
class Meta:
model = User
fields = ['username', 'email' , 'password1', 'password2']
然后我將它呈現在 html 中作為脆皮形式
<form method="POST">
{% csrf_token %}
<fieldset>
<legend class="hello4">
<i>Join Today</i>
</legend>
<div >
{{form|crispy}}
</div>
</fieldset>
<div>
<button type="submit" class="btn btn-light">Sign Up</button>
</div>
</form>
嘗試編輯類 Meta 如下:
class Meta:
model = User
fields = ['username', 'email' , 'password1', 'password2']
help_texts = {
'username': None,
'password1': None,
'password2': None,
}
如果您只是不想在頁面上顯示它們,
您可以使用 css 擺脫它們:
.helptext { display: none; }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.