ImportError: No module named mysite.settings (Django)

前端 未结 5 738
清酒与你
清酒与你 2020-12-31 06:37

I have installed Django and mod_wsgi-express on an ubuntu 15.10. Basically (notice I did not do this as root):

pip install Django
pip instal         


        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-31 07:25

    Please try:

    
        import os
        import sys
        BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        sys.path.append(BASE_DIR)
        os.environ['DJANGO_SETTINGS_MODULE'] = 'YOURAPP.settings'
        os.environ.setdefault("DJANGO_SETTINGS_MODULE", "YOURAPP.settings")
    

    This is working for scripts in main project directory, as well ..

提交回复
热议问题