极其奇怪的 django-mongoengine 错误
这是我见过的最奇怪、最不合逻辑的错误。我正在使用 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') 的顺序呈现,
我醉了吗?我错过了什么吗?有什么建议吗?这会让我发疯的...
This is the most weird and illogical error I have ever seen. I am using django+mongoengine, and lets say my view is:
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))
But when I loop through articles in index.html, those are always presented as if the ordering was order_by('date_added')
Am I drunk? Am I missing something? Any suggestions? This is gonna drive me crazy...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已解决:这实际上是 mongoengine 版本的问题。只需从 mongoengine 的 dev 分支安装...
SOLVED: This was actually an issue with mongoengine's version. Just install from the dev branch of mongoengine...