想单独启动调试单个py文件,从pycharm启动单独py程序
ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
求怎么配置settings.
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
需要再单独文件的头部上添加
这里settings就是项目包程序的配置的settings. 需要项目的工作路径引入进来。
Pycharm debug django问题
报错:
django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
解决:配置一下 run/edit configuration,注意我第二个红色覆盖掉的只setting所在的模块,比如你可能settings是在mysite模块下,那就写mysite.settings

如果之前已经在terminal里runserver 了,先把他们关掉
开始debug,出现下面这样的情况就OK了!

参考http://www.cnblogs.com/lout/articles/4149591.html
http://stackoverflow.com/questions/27269574/how-to-run-debug-server-for-django-project-in-pycharm-community-edition