Home>

I'm studying Django here.
"Super Primer" The first web application made with Django Part6 (Data acquisition, detail page)

static folder and madia folder,
I didn't like having two image folders
Images uploaded by users
I changed it as follows so that it will be uploaded to the static folder and it worked normally.

blog/blog/settings.py

MEDIA_ROOT = os.path.join (BASE_DIR,'blog_app/static')
MEDIA_URL ='/ media /'

Existing image files are static folders
Images uploaded by the user are in the madia folder
What is the reason for separating them?

I also don't know why STATIC_URL and MEDIA_URL are created separately

Django 1.3: MEDIA_URL vs. STATIC_URL-Stack Overflow
It seems that there is no particular reason to create a madea folder or MEDIA_URL on this site ...

  • Answer # 1

    I'm sorry I'm not familiar with it, but I looked it up.
    Deployment Checklist | Django Documentation

    STATIC_ROOTPlaces static files provided by the developer
    MEDIA_ROOTPlaces files uploaded by users

    It seems to assume that.

  • Answer # 2

    I found a URL that seems to be helpful, so I will post it instead of a memo

    [Django] How to use the file upload function [Basic settings]