Django, register user with first name and last name?

前端 未结 2 797
无人及你
无人及你 2021-02-07 10:27

I\'m using Django-Registration and the form just has 3 fields (Username, Email, Password, and Re-password), but why I can\'t add last name and first name??

In the Form a

相关标签:
2条回答
  • 2021-02-07 10:46

    I did it :

    new_user = User.objects.create_user(username, email, password)
    new_user.is_active = False
    new_user.first_name = first_name
    new_user.last_name = last_name
    new_user.save()
    
    0 讨论(0)
  • 2021-02-07 10:55

    I know you found a way around, but this way below may also interest you. This is because it requires keywords arguments (which will be passed to the User's __init__ method). https://docs.djangoproject.com/en/1.6/ref/contrib/auth/#manager-methods

    User.objects.create_user("user1", "user1@foo.bar", "pwd", first_name="First", last_name="Last")
    
    0 讨论(0)
提交回复
热议问题