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?
collectstatic. Collects the static files into STATIC_ROOT . Duplicate file names are by default resolved in a similar way to how template resolution works: the file that is first found in one of the specified locations will be used. If you're confused, the findstatic command can help show you which files are found.
STATIC_URL is simply the prefix or url that is prepended to your static files and is used by the static method in Django templates mostly. For more info, read this. STATIC_ROOT is the directory or location where your static files are deployed when you run collectstatic .
So django by default overwrites your modified files on collectstatic command, --noinput flag means it will not ask for your permission. Follow this answer to receive notifications. answered Mar 17, 2021 at 19:28.
The {% static %} template tag generates the absolute URL of static files. That's all you need to do for development. Reload http://localhost:8000/polls/ and you should see that the question links are green (Django style!) which means that your stylesheet was properly loaded.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With