Search code examples
pythondjangodjango-sessionsdjango-file-upload

Django: put request.FILES in request.SESSION


I'm trying to put the request.session fields in my request.session for use it later. But when I simply write:

request.session['fileInfo'] = request.FILES

I always get this error:

Pickilng error: Can't pickle <type 'cStringIO.StringO'>: attribute lookup cStringIO.StringO failed

What's the problem?


Solution

  • The problem is sessions are transformed to strings using a standard module called pickle. pickle must be able to transform all objects in the session dict.

    The request.FILES object is not pickle-able.