Apache mod-wsgi django problem -
i got error messages while trying deploy django app under mod-wsgi in apache.
[thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] mod_wsgi (pid=4152): exception occurred processing wsgi script 'c:/djangoprojects/tryserver/apache/django.wsgi'. [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] traceback (most recent call last): [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] file "c:\\python27\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 250, in __call__ [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] self.load_middleware() [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] file "c:\\python27\\lib\\site- packages\\django\\core\\handlers\\base.py", line 39, in load_middleware [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] middleware_path in settings.middleware_classes: [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] file "c:\\python27\\lib\\site-packages\\django\\utils\\functional.py", line 276, in __getattr__ [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] self._setup() [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] file "c:\\python27\\lib\\site-packages\\django\\conf\\__init__.py", line 42, in _setup [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] self._wrapped = settings(settings_module) [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] file "c:\\python27\\lib\\site-packages\\django\\conf\\__init__.py", line 87, in __init__ [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] mod = importlib.import_module(self.settings_module) [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] file "c:\\python27\\lib\\site-packages\\django\\utils\\importlib.py", line 28, in import_module [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] raise typeerror("relative imports require 'package' argument") [thu jun 30 23:03:35 2011] [error] [client 127.0.0.1] typeerror: relative imports require 'package' argument
this django.wsgi , in proper location.
import os import sys os.environ['django_settings_module'] = '../tryserver/tryserver.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.wsgihandler()
what problem ?
thanks
your problem is:
os.environ['django_settings_module'] = '../tryserver/tryserver.settings'
django_settings_module needs importable python module contains settings. django going import ../tryserver/tryserver.settings
current django.wsgi
the best fix trying add tryserver directory python path. assuming directory layout looks like:
./ tryserver/ tryserver/ settings.py deploy/ django.wsgi
then in django.wsgi like:
import os import sys sys.path = sys.path + ["/path/to/tryserver/"] # first 1 os.environ['django_settings_module'] = 'tryserver.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.wsgihandler()
Comments
Post a Comment