2015-01-01 4 views
0

을 적절히 설정하십시오 : settings.DATABASES가 잘못 구성되었습니다. ENGINE 값을 입력하십시오.ImproperlyConfigured : settings.DATABASES 오류가 부적절하게 구성되었습니다. ENGINE 값

지난 3 일 동안이 문제로 고통 받고 있습니다.

다른 블로그 (심지어 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 = '[email protected]' 
EMAIL_HOST_PASSWORD = 'xxxxxxx' 
DEFAULT_FROM_EMAIL = '[email protected]' 
DEFAULT_TO_EMAIL = '[email protected]' 

ADMINS = (
    ('XXXX', '[email protected]'), 
) 

#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/" 

최근 내 프로젝트 장고 1.4에서 실행했지만, 난이 때문에 일부 smartbyte 인코딩 오류로 1.5으로 업데이트되었습니다. 그 문제가 시작된 후 나는 장고 1.4로 다운 그레이드했다. 다운 그레이드가 끝나지 않았어도 내 전체 프로젝트를 새로운 AWS 인스턴스 (우분투 14.04)로 옮겼습니다.

내가 장고 1.5 python2.7

+1

'SECRET_KEY' 키를 비밀로 유지해야합니다. : P –

+0

나는 그 비밀만을 알고, 샘플 값을 언급했다. – PK10

+2

설정 파일의 중간에서'settings.configure()'를 호출하는 이유는 무엇입니까? –

답변

2
settings.configure() 

을 사용하고하면 privious 설정을 오버라이드 (override) 할 것으로 보인다. 이것은 귀하의 문제의 열쇠가되어야합니다.

실제로 인수없이 configure()를 호출하면 django는 일반적으로 db 엔진이 정의되지 않은 기본 설정을 사용하므로 오류가 발생합니다.

+2

https://docs.djangoproject.com/en/1.7/topics/settings/ –