Django随机排序列表

时间:2017-04-06 10:08:31

标签: python django

当我从db获取它时,如何对列表'articles_list'进行排序?

def article_theme(request, articleblock_id=2):
    return render_to_response('article_theme.html', 
   {"ArticleBlock_name": ArticleBlock.objects.get(id=articleblock_id), 
   'articles_list': Articles.objects.filter
   (articles_articleblock_id=articleblock_id)})

1 个答案:

答案 0 :(得分:1)

这是:

Articles.objects.filter(articles_articleblock_id=articleblock_id).order_by('?')