10

I am using Amazon S3 bucket to store my static files. And I have compressor app in Django to compress all the static files. Django gives me error:

'home_page/css/bootstrap.min.css' isn't accessible via COMPRESS_URL ('https://alphagravel.s3.amazonaws.com/static/') and can't be compressed

Same you can check here: http://52.5.32.9/

But: URL - 'https://alphagravel.s3.amazonaws.com/static/home_page/css/bootstrap.min.css' is accessible

Here is my setting.py snapshot """

INSTALLED_APPS = (
    ...
    'storages',
    'compressor',
    '...
)
AWS_ACCESS_KEY_ID = '****'
AWS_SECRET_ACCESS_KEY = '***********'
AWS_QUERYSTRING_AUTH = False

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

AWS_STORAGE_BUCKET_NAME = 'alphagravel'
AWS_PRELOAD_METADATA = True

STATIC_URL = 'https://alphagravel.s3.amazonaws.com/static/'
ADMIN_MEDIA_PREFIX = 'https://s3-us-west-2.amazonaws.com/alphagravel/admin/'

COMPRESS_ROOT = STATIC_URL
COMPRESS_URL = STATIC_URL
COMPRESS_STORAGE = STATICFILES_STORAGE
COMPRESS_ENABLED = True
COMPRESS_OFFLINE_MANIFEST = "manifest.json" # Is created in CACHE directory
COMPRESS_PARSER = 'compressor.parser.HtmlParser'
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
)

Can anyone tell me that why compressor URL is not able to find static files for compression. And how to resolve the error.

Also, on commandline: on executing command python manage.py compress --force I get following error:

CommandError: An error occured during rendering /var/www/alphagravel/dashboard/templates/header.html: 'css/bootstrap.min.css' could not be found in the COMPRESS_ROOT '/var/www/alphagravel/https:/alphagravel.s3.amazonaws.com/static' or with staticfiles.

1
  • What is your ALLOWED_HOSTS setting? Commented Feb 16, 2016 at 15:18

2 Answers 2

1

I had the same problem and the error was rather silly- the static files were being accessed via https but the compress files were being accessed via http.

You've set your COMPRESS_URL to your STATIC_URL with https, but the actual file path is relative, so I'm guessing it will be accessed via http if your site is accessed via http as well?

PS- You seem to have solved the problem. Was it this?

Sign up to request clarification or add additional context in comments.

1 Comment

No the problem is not yet solved, I am using Amazon S3 bucket an it is accessed by HTTPS: only.
0

Some another variant of the problem "UncompressableFileError":

Error: 
'js/jquery-3.3.1.min.js ' could not be found in the COMPRESS_ROOT '/home/project/app/static' or with staticfiles.

Answer: The problem is that you have a space at the end of your href, between %} and ".
The original answer.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.