Skip to content

Serialization error with JSON session serializer #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eduardostalinho opened this issue Aug 14, 2014 · 2 comments
Closed

Serialization error with JSON session serializer #17

eduardostalinho opened this issue Aug 14, 2014 · 2 comments

Comments

@eduardostalinho
Copy link

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
Copy link
Owner

tarak commented Oct 6, 2014

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...

aclark4life added a commit to aclark4life/test-django-password-policies that referenced this issue Oct 14, 2014
SESSION_SERIALIZER='django.contrib.sessions.serializers.PickleSerializer'
tarak/django-password-policies#17
@tarak
Copy link
Owner

tarak commented Nov 9, 2014

@tarak tarak closed this as completed Nov 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants