![](/img/trans.png)
[英]TypeError: 'module' object is not callable (+static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT))
[英]Is it possible to serve media files by Django on Production with static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
我想為我的應用程序使用非靜態圖像。 這意味着管理員將能夠上傳圖像(並創建文章)。 用戶將具有對文章的只讀訪問權限。
在這種情況下,可以在Production上使用函數static()來存儲和提供圖像嗎?
static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
還是我應該僅使用第三方資源來存儲/保存圖像?
答案碰巧很簡單:
功能
static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
根本無法與“ Debug = false”一起使用。
這就是為什么它不能在生產中使用的原因。 這是來自文檔的報價:
僅在給定前綴是本地(例如/ media /)而不是URL(例如http://media.example.com/ )的情況下,此幫助器功能僅在調試模式下起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.