djangodeploymentdjango-staticfilesstatic-files

Why do I need to define both STATIC_URL and STATICFILES_DIRS?


If I define only one, the page displays without any CSS/JS. If I define both, the pages load fine. Why is that? I thought STATICFILES_DIRS is extraneous?

There's an answer here, but it doesn't answer why I need both. It simply says what both do, which in my eyes is the same thing.

What's the difference?


Solution

  • From what I have scoured on StackOverflow, I think I can sum it up as follows:

    STATIC_ROOT is referenced as the static server, be it the default Django static server or the static server made on Heroku/etc. You point to this in urls.py

    STATICFILES_DIR is referencing the stuff within static assets so if there are separate folders, one for CSS, one for JS, etc.

    Feel free to add!