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?
Asked
Active
Viewed 1,111 times
9

Kurtis Nusbaum
- 30,445
- 13
- 78
- 102
1 Answers
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
-
I installed python-dateutil==2.1 with django-storages==1.1.8 and it works too. Thanks! – Garth Humphreys Jul 03 '13 at 03:35
-
Does not work for me with `python-dateutil==2.5.3` and `django-storages==1.5.2` – scythargon Dec 16 '19 at 10:18