From this answer,
collectstatic
is a ready-made script that prepares this directory for you, so that you can connect it directly to your deployment script.
After running the collectstatic
command, all static files in my apps are copied to a static
folder in the root of my project.
Can I delete the static
folder in my apps? Since they are copied already. I kind of felt like it's just duplicating and costing me file size or am I missing something?
I deleted the static
folder in my apps but it does not work anymore. Why duplicating my static files then or can I delete them after going live?
When you run collectstatic, Django collects all statics files in all apps and put in into a designated folder for static files. This is much for suitable for deployment, on Apache or Nginx for example because they know where to looks for static files. Any extra static files (that don’t belong to any app, can be put into this folder as well).
Yes, in production you can delete the static files in each apps if you worry about disk storage. But if your files are that huge, look into solutions of serving your static files from S3 or Azure Blob Storage.
Also, if DEBUG mode is on, Django will serve static files from apps folders. If off, it will look for statics file from statics folder.