简体   繁体   中英

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

Greeting, I am new in 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:

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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