在我的 Django 应用程序中,我有一个多步骤注册,几乎没有条件参数。因此,我想出了在会话中存储表单数据的方法。不幸的是,会话使用pickle序列化数据,它不支持文件序列化并导致
PicklingError:无法pickle :属性查找cStringIO.StringO失败
。如何解决这个问题?我应该将图像作为变量发送到所有以下视图,还是将其作为 GET 参数发送或以其他方式发送?我不确定是否需要任何示例代码,因为问题似乎很清楚。
In my django application I have a multi step registration, with few conditional parameters. Because of this I figured out to store data from forms in session. Unfortunatelly sessions serialize data using pickle, which doesn't support file serialization and causes
PicklingError: Can't pickle <type 'cStringIO.StringO'>: attribute lookup cStringIO.StringO failed
. How to get around this problem ? Should I send image as a variable to all following views, or send it as a GET parameter or do it in some other way ? I'm not sure if any sample code is needed since problems seems pretty clear.
发布评论
评论(1)
如果正在上传的文件大小超过几 KB,那么您可能不希望将它们存储在会话中(并且您绝对不希望通过 GET 将它们发送回浏览器)。
我可以想到几个选择:
If the files that are being uploaded are larger than a few KB in size, then you probably don't want to store them in the session (and you definitely don't want to send them back to the browser via a GET).
I can think of a few options: