This article describes how to use the same Apache instance to run Django and Media files. Django is the most popular Pythonweb development framework, if you need media files, you can refer to Django which does not need to serve media files. leave this work to the network server you choose. We recommend that you use a separate network server (that is, one that does not run Django) to serve media. For more information, see the following section.
However, if you have no other options, you can only serve media files on Apache VirtualHost like Django. here you can disable mod_python for specific parts of this site:
SetHandler None
将 Location 改成你的media文件所处的根目录。
你也可以使用 来匹配正则表达式。 比如,下面的写法将Django定义到网站的根目录,并且显式地将 media 子目录以及任何以 .jpg , .gif , 或者 .png 结尾的URL屏蔽掉:
SetHandler python-program PythonHandler django. core. handlers. modpython SetEnv DJANGO_SETTINGS_MODULE mysite. settings
SetHandler None
SetHandler None
在所有这些例子中,你必须设置 DocumentRoot ,这样apache才能知道你存放静态文件的位