2006年12月31日 星期日 22:23
=?GB2312?B?t+fP8rHq?=,您好! 把SQL打印出来就知道了。 在 2006-12-29 23:50:00 您写道: >我在设计程序雏形的时候建立了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 > >一个返回完全正常,一个就引发上面的代码 >实在不清楚原因,请解惑。 > >谢谢 >_______________________________________________ >python-chinese >Post: send python-chinese在lists.python.cn >Subscribe: send subscribe to python-chinese-request在lists.python.cn >Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn >Detail Info: http://python.cn/mailman/listinfo/python-chinese 致 礼! cry zyqmail在tom.com
Zeuux © 2025
京ICP备05028076号