使用会话时出现Python pickling错误
作者:互联网
在我的django应用程序中,我使用会话变量创建了扩展的用户配置文件.但是当保存注册表单并且用户即将创建时,我收到以下错误:
Traceback (most recent call last):
File "\Python26\Lib\site-packages\django\core\servers\basehttp.py", line 279, in run
self.result = application(self.environ, self.start_response)
File "\Python26\Lib\site-packages\django\core\servers\basehttp.py", line 651, in __call__
return self.application(environ, start_response)
File "\Python26\Lib\site-packages\django\core\handlers\wsgi.py", line 245, in __call__
response = middleware_method(request, response)
File "\Python26\Lib\site-packages\django\contrib\sessions\middleware.py", line 36, in process_response
request.session.save()
File "\Python26\Lib\site-packages\django\contrib\sessions\backends\db.py", line 53, in save
session_data = self.encode(self._get_session(no_load=must_create)),
File "\Python26\Lib\site-packages\django\contrib\sessions\backends\base.py", line 88, in encode
pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL)
PicklingError: Can't pickle <type 'cStringIO.StringO'>: attribute lookup cStringIO.StringO failed
我用谷歌搜索了答案,但没有发现任何有趣的东西.有没有解决方法呢?
解决方法:
看来你的会话中有一个cStringIO对象(也许是一个上传的文件?),这些不能被腌制.编写自定义酸洗代码或确保所有会话数据都可以序列化.
标签:python,django,session-variables,pickle 来源: https://codeday.me/bug/20190827/1739399.html