Confusion in static settings of Django
27 May ’13
There are some not crystal clear points at the settings of static files documentation in Django.
STATIC_URLproperty is the easiest one to differ from other settings. We just need to define a url from where we would serve static files. This can be
/static/if files will be served with the same machine on which web server runs, not recommended though. S3 of Amazon provides pretty cheap storage so
"https://" + YOUR_BUCKET + ".s3.amazonaws.com/"may be perfectly appropriate for an industry standard website. By the way, it is better to note that S3 isn't a CDN so it should not be used as a CDN.
STATICFILES_FINDERSspecifies the classes that are capable of finding of static files. For example,
AppDirectoriesFindersearches app directories for a
STATICFILES_DIRSis the list of directories where we could also put other static files. This setting is related to
FileSystemFinderbecause if it is added, it'll be able to collect files from specified directories written in this setting.
STATIC_ROOTis the absolute path of the directory where all static files will be collected for production, i.e the place where
collectstaticcollects files to. This setting must be different than
STATICFILES_DIRSand likely outside of the project tree because it has nothing to do with the project itself. When
runserveris executed and
debugis set to true,
collectstaticis automatically executed at background. That's why we can't see difference easily. However, in production, that's not the case. For example,
assetsinside of the project folder but
assetsand all other static files, i.e that come from apps, only when
I hope that the clarification between
STATIC_ROOT helps someone.