我已经根据文档安装了django-user-account,当尝试"注册"时,我得到"匿名用户"对象没有属性"_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'
我们正在开发一个与 Django 2.1+ 兼容的版本。 目前,https://github.com/pinax/django-user-accounts/issues/292 概述了解决方法。
谢谢!