Django Shell No module named settings

后端 未结 12 1373
温柔的废话
温柔的废话 2020-12-02 20:26

I\'ve deployed Django to Apache via mod_wsgi. Django is running fine when hosted from Apache. However, I\'m trying to do some maintenance via manage.py

12条回答
  •  Happy的楠姐
    2020-12-02 21:18

    In my case the wsgi.py file was working when the system was running normally, but I was getting the ImportError when trying to do a manual manage.py command like migrate or collectstatic.

    I checked wsgi.py for the way it imports the settings and noticed that it first adds the settings path to the sys.path as follows:

    import sys
    sys.path.append('/opt/server/settings')
    

    I added that to the top of the manage.py and it works.

提交回复
热议问题