3

Django-allauth をインストールし、すべての手順を慎重に実行しました。

設定.py

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    'django.core.context_processors.request',
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.static",
    "django.core.context_processors.tz",
    "django.contrib.messages.context_processors.messages",    
    "allauth.account.context_processors.account",
    "allauth.socialaccount.context_processors.socialaccount",
)

AUTHENTICATION_BACKENDS =  (
    'django.contrib.auth.backends.ModelBackend',    
    "allauth.account.auth_backends.AuthenticationBackend",
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',    
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.google',
    ...
)

ACCOUNT_AUTHENTICATION_METHOD="username_email"

url.py

(r'^accounts/', include('allauth.urls')),

ただし、実行すると404が発生しますhttp://localhost:8000/accounts/

手動で逆一致させようとしました:

./manage.py shell
from allauth.socialaccount.providers.google.urls import *

正常に動作します。

./manage.py shell
from django.core.urlresolvers import reverse
reverse('/accounts/google/login/')

ただし、これは失敗します。

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/kave/vc/cb-env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 476, in reverse
    return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
  File "/home/kave/vc/cb-env/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 396, in _reverse_with_prefix
    "arguments '%s' not found." % (lookup_view_s, args, kwargs))
NoReverseMatch: Reverse for '/accounts/google/login/' with arguments '()' and keyword arguments '{}' not found.

仮想環境内に正しくインストールしました。何がうまくいかなかったのでしょうか?それともバグですか?

4

2 に答える 2