看錯誤是: django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MOD
百度了下,效果都不太好,最后找到的解決辦法如下:
1.在需要執行的程序中添加:
import django
django.setup()
2.在pycharm的設置中設置settings路徑即可(app.settings)