Confusion in Django admin, static and media files

后端 未结 3 1709
别那么骄傲
别那么骄傲 2020-11-27 15:25

I\'m relatively new to Django (1.4) and I\'m having a hard time understanding the philosophy behind static, media, and admin files. The structure of the project is different

3条回答
  •  遥遥无期
    2020-11-27 16:08

    Static files are files needed by your applications that server can serve without modifications, like custom JS scripts, icons, applets, etc. The best way to use it is to place static files in a "static" folder in each of your app's folder. Like this, the test server will find them there, and if you deploy on a production server, you'll just have to run python manage.py collectstatic to copy them all in the root static folder defined in you settings.py

    Media files are those uploaded by the users of your applications, like avatar's pics, etc.

    Admin files are static files used by Django admin, django test server will just find them, but on production, you'll have to copy or link to this folder for the admin to actually work.

    Hope it helps you see things better...

提交回复
热议问题