【问题标题】:Trouble understanding Django-regustration-redux无法理解 Django-regusration-redux
【发布时间】:2016-04-03 12:53:09
【问题描述】:

django-registration-redux 使用什么模型来存储注册用户的信息?

而且,我什至可以通过registration-redux (http://127.0.0.1:8000/accounts/login) 提供的界面登录我的超级用户帐户。这怎么可能?

【问题讨论】:

    标签: django django-authentication django-registration


    【解决方案1】:

    django-registeration-redux 使用基本用户模型来存储用户信息。

    以下代码来自https://raw.githubusercontent.com/macropin/django-registration/master/registration/users.py

    from django.conf import settings
    from django.contrib.auth import get_user_model
    
    UserModel = get_user_model
    

    这是这里导入和使用的:https://github.com/macropin/django-registration/blob/master/registration/models.py#L90-L105

    从技术上讲,所有用户都是此基本用户模型的实例,因此您的超级用户帐户没有什么不同,应该能够登录,除非您编写了一些自定义代码来防止超级用户无法登录。

    【讨论】:

      猜你喜欢
      • 2017-03-28
      • 2016-10-18
      • 1970-01-01
      • 1970-01-01
      • 2017-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多