File tree Expand file tree Collapse file tree 3 files changed +8
-5
lines changed Expand file tree Collapse file tree 3 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 8
8
from django .utils .translation import ungettext
9
9
10
10
from haystack import connections
11
+ from haystack .constants import DEFAULT_ALIAS
11
12
from haystack .query import SearchQuerySet
12
13
from haystack .utils import get_model_ct_tuple
13
14
14
15
15
16
class SearchChangeList (ChangeList ):
16
17
def __init__ (self , ** kwargs ):
17
- self .haystack_connection = kwargs .pop ("haystack_connection" , "default" )
18
+ self .haystack_connection = kwargs .pop ("haystack_connection" , DEFAULT_ALIAS )
18
19
super (SearchChangeList , self ).__init__ (** kwargs )
19
20
20
21
def get_results (self , request ):
@@ -58,7 +59,7 @@ def get_results(self, request):
58
59
59
60
class SearchModelAdminMixin (object ):
60
61
# haystack connection to use for searching
61
- haystack_connection = "default"
62
+ haystack_connection = DEFAULT_ALIAS
62
63
63
64
@csrf_protect_m
64
65
def changelist_view (self , request , extra_context = None ):
Original file line number Diff line number Diff line change 2
2
from django .core .management .base import BaseCommand
3
3
4
4
from haystack import connections
5
+ from haystack .constants import DEFAULT_ALIAS
5
6
6
7
7
8
class Command (BaseCommand ):
@@ -10,7 +11,7 @@ class Command(BaseCommand):
10
11
def handle (self , ** options ):
11
12
"""Provides feedback about the current Haystack setup."""
12
13
13
- unified_index = connections ["default" ].get_unified_index ()
14
+ unified_index = connections [DEFAULT_ALIAS ].get_unified_index ()
14
15
indexed = unified_index .get_indexed_models ()
15
16
index_count = len (indexed )
16
17
self .stdout .write ("Number of handled %s index(es)." % index_count )
Original file line number Diff line number Diff line change 5
5
from django .utils .encoding import force_str
6
6
from django .utils .text import capfirst
7
7
8
+ from haystack .constants import DEFAULT_ALIAS
8
9
from haystack .exceptions import NotHandled , SpatialError
9
10
from haystack .utils import log as logging
10
11
from haystack .utils .app_loading import haystack_get_model
@@ -67,7 +68,7 @@ def __getattr__(self, attr):
67
68
def _get_searchindex (self ):
68
69
from haystack import connections
69
70
70
- return connections ["default" ].get_unified_index ().get_index (self .model )
71
+ return connections [DEFAULT_ALIAS ].get_unified_index ().get_index (self .model )
71
72
72
73
searchindex = property (_get_searchindex )
73
74
@@ -212,7 +213,7 @@ def get_stored_fields(self):
212
213
from haystack import connections
213
214
214
215
try :
215
- index = connections ["default" ].get_unified_index ().get_index (self .model )
216
+ index = connections [DEFAULT_ALIAS ].get_unified_index ().get_index (self .model )
216
217
except NotHandled :
217
218
# Not found? Return nothing.
218
219
return {}
You can’t perform that action at this time.
0 commit comments