1

我已经安装了 django-allauth,之后这是我的 settings.py

Django_apps = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
)

Third_party_apps = (
    'avatar',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'bootstrapform',
    'allauth.socialaccount.providers.github',
    'allauth.socialaccount.providers.twitter',
)

My_apps = ()

INSTALLED_APPS = Django_apps + Third_party_apps +  My_apps

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    "django.core.context_processors.request",
    "allauth.account.context_processors.account",
    "allauth.socialaccount.context_processors.socialaccount",
)
AUTHENTICATION_BACKENDS = (
    "django.contrib.auth.backends.ModelBackend",
    "allauth.account.auth_backends.AuthenticationBackend",
)
ACCOUNT_ADAPTER ="allauth.account.adapter.DefaultAccountAdapter"
ACCOUNT_AUTHENTICATION_METHOD = "username_email"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "optional"
ACCOUNT_USERNAME_MIN_LENGTH = 3

我相信我也正确设置了我的 urls.py。而且我还有两个来自 django admin 的社交应用程序,带有正确的 twitter 和 github api 密钥和秘密。

但是问题是每当我点击通过 twitter 登录时,它都会向我显示正确的 twitter auth 页面,并且在我授权应用程序后它会给我这个错误..

<allauth.socialaccount.models.SocialLogin object at 0x7feb5875a650> is not JSON serializable

而且我在github上也遇到了几乎相同的错误。喜欢

<allauth.socialaccount.models.SocialLogin object at 0x7feb5877a590> is not JSON serializable

,所以请帮助我了解问题所在

4

1 回答 1

19

在 Django 1.6 中,您必须将 SESSION_SERIALIZER 参数更改为 pickle。把它放在你的settings.py中:

SESSION_SERIALIZER='django.contrib.sessions.serializers.PickleSerializer'

我不知道allauth 什么时候会兼容这种新的Django 序列化格式。请参阅Django 1.6 发行说明

于 2013-10-15T16:00:25.700 回答