Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django UncompressableFileError

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.

like image 862
Piyush Aggarwal Avatar asked Apr 30 '15 16:04

Piyush Aggarwal


1 Answers

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?

like image 186
kanu Avatar answered Oct 06 '22 18:10

kanu