This question is a bit old, but if it helps someone in the future, I decided that I would share my experience. Following the tips outlined in other topics, I confirmed that for me this was due to the difference in time zone. My django time was not wrong, but it was set to EST and S3 to GMT. When testing, I returned to django repositories 1.1.5, which seemed to work collectively. Partly due to personal preferences, I didnโt want to: roll back three versions of django repositories and lose any possible bug fixes or b) change the time zones for the components of my project, which basically comes down to the convenience function (although one is important).
I wrote a short script to do the same work as collectstatic without the above changes. This will require a little modification for your application, but should work for standard cases if it is hosted at the application level and "static_dirs" is replaced with the names of your project applications. It runs through a terminal with the name "python whatever_you_call_it.py -e environment_name" (install this in your aws file).
import sys, os, subprocess import boto3 import botocore from boto3.session import Session import argparse import os.path, time from datetime import datetime, timedelta import pytz utc = pytz.UTC DEV_BUCKET_NAME = 'dev-homfield-media-root' PROD_BUCKET_NAME = 'homfield-media-root' static_dirs = ['accounts', 'messaging', 'payments', 'search', 'sitewide'] def main(): try: parser = argparse.ArgumentParser(description='Homfield Collectstatic. Our version of collectstatic to fix django-storages bug.\n') parser.add_argument('-e', '--environment', type=str, required=True, help='Name of environment (dev/prod)') args = parser.parse_args() vargs = vars(args) if vargs['environment'] == 'dev': selected_bucket = DEV_BUCKET_NAME print "\nAre you sure? You're about to push to the DEV bucket. (Y/n)" elif vargs['environment'] == 'prod': selected_bucket = PROD_BUCKET_NAME print "Are you sure? You're about to push to the PROD bucket. (Y/n)" else: raise ValueError acceptable = ['Y', 'y', 'N', 'n'] confirmation = raw_input().strip() while confirmation not in acceptable: print "That an invalid response. (Y/n)" confirmation = raw_input().strip() if confirmation == 'Y' or confirmation == 'y': run(selected_bucket) else: print "Collectstatic aborted." except Exception as e: print type(e) print "An error occured. S3 staticfiles may not have been updated." def run(bucket_name):
RyCSmith
source share