4
我对这个查询错误而执行查询
query = "select count(*) from pgns_game where raw_moves = %s"
params = ('a',)
total_rows = self.model.objects.raw(query, params)
得到一个错误信息,它说
InvalidQuery('Raw query must include the primary key')
我清楚地失去了一些东西,但我不知道是什么。有任何想法吗?
在这里说的文档(http://docs.djangoproject.com/en/1.2/topics/db/sql/#deferring-model-fields):“只有一个领域,你不能离开 - 主键字段Django使用主键来标识模型实例,因此它必须始终包含在原始查询中,如果忘记包含主键,则会引发InvalidQuery异常。 – bernie 2010-05-26 03:19:37