簡體   English   中英

受夠了錯誤ImproperlyConfigured:settings.DATABASES配置不正確。 請提供引擎值

[英]Fed up with the error ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value

配置不正確:settings.DATABASES配置不正確。 請提供引擎值

自最近三天以來,我一直在遭受這個問題的困擾。

我在不同的博客(甚至在stackoverflow上)和解決方案中都看到過重復票的音色,但是它們都不對我有用。

最后,我別無選擇,只能在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)gdq$1d^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將使用默認設置,該默認設置通常未定義任何數據庫引擎,因此會出現錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM