对于我的需要内置模型用户是不够的...所以我有我自己的模型UserProfile,我想通过此模型在网站上进行身份验证(UserProfile不从用户模型继承,它根本)。使用自定义模型的Django身份验证用户
我的模型:
class UserProfile(models.Model):
password = models.CharField(max_length = 40)
email = models.EmailField(max_length = 72, unique = True)
## Add this so that you can use request.user.is_authenticated
def is_authenticated(self):
return True
但内置的身份验证使用模式的用户。
所以我想了解我该如何改变这一点,所以身份验证使用我的模型UserProfile与所有身份验证功能??
一个好的教程将是伟大的!
(在视图模型的步骤和验证步骤)
PS:我知道我可以存储在其他模型额外的数据,但我不希望
这帮助我分配。我正朝着正确的方向努力。唯一我忘记的是在我的UserProfile模型中添加'def is_authenticated(self):return True'。往上看 – nelsonvarela 2012-04-25 14:25:09