开发者

Django: Moving from development server to deployment (Apache+mod_wsgi)

开发者 https://www.devze.com 2023-02-07 01:14 出处:网络
I\'m developing application on Django, and ready to move to deployment server. I\'m able to run a new django project on apache(I can see the welcome page).

I'm developing application on Django, and ready to move to deployment server. I'm able to run a new django project on apache(I can see the welcome page). However, when I copy my original project's files to apache project directory, I start getting errors. Here is a sample from apache/error.log.

[Wed Jan 26 19:22:08 2011] [error] [client 127.0.0.1] TemplateSyntaxError: Caught     ImportError while rendering: No module named charts
[Wed Jan 26 19:22:36 2011] [error] [client 127.0.0.1] mod_wsgi (pid=4670): Exception   occurred processing WSGI script '/srv/www/enpass/apache/django.wsgi'.
[Wed Jan 26 19:22:36 2011] [error] [client 127.0.0.1] Traceback (most recent call last):
[Wed Jan 26 19:22:36 2011] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 241, in __call__
[Wed Jan 26 19:22:36 2011] [error] [client 127.0.0.1]     response = self.get_response(request)
[Wed Jan 26 19:22:36 2011] [error] [client 127.0.0.1]   File 开发者_运维知识库"/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 141, in get_response

My django.wsgi file looks like

import os
import sys

path = '/srv/www'
if path not in sys.path:
    sys.path.insert(0, '/srv/www')

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

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

I've changed all the paths in files to suit the new directory structure, so I'm pretty sure thats not the problem. FIY, I followed the steps given in this tutorial http://blog.stannard.net.au/2010/12/11/installing-django-with-apache-and-mod_wsgi-on-ubuntu-10-04/


I figured it out myself. We need to add the project directory path to sys.path. The following code solved the problem in django.wsgi

path = '/srv/www/enpass'
if path not in sys.path:
    sys.path.append(path)


Looks like you are missing the charts module..

install pip

sudo easy_install pip

list packages

pip freeze

do the same on the development machine and look for a chart module, then install it on the production server with

sudo pip install <packagename>
0

精彩评论

暂无评论...
验证码 换一张
取 消