id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 21404,session.set_expiry() causes a TypeError when using JSONSerializer,René Puls,nobody,"I am using django.contrib.sessions.backends.cached_db as the SESSION_ENGINE and django.contrib.sessions.serializers.JSONSerializer as the SESSION_SERIALIZER. Setting a session expiration date using session.set_expiry() results in a TypeError when the session is saved: {{{ Traceback: File ""/Users/pwr/Library/Python/2.7/lib/python/site-packages/django/core/handlers/base.py"" in get_response 201. response = middleware_method(request, response) File ""/Users/pwr/Library/Python/2.7/lib/python/site-packages/django/contrib/sessions/middleware.py"" in process_response 38. request.session.save() File ""/Users/pwr/Library/Python/2.7/lib/python/site-packages/django/contrib/sessions/backends/cached_db.py"" in save 62. super(SessionStore, self).save(must_create) File ""/Users/pwr/Library/Python/2.7/lib/python/site-packages/django/contrib/sessions/backends/db.py"" in save 57. session_data=self.encode(self._get_session(no_load=must_create)), File ""/Users/pwr/Library/Python/2.7/lib/python/site-packages/django/contrib/sessions/backends/base.py"" in encode 87. serialized = self.serializer().dumps(session_dict) File ""/Users/pwr/Library/Python/2.7/lib/python/site-packages/django/core/signing.py"" in dumps 88. return json.dumps(obj, separators=(',', ':')).encode('latin-1') File ""/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py"" in dumps 250. sort_keys=sort_keys, **kw).encode(obj) File ""/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py"" in encode 207. chunks = self.iterencode(o, _one_shot=True) File ""/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py"" in iterencode 270. return _iterencode(o, 0) File ""/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py"" in default 184. raise TypeError(repr(o) + "" is not JSON serializable"") Exception Type: TypeError at /users/login/ Exception Value: datetime.datetime(2013, 11, 9, 5, 0, tzinfo=) is not JSON serializable }}} The documentation already notes that [https://docs.djangoproject.com/en/1.6/topics/http/sessions/#django.contrib.sessions.serializers.JSONSerializer JSONSerializer cannot handle datetime values], which is working as intended according to #21124. The documentation for [https://docs.djangoproject.com/en/dev/topics/http/sessions/#django.contrib.sessions.backends.base.SessionBase.set_expiry set_expiry] also notes that ""datetime and timedelta values are only serializable if you are using the PickleSerializer"". If this is indeed intentional, I suggest that the 1.6 release notes should at least mention that session expiration times can no longer be set in the default configuration.",Cleanup/optimization,closed,Documentation,1.6,Normal,fixed,,,Accepted,1,0,0,0,1,0