Django allauth会话JSON序列化错误后登录 [英] Django allauth session JSON serializable error after login

查看:216
本文介绍了Django allauth会话JSON序列化错误后登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have installed django-allauth, after that this is my 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管理员的社交应用程序,具有正确的twitter和github api密钥和秘密。

and i believe i also correctly set my urls.py. And also i have two Social app from django admin with correct twitter and github api keys and secrets.

但是,当我点击通过twitter登录,它显示我正确的twitter认证页面,之后我授权的应用程序它给我这个错误..

But then problem is whenever i click to login via twitter it shows me the correct twitter auth page and after i authorize the app it gives me this error..

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

,我也得到几乎与github相同的错误。像

and also i get almost the same error with github. like

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

所以请帮我看看有什么问题

, So please help me to understand what's the problem

推荐答案

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

In Django 1.6 you have to change the SESSION_SERIALIZER parameter to pickle. Put this in your settings.py:

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

我不知道allauth何时会与这个新的Django序列化格式兼容。请参阅 Django 1.6发行说明

I don't know when allauth will become compatible with this new Django serialization format. See Django 1.6 release notes.

这篇关于Django allauth会话JSON序列化错误后登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆