【发布时间】:2013-09-09 13:09:19
【问题描述】:
我尝试通过两种不同的方式在 django 中创建 Users (django.contrib.auth.models.User):
- 使用
User.objects.create(username="<username_here>", password="<password_here>", email="<email_here>)-> 当我使用它时,登录用户并没有收到auth.models.User带来的所有其他好处,例如,我不能对以这种方式创建的用户使用authenticate。 - 使用
User.objects.create_user("<username>", "<email>", "<password>")。以这种方式做事没有问题,您可以使用 django 的auth应用程序附带的所有免费内容。
我的问题是,为什么会这样?
【问题讨论】:
-
第一种情况,创建后需要使用
set_password函数。 -
@sneawo 更详尽的答案将不胜感激。
标签: python django django-models django-authentication