Skip to content
Advertisement

After splitting settings.py file, mod_wsgi failed to exec Python script file. And application = get_wsgi_application() errors occured over and over

Hi everybody I tried to deploy my django project with apache, mod_wsgi in windows.

I splited my settings.py like this:

  • source root folder
    • project folder
      • apps
      • config
        • settings
          • init.py
          • base.py
          • local.py
          • prod.py
      • init.py
      • asgi.py
      • urls.py
      • wsgi.py
    • myenv

After I splited settings.py, Mod_wsgi failed to exec python scripts file : ‘C:/user/users/desktop/source_root_folder/project_folder/wsgi.py’.

Mod_wsgi also show the exception that Exception occurred processing WSGI script : ‘C:/user/users/desktop/source_root_folder/project_folder/wsgi.py’

In Apache24 error log, ‘C:/user/users/desktop/source_root_folder/project_folder/wsgi.py’ application = get_wsgi_application() error occured.

# project_folder/wsgi.py

import os
from django.core.wsgi import get_wsgi_application
import sys

sys.path.append('C:/Apache24/htdocs/ C:/user/users/desktop/source_root_folder')

os.environ['DJANGO_SETTINGS_MODULE'] = 'project_folder.config.settings'
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project_folder.config.settings')


application = get_wsgi_application()

how can i deal with those errors? please give me some helps.

Advertisement

Answer

you need to specify the *.py settings file:

os.environ['DJANGO_SETTINGS_MODULE'] = 'project_folder.config.settings.init'
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement