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
pri开发者_C百科nt 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...
SOLVED: This was actually an issue with mongoengine's version. Just install from the dev branch of mongoengine...
精彩评论