Skip to content

Commit a948e37

Browse files
committed
Fixed hardcoded default connection alias
1 parent 193b418 commit a948e37

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

haystack/admin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
from django.utils.translation import ungettext
99

1010
from haystack import connections
11+
from haystack.constants import DEFAULT_ALIAS
1112
from haystack.query import SearchQuerySet
1213
from haystack.utils import get_model_ct_tuple
1314

1415

1516
class 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

5960
class 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):

haystack/management/commands/haystack_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from django.core.management.base import BaseCommand
33

44
from haystack import connections
5+
from haystack.constants import DEFAULT_ALIAS
56

67

78
class 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)

haystack/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from django.utils.encoding import force_str
66
from django.utils.text import capfirst
77

8+
from haystack.constants import DEFAULT_ALIAS
89
from haystack.exceptions import NotHandled, SpatialError
910
from haystack.utils import log as logging
1011
from 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 {}

0 commit comments

Comments
 (0)