这是我见过的最奇怪和最不合逻辑的错误。我正在使用 django+mongoengine,可以说我的观点是:
def index(request, template_name='index.html'):
articles = Article.objects.order_by('-date_added')
for i in articles: # test to see if the ordering works
print i.title # ok, prints correctly all the titles ordered_by "-date_added"
return render_to_response( template_name, locals(), context_instance=RequestContext(request))
但是当我循环浏览 index.html 中的文章时,它们总是呈现为好像排序是 order_by('date_added')
我喝醉了吗?我错过了什么吗?有什么建议么?这会让我发疯...