【问题标题】:Django authentication with custom model UserProfile (not builtin User)使用自定义模型 UserProfile(非内置用户)进行 Django 身份验证
【发布时间】:2011-11-03 06:04:20
【问题描述】:

对于我的需要内置模型用户是不够的...... 所以我有自己的模型 UserProfile ,我想通过这个模型在现场进行身份验证(UserProfile 不继承自 User 模型,并且根本与它无关)。

但内置身份验证使用模型用户。

所以我想了解如何更改它,因此身份验证使用我的模型 UserProfile 和所有身份验证功能???

提前致谢!!!

【问题讨论】:

    标签: django django-authentication


    【解决方案1】:

    你必须创建自己的Authentication Backend 来告诉 Django 创建一个 UserProfile 而不是一个用户。

    在此示例中,用户模型已扩展,因此您必须根据自己的要求对其进行调整:

    Example 1

    Example 2

    【讨论】:

      猜你喜欢
      • 2012-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多