python - 从 django UserCreationForm 中删除 help_text
问题描述
我正在制作注册页面,但我不喜欢用户名下的文字,例如 :
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,
}
推荐阅读
- html - 当数据列表中引入的字符串不在数据列表中时,有什么方法可以显示输入?
- php - fwrite():SSL 操作失败,代码为 1。OpenSSL 错误消息:错误:1420C0CF:SSL 例程:ssl_write_internal:协议已关闭
- magento - Magento 后端在 Galera 集群中抛出 lock_wait_timeout 错误
- python - 如何用两种颜色绘制imshow?
- ios - iOS:如何检查是否启用了触觉反馈(iOS 设置)
- javascript - 在 DataTable Edit 按钮上打开一个弹出窗体单击
- excel - 在 Excel 表中为子范围使用结构化引用
- django - 如何在 PUT 请求中将表单数据从 ajax 发送到 Django 视图?
- python - Python 3.7 中是否有预训练的 doc2vec 模型?
- regex - 在字符串中查找变音符号(规范化字符串)