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.

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.

 

posted @ 2020-06-17 17:30  Delta.Farce  阅读(1144)  评论(1编辑  收藏  举报