Rami Santina
Rami Santina

Reputation: 1

CommandError: An error occurred during rendering: This backend doesn't support absolute paths

Getting **CommandError: An error occurred during rendering app/relative-path/to/page.html: This backend doesn't support absolute paths. ** While updating to django-comressor 4.5 and Django 5.0.6

STORAGES = {
        "default": {
            "BACKEND": 'app.storage_backends.MediaStorage',
        },
        "staticfiles": {
            "BACKEND": 'app.storage_backends.CachedS3Boto3Storage',
        },
        "compressor": {
            "BACKEND": 'app.storage_backends.CachedS3Boto3Storage',
        }
    }

and

AWS_ACCESS_KEY_ID = 'xxxx'
AWS_SECRET_ACCESS_KEY = 'xxxx'
AWS_STORAGE_BUCKET_NAME = 'xxxx'
AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
AWS_DEFAULT_ACL = None
AWS_BUCKET_ACL = 'public-read'
AWS_LOCATION = 'static'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION)
COMPRESS_ROOT = STATIC_ROOT
COMPRESS_URL = STATIC_URL

and

class CachedS3Boto3Storage(S3Boto3Storage):
    location = settings.AWS_LOCATION
    default_acl = 'public-read'
    file_overwrite = True
    preload_metadata = True
    """
    S3 storage backend that saves the files locally, too.
    """
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.local_storage = storages.create_storage({
            "BACKEND": "compressor.storage.CompressorFileStorage"
        })

    def save(self, name, content):
        self.local_storage.save(name, content)
        super().save(name, self.local_storage._open(name))
        return name

Any idea how to resolve this, the above follows the documentation of djnago-compressor

Tried all options with and without STORAGES settings

Upvotes: 0

Views: 38

Answers (0)

Related Questions