How do I modify sys.path from .htaccess to allow mod_python to see Django?

半世苍凉 提交于 2019-12-09 18:42:11

问题


The host I'm considering for hosting a Django site has mod_python installed, but does not have Django. Django's INSTALL file indicates that I can simply copy the django directory to Python's site-packages directory to install Django, so I suspect that it might be possible to configure Python / mod_python to look for it elsewhere (namely my user space) by modifying sys.path, but I don't know how to change it from .htaccess or mod_python.

How do I modify sys.path from .htaccess to allow mod_python to see Django?

P.S. I can only access the site via FTP (i.e. no shell access). I realize that it sounds like I should just switch hosts, but there are compelling reasons for me to make this work so I'm at least going to try.


回答1:


According to ticket #2255 for Django, you need admin access to httpd.conf in order to use Django with mod_python, and this is not going to change, so you may be dead in the water. To answer the basic question of how to modify sys.path from .htaccess, you can use the PythonPath directive in .htaccess.




回答2:


Is the PythonPath setting what you are looking for? I haven't tried it with Django, but I would assume that it should do the job for you.




回答3:


You're using mod_python wrong. It was never intended to serve python web applications. You should be using WSGI for this... or at least FastCGI.



来源:https://stackoverflow.com/questions/764312/how-do-i-modify-sys-path-from-htaccess-to-allow-mod-python-to-see-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!