Django,用户名和姓氏注册用户? [英] Django, register user with first name and last name?
本文介绍了Django,用户名和姓氏注册用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Django-Registration,该表单只有3个字段(用户名,电子邮件,密码和重新密码),但为什么我不能添加姓氏和名字?
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??
在表格一切都很好,但用户模型只接受3个参数:
In the Form all is fine but the User Model just accepts 3 arguments:
new_user = User.objects.create_user(username, email, password)
但为什么我不能这样做?
but why I can't do that:
new_user = User.objects.create_user(username, email, password, first_name ,last_name)
Django文档对于3个参数没有任何说明;网上的所有教程只需使用3个参数...
The Django Documentation doesn't say anything about just 3 arguments; all tutorials on the net just use 3 arguments...
为什么?或者我如何使用姓氏?
Why?? Or how will I make use of first and last name?
推荐答案
我做到了:
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()
这篇关于Django,用户名和姓氏注册用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文