Django会话奇怪的行为:Decimal的文字无效:'2011-01-04 09:36:59'错误

时间:2010-12-21 20:57:41

标签: django django-sessions

我在尝试从我的网络应用上的django_session表中检索会话内容时遇到此错误。我正在使用request.session.get('mykey_name') 查询django执行此操作是:

s = Session.objects.get(session_key = self.session_key,expire_date__gt=datetime.datetime.now()

kwargs是:{'expire_date__gt':datetime.datetime(2010,12,21,14,27,6,138883),'session_key':'721c947a60432c3ac3bbdd485931c945'}

以下是完整的追溯:

Traceback:
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  80.                     response = middleware_method(request)
File "/usr/local/lib/python2.7/site-packages/pyfacegraph-0.0.4-py2.7.egg/facegraph/django/middleware.py" in process_request
  46.         request.graph = self.graph_for_request(request)
File "/usr/local/lib/python2.7/site-packages/pyfacegraph-0.0.4-py2.7.egg/facegraph/django/middleware.py" in graph_for_request
  51.         access_token = self.access_token(request)
File "/home/roohitne/djangoCode/roohit/fb/middleware.py" in access_token
  7.         return request.session.get('access_token')
File "/usr/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in get
  63.         return self._session.get(key, default)
File "/usr/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in _get_session
  172.                 self._session_cache = self.load()
File "/usr/local/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in load
  20.                 expire_date__gt=datetime.datetime.now()
File "/usr/local/lib/python2.7/site-packages/django/db/models/manager.py" in get
  132.         return self.get_query_set().get(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py" in get
  336.         num = len(clone)
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py" in __len__
  81.                 self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py" in iterator
  269.         for row in compiler.results_iter():
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in results_iter
  672.         for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  727.         cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/util.py" in execute
  15.             return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py" in execute
  86.             return self.cursor.execute(query, args)
File "/usr/local/lib/python2.7/site-packages/MySQL_python-1.2.2-py2.7-linux-i686.egg/MySQLdb/cursors.py" in execute
  166.             self.errorhandler(self, exc, value)
File "/usr/local/lib/python2.7/site-packages/MySQL_python-1.2.2-py2.7-linux-i686.egg/MySQLdb/connections.py" in defaulterrorhandler
  35.     raise errorclass, errorvalue

Exception Type: InvalidOperation at /oauth/callback/
Exception Value: Invalid literal for Decimal: '2011-01-04 14:04:39'

我是usig django 1.2.3和python 2.7,数据库版本是CentOS下的5.1.33社区。 任何猜测为什么会发生这种情况? 提前谢谢!

2 个答案:

答案 0 :(得分:0)

似乎是一个非常模糊的问题。我能找到的就是这个帖子: http://groups.google.com/group/django-users/browse_thread/thread/2e04a75e5da3c278

您最近是否升级或迁移了数据库?问题是否在新syncdb数据库中持久存在?可能想要统治那个。

由于错误在您没有提供该信息时返回2011-01-04 14:04:39,因此有些东西成功写入数据库并从中读取,但其他东西正在将其转换为小数...不幸的是我不知道django或mysqldb如何/何时尝试将日期时间转换为小数

如果没有人回答,我会联系上面链接中的那个人,因为它实际上是互联网上的唯一提及。

答案 1 :(得分:0)

似乎问题与在同一个apache实例中运行的php和python有关,

当我评论该行

LoadModule php5_module                    /usr/lib/apache2/mod_php5.so

在httpd.conf中,它开始正常工作。