DEBUG=False下,static静态文件引用方法
问题特征:
django网站中的静态文件CSS、Image在本地服务器使用runserver指令可以完美加载,部署到IIS上后CSS失效、静态文件消失的问题
方法来源:
解决步骤:
①在项目的具体app路径下的static文件夹(settings中STATIC_URL指定的目录),新建web.config文件,注意不要弄错目录,是app中存放静态文件的目录下
web.config内容如下:
- <?xml version="1.0" encoding="UTF-8"?>
- <configuration>
- <system.webServer>
- <!-- this configuration overrides the FastCGI handler to let IIS serve the static files -->
- <handlers>
- <clear/>
- <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
- </handlers>
- </system.webServer>
- </configuration>
③ 填写虚拟路径的别名和路径,别名一般为static,路径则是该网页app下的static文件夹,也就是刚才创建web.config的文件夹
⑤ 重新运行一下IIS,应该就没有问题了
转自:http://blog.****.net/qq_18075613/article/details/56970016