Django collectstatic AWS S3

Asked

Viewed 89 times

2

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

The most efficient way in case of small edits is to make collectstatic -i folder/file.png (in the specific file or folder) or need to do general? How not to overload S3 submissions?

I know I wavered doing several collectstatic in "production" environment. But I need to make all the files always?

1 answer

1


The correct is for you to send only what you have changed, it makes no sense to send 100MB of files to S3 if you have only changed 1 10kb file.

I usually organize my directories well, example:

  • Static/img/
  • Static/videos/
  • Static/videos/homepage

When running collecstatic, ignore all directories you haven’t 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 the logic and organize as you please, in my project I made something simpler. The idea is to ignore the parent directory, or specifically indicate the child directories.

  • Cool guy, really cool. I don’t know how to ignore files. I already heard that only to organize the Timezone of the Settings already would solve because it would check the change schedules and only to climb what was modified. But it’s not happening to me. To tell you the truth only 1 time it worked, then it’s always going up all the files. Could you tell me where I create this ignore files? In my case I just wanted to move up mine /static/css/main.css and /static/js/main.js. Thank you!

  • I use fabric, you can see more information on this site http://www.fabfile.org, you run the command on the terminal that reads the file with the logic you set, and it performs the procedures. In my case I created a method def collecstatic that accesses my EC2 and runs the collectstatic with the list of ignored files that I set myself.

  • It’s strange not to work naturally. My S3 is set up for South America, and in another project it works well. It identifies the time of the file change and moves up only the ones that have been modified. Is there only this way even?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.