Django: static image file should be stored in git repository when using AWS cloudfront and S3?

581 views Asked by At

I developed my Django project with AWS cloudfront and S3.

I wonder whether static image file(not media file) should be stored in git repository.

I think that if I run collectstatic --settings="production.settings all static files seems to be uploaded on my S3.

If so, I think that I don't need to store all static image files in git repository.

Am I right?

1

There are 1 answers

4
Alexander Tyapkov On

In general yes. You can remove them from repository, because you have uploaded static files to S3

but...

Consider following scenario. Accidentally you will call collectstatic with clear option. All the static files will be removed from S3. Then you have to upload static files again into repository. Do you want it?

Also there is another reason why it is convenient to keep static files. If you are using S3, then you can save some money and time uploading only changed files into the bucket. For that you can use, for instance, collectfast. If you will delete files then collectfast won't be able to calculate md5 checksums and probably won't work at all.