ImportError: No module named 'django.contrib.sitesallauth' in django-allauth
ImportError: No module named 'django.contrib.sitesallauth' in django-allauth
我正在使用 Django 1.7 和 python 3.4。
我正在尝试使用 django-allauth 进行用户身份验证,我正在关注此 link http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/
但是我在尝试迁移应用程序时遇到了这个问题。
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\django\apps\config.py", line 118, in creat
e
cls = getattr(mod, cls_name)
AttributeError: 'module' object has no attribute 'sitesallauth'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line
385, in execute_from_command_line
utility.execute()
File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line
354, in execute
django.setup()
File "C:\Python34\lib\site-packages\django\__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python34\lib\site-packages\django\apps\registry.py", line 85, in popu
late
app_config = AppConfig.create(entry)
File "C:\Python34\lib\site-packages\django\apps\config.py", line 123, in creat
e
import_module(entry)
File "C:\Python34\lib\importlib\__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'django.contrib.sitesallauth'
问题的可能原因和解决方法。
您在 INSTALLED_APPS 中的 "django.contrib.sites" 条目后遗漏了一个逗号。
您似乎忘记在 django.contrib.sites
和 allauth
应用程序之间添加逗号。
没有sitesallauth
这样的模块,应该是allauth
,例如
INSTALLED_APPS = (
# ...
'django.contrib.allauth',
)
然后通过 pip 安装:
pip install allauth
对于 Python 3 你可能想使用 pip3
.
简单测试:
$ python3
>>> import django
>>> from django.contrib import auth
>>> from django.contrib import allauth
# If it fails, check if your `sys.path` is correct.
>>> import sys
>>> sys.path
我正在使用 Django 1.7 和 python 3.4。 我正在尝试使用 django-allauth 进行用户身份验证,我正在关注此 link http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/ 但是我在尝试迁移应用程序时遇到了这个问题。
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\django\apps\config.py", line 118, in creat
e
cls = getattr(mod, cls_name)
AttributeError: 'module' object has no attribute 'sitesallauth'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line
385, in execute_from_command_line
utility.execute()
File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line
354, in execute
django.setup()
File "C:\Python34\lib\site-packages\django\__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python34\lib\site-packages\django\apps\registry.py", line 85, in popu
late
app_config = AppConfig.create(entry)
File "C:\Python34\lib\site-packages\django\apps\config.py", line 123, in creat
e
import_module(entry)
File "C:\Python34\lib\importlib\__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
ImportError: No module named 'django.contrib.sitesallauth'
问题的可能原因和解决方法。
您在 INSTALLED_APPS 中的 "django.contrib.sites" 条目后遗漏了一个逗号。
您似乎忘记在 django.contrib.sites
和 allauth
应用程序之间添加逗号。
没有sitesallauth
这样的模块,应该是allauth
,例如
INSTALLED_APPS = (
# ...
'django.contrib.allauth',
)
然后通过 pip 安装:
pip install allauth
对于 Python 3 你可能想使用 pip3
.
简单测试:
$ python3
>>> import django
>>> from django.contrib import auth
>>> from django.contrib import allauth
# If it fails, check if your `sys.path` is correct.
>>> import sys
>>> sys.path