Django collectstatic AWS S3

2

I have a question regarding collectstatic . I'm using Amazon Free Tier and realized that I've exceeded the S3 PUT usage limit because I made several collectstatic . I was developing one day in the Amazon environment due to laziness and every change in the JS I made, as I did not know how to do collectstatic of 1 file, I did general.

The most efficient way for small editions is to do collectstatic -i folder/file.png (in the specific file or folder) or do I need to do general? How can I not overwrite S3 uploads?

I know that I hesitated doing several collectstatic in "production" environment. But do I need to make all files always?

    
asked by anonymous 13.07.2017 / 21:57

1 answer

1

The correct thing is to send only what you have changed, it does not make sense to send 100MB of files to S3 if you changed only 1 file of 10Kb.

I usually organize my directories well, for example:

  • static / img /
  • static / videos /
  • static / videos / homepage

When running collecstatic, ignore all directories you have not changed, including 'admin'. If the file you changed is in a directory with many other files, you can ignore extensions as well.

In my fabfile I usually create a dictionary with the directory tree of my static, and in it I inform which will be ignored or not, example:

ignore = {
    'app': {
        'img': None
    }
}

You can create logic and organize as you wish, in my project I did something simpler. The idea is to ignore the parent directory, or specifically specify child directories.

    
15.07.2017 / 21:19