受够了错误 ImproperlyConfigured:settings.DATABASES 配置不当。请提供引擎值
Fed up with the error ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value
配置不当:settings.DATABASES 配置不当。请提供引擎值
我最近 3 天就被这个问题困扰了。
我在不同的博客(甚至在 Whosebug 上)和解决方案中看到了重复票证的音调,但没有一个对我有效。
最后我别无选择,只能问我的settings.py这里出了什么问题,为什么即使在新的 AWS 实例上转移 django 应用程序后问题也没有解决。
我的setting.py:
# Django settings for smartDNA project.
import os
import sys
import logging
from django.conf import settings
DEBUG = True
TEMPLATE_DEBUG = DEBUG
WINDOWS=False
#EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend'
EMAIL_USE_SSL = True
#EMAIL_USE_TLS = True
EMAIL_HOST = 'xxx.xxx.xxx.xxx'
EMAIL_PORT = 80
EMAIL_HOST_USER = 'xxxx@xxxx'
EMAIL_HOST_PASSWORD = 'xxxxxxx'
DEFAULT_FROM_EMAIL = 'xxx.xxx@xxxx'
DEFAULT_TO_EMAIL = 'xxxxx.xxxx@xxxx'
ADMINS = (
('XXXX', 'XXXX@xxxxxx'),
)
#SESSION_COOKIE_DOMAIN="http://ec2-xx-xx-xx-xxx.compute-1.amazonaws.com"
SESSION_COOKIE_NAME = 'site2'
#SESSION_COOKIE_PATH =':/tmp'
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'livedb1', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': 'SMARTDNA', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# system time zone.
TIME_ZONE = 'Asia/Calcutta'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
if WINDOWS:
MEDIA_ROOT = ('%s/media/' % (os.path.dirname(__file__))) #'D:/smartDNA/media/'
else:
MEDIA_ROOT = ('%s/media/' % (os.path.dirname(__file__))) #'/home/ubuntu/server/smartDNA/media/'
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
if WINDOWS:
STATIC_ROOT = ('%s/static/' % (os.path.dirname(__file__))) #'D:/smartDNA/static/'
else:
STATIC_ROOT = ('%s/static/' % (os.path.dirname(__file__))) #'/home/ubuntu/server/smartDNA/static/'
# STATIC_ROOT = '/home/ubuntu/server/smartDNA/static'
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.request",
"django.core.context_processors.static",
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.DefaultStorageFinder',
'djangobower.finders.BowerFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = '192(q1m!d)k9n)gdqd^e7p4%n*3gsbb0waubmuftw)*0lt__'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
#'smartDNA.trackware.UserLocationLoggerMiddleware',
'pagination.middleware.PaginationMiddleware',
)
ROOT_URLCONF = 'smartDNA.urls'
if WINDOWS:
TEMPLATE_DIRS = ('%s/templates' % (os.path.dirname(__file__))) #('D:/smartDNA/templates',)
else:
TEMPLATE_DIRS = ('%s/templates' % (os.path.dirname(__file__))) #('/home/ubuntu/server/smartDNA/templates',)
INSTALLED_APPS = (
#'grappelli',
#'grappelli.dashboard',
'suit',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'smartDNA.core',
'googlecharts',
'pagination',
)
settings.configure()
ADMIN_REORDER = (
("core", ("Alert","Verification","AlertSubscriber","Anomaly","Logger","AssetWithPeriodicScanPolicy")),
)
# Django Suit configuration example
SUIT_CONFIG = {
# header
'ADMIN_NAME': 'XXXXX RETAIL SECURITY PROGRAMME',
'HEADER_DATE_FORMAT': 'l, j. F Y',
'HEADER_TIME_FORMAT': 'H:i',
# forms
'SHOW_REQUIRED_ASTERISK': True, # Default True
'CONFIRM_UNSAVED_CHANGES': True, # Default True
# menu
'SEARCH_URL': '/admin/auth/user/',
'MENU_ICONS': {
'sites': 'icon-leaf',
'auth': 'icon-lock',
'core': 'icon-globe'
},
'MENU_OPEN_FIRST_CHILD': True, # Default True
'MENU_EXCLUDE': ('auth.group',),
'MENU': (
'sites',
{'app': 'core', 'icon':'icon-globe', 'models': ('Verification', 'Verification')},
{'app': 'auth', 'icon':'icon-lock', 'models': ('user', 'group')},
{'label': 'Settings', 'icon':'icon-cog', 'models': ('auth.user', 'auth.group')},
{'label': 'Support', 'icon':'icon-question-sign', 'url': '/support/'},
),
# misc
'LIST_PER_PAGE': 15
}
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
}
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
GEOIP_PATH = "/home/ubuntu/xxxxx/smartDNA/"
最近我的项目在 Django 1.4 上运行,但由于一些 smartbyte 编码错误我更新到 1.5。在那个问题开始之后,我降级到 Django 1.4。即使在降级后它也不会继续,然后我将整个项目转移到新的 AWS 实例 (ubuntu 14.04)。
我正在使用 Django 1.5 python2.7
settings.configure()
似乎覆盖了原来的设置。这一定是你问题的关键。
事实上,如果您不带任何参数调用 configure(),django 将使用默认设置,该默认设置通常没有定义任何数据库引擎,因此您会收到错误消息。
配置不当:settings.DATABASES 配置不当。请提供引擎值
我最近 3 天就被这个问题困扰了。
我在不同的博客(甚至在 Whosebug 上)和解决方案中看到了重复票证的音调,但没有一个对我有效。
最后我别无选择,只能问我的settings.py这里出了什么问题,为什么即使在新的 AWS 实例上转移 django 应用程序后问题也没有解决。
我的setting.py:
# Django settings for smartDNA project.
import os
import sys
import logging
from django.conf import settings
DEBUG = True
TEMPLATE_DEBUG = DEBUG
WINDOWS=False
#EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend'
EMAIL_USE_SSL = True
#EMAIL_USE_TLS = True
EMAIL_HOST = 'xxx.xxx.xxx.xxx'
EMAIL_PORT = 80
EMAIL_HOST_USER = 'xxxx@xxxx'
EMAIL_HOST_PASSWORD = 'xxxxxxx'
DEFAULT_FROM_EMAIL = 'xxx.xxx@xxxx'
DEFAULT_TO_EMAIL = 'xxxxx.xxxx@xxxx'
ADMINS = (
('XXXX', 'XXXX@xxxxxx'),
)
#SESSION_COOKIE_DOMAIN="http://ec2-xx-xx-xx-xxx.compute-1.amazonaws.com"
SESSION_COOKIE_NAME = 'site2'
#SESSION_COOKIE_PATH =':/tmp'
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'livedb1', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': 'SMARTDNA', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# system time zone.
TIME_ZONE = 'Asia/Calcutta'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
if WINDOWS:
MEDIA_ROOT = ('%s/media/' % (os.path.dirname(__file__))) #'D:/smartDNA/media/'
else:
MEDIA_ROOT = ('%s/media/' % (os.path.dirname(__file__))) #'/home/ubuntu/server/smartDNA/media/'
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
if WINDOWS:
STATIC_ROOT = ('%s/static/' % (os.path.dirname(__file__))) #'D:/smartDNA/static/'
else:
STATIC_ROOT = ('%s/static/' % (os.path.dirname(__file__))) #'/home/ubuntu/server/smartDNA/static/'
# STATIC_ROOT = '/home/ubuntu/server/smartDNA/static'
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.request",
"django.core.context_processors.static",
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.DefaultStorageFinder',
'djangobower.finders.BowerFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = '192(q1m!d)k9n)gdqd^e7p4%n*3gsbb0waubmuftw)*0lt__'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
#'smartDNA.trackware.UserLocationLoggerMiddleware',
'pagination.middleware.PaginationMiddleware',
)
ROOT_URLCONF = 'smartDNA.urls'
if WINDOWS:
TEMPLATE_DIRS = ('%s/templates' % (os.path.dirname(__file__))) #('D:/smartDNA/templates',)
else:
TEMPLATE_DIRS = ('%s/templates' % (os.path.dirname(__file__))) #('/home/ubuntu/server/smartDNA/templates',)
INSTALLED_APPS = (
#'grappelli',
#'grappelli.dashboard',
'suit',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'smartDNA.core',
'googlecharts',
'pagination',
)
settings.configure()
ADMIN_REORDER = (
("core", ("Alert","Verification","AlertSubscriber","Anomaly","Logger","AssetWithPeriodicScanPolicy")),
)
# Django Suit configuration example
SUIT_CONFIG = {
# header
'ADMIN_NAME': 'XXXXX RETAIL SECURITY PROGRAMME',
'HEADER_DATE_FORMAT': 'l, j. F Y',
'HEADER_TIME_FORMAT': 'H:i',
# forms
'SHOW_REQUIRED_ASTERISK': True, # Default True
'CONFIRM_UNSAVED_CHANGES': True, # Default True
# menu
'SEARCH_URL': '/admin/auth/user/',
'MENU_ICONS': {
'sites': 'icon-leaf',
'auth': 'icon-lock',
'core': 'icon-globe'
},
'MENU_OPEN_FIRST_CHILD': True, # Default True
'MENU_EXCLUDE': ('auth.group',),
'MENU': (
'sites',
{'app': 'core', 'icon':'icon-globe', 'models': ('Verification', 'Verification')},
{'app': 'auth', 'icon':'icon-lock', 'models': ('user', 'group')},
{'label': 'Settings', 'icon':'icon-cog', 'models': ('auth.user', 'auth.group')},
{'label': 'Support', 'icon':'icon-question-sign', 'url': '/support/'},
),
# misc
'LIST_PER_PAGE': 15
}
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
}
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
GEOIP_PATH = "/home/ubuntu/xxxxx/smartDNA/"
最近我的项目在 Django 1.4 上运行,但由于一些 smartbyte 编码错误我更新到 1.5。在那个问题开始之后,我降级到 Django 1.4。即使在降级后它也不会继续,然后我将整个项目转移到新的 AWS 实例 (ubuntu 14.04)。
我正在使用 Django 1.5 python2.7
settings.configure()
似乎覆盖了原来的设置。这一定是你问题的关键。
事实上,如果您不带任何参数调用 configure(),django 将使用默认设置,该默认设置通常没有定义任何数据库引擎,因此您会收到错误消息。