我让 Haystack 在下面的“旧 urls.py”中工作。当我尝试在模型字段“canonical_school_score”上使用order_by对搜索结果进行排序时,如“New urls.py”中所示,我一直没有得到任何搜索结果。关于我做错了什么有什么建议吗?
# Old urls.py
urlpatterns = patterns('',
url(r'^search/', include('haystack.urls')),
)
# New urls.py
from haystack.views import search_view_factory, SearchView
from haystack.query import SearchQuerySet
sqs = SearchQuerySet().order_by('-canonical_school_score')
urlpatterns = patterns('',
url(r'^search/', search_view_factory(
view_class=SearchView,
template='search/search.html',
searchqueryset=sqs
), name='haystack_search'),
)