我遇到了这个错误。突然之间,它在我的本地工作正常。但是当我尝试部署应用程序时出现此错误,我使用的是包 two_factor
Otp,这是回溯
回溯:
File "/tmp/8d909c171bfae2c/antenv/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/tmp/8d909c171bfae2c/antenv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "/tmp/8d909c171bfae2c/antenv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/tmp/8d909c171bfae2c/antenv/lib/python3.7/site-packages/django/contrib/admin/sites.py" in wrapper
241. return self.admin_view(view, cacheable)(*args, **kwargs)
File "/tmp/8d909c171bfae2c/antenv/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapped_view
142. response = view_func(request, *args, **kwargs)
File "/tmp/8d909c171bfae2c/antenv/lib/python3.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/tmp/8d909c171bfae2c/antenv/lib/python3.7/site-packages/django/contrib/admin/sites.py" in inner
212. if not self.has_permission(request):
File "/tmp/8d909c171bfae2c/antenv/lib/python3.7/site-packages/two_factor/admin.py" in has_permission
28. return request.user.is_verified()
File "/tmp/8d909c171bfae2c/antenv/lib/python3.7/site-packages/django/utils/functional.py" in inner
257. return func(self._wrapped, *args)
Exception Type: AttributeError at /
Exception Value: 'User' object has no attribute 'is_verified'
如有任何帮助,我们将不胜感激。谢谢
最佳答案
我认为这是因为你没有添加中间件。在你的settings.py中,找到MIDDLEWARE变量。下
'django.contrib.auth.middleware.AuthenticationMiddleware',
添加
'django_otp.middleware.OTPMiddleware',
还要确保应用迁移:
python manage.py migrate
关于python - “用户”对象没有属性 'is_verified',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67291357/