我实现了一个自定义用户管理器。但是,对于一些django特性,例如auth\u user forgot password,我希望能够使用标准django方法引用用户:django.contrib.auth.models.User
。但这是我尝试时遇到的错误:
>>> from django.contrib.auth.models import User
>>> User.objects.all()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/Desktop/CueCloud/Django/Cuecloud/lib/python2.7/site- packages/django/db/models/manager.py", line 273, in __get__
self.model._meta.object_name, self.model._meta.swapped
AttributeError: Manager isn't available; User has been swapped for 'main.User'
我该怎么解决这个问题?你知道吗
关于“引用用户的标准方式”,你错了。Django文档中有一个referencing-the-user-model部分,它告诉您如何做到这一点。你知道吗
基本上,使用
settings.AUTH_USER_MODEL
。你知道吗相关问题 更多 >
编程相关推荐