7

我已经安装了 django_allauth,但是账户/登录视图显示了这个错误。

ImportError at /accounts/login/
No module named path.to
Request Method: GET
Request URL:    http://chew.local:5000/accounts/login/
Django Version: 1.5.1
Exception Type: ImportError
Exception Value:    
No module named path.to
Exception Location: /Users/benbowler/Sites/Repositories/chew/venv/lib/python2.7/site-packages/django/utils/importlib.py in import_module, line 35
Python Executable:  /Users/benbowler/Sites/Repositories/chew/venv/bin/python
Python Version: 2.7.2
Python Path:    
['/Users/benbowler/Sites/Repositories/chew',
 '/Users/benbowler/Sites/Repositories/chew/venv/bin',
 '/Users/benbowler/Sites/Repositories/chew/venv/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg',
 '/Users/benbowler/Sites/Repositories/chew/venv/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
 '/Users/benbowler/Sites/Repositories/chew/venv/lib/python27.zip',
 '/Users/benbowler/Sites/Repositories/chew/venv/lib/python2.7',
 '/Users/benbowler/Sites/Repositories/chew/venv/lib/python2.7/plat-darwin',
 '/Users/benbowler/Sites/Repositories/chew/venv/lib/python2.7/plat-mac',
 '/Users/benbowler/Sites/Repositories/chew/venv/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/benbowler/Sites/Repositories/chew/venv/Extras/lib/python',
 '/Users/benbowler/Sites/Repositories/chew/venv/lib/python2.7/lib-tk',
 '/Users/benbowler/Sites/Repositories/chew/venv/lib/python2.7/lib-old',
 '/Users/benbowler/Sites/Repositories/chew/venv/lib/python2.7/lib-dynload',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/benbowler/Sites/Repositories/chew/venv/lib/python2.7/site-packages']
Server time:    Thu, 16 May 2013 15:01:20 +0100

providers_media_js 下面是红色的:

Error during template rendering

In template /Users/benbowler/Sites/Repositories/chew/venv/lib/python2.7/site-packages/allauth/templates/socialaccount/snippets/login_extra.html, error at line 3
No module named path.to
1   {% load socialaccount %}
2   
3   **{% providers_media_js %}**
4

1 回答 1

15

看看你的设置。我认为您犯了复制粘贴错误:

可能导致此错误的此片段来自https://django-allauth.readthedocs.org/en/latest/index.html?highlight=path.to#facebook

SOCIALACCOUNT_PROVIDERS = \
{
    'facebook':
    {
        'SCOPE': ['email', 'publish_stream'],
        'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
        'METHOD': 'oauth2',
        'LOCALE_FUNC': 'path.to.callable',
        'VERIFIED_EMAIL': False
    }
}

我认为你的问题出在LOCALE_FUNC因为你必须在那里定义一个适当的功能而不是一条不存在的路径。

这是它的一些例子。它怎么可能是 Slideshare:https ://speakerdeck.com/tedtieken/signing-up-and-signing-in-users-in-django-with-django-allauth?slide=55

SOCIALACCOUNT_PROVIDERS = \
{
    'facebook':
    {
        'SCOPE': ['email'],
        'AUTH_PARAMS': { 'auth_type': 'reauthenticate'},
        'METHOD': 'oauth2',
        'LOCALE_FUNC': lambda request: 'en_US'
    }
}

希望这可以帮助你

于 2014-02-12T16:00:24.690 回答