# Differences between STATICFILES_DIR, STATIC_ROOT and MEDIA_ROOT
To understand the difference, it is necessary to figure out what these three constants are for.
In this article, You will learn about STATICFILES_DIR, STATIC_ROOT and MEDIA_ROOT.
1.) STATICFILES_DIRS :
Need to be used in the development mode. Static files are usually placed in two places:
The static directory under each app.
The static directory under the project root directory (because some static files are not unique to an app).
# BASE_DIR is the absolute address of the project
STATIC_ROOT = os.path.join(BASE_DIR, 'xxxxxx')
STATICFILES_DIRS tells django to first look for static files in STATICFILES_DIRS, and then go to the static folder of each app.
Note : django finds static files as lazy lookups. When you find the first one, it stops looking up.
2.) STATIC_ROOT :
# BASE_DIR is the absolute address of the project
STATIC_ROOT = os.path.join(BASE_DIR, 'xxxxxx')
This constant is not used in development mode and will be used during deployment.
Python manage.py collectstatic when deploying, django will copy the static files of all apps to the STATIC_ROOT folder.
3.) STATIC_URL :
Django uses STATIC_URL to give browsers direct access to static files
STATIC_URL = '/static/'
So if your project root / static / there is a 123.png image.
Then you can go directly through the browserhttp://IP: port number / static / 123.png to access your picture
Comments