【问题标题】:Apache 2: TemplateSyntaxError: Caught ImportError while rendering: No module named aboutApache 2: TemplateSyntaxError: Caught ImportError while rendering: No module named about
【发布时间】:2012-09-13 15:35:58
【问题描述】:

这是我的 wsgi 文件的内容:

import os
import sys

# put virtual environment on sys.path
sys.path.append("/check/www/pyapps/lib/python2.7/site-packages")

# put the Django project on sys.path
#sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")))
sys.path.append("/check/www/")
sys.path.append("/check/www/textpisodes")

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

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

我创建了一个基本的 pinax 帐户项目,并试图使其与 apache 和 mod_wsgi 一起使用。但我得到的只是TemplateSyntaxError: Caught ImportError while rendering: No module named about。我做错了什么?

【问题讨论】:

  • 在我们的 django 应用设置中是否有“关于”应用?
  • 是的。Pinax 会自动创建它

标签: django apache mod-wsgi


【解决方案1】:

您可以使用我网站上的此代码。希望能帮到你!

#!/usr/bin/python
import os, site, sys

# add the virtual environment path
site.addsitedir('/home/admin/webapps/djangotest/env/lib/python2.7/site-packages') # if you are using virtualenv
site.addsitedir('/home/admin/webapps/djangotest/django_project')
site.addsitedir('/home/admin/webapps/djangotest')

# fix markdown.py (and potentially others) using stdout
sys.stdout = sys.stderr

#Calculate the path based on the location of the WSGI script.
project = os.path.dirname(__file__)
workspace = os.path.dirname(project)
sys.path.append(workspace)

os.environ['PYTHON_EGG_CACHE'] = '/tmp'
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_project.settings'
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-23
    • 2016-12-19
    • 1970-01-01
    • 2017-02-10
    • 1970-01-01
    • 2015-09-10
    相关资源
    最近更新 更多