I am developing a web app based on django for a while. At the beginning, I just put all the static files such as css, js and some icons in one folder and served the folder as static files. While the project evolves, more and more apps added, and there are too many files stored in the folder.
Therefore, I would like to reorganize static files. What would be a good way? Should I classify files according to the apps they belong to or classify them by css, img, and js, or classify by apps first, and then by their types.
You could probably do a mix. Project wide templates and static files could be stored in one central location. And all the app related files would be stored in a dedicated static-subdirectory in each app’s folder.
If you use Django 1.3
contrib.staticfilesmakes this really easy.It even provides a handy
collectstaticcommand, that fetches the static files from all your apps and stores them in a central, configurable location, where you can serve them from.