我想使用allauth django应用程序。
我完成了本教程中描述的所有内容:http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/。我继续到“现在我们可以登录使用Django或Facebook”的子部分。
之后,我无法转到教程中指出的地址:http://127.0.0.1:8000/accounts/login/
我要你看看我的数据库。它巧妙地像本教程一样指出:

这是我的setting.py文件:
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
"/srv/http/proj04/proj/templates",
)
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
"django.contrib.auth.backends.ModelBackend",
# `allauth` specific authentication methods, such as login by e-mail
"allauth.account.auth_backends.AuthenticationBackend"
)
TEMPLATE_CONTEXT_PROCESSORS = (
# Required by allauth template tags
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.request",
# allauth specific context processors
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
)
LOGIN_REDIRECT_URL = '/'
SOCIALACCOUNT_QUERY_EMAIL = True
SOCIALACCOUNT_PROVIDERS = {
'google': {
'SCOPE': ['email', 'publish_stream'],
'METHOD': 'oauth2' # instead of 'oauth2'
}
}
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp',
'captcha',
'django.contrib.admin',
# Uncomment the next line to enable the admin:
# Uncomment the next line to enable admin documentation:
'allauth',
'allauth.account',
'allauth.socialaccount',
# ... include the providers you want to enable:
'allauth.socialaccount.providers.amazon',
'allauth.socialaccount.providers.dropbox',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.flickr',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.instagram',
'allauth.socialaccount.providers.linkedin',
'allauth.socialaccount.providers.linkedin_oauth2',
'allauth.socialaccount.providers.openid',
'allauth.socialaccount.providers.tumblr',
'allauth.socialaccount.providers.twitter',
'allauth.socialaccount.providers.vimeo',
'allauth.socialaccount.providers.vk',
# 'django.contrib.admindocs',
)这是我的url.py文件:
....
admin.autodiscover()
urlpatterns = patterns('',
(r'^accounts/', include('allauth.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
urlpatterns += [
# ... the rest of your URLconf goes here ...
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)我不知道下一步该怎么办。
我试过了
http://127.0.0.1:8000/accounts/login/只是为了得到这个异常:
DoesNotExist at /accounts/login/
Site matching query does not exist.
Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/login/
Django Version: 1.6.5
Exception Type: DoesNotExist
Exception Value:
Site matching query does not exist.
Exception Location: /srv/http/proj04/lib/python3.4/site-packages/django/db/models/query.py in get, line 310
Python Executable: /srv/http/proj04/bin/python
Python Version: 3.4.1
...或者有时我会得到这个异常(我不知道为什么,但这些异常是交替的):
ImproperlyConfigured at /accounts/login/
No Facebook app configured: please add a SocialApp using the Django admin
Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/login/
Django Version: 1.6.5
Exception Type: ImproperlyConfigured
Exception Value:
No Facebook app configured: please add a SocialApp using the Django admin
Exception Location: /srv/http/proj04/lib/python3.4/site-packages/allauth/socialaccount/providers/facebook/provider.py in media_js, line 106
Python Executable: /srv/http/proj04/bin/python
Python Version: 3.4.1我遗漏了什么?提前谢谢。
发布于 2014-06-10 19:52:23
你需要在你的应用程序设置中修改你的谷歌设置。查看一下文档,看看哪些设置是可以维护的。
http://django-allauth.readthedocs.org/en/latest/#google
您还需要将已安装的应用程序更改为只包含以下这些应用程序
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google'发布于 2015-07-21 07:50:50
在SITE_ID中添加“settings.py”
django_site表必须包含与SITE_ID相同的id值(默认为1)的行。
在您的'localhost:8000/admin/socialaccount/socialapp/‘表中,对于不同的提供者,提供这个站点ID并尝试再次运行,它将工作。
https://stackoverflow.com/questions/24128667
复制相似问题