When I run my django project on apache with mod_wsgi, I receive something like that:

    [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145] Traceback (most recent call last):
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]   File "/usr/local/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/handlers/wsgi.py", line 245, in __call__
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]     response = middleware_method(request, response)
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]   File "/usr/local/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/contrib/sessions/middleware.py", line 28, in process_response
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]     if request.session.get_expire_at_browser_close():
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]   File "/usr/local/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/contrib/sessions/backends/base.py", line 229, in get_expire_at_browser_close
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]     if self.get('_session_expiry') is None:
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]   File "/usr/local/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/contrib/sessions/backends/base.py", line 63, in get
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]     return self._session.get(key, default)
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]   File "/usr/local/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/contrib/sessions/backends/base.py", line 172, in _get_session
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]     self._session_cache = self.load()
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]   File "/usr/local/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/contrib/sessions/backends/db.py", line 18, in load
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]     return self.decode(force_unicode(s.session_data))
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]   File "/usr/local/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/contrib/sessions/backends/base.py", line 93, in decode
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]     encoded_data = base64.decodestring(session_data)
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]   File "/usr/local/lib/python2.6/base64.py", line 321, in decodestring
        [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145]     return binascii.a2b_base64(s)
 [Wed Mar 10 08:46:43 2010] [error] [client 10.13.1.145] Error: Incorrect padding

Is there any suggestion, clue or solution?

Accepted Answer

Sounds like one of the entries in the django_session table might be malformed. Either inspect the table and remove the broken row, or you can truncate the table altogether if you can live with that.

This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki