Skip to content

Instantly share code, notes, and snippets.

@nz
Created September 5, 2014 02:32
Show Gist options
  • Save nz/e46a9ab825281918dd39 to your computer and use it in GitHub Desktop.
Save nz/e46a9ab825281918dd39 to your computer and use it in GitHub Desktop.
ES_URL = urlparse(os.environ.get('BONSAI_URL') or 'http://127.0.0.1:9200/')
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': ES_URL.scheme + '://' + ES_URL.hostname + ':80',
'INDEX_NAME': 'haystack',
},
}
if ES_URL.username:
HAYSTACK_CONNECTIONS['default']['KWARGS'] = {"http_auth": ES_URL.username + ':' + ES_URL.password}
@apiljic
Copy link

apiljic commented Sep 8, 2014

Hi Nick,

The ticket at Heroku is closed, so I'll reply here.
This code worked, thanks a lot!

One question: while testing this, at some point I removed the last two lines, and everything worked regardless. Isn't it supposed not to work without the username and password?

Cheers,
Alen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment