虽然尝试从 mysite 的主目录运行django-admin.py inspectdb
命令,但我收到以下错误。
错误
Traceback (most recent call last):
File "C:\_Data\MyFolder\Python\Scripts\django-admin.py", line 5, in <module> management.execute_from_command_line()
File "C:\_Data\MyFolder\Python\lib\site-packages\django\core\management\__init__.py", line 453, in execute_from_command_line utility.execute()
File "C:\_Data\MyFolder\Python\lib\site-packages\django\core\management\__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\_Data\MyFolder\Python\lib\site-packages\django\core\management\__init__.py", line 272, in fetch_command klass = load_command_class(app_name, subcommand)
File "C:\_Data\MyFolder\Python\lib\site-packages\django\core\management\__init__.py", line 77, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name))
File "C:\_Data\MyFolder\Python\lib\site-packages\django\utils\importlib.py", line 35, in import_module __import__(name)
File "C:\_Data\MyFolder\Python\lib\site-packages\django\core\management\commands\inspectdb.py", line 8, in <module> from django.db import connections, DEFAULT_DB_ALIAS
File "C:\_Data\MyFolder\Python\lib\site-packages\django\db\__init__.py", line 11, in <module> if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:
File "C:\_Data\MyFolder\Python\lib\site-packages\django\conf\__init__.py", line53, in __getattr__ self._setup(name)
File "C:\_Data\MyFolder\Python\lib\site-packages\django\conf\__init__.py", line46, in _setup % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
我的 settings.py 文件定义了 oracle DB 设置:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.oracle',
'NAME': 'MyDB',
'USER': 'MyUser',
'PASSWORD': 'MyPSW',
'HOST': 'Host',
'PORT': '1521',
}
}
为什么系统无法识别数据库设置?