tarak / django-password-policies

Django unicode-aware password policies.
Other
59 stars 92 forks source link

Serialization error with JSON session serializer #17

Closed eduardostalinho closed 9 years ago

eduardostalinho commented 10 years ago

When using password policies, I get the following error when trying changing the password:

Traceback (most recent call last):
  File "/Users/eduardo.carvalho/workspace/kolab-dashboard/env/lib/python2.7/site-packages/django/core/handlers/base.py", line 201, in get_response
    response = middleware_method(request, response)
  File "/Users/eduardo.carvalho/workspace/kolab-dashboard/env/lib/python2.7/site-packages/django/contrib/sessions/middleware.py", line 38, in process_response
    request.session.save()
  File "/Users/eduardo.carvalho/workspace/kolab-dashboard/env/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py", line 57, in save
    session_data=self.encode(self._get_session(no_load=must_create)),
  File "/Users/eduardo.carvalho/workspace/kolab-dashboard/env/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py", line 87, in encode
    serialized = self.serializer().dumps(session_dict)
  File "/Users/eduardo.carvalho/workspace/kolab-dashboard/env/lib/python2.7/site-packages/django/core/signing.py", line 88, in dumps
    return json.dumps(obj, separators=(',', ':')).encode('latin-1')
  File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 250, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/Cellar/python/2.7.6_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: datetime.datetime(2014, 8, 14, 17, 57, 53, 151293, tzinfo=<UTC>) is not JSON serializable

The password changes, but I get the error because of the json session serializer. When I change the following setting on settings.py:

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

I gess it should be in the docs.

tarak commented 9 years ago

It should. Sorry for the delay, but my work took all my attention, even on weekends... just wanted to let you know that the project is not dead... I'll take care of this soon...

tarak commented 9 years ago

See new documentation: http://tarak.github.io/django-password-policies/topics/setup.html#serializer