By jonasblickle
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!
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, and AWS_S3_ENDPOINT_URL in your settings.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, ensure storages is properly placed in INSTALLED_APPS.Boto3 and Django-Storages Version:
boto3 and django-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 in INSTALLED_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:
from django.core.files.storage import default_storage
default_storage.url('path_to_your_file')
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 and django-storages packages.Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.