this is my first post and i was to highlight a problenm that i’ve struggled with for a whole day.
While configuring my django project by recovering the static files from an s3 bucket i’ve ended up with a problem, the url prefixed in fron of the static resources was generating without : after the protocol, like this:
<link rel="shortcut icon" type="image/png" href="https//django-examplebucketname.s3.amazonaws.com/static/images/favicon.png">
so at the css, js and all the other static resources were giving 404.
in the tamplate i had:
{% load static %}
and
the settings file instead was configured like that:
WS_ACCESS_KEY_ID = "myid"
AWS_SECRET_ACCESS_KEY = "mykey"
AWS_STORAGE_BUCKET_NAME = "django-examplebucketname"
AWS_S3_REGION_NAME = "my-region"
AWS_S3_CUSTOM_DOMAIN = "django-examplebucketname.s3.amazonaws.com"
AWS_S3_URL_PROTOCOL = "https"
AWS_S3_USE_SSL = True
AWS_S3_VERIFY = True
AWS_LOCATION = "static/"
STATIC_URL = "https://django-examplebucketname.s3.amazonaws.com/static/"
STATICFILES_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
STATICFILES_DIRS = [BASE_DIR / "static"]
but the static url was not taken in consideration and once released over apprunning the url was always missing the : (colon) after the protocol
no other configurations were applied over the project.
With the local setting and whitenoise was working.
I’ve checked:
- the policy on the bucket –> they were ok (trying to connect directly to a resource via the bucket url was reachable)
- changing the static_url manually
- override the static method
- use the FORCE_SCRIPT_NAME and the get_static_prefix
- check that every field was configured correctly
junjei is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.