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_URL defines 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
    Never miss a story on Django.wiki

    Subscribe for fresh tutorials, snippets, and updates.

    By subscribing you agree to our Privacy Policy.