升级到Django 1.5获取UnicodeDecodeError

时间:2013-11-09 19:23:11

标签: django django-1.5

我正在从Django 1.3升级到1.5一切都在1.3中工作但在1.5.5中我得到了一堆编码错误。看到堆栈:

 Traceback:
 File "/Users/athom09/Projects/myapp/myappEnv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
   187.                 response = middleware_method(request, response)
 File "/Users/athom09/Projects/myapp/myappEnv/lib/python2.7/site-packages/django/contrib/sessions/middleware.py" in process_response
   38.                     request.session.save()
 File "/Users/athom09/Projects/myapp/myappEnv/lib/python2.7/site-packages/django/contrib/sessions/backends/cached_db.py" in save
   55.         super(SessionStore, self).save(must_create)
 File "/Users/athom09/Projects/myapp/myappEnv/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in save
   51.             session_data=self.encode(self._get_session(no_load=must_create)),
 File "/Users/athom09/Projects/myapp/myappEnv/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in encode
   84.         serialized = self.serializer().dumps(session_dict)
 File "/Users/athom09/Projects/myapp/myappEnv/lib/python2.7/site-packages/django/core/signing.py" in dumps
   100.         return json.dumps(obj, separators=(',', ':')).encode('latin-1')
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py" in dumps
   238.         **kw).encode(obj)
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py" in encode
   201.         chunks = self.iterencode(o, _one_shot=True)
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py" in iterencode
   264.         return _iterencode(o, 0)

 Exception Type: UnicodeDecodeError at /login/
 Exception Value: 'utf8' codec can't decode byte 0xaa in position 0: invalid start byte

1 个答案:

答案 0 :(得分:1)

我的问题是我已经设置了

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

我删除了所有的编码问题(在正常运行期间,夹具装载不起作用)被修复。