import os if __name__ == '__main__': # 下面的autoUI改成你当前的项目名称 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "autoUI.settings") import django django.setup() from appo3.views import fun
在文件头部添加以上内容,python 3.7 Django 3.0.6
报错信息
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.