Python论坛  - 讨论区

标题:[python-chinese] 【django】同样models建立出来的两个库,却出现奇怪的错误

2006年12月29日 星期五 23:50

风向标 vaneoooo在gmail.com
星期五 十二月 29 23:50:06 HKT 2006

我在设计程序雏形的时候建立了models
一切运行都正常
当我在雏形的基础上重写程序,在models中重用之前设计的代码时,
就出现了下列的Mysql错误

Traceback (most recent call last):
  File "", line 1, in ?
  File "C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\que
ry.py", line 103, in __iter__
    return iter(self._get_data())
  File "C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\que
ry.py", line 430, in _get_data
    self._result_cache = list(self.iterator())
  File "C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\que
ry.py", line 172, in iterator
    cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join
(select) + sql, params)
  File "C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\backends\u
til.py", line 12, in execute
    return self.cursor.execute(sql, params)
  File "C:\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\backends\m
ysql\base.py", line 35, in execute
    return self.cursor.execute(sql, params)
  File "C:\Python24\lib\site-packages\MySQLdb\cursors.py", line 163, in execute
    self.errorhandler(self, exc, value)
  File "C:\Python24\lib\site-packages\MySQLdb\connections.py", line 35, in defau
lterrorhandler
    raise errorclass, errorvalue
ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual
 that corresponds to your MySQL server version for the right syntax to use near
')) ORDER BY `group_topic_group`.`last_date` DESC' at line 1")


雏形和现在做的版本在group这个app下面的models是完全一样的
同样的模块,执行:
from test.group.models import Group, Topic_group
group_list = Group.objects.all()
group_list = group_list[:6]
group_id = [group.id for group in group_list]
topic_list = Topic_group.objects.filter(forgroup__in = group_id)
for topic in topic_list:
    print topic.title,topic.forgroup.name

一个返回完全正常,一个就引发上面的代码
实在不清楚原因,请解惑。

谢谢

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号