1

I have Haystack working in "Old urls.py" below. When I try to order my search results using order_by on the model field 'canonical_school_score', as seen in "New urls.py," I keep getting no search results. Any suggestions on what I'm doing wrong?

# 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'),
    )
wsvincent
  • 207
  • 4
  • 13

1 Answers1

1

So the problem was that 'canonical_school_score', while a model field, was not part of the search index, search_indexes.py.

Makes sense in retrospect. Hopefully this helps others not repeat the same mistake.

wsvincent
  • 207
  • 4
  • 13