【发布时间】:2021-01-27 08:45:52
【问题描述】:
当我执行单元测试命令:python3 -m unittest filepath/filename.py 时,它会抛出一个配置不正确的错误,谁能帮助解决这个问题,不胜感激
错误:
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but
settings are not configured. You must either define the environment variable
DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
【问题讨论】:
-
如果您运行
python -m django unittestfilepath/filename.py,它应该可以工作,因为当您将django作为子命令运行时,环境变量已设置
标签: python python-3.x django unit-testing