You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.py 1.0KB

12345678910111213141516171819202122232425262728293031323334
  1. from django.conf.urls import url
  2. from haystack.views import search_view_factory
  3. from oscar.core.application import Application
  4. from oscar.core.loading import get_class
  5. from oscar.apps.search import facets
  6. class SearchApplication(Application):
  7. name = 'search'
  8. search_view = get_class('search.views', 'FacetedSearchView')
  9. search_form = get_class('search.forms', 'SearchForm')
  10. def get_urls(self):
  11. # The form class has to be passed to the __init__ method as that is how
  12. # Haystack works. It's slightly different to normal CBVs.
  13. urlpatterns = [
  14. url(r'^$', search_view_factory(
  15. view_class=self.search_view,
  16. form_class=self.search_form,
  17. searchqueryset=self.get_sqs()),
  18. name='search'),
  19. ]
  20. return self.post_process_urls(urlpatterns)
  21. def get_sqs(self):
  22. """
  23. Return the SQS required by a the Haystack search view
  24. """
  25. return facets.base_sqs()
  26. application = SearchApplication()