简体   繁体   English

当我在 django 中创建 usercreationform 时,用户名字段是自动选择的,我该如何修复它

[英]When i create usercreationform in django the username field is auto selected and how can i fix it

Greeting, I am new in django.您好,我是 django 的新手。 Username is auto selected when i reload the page why is this and how can i fix it.重新加载页面时会自动选择用户名,这是为什么以及如何修复它。

看图片

Please share your forms.py file and try to change username field by label:请分享您的 forms.py 文件并尝试通过 label 更改用户名字段:

class UserCreateForm(UserCreationForm):

class Meta():
    model = get_user_model()
    fields = ('username','email','password1','password2')

    def __init__(self,*args,**kwargs):
        super().__init__(*args,**kwargs)
        self.fields['username'].label = 'User Name'
        self.fields['email'].label = 'Email Address'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Django中的UserCreationForm中删除用户名字段 - How to remove the Username field from the UserCreationForm in Django 如何调试Django UserCreationForm? - How can I debug my Django UserCreationForm? 为什么我不能使用UserCreationForm在Django中创建自定义用户? - Why can't I create a custom user in Django using the UserCreationForm? 如何将电话号码字段添加到 django UserCreationForm? - How do I add phone number field to django UserCreationForm? 如何在Django中使用用户名填充字段? - How can I fill a field in Django with the username? 如何从 Django 的 UserCreationForm 中的用户名字段禁用自动对焦? - How to disable autofocus from username field in Django's UserCreationForm? 自定义Django UserCreationForm,以便我根据姓氏和名字创建用户名,而不是由用户输入? - customizing Django UserCreationForm so that I create the username from lastname and firstname, not the user entering it? 如何在 Django 中设置 USerCreationForm 的表单错误样式? - How can i style the form errors of the USerCreationForm in django? 如何在 Django 的 UserCreationForm 中扩展字段? - How to extend field in UserCreationForm in django? 我可以将模型中的“Player”类连接到Django库中UserCreationForm中的字段 - Can I connect a “Player” class from models to a field in UserCreationForm from the Django library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM