Search code examples
djangostatic-filescollectstatic

Does Django's collectstatic command double the space used in production?


I understand that collectstatic command copies static-files found in different Django apps of the Django project to a defined single path so that webserver can easly serve files.

Here is what question me:

For example, I have many big static-files in several apps and I push my Django project to production. I run collectstatic. The static-files will be copied to project static folder. It means that the static-files are now in two different locations so use twice the storage isn't it?

I probably miss a point somewhere in the production deployment process because it doesn't feel right to me in term of storage space.


Solution

  • I believe it does, and this is intended behavior. How large your files are? Git itself (presuming you use it) is not well-suited to store large files, I would suggest offloading those files into external services like S3. If this is not an option, storage should not be a big issue nowadays - it's pretty cheap, I would worry more about bandwidth and deploy time to copy those assets.

    P.S. You could move files instead of copying them with the custom collectstatic command, if that's worth the hassle for you. Extend the default collectstatic.Command and provide a new copy_file implementation.