[英]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.