我执行以下操作:
我的脚本.py
# settings.py
from django.conf import settings
from django.db import models
from myApp.models import *
settings.configure(
DATABASE_ENGINE = 'django.db.backends.mysql',
DATABASE_NAME = 'Test',
DATABASE_USER = 'root',
DATABASE_PASSWORD = 'testpw',
DATABASE_HOST = '/var/run/mysql',
DATABASE_PORT = '3306',
INSTALLED_APPS = ('myApp')
)
from django.db import models
from myApp.models import *
使用以下 settings.py
DATABASE_ENGINE = 'mysql'
DATABASE_NAME = 'Test'
DATABASE_USER = 'root'
DATABASE_PASSWORD = 'testpw'
DATABASE_HOST = '/var/run/mysql'
DATABASE_PORT = '3306'
INSTALLED_APPS = ('myApp')
我的设置有误,但不知道错误是什么。数据库运行良好,可通过密码和用户名访问...在我的 manage.py 中,我接下来执行:"DJANGO_SETTINGS_MODULE", "standAlone.myScript"
这是我的错误: raise ImproperlyConfigured("settings.DATABASES is improperly configured. "django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured.