File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 34
34
raise ImproperlyConfigured ('The HAYSTACK_CONNECTIONS setting is required.' )
35
35
if DEFAULT_ALIAS not in settings .HAYSTACK_CONNECTIONS :
36
36
raise ImproperlyConfigured ("The default alias '%s' must be included in the HAYSTACK_CONNECTIONS setting." % DEFAULT_ALIAS )
37
- for alias , connection in settings .HAYSTACK_CONNECTIONS .items ():
38
- if 'ENGINE' not in connection :
39
- raise ImproperlyConfigured ("You must specify a 'ENGINE' for connection '%s'" % alias )
40
37
41
38
# Load the connections.
42
39
connections = loading .ConnectionHandler (settings .HAYSTACK_CONNECTIONS )
Original file line number Diff line number Diff line change @@ -82,13 +82,20 @@ def __init__(self, connections_info):
82
82
self ._connections = {}
83
83
self ._index = None
84
84
85
+ def ensure_defaults (self , alias ):
86
+ try :
87
+ conn = self .connections_info [alias ]
88
+ except KeyError :
89
+ raise ImproperlyConfigured ("The key '%s' isn't an available connection." % alias )
90
+
91
+ if not conn .get ('ENGINE' ):
92
+ conn ['ENGINE' ] = 'haystack.backends.simple_backend.SimpleEngine'
93
+
85
94
def __getitem__ (self , key ):
86
95
if key in self ._connections :
87
96
return self ._connections [key ]
88
97
89
- if not key in self .connections_info :
90
- raise ImproperlyConfigured ("The key '%s' isn't an available connection." % key )
91
-
98
+ self .ensure_defaults (key )
92
99
self ._connections [key ] = load_backend (self .connections_info [key ]['ENGINE' ])(using = key )
93
100
return self ._connections [key ]
94
101
You can’t perform that action at this time.
0 commit comments