Hi there,
I followed a long this tutorial but it seems it doesn’t work. The media files are not rendered due to bad URL I guess.
I hope you dont mind if I reference the related stackoverflow post to my issue: https://stackoverflow.com/questions/62859990/storing-django-media-files-on-digitalocean-aws-doesnt-work-due-to-bad-url?noredirect=1#comment111160066_62859990
Any advise on what to fix is highly appreciated :)
Thank you and best regards, Jonas
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hi there,
It looks like that the SO question is no longer available, so I could share some general suggestions based on the information here.
Here are some common troubleshooting steps:
Correct AWS/Spaces Credentials:
AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
,AWS_STORAGE_BUCKET_NAME
, andAWS_S3_ENDPOINT_URL
in yoursettings.py
are correctly set.Correct Bucket and Object Permissions:
Correct URLs:
STATIC_URL
is correctly formatted and pointing to the right space and folder.Middleware and Apps Order:
settings.py
, ensurestorages
is properly placed inINSTALLED_APPS
.Boto3 and Django-Storages Version:
boto3
anddjango-storages
are needed. Make sure they are up-to-date, or check if there are known issues with the versions you are using.Check your Static File Referencing in Templates:
{% static 'path_to_file' %}
and ensure that'django.contrib.staticfiles'
is inINSTALLED_APPS
.Server Error Logs:
Browser Developer Tools:
SSL Certificate:
Some additional things that you could check are:
You can use
python manage.py shell
to debug your storage backend and try to retrieve a file URL. Example:This should return the full URL to your file in the storage backend. Make sure this URL is valid and reachable.
Test static serving with Django’s default backend to ensure the problem is not with the Django application. If the files are served correctly with Django’s default backend, it points towards a configuration issue with
django-storages
and DigitalOcean Spaces.Based on your findings from the above checklist and further debugging, you may need to:
settings.py
.boto3
anddjango-storages
packages.Best,
Bobby