'StaticFiles vs MediaFiles [duplicate]

What is the difference between static files and media files? Django says that the SATIC_ROOT and MEDIA_ROOT must be different. I just know that in static folder we can have css files and images or other files to be uploaded goes to media folder. I have directory as

static

|-->images

|-->css

in settings.py >>

STATIC_URL = 'static/'

STATICFILES_DIRS = [ BASE_DIR / 'static' ]

MEDIA_URL = '/images/'

MEDIA_ROOT = os.path.join(BASE_DIR, 'static/images')


Is the ROOT and URL for static and media files are okay or not?



Solution 1:[1]

  • MEDIA_ROOT is the folder where files uploaded using FileField will go.

  • STATIC_ROOT is the folder where static files will be stored after using manage.py collectstatic

  • We generally use STATIC_ROOT in production

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tariq Ahmed