9

I'm using amazon s3 to store all of my static files (via django-storages) and it costs a lot more money to do PUTs than it does GETs. When I run manage.py collectstatic, Django does a PUT for every single static file I have. Is there a way to have it check first to see if the file has changed at all, and if it hasn't don't bother with the PUT?

Kurtis Nusbaum
  • 30,445
  • 13
  • 78
  • 102

1 Answers1

13

It appears that all you need to do is install python-dateutil:

pip install python-dateutil==1.2

Without this django-storages won't check the dates because of this code:

def modified_time(self, name):
  try:
    from dateutil import parser, tz
  except ImportError:
    raise NotImplementedError()

The modified_time throws an error but django just keeps going because it allows the modified_time method of a storage subclass to be unimplemented. I understand why they do it, because this functionality isn't strictly needed. That said, it'd be nice to have some sort of warning saying why EVERYTHING is being uploaded.

Note that I'm using python-dateutil version 1.2. If you use the most latest version of dateutil, you'll get an error with django-storages (that is django-storages version 1.1.4).

Kurtis Nusbaum
  • 30,445
  • 13
  • 78
  • 102