django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment varia

前端 未结 8 1847
遇见更好的自我
遇见更好的自我 2020-12-28 14:46

I\'ve tried everything that I could find to fix this issue, and I\'m starting to tear my hair out a little. I\'m getting this error:

django.core.exceptions.I         


        
8条回答
  •  南方客
    南方客 (楼主)
    2020-12-28 15:20

    In your python script, you are trying to access Django models before setting the environment try it in this order :

    os.environ.setdefault("DJANGO_SETTINGS_MODULE", ".`settings`")
    from .models import Class1, Class2,...
    

提交回复
热议问题