为什么我在生产服务器上获取TypeError,我试图在会话中保存数据?

时间:2013-09-03 20:04:07

标签: python django apache pickle django-sessions

环境:

Request Method: GET
Request URL: django_server_running_on_apache

Django Version: 1.3.3
Python Version: 2.7.3

Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  178.                 response = middleware_method(request, response)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/sessions/middleware.py" in process_response
  36.                 request.session.save()
File "/usr/local/lib/python2.7/dist-packages/django/contrib/sessions/backends/file.py" in save
  121.                     os.write(output_file_fd, self.encode(session_data))
File "/usr/local/lib/python2.7/dist-packages/django/contrib/sessions/backends/base.py" in encode
  93.         pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL)

Exception Type: TypeError at /
Exception Value: expected string or Unicode object, NoneType found

1 个答案:

答案 0 :(得分:0)

建议在会话中仅存储标量对象。 Pickel无法序列化其他对象。