0
我想在某个时间之前或之后获得线程中的所有帖子。那么,如何让Django允许我输入自己的查询呢?Django模型创建Coustom查询
这是我可以使用Django的模型函数最接近的。
# need to get all the post from Thread post_set that were created before Thread post_set 9
posts = Thread.post_set.filter(created <= Thread.post_set.all()[9].created)
谢谢'raw'就是我一直在寻找。还有一种方法可以查看过滤器使用的查询吗?或者是翻译过滤器的网站。即'created_lt','id__exact' – Crispy 2013-05-11 00:08:54
只要'print post.query',用你的查询对象的名称替换'post'。 – 2013-05-11 00:14:57
@Crispy查看此答案的信息:http://stackoverflow.com/a/1074224/1888559 – Ngenator 2013-05-11 00:15:28