Serve static files on heroku using AWS S3 for django?


i’m deploying a django application using heroku and AWS S3 for static files, the problem is that i haven’t found information on how to link the Postgres DB of heroku with the S3 service.

I’ve already set the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, S3_BUCKET, Add CORS Configuration, but my question is how can i link the S3 storage with the postgres DB of Heroku? Is this possible?

This is how my model looks in the admin, but if i upload the images here, after 5 minutes disappears.
Image Upload for the model

Of course i can use static urls like this, but the problem is that i want to display different images for very course, not the same image for all.
serve in the db

So my code needs to be like this, to serve different images
aws static file

I hope some one could help me, Thanks.


I found the solution in this posts:

Basically i need to download boto (pip install boto) and put it in requirements.txt(pip freeze > requirements.txt), and in add:



Update the src and href in your html:


Finally you need to update the permissions in

Leave a Reply