【发布时间】:2012-05-06 04:25:54
【问题描述】:
对于我的需要,内置模型 User 是不够的......所以我有自己的模型 UserProfile,我想通过这个模型在现场进行身份验证(UserProfile 不继承自 User 模型并且根本与它无关)。
我的模特:
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:我知道我可以在其他模型中存储额外的数据,但我不希望这样
【问题讨论】:
标签: django django-models django-forms django-admin django-views