如何使用mod_wsgi和Django提供静态文件?

时间:2021-01-31 19:17:07

I would like to serve static plist files using mod_wsgi. In have configured apache as follows

我想使用mod_wsgi提供静态plist文件。在已配置apache如下

Alias /site_media/ "/var/www/mysite/media/"
<Directory "/var/www/mysite/media">
Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</Directory>

When I go to http://localhost/mysite/site_media/mac_config.plist I get the error

当我转到http://localhost/mysite/site_media/mac_config.plist时,我收到错误

Page not found (404)
Request Method: GET
Request URL:    http://localhost/mysite/site_media/mac_config.plist
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^config/
^admin/doc/
^admin/
The current URL, site_media/mac_config.plist, didn't match any of these.

This error is telling me that Django is intercepting the request. How is it possible to serve this static file without having to use python to read the file from disk and respond with an http request?

这个错误告诉我Django正在拦截请求。如何在不必使用python从磁盘读取文件并使用http请求进行响应的情况下提供此静态文件?

1 个解决方案

#1


1  

Just as @sdolan suggested, doing localhost/site_media/mac_config.plist corrected the problem.

就像@sdolan建议的那样,做localhost / site_media / mac_config.plist纠正了这个问题。

#1


1  

Just as @sdolan suggested, doing localhost/site_media/mac_config.plist corrected the problem.

就像@sdolan建议的那样,做localhost / site_media / mac_config.plist纠正了这个问题。