【发布时间】:2015-08-26 01:14:31
【问题描述】:
views.py 中为我的 django 项目定义了以下函数。我遇到的唯一问题是按小写顺序(即Lower())和相反的顺序(即'-title'而不是'title')对所有书籍进行排序。我可以选择其中之一,但不能同时订购。
我收到以下错误:
Cannot resolve keyword '-title' into field. Choices are: author, date_modified, title
def book_list_title(request):
all_entries = Book.objects.all().order_by(Lower('-title'))
books_list=[]
//Do stuff to create a proper list of books
return render(request,'books_app/books_list.html', {'books_list':books_list})
【问题讨论】:
标签: python django django-views django-queryset