diff --git a/manage.py b/manage.py index 2aaa5a5..7074dda 100755 --- a/manage.py +++ b/manage.py @@ -1,10 +1,21 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" import os import sys -if __name__ == "__main__": - os.environ["DJANGO_SETTINGS_MODULE"] = "webvirtcloud.settings" - - from django.core.management import execute_from_command_line +def main(): + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'webvirtcloud.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/webvirtcloud/wsgi.py b/webvirtcloud/wsgi.py index aafa04f..53925ed 100644 --- a/webvirtcloud/wsgi.py +++ b/webvirtcloud/wsgi.py @@ -8,7 +8,9 @@ https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ """ import os -os.environ["DJANGO_SETTINGS_MODULE"] = "webvirtcloud.settings" from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'webvirtcloud.settings') + application = get_wsgi_application() diff --git a/webvirtcloud/wsgi_custom.py b/webvirtcloud/wsgi_custom.py index 0abf5da..90c8522 100644 --- a/webvirtcloud/wsgi_custom.py +++ b/webvirtcloud/wsgi_custom.py @@ -6,15 +6,17 @@ It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ """ -import os, sys +import os +import sys + from django.core.wsgi import get_wsgi_application -# execfile('/srv/webvirtcloud/venv/bin/activate_this.py', dict(__file__='/srv/webvvirtcloud/venv/bin/activate_this.py')) -exec(compile(open('/srv/webvirtcloud/venv/bin/activate_this.py', "rb").read(), - '/srv/webvirtcloud/venv/bin/activate_this.py', 'exec')) +# execfile('/srv/webvirtcloud/venv/bin/activate_this.py', dict(__file__='/srv/webvirtcloud/venv/bin/activate_this.py')) +exec(compile(open('/srv/webvirtcloud/venv/bin/activate', "rb").read(), + '/srv/webvirtcloud/venv/bin/activate', 'exec')) sys.path.append('/srv/webvirtcloud') -os.environ["DJANGO_SETTINGS_MODULE"] = "webvirtcloud.settings" +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'webvirtcloud.settings') application = get_wsgi_application()