开发者

django MEDIA_ROOT

开发者 https://www.devze.com 2023-04-06 09:56 出处:网络
if i am setting up apache (PRODUCTION) to serve static files(js,css,jpg,pdf,mp4),should i set the variable MEDIA_ROOT in settings.py.

if i am setting up apache (PRODUCTION) to serve static files(js,css,jpg,pdf,mp4),should i set the variable MEDIA_ROOT in settings.py.

I mean a开发者_开发知识库nyways any thing matching /media/ will be served by apache not django.So what exactly is then the use of MEDIA_ROOT.In such an enviornment is there any purpose of MEDIA_URL except as a shortcut to /media/.Similarly whats the purpose of ADMIN_MEDIA_PREFIX other than as a shortcut.


Here

I got the answer to my question(as mentioned in my comment).I is was reviewing my stalkoverflow profile and I saw this question unanswered and unclosed.So have pasted the link as an answer once again.


Yes, because you need to tell Django where to the browser can find those files that are being served by Apache.


difference is MEDIA_ROOT indicates where you should put your static files, and MEDIA_URL is the relative path where those are being served.

in a production environement, MEDIA_* paths are (commonly, but it's not strict to follow) used to store application related static files (css, imgs and javascripts). For user uploaded content, it's good practice (but again, it's not a rule) to save them inside the STATIC path, so you can move/delete/dostuff with them without compromising your app

so basically, to answer your question (didn't see any question mark in your post, btw) MEDIA_ROOT is the absolute path on the server where the static files have to be stored.

Here you can find something about MEDIA_ROOT and MEDIA_URL

Here something about static files management with django

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号