我有win32,python2.5,django1.2,apache2.2和mod_python3.3.1
我已经正确安装了mod_python。 现在我的应用程序名称是myapp.setting,其路径是c:\ myapp.setting。在myapp.settings中,我的文件是myapp.settings \ url.py,settings.py等。
现在在apache httpd.conf文件中我有以下更改: -
<Location "/mysite">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE myapp.settings
PythonDebug On
PythonPath "['/'] + sys.path"
</Location>
我在PythonPath中尝试了很多更改。但是当我输入http://localhost/mysite时,错误如下: -
MOD_PYTHON ERROR
ProcessId: 1384
Interpreter: '192.168.1.166'
ServerName: '192.168.1.166'
DocumentRoot: 'C:/Program Files/Apache Software Foundation/Apache2.2/htdocs'
URI: '/mysite'
Location: '/mysite'
Directory: None
Filename: 'C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/mysite'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'django.core.handlers.modpython'
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\mod_python\importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "C:\Python25\Lib\site-packages\mod_python\importer.py", line 1229, in _process_target
result = _execute_target(config, req, object, arg)
File "C:\Python25\Lib\site-packages\mod_python\importer.py", line 1128, in _execute_target
result = object(arg)
File "C:\Python25\Lib\site-packages\django\core\handlers\modpython.py", line 228, in handler
return ModPythonHandler()(req)
File "C:\Python25\Lib\site-packages\django\core\handlers\modpython.py", line 191, in __call__
self.load_middleware()
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py", line 33, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:
File "C:\Python25\Lib\site-packages\django\utils\functional.py", line 276, in __getattr__
self._setup()
File "C:\Python25\Lib\site-packages\django\conf\__init__.py", line 40, in _setup
self._wrapped = Settings(settings_module)
File "C:\Python25\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 'myapp.settings' (Is it on sys.path? Does it have syntax errors?): No module named myapp.settings
请帮帮我,我是Django的新手......
答案 0 :(得分:2)
正如rebus在评论中所说,将你的项目称为'myapp.settings'是无稽之谈。它既不是应用程序(它是站点的组件),也不是设置文件。称之为合情合理的东西 - 如果你真的想不出什么,可以称之为'mysite'。
但是,最后,您不应该使用mod_python。改为使用mod_wsgi。