Django static files get from wrong url

I am migrating an old Django 2.2 project to Django 3.2. I use AWS Cloudfront and S3.

I have done most of the tasks to do. But i have something weird in my static files serving. When 'static' template tag is called, the rendered url is "https//<cloudfront_url>/static.." instead of "https://<cloudfront_url>/static..". The comma disapears ! It obviously results to a 404 not found. It worked without any problem on Django2.2. So for the moment i dirty patched this by doing a '.replace("https//", "https://")' on django static template tag.

My settings relatives to static files are :

AWS_CLOUDFRONT_DOMAIN = <idcloudfront>
STATICFILES_STORAGE = 'app.custom_storages.StaticStorage'

class StaticStorage(S3Boto3Storage):
    location = settings.STATICFILES_LOCATION
    bucket_name = settings.AWS_STORAGE_STATIC_BUCKET_NAME

    def __init__(self, *args, **kwargs):
        kwargs['custom_domain'] = settings.AWS_CLOUDFRONT_DOMAIN
        super(StaticStorage, self).__init__(*args, **kwargs)```
Back to Top