错误:“ AnonymousUser”对象没有来自Pinax / Django-User-Account

时间:2018-10-14 22:41:25

标签: django django-apps pinax

我已经根据文档安装了django-user-account,当尝试“注册”时,我得到“ AnonymousUser”对象没有属性“ _meta”。

我不确定为什么会收到此错误,我的理解是,该应用应该在从pinax-theme-bootstrap提供模板后才能正常工作。

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/account/signup/

Django Version: 2.1.1
Python Version: 3.6.5
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'apps.accounts.apps.AccountsConfig',
 'account',
 'django_extensions',
 'pinax.webanalytics',
 'django_forms_bootstrap',
 'bootstrap4',
 'pinax_theme_bootstrap',
 'bootstrapform']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'account.middleware.LocaleMiddleware',
 'account.middleware.TimezoneMiddleware']



Traceback:

File "/Applications/anaconda3/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/Applications/anaconda3/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  126.                 response = self.process_exception_by_middleware(e, request)

File "/Applications/anaconda3/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  124.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/Applications/anaconda3/lib/python3.6/site-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/Applications/anaconda3/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
  45.         return bound_method(*args, **kwargs)

File "/Applications/anaconda3/lib/python3.6/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
  76.             return view(request, *args, **kwargs)

File "/Applications/anaconda3/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
  45.         return bound_method(*args, **kwargs)

File "/Applications/anaconda3/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view
  142.                     response = view_func(request, *args, **kwargs)

File "/Applications/anaconda3/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
  45.         return bound_method(*args, **kwargs)

File "/Applications/anaconda3/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)

File "/Applications/anaconda3/lib/python3.6/site-packages/account/views.py" in dispatch
  151.         return super(SignupView, self).dispatch(request, *args, **kwargs)

File "/Applications/anaconda3/lib/python3.6/site-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/Applications/anaconda3/lib/python3.6/site-packages/account/views.py" in post
  177.         return super(SignupView, self).post(*args, **kwargs)

File "/Applications/anaconda3/lib/python3.6/site-packages/django/views/generic/edit.py" in post
  142.             return self.form_valid(form)

File "/Applications/anaconda3/lib/python3.6/site-packages/account/views.py" in form_valid
  243.             self.login_user()

File "/Applications/anaconda3/lib/python3.6/site-packages/account/views.py" in login_user
  293.         auth.login(self.request, user)

File "/Applications/anaconda3/lib/python3.6/site-packages/django/contrib/auth/__init__.py" in login
  126.     request.session[SESSION_KEY] = user._meta.pk.value_to_string(user)

File "/Applications/anaconda3/lib/python3.6/site-packages/django/utils/functional.py" in inner
  214.         return func(self._wrapped, *args)

Exception Type: AttributeError at /account/signup/
Exception Value: 'AnonymousUser' object has no attribute '_meta'

1 个答案:

答案 0 :(得分:0)

我们正在开发与Django 2.1+兼容的发行版。目前,https://github.com/pinax/django-user-accounts/issues/292中概述了解决方法。

谢谢!