diff --git a/oscar/apps/search/app.py b/oscar/apps/search/app.py index d6160c1927b..a3de0be8d98 100644 --- a/oscar/apps/search/app.py +++ b/oscar/apps/search/app.py @@ -3,10 +3,11 @@ from haystack.query import SearchQuerySet from oscar.core.application import Application -from oscar.apps.search.views import SuggestionsView, MultiFacetedSearchView -from oscar.apps.search.search_indexes import ProductIndex -from oscar.apps.search.forms import MultiFacetedSearchForm +from oscar.core.loading import import_module +import_module('search.views', ['SuggestionsView', 'MultiFacetedSearchView'], locals()) +import_module('search.search_indexes', ['ProductIndex'], locals()) +import_module('search.forms', ['MultiFacetedSearchForm'], locals()) class SearchApplication(Application): name = 'search' @@ -19,7 +20,7 @@ def get_urls(self): for field_name, field in ProductIndex.fields.items(): if field.faceted is True: # Ensure we facet the results set by the defined facetable fields - sqs.facet(field_name) + sqs = sqs.facet(field_name) urlpatterns = patterns('', url(r'^suggest/$', self.suggestions_view.as_view(), name='suggest'), @@ -29,4 +30,4 @@ def get_urls(self): return self.post_process_urls(urlpatterns) -application = SearchApplication() \ No newline at end of file +application = SearchApplication() diff --git a/oscar/apps/search/urls.py b/oscar/apps/search/urls.py deleted file mode 100644 index dfc7796d07b..00000000000 --- a/oscar/apps/search/urls.py +++ /dev/null @@ -1,20 +0,0 @@ -from django.conf.urls.defaults import * -from haystack.query import SearchQuerySet - -from oscar.core.loading import import_module -import_module('search.views', ['Suggestions', 'MultiFacetedSearchView'], locals()) -import_module('search.forms', ['MultiFacetedSearchForm'], locals()) -import_module('search.search_indexes', ['ProductIndex'], locals()) - - -sqs = SearchQuerySet() -for field_name, field in ProductIndex.fields.items(): - if field.faceted is True: - # Ensure we facet the results set by the defined facetable fields - sqs.facet(field_name) - -urlpatterns = patterns('search.apps.views', - url(r'^suggest/$', Suggestions.as_view(), name='oscar-search-suggest'), - url(r'^$', MultiFacetedSearchView(form_class=MultiFacetedSearchForm, - searchqueryset=sqs), name='oscar-search'), -) \ No newline at end of file