Configure STATIC_URL and STATICFILES_DIRS
A snippet showing how to configure Django static files in settings.py.
# settings.py
STATIC_URL = '/static/'
STATICFILES_DIRS = [BASE_DIR / "static"]
# production
STATIC_ROOT = BASE_DIR / "staticfiles"
Explanation:
-
STATIC_URLdefines the URL prefix for static files.
STATICFILES_DIRS lists additional static folders.
STATIC_ROOT is used for collectstatic in production.
- Category Static & Media Files
- Total Views 477
- Last Modified 12 April, 2026
- Tags #static #files #settings #django
Previous snippet
Continuous Integration with Tests
Next snippet