我正在尝试使用带有 django-allauth/social auth 的自定义用户在 settings.py 中,我有
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",
)
SOCIALACCOUNT_PROVIDERS = \
{'facebook':
{'SCOPE': ['email', 'user_likes', 'user_status', 'user_about_me', 'basic_info', 'read_stream'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'METHOD': 'oauth2',
'LOCALE_FUNC': 'path.to.callable',
'VERIFIED_EMAIL': False}}
LOGIN_REDIRECT_URL = '/results/'
AUTH_USER_MODEL = 'users.User'
在项目文件夹中的用户文件夹中,我有adapter.py:
from django.conf import settings
from allauth.account.adapter import DefaultAccountAdapter
class MyAccountAdapter(DefaultAccountAdapter):
def get_login_redirect_url(self, request):
path = "/results/{username}/"
return path.format(username=request.user.username)
在模型.py 中:
from django.db import models
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
user_data = models.TextField(null=True)
当我尝试使用 facebook 登录时,我被重定向到 facebook 但返回该站点,我收到以下错误消息
Django version 1.6.2
Exception Type: DoesNotExist
User matching query does not exist.
在控制台中
"GET /results/facebook/login/? HTTP/1.1" 302 0
"GET /results/facebook/login/callback/XXX HTTP/1.1" 500
知道我做错了什么吗?