[Fixed]-Why use Django's collectstatic instead of just serving the files directly from your static directory?

25👍

Why not just serve your static directory? You might use more than one app, and some of your apps may not be under your control. Before the staticfiles app existed, you then had to either manually copy the static files for all apps to a common directory, upload them to your CDN, or symlink them to the document root of your web server.

The staticfiles app established a convention: put static files for each app under a static directory and let Django do the work for you.

👤sk1p

12👍

The STATIC_ROOT can be on a different machine than the application, so copying your static files to the static root means that you can serve your static files from a different server (CDN FTW!) which you wouldn’t be able to do if those files where only located within their respective app directories.

Leave a comment