繁体   English   中英

从 django UserCreationForm 中删除 help_text

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM