settings.DATABASES配置不正确(Elasticsearch)

时间:2017-07-31 06:12:01

标签: python django elasticsearch django-haystack

我正在使用elasticsearch作为我的Django应用程序的数据库。但每当我运行python manage.py rebuild_index时,我都会出现以下错误:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/core/management/base.py", line 305, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/core/management/base.py", line 356, in execute
    output = self.handle(*args, **options)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/haystack/management/commands/rebuild_index.py", line 37, in handle
    call_command('update_index', **options)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/core/management/__init__.py", line 130, in call_command
    return command.execute(*args, **defaults)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/core/management/base.py", line 356, in execute
    output = self.handle(*args, **options)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 214, in handle
    self.update_backend(label, using)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 240, in update_backend
    total = qs.count()
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/db/models/query.py", line 369, in count
    return self.query.get_count(using=self.db)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/db/models/sql/query.py", line 476, in get_count
    number = obj.get_aggregation(using, ['__count'])['__count']
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/db/models/sql/query.py", line 457, in get_aggregation
    result = compiler.execute_sql(SINGLE)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 824, in execute_sql
    sql, params = self.as_sql()
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 374, in as_sql
    from_, f_params = self.get_from_clause()
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 612, in get_from_clause
    clause_sql, clause_params = self.compile(from_clause)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 353, in compile
    sql, params = node.as_sql(self, self.connection)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/db/models/sql/datastructures.py", line 146, in as_sql
    base_sql = compiler.quote_name_unless_alias(self.table_name)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 344, in quote_name_unless_alias
    r = self.connection.ops.quote_name(name)
  File "/Manish/Projects/Spark/ad-tracking-django-env/lib/python2.7/site-packages/django/db/backends/dummy/base.py", line 21, in complain
    raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

主要错误是:

raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
    django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

我也在使用Haystack作为我的搜索引擎。我对Haystack连接的settings.py是:

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.elasticsearch2_backend.Elasticsearch2SearchEngine',
        'URL': 'http://127.0.0.1:9200/',
        'INDEX_NAME': 'haystack',
    },
}

1 个答案:

答案 0 :(得分:1)

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'mydatabase',
    }
}

创建一个名为db.sqlite3的文件manage.py,然后运行您正在运行的文件