Pergunta

I just deployed my Django project via FTP, now when I try to run ./manage.py shell it keeps on saying ImportError: Could not import settings 'somedjango.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named settings

Its an ubuntu server.I even updated httpd.conf to

WSGIScriptAlias / /var/www/django_venv/mydjango/wsgi.py
WSGIPythonPath /var/www/django_venv
<Directory /var/www/django_venv>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

Still no luck

Please let me know if I lack any information and I will add that as well

Structure of the app

django_venv
--venv
--templates
--mydjango
----settings.py
----wsgi.py
----url.py
--app1
--app2
--requirement.txt
--Procfile
--manage.py

manage.py

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mydjango.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)
Foi útil?

Solução

As a last resort, you should try to append absolute paths to your sys.path, inside your wsgi.py file.

import sys 
import os

sys.path.append('path/to/mydjango')
# sys.path.append('path/to/mydjango/mydjango')
# more as needed.

And then the usual :

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mydjango.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Once you get it up and running, you can start replacing absolute paths with relative ones (or if confident, do so from beginning).

Hope this helps,

Regards,

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top