我想做什么?
我正在尝试使用他们的社交帐户登录用户,我在Django allauth的帮助下这样做。
有什么问题?
我的项目在我的笔记本电脑上工作正常(现在已经坏了),但我不知道为什么它不能在我的桌面上工作。每当我尝试使用社交帐户登录时,我都会在控制台上收到以下错误(在我的情况下是Facebook):
错误: Not Found: /accounts/facebook/login
我的代码:
settings.py:
DEBUG = True
INSTALLED_APPS = [
...
'django.contrib.auth',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook'
]
LOGIN_URL = 'login_url'
LOGOUT_URL = 'logout_url'
LOGIN_REDIRECT_URL = 'redirect_url'
SITE_ID = 1
AUTHENTICATION_BACKENDS = [
'allauth.account.auth_backends.AuthenticationBackend',
'Authentication.backends.EmailBackend',
]
SOCIALACCOUNT_QUERY_EMAIL = True
SOCIALACCOUNT_EMAIL_VERIFICATION = True
SOCIALACCOUNT_EMAIL_REQUIRED = True
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(SETTINGS_PATH, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
...
'django.template.context_processors.request'
],
},
},
]
HTML:
<div class="modal" id="loginModal" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close">×</button>
</div>
<form id='loginForm'>{% csrf_token %}
<div class="modal-body">
<div class="col-xs-12">
<a href="/accounts/facebook/login"> Facebook </a>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default" id="login"> Login </button>
</div>
</form>
</div>
</div>
</div>
urls.py:
urlpatterns = [
url(r'^accounts/', include('allauth.urls')),
...
]
并在我的Django管理员中完美设置了Facebook的社交应用程序。
可能有什么不对?我还将我笔记本电脑的Python27
目录中的一些文件复制粘贴到我的桌面Python27
目录中,但仍然遇到同样的错误。
任何帮助都将受到高度赞赏。
答案 0 :(得分:0)
终于找到了解决方案,在这里:
你只需要重新安装django-allauth。
pip uninstall django-allauth
pip install django-allauth