Set Up Django1.1.4 with mod_wsgi

n.imp

I have a project in Django 1.1.4 and I am trying to set up this project on production with mod_wsgi but I am getting some errors :

My wsgi file code :

import os
import sys
import site

# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('path_to_\site-packages')

# Add the app's directory to the PYTHONPATH
sys.path.append('path_to_dir')
sys.path.append('path_to_dir')

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

I have tried to debug the error like when I print something in my settings It doesn't get print so I guess my settings is not being called.

My wsgi and settings file are in the same level and I have used two ways to mention settings in my wsgi file like os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' and os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings' but both fails. .

error - log :

File "C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 230, in __call__
     self.load_middleware()
   File "C:\\Python27\\lib\\site-packages\\django\\core\\handlers\\base.py", line 33, in load_middleware
     for middleware_path in settings.MIDDLEWARE_CLASSES:
   File "C:\\Python27\\lib\\site-packages\\django\\utils\\functional.py", line 272, in __getattr__
     self._setup()
   File "C:\\Python27\\lib\\site-packages\\django\\conf\\__init__.py", line 40, in _setup
     self._wrapped = Settings(settings_module)
   File "C:\\Python27\\lib\\site-packages\\django\\conf\\__init__.py", line 75, in __init__
     raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
 ImportError: Could not import settings 'cbc_website.settings' (Is it on sys.path? Does it have syntax errors?): No module named cbc_website.settings
dukebody

Python is interpreting your '\' in the path definitions as an escape character. https://docs.python.org/2/reference/lexical_analysis.html#string-literals

Use r'path' when specifying a literal path with backslashes. So instead of:

sys.path.append('C:\\\something')

You specify:

sys.path.append(r'C:\\\something')

in your wsgi.py file.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Internal 500 error with Django: trying to set up mod_wsgi

Trying to set up flask with mod_wsgi

Django with mod_wsgi how to set PYTHONHASHSEED env variable?

Is there a way to pass options values during mod_wsgi server start up in Django app

Django, apache and mod_wsgi

Apache, Django and mod_wsgi

Apache + mod_wsgi + flask app: doing graceful restart due to receiving SIGUSR1 signal

mod_wsgi shared library is over 1MB using pyenv

FreeBSD: How to install Django with mod_wsgi?

multiple django sites with apache & mod_wsgi

Setup Django with apache using mod_wsgi

Django apache configuration with mod_wsgi module

apache mod_wsgi error with django in virtualenv

Django and mod_wsgi python versions?

Deploying django(python) project with mod_wsgi

Deploying Django on Apache with mod_wsgi

mod_wsgi: Exception occurred processing WSGI script (django deployment)

Django (mod_wsgi) Exception occurred processing WSGI script

pip install mod_wsgi, How to Set MOD_WSGI_APACHE_ROOTDIR environment?

Asking for advice on Django deployment settings with Apache and mod_wsgi

Gateway Timeout Using Django on Apache with mod_wsgi

Django + mod_wsgi + apache2: server hangs

Apache with virtualenv and mod_wsgi : ImportError : No module named 'django'

Cannot deploy Official Django tutorial on Apache (mod_wsgi)

Django Custom Error Handlers in Apache and mod_wsgi

Django on Apache with mod_wsgi CSRF Verification Failed

Django on apache wtih mod_wsgi (Linux) - 403 Forbidden

Deploying django3 project with mod_wsgi

Django: Wrong permissions for created SOCK file using mod_wsgi