Last Updated: February 25, 2016
·
568
· scott2b

Set STATIC_ROOT to SOMETHING

Somewhere along the line, the Django dev community forgot that explicit is better than implicit.

With regard to Django's collectstatic feature, and the STATIC ROOT setting, the default value of STATIC_ROOT = '' (the empty string) is just a bad idea. If you run collectstatic with this default setting, all of your static files will be collected into your project root. What a nightmare.

So, even if you are not generally using collectstatic, it is best to have STATIC_ROOT set to something rather than nothing, just in case someone comes along and does run collectstatic.

I am currently experimenting with STATIC_ROOT='/dev/null'. Then, when I run collectstatic, I get a nice:

IOError: /dev/null exists and is not a directory.

Which (a) tells me I am trying to do something dumb, and (b) doesn't leave me with a mess to clean up.