作者sean72 (.)
看板Python
標題[問題] django static file cashed
時間Sun Sep 27 07:31:50 2015
1
我修改static file之後 ex map.js
甚至我從static_root移除了map.js
瀏覽器卻還是顯示之前的map資訊
請問是誰(django dev server or web browser?) cach了這些static files?
2
每次修改static file之後都還要執行collectstatic
之後再跑runserver 這樣實在很麻煩
請問大家都是如何做static file修改?
3
即使我使用了{% load staticfiles %}
我是否仍然可以使用
<link rel="icon" href="../../map.js"> 這種方法來讀取static files?
4
collectstatic 這個app好用的地方在哪?
我看了這篇卻沒有感覺
http://0rz.tw/B8AWT
無論我有多少個app 我仍然要在每個html head裡面標明static file的位置
<script src="{% static 'js/map.js' %}"></script>
那跟我直接連去static file dir也是一樣的意思 不是嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 204.96.168.3
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1443310313.A.F57.html
→ Daishi: 1. 通常是browser,你可以重啟django看看結果是否一樣。 09/27 09:37
→ Daishi: collectstatic在開發環境下(DEBUG=False)的功能不大 09/27 09:42
→ Daishi: 如果正式環境會讓一台web server在前面負責直接提供static 09/27 09:46
→ Daishi: file而不透過django,這時就需要collectstatic來集中檔案 09/27 09:46
→ Daishi: 而當我們用另一台主機或CDN來提供這些檔案時,所屬的域名 09/27 09:49
→ Daishi: 如果你在template用的是{% static 'js/map.js' %}就只需要 09/27 09:50
→ Daishi: 更改STATIC_URL這個變數就好 09/27 09:51
→ Daishi: *所屬的域名可能不同 09/27 09:51
→ uranusjr: 你對 static files 的概念有誤, 感覺開發方法也有些問題 09/28 12:33
→ uranusjr: 建議找個正規的教學或課程來打基礎 09/28 12:33
推 ihcaoe: 回2,改static不用重跑runserver 09/30 21:17
→ ihcaoe: 回4,因為你用runserver而不是gunicorn,gunicorn有差 09/30 21:18