Django deployment problem in Apache/mod_wsgi. ImportError: Could not import settings 'site.settings'

后端 未结 5 1518
野性不改
野性不改 2021-01-05 09:15

When I\'m executing

django-admin.py startproject site

it works.
But if I\'m only copying site folder it doesn\'t work.
Why?

5条回答
  •  再見小時候
    2021-01-05 10:21

    If you have something like this in apache configs:

    WSGIScriptAlias /path /base/path/devel/your_project.wsgi
    

    And this inside your_project.wsgi:

    sys.path.append('/base/path')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'devel.settings'
    

    Then apache will look at /base/path/devel/settings.py. If you move or copy /base/path/devel to /base/path/production you have to edit DJANGO_SETTINGS_MODULE at your_project.wsgi pointing to 'production.settings'.

提交回复
热议问题