我安装了 Django 并能够仔细检查该模块实际上是在 Python 中,但是在尝试实现诸如 runserver 或使用 manage.py 之类的基本命令时;我收到 DJANGO_SETTEINGS_MODULE 错误。我已经按照建议使用了“set DJANGO_SETTINGS_MODULE = mysite.settings”,并将 mysite.settings 插入到 Python 的 PATH 中,因为一些在线文档指示我这样做。
现在它不是 undefined 而是说不存在这样的模块。我在文档中找不到任何其他内容,我使用了我的测试站点名称而不是“mysite”,没有进行任何更改。有谁知道我错过了什么?我在 Python 中的 Django 模块库中只能找到这段代码。
从未来导入 unicode_literals
from django.utils.version import get_version
VERSION = (1, 11, 5, 'final', 0)
__version__ = get_version(VERSION)
def setup(set_prefix=True):
"""
Configure the settings (this happens as a side effect of accessing the first setting), configure logging and populate the app registry.
Set the thread-local urlresolvers script prefix if `set_prefix` is True.
"""
from django.apps import apps
from django.conf import settings
from django.urls import set_script_prefix
from django.utils.encoding import force_text
from django.utils.log import configure_logging
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
if set_prefix:
set_script_prefix(
'/' if settings.FORCE_SCRIPT_NAME is None else force_text(settings.FORCE_SCRIPT_NAME)
)
apps.populate(settings.INSTALLED_APPS)