Django deployment issue in Apache / mod_wsgi. ImportError: Failed to import 'site.settings' settings

When i do

django-admin.py startproject site 

it works.
But if I only copy the site folder, it does not work.
Why?

 <VirtualHost *:80> ServerName django.stanislavfeldman.com # Django settings WSGIScriptAlias / /var/www/django/wsgi_handler.py WSGIDaemonProcess django.stanislavfeldman.com maximum-requests=200 stack-size=524288 ErrorLog /var/www/django/error.log LogLevel warn </VirtualHost> 

wsgi_handler.py:

 import os, sys sys.path.append('/var/www/django') os.environ['DJANGO_SETTINGS_MODULE'] = 'site.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() 
+7
python django
Dec 16 '10 at 15:15
source share
5 answers

Make sure you read:

http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

and also see this presentation:

http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations

Your issue will be the issue of sys.path or permissions, which are both covered above.

What do you use in the WSGIDaemonProcess settings with the parameters 'maximum-requests = 200 stack-size = 524288', asks if you are referring to the main documentation as basic instructions, do not say that you use them. Instead, it looks like you were using some kind of arbitrary blog post on how to set it up, or relying on some kind of folklore provided to you on the IRC channel. :-)

+4
Dec 16 '10 at 20:38
source share

If you have something like this in apache configurations:

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

And this is inside your_project.wsgi:

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

Then apache will search for /base/path/devel/settings.py. If you move or copy / base / path / devel to / base / path / production, you need to edit DJANGO_SETTINGS_MODULE on your_project.wsgi page, pointing to "production.settings".

+6
Dec 16 '10 at 15:24
source share

Check your python path to make sure WSGI can reference it.

+1
Dec 16 '10 at 15:18
source share

I had a problem with the lack of a link to a symbolic link from the site-packages directory. Double check apache configuration and symlinks.

+1
Jan 19 2018-11-21T00:
source share

This is not a problem in your case, but I encountered the same ImportError when I used the WSGIPythonPath directive (instead of the .wsgi file) to configure sys.path . This worked fine until I switched to starting WSGI in daemon mode. Once you do this, you should use the python-path argument to the WSGIDaemonProcess directive.

0
Jan 04 '12 at 5:11
source share



All Articles