0

I'm using django-pipeline + django-storage and an S3 backend, but I'm going crazy trying to load my static files properly using {% static %} tag. I read and followed the pipeline docs: http://django-pipeline.readthedocs.org/en/latest/storages.html#using-with-other-storages

And I created the following mixed class:

from django.contrib.staticfiles.storage import CachedFilesMixin

from pipeline.storage import PipelineMixin

from storages.backends.s3boto import S3BotoStorage


class S3PipelineStorage(PipelineMixin, CachedFilesMixin, S3BotoStorage):
    pass

in my production settings file I have:

AWS_QUERYSTRING_AUTH = False
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATICFILES_STORAGE = 'myapp.S3PipelineStorage'
AWS_ACCESS_KEY_ID = 'xxx'
AWS_SECRET_ACCESS_KEY = 'xxx
AWS_STORAGE_BUCKET_NAME = 'mybucket'
from datetime import datetime, timedelta
AWS_HEADERS = {
    'Expires': (datetime.now() + timedelta(days=365*10)).strftime('%a, %d %b %Y 00:00:00 GMT')
}
STATIC_URL = 'https://mybucket.s3.amazonaws.com/'
STATIC_ROOT = ''

When I run collectstatic using these settings, all works as it should, but by using:

{% static 'path/file.xxx' %}

I get an URL containing the querystring auth, despite I set False in AWS_QUERYSTRING_AUTH and thus my static files are not loaded… By removing that querystring I can load them propaerly. I also tryed to set "querystring_auth = False" in myapp.S3PipelineStorage, but it seems to being ignored :(

Why settings are not respected? What could be an effective solution to remove that qs? (I'm thinking about a custom filter to strip it away… but I hate to write such "patch") …and finally, in case I have to keep that authentication query string, why is not working? How can I debug this behavior?

EDIT: it works… it was a problem related with caching :|

daveoncode
  • 18,900
  • 15
  • 104
  • 159

1 Answers1

0

Look at this answer. Maybe this is matter of order (e.g. django-storages overrides your settings). Maybe try to set per-bucket?

Community
  • 1
  • 1
eran
  • 6,731
  • 6
  • 35
  • 52
  • I already seen that answer, but honestly I'm unable to fix my problem… I mean, I'm not initializing an instance of S3BotoStorage by myself… so what should I do? (currently I tried also to import "storages" app after pipeline and to move AWS_QUERYSTRING_AUTH, but it's not working anyway) – daveoncode Feb 02 '14 at 20:04