django + mod_wsgi + apache

时间:2010-03-10 20:54:22

标签: django apache mod-wsgi

当我使用mod_wsgi在apache上运行我的django项目时,我会收到类似的内容:

    [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

有任何建议,线索或解决方案吗?

2 个答案:

答案 0 :(得分:0)

听起来django_session表中的一个条目可能格格不入。检查表并删除损坏的行,或者如果可以使用它,则可以完全截断表。

答案 1 :(得分:0)

以下是一些有关观看地点的建议:

  1. 回溯中的路径指向/usr/local/lib/python2.6/ ...也许您使用不同版本的Python构建mod_wsgi,尤其是可能在/usr/lib/pythonX.X中的系统安装版本。构建mod_wsgi时,您需要使用它:

    ./ configure --with-python = / usr / local / bin / python2.6

  2. 检查您的apache错误日志,看看是否有任何有用的消息,特别是mod_wsgi Installation Issues中记录的消息。

  3. 当您运行syncdb时,即使是“第一次”,您是否看到有关正在创建的auth表的消息?也许您的数据库中仍然有一个旧的auth表,可以通过完全删除数据库并从头开始(或执行类似manage.py reset

  4. 之类的操作来解决问题