Working on ES integration for Heroku.

master
Nick Sergeant 2014-10-20 19:26:16 -04:00
parent 855d82674d
commit 731b1b9ebe
1 changed files with 16 additions and 4 deletions

View File

@ -1,14 +1,26 @@
import dj_database_url, os
from urlparse import urlparse
if 'DATABASE_URL' in os.environ:
DATABASES = {
'default': dj_database_url.config()
}
DATABASES = { 'default': dj_database_url.config() }
es = urlparse(os.environ.get('SEARCHBOX_URL') or 'http://127.0.0.1:9200/')
port = es.port or 80
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': es.scheme + '://' + es.hostname + ':' + str(port),
'INDEX_NAME': 'snipts',
},
}
if es.username:
HAYSTACK_CONNECTIONS['default']['KWARGS'] = {"http_auth": es.username + ':' + es.password}
else:
DATABASES = {
'default': {