找不到:/ accounts / facebook /登录django allauth

时间:2018-02-08 15:15:19

标签: django django-allauth

我想做什么?

我正在尝试使用他们的社交帐户登录用户,我在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">&times;</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目录中,但仍然遇到同样的错误。

任何帮助都将受到高度赞赏。

1 个答案:

答案 0 :(得分:0)

终于找到了解决方案,在这里:

你只需要重新安装django-allauth。

  1. 使用命令pip uninstall django-allauth
  2. 卸载django-allauth
  3. 然后使用命令pip install django-allauth
  4. 再次安装它