外部程序调用Django模块的解决办法

 Question

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.

Awnser

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "项目名.settings")

  

猜你喜欢

转载自www.cnblogs.com/standby/p/9188959.html