D
D
Dmitry2018-09-14 08:31:01
Django
Dmitry, 2018-09-14 08:31:01

KeyError Django where to dig?

Good afternoon.
When I try to start the test server (py manage.py runserver), I get the following error:
KeyError: 'ELASTIC_HOST'
And it refers to:

...line 147, in <module> 
'URL': ':'.join([ENV_DICT['ELASTIC_HOST'], str(ENV_DICT['ELASTIC_PORT'])]),

Actually the code itself:
HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'elasticstack.backends.ConfigurableElasticSearchEngine',
        'URL': ':'.join([ENV_DICT['ELASTIC_HOST'], str(ENV_DICT['ELASTIC_PORT'])]),
        'INDEX_NAME': 'aden',
    },
}

But everything works on the production server. Explain what's the matter?
PS python 3.6.6; django 1.11

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem, 2018-09-14
@ulkoart

ENV_DICT ='ЗНАЧЕНИЕ' ./manage.py runserver
apparently, you need to set an environment variable ... or disable elastic

D
dastrix_dude, 2018-09-15
@dastrix_dude

Default config looks like this

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        'URL': 'http://localhost:9001/solr/default',
        'TIMEOUT': 60 * 5,
        'INCLUDE_SPELLING': True,
        'BATCH_SIZE': 100,
        'EXCLUDED_INDEXES': ['thirdpartyapp.search_indexes.BarIndex'],
    },

most likely you forgot to import the file with settings variables, look in the last config if everything is imported

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question