I’m using s3 and S3Boto3Storage to host and manage my static files, including django admin’s files: #settings.py STATIC_URL = “``https://my-static-files.s3.eu-west-1/static/``” STORAGES = { “staticfiles”: { “BACKEND”: “storages.backends.s3boto3.S3Boto3Storage”, }, }
The bucket is not publicly accessible, unless the requested urls are presigned. S3Boto3Storage does this automatically in the context of the template renderer, which is great. However, the urls that are included in the css files are not presigned:
This results in requests to those urls being rejected:
If I understand your solution well, I’d be turning every css static file with included urls into templates? I’m ok with this but in that case is there a way to not do it manually but instead to have some kind of template processor, so it can be cross-django-versions safe? I’m not too familiar with that part of django, I’ll look into it.
The turning the public statics private is a new company policy. I could make my boss read that sentence and convince them this is stupid but I’d rather comply if possible.
I wouldn’t say every but some of them, that needs this processing yes.
I’m not saying that you should do the approaches that I’ve mentioned, rather that you can do them.
I also agree on this one:
In this case, I would try my best to explain to my boss that this decision doens’t make any sense, if you believe that some approach is not benefical and does nothing about it, then in the end you agreeing with the “madness” instead of fighting it.
In the end, you might get a direct order to do something in other way, but if you tried to do something against it, then at least you know that you’ve tried your best to do things on the way they should be.
Some of our static files are images that are company property and may only be displayed in certain contexts (django admin panel for instance). I placed them in another private storage and de-privated the public static storage. I think that covers the new requirements.