Django-MEDIA_ROOT和MEDIA_URL [英] Django - MEDIA_ROOT and MEDIA_URL

查看:136
本文介绍了Django-MEDIA_ROOT和MEDIA_URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否请您向我推荐一份很好的文档,使我可以理解MEDIA_URL和MEDIA_ROOT?

Could you please suggest me the good documentation where I can understand the MEDIA_URL and MEDIA_ROOT? It's really confusing me.

推荐答案

MEDIA_ROOT 是路径在文件系统上到包含您的静态媒体的目录。

The MEDIA_ROOT is the path on the filesystem to the directory containing your static media.

MEDIA_URL 是该URL

文档: http://docs.djangoproject.com/en/1.2/ref/settings/#media-root

主要思想是通过python + django提供服务的成本很高。由于您的媒体是静态的,因此您无需支付该费用,因此您可以采用不同的方式(例如,直接通过nginx或CDN)进行投放。但是,您仍然需要知道媒体在文件系统中的位置(例如,用于文件上传)以及URL是什么(例如,放置在模板中)。这些设置可以将所有内容捆绑在一起。

The main idea is that serving things through python+django is expensive. Since your media is static you don't need to pay that cost, so you serve it differently (e.g. directly via nginx or through a CDN). However, you still need to know where the media is located in the file system (e.g. for file uploads) and what the URL is (e.g. to put in templates). The settings exist to tie all that together.

这篇关于Django-MEDIA_ROOT和MEDIA_URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆