File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88from django .utils .translation import ungettext
99
1010from haystack import connections
11+ from haystack .constants import DEFAULT_ALIAS
1112from haystack .query import SearchQuerySet
1213from haystack .utils import get_model_ct_tuple
1314
1415
1516class SearchChangeList (ChangeList ):
1617 def __init__ (self , ** kwargs ):
17- self .haystack_connection = kwargs .pop ("haystack_connection" , "default" )
18+ self .haystack_connection = kwargs .pop ("haystack_connection" , DEFAULT_ALIAS )
1819 super (SearchChangeList , self ).__init__ (** kwargs )
1920
2021 def get_results (self , request ):
@@ -58,7 +59,7 @@ def get_results(self, request):
5859
5960class SearchModelAdminMixin (object ):
6061 # haystack connection to use for searching
61- haystack_connection = "default"
62+ haystack_connection = DEFAULT_ALIAS
6263
6364 @csrf_protect_m
6465 def changelist_view (self , request , extra_context = None ):
Original file line number Diff line number Diff line change 22from django .core .management .base import BaseCommand
33
44from haystack import connections
5+ from haystack .constants import DEFAULT_ALIAS
56
67
78class Command (BaseCommand ):
@@ -10,7 +11,7 @@ class Command(BaseCommand):
1011 def handle (self , ** options ):
1112 """Provides feedback about the current Haystack setup."""
1213
13- unified_index = connections ["default" ].get_unified_index ()
14+ unified_index = connections [DEFAULT_ALIAS ].get_unified_index ()
1415 indexed = unified_index .get_indexed_models ()
1516 index_count = len (indexed )
1617 self .stdout .write ("Number of handled %s index(es)." % index_count )
Original file line number Diff line number Diff line change 55from django .utils .encoding import force_str
66from django .utils .text import capfirst
77
8+ from haystack .constants import DEFAULT_ALIAS
89from haystack .exceptions import NotHandled , SpatialError
910from haystack .utils import log as logging
1011from haystack .utils .app_loading import haystack_get_model
@@ -67,7 +68,7 @@ def __getattr__(self, attr):
6768 def _get_searchindex (self ):
6869 from haystack import connections
6970
70- return connections ["default" ].get_unified_index ().get_index (self .model )
71+ return connections [DEFAULT_ALIAS ].get_unified_index ().get_index (self .model )
7172
7273 searchindex = property (_get_searchindex )
7374
@@ -212,7 +213,7 @@ def get_stored_fields(self):
212213 from haystack import connections
213214
214215 try :
215- index = connections ["default" ].get_unified_index ().get_index (self .model )
216+ index = connections [DEFAULT_ALIAS ].get_unified_index ().get_index (self .model )
216217 except NotHandled :
217218 # Not found? Return nothing.
218219 return {}
You can’t perform that action at this time.
0 commit comments