Skip to main content

How to serve media files for Django website

Comments

4 comments

  • Fabius
    I suppose the files don't even have to be in that folder - I could put them anywhere. So the question is: Given the site is a python site served with passenger_wsgi.py, how do I also serve a folder full of images etc?
    0
  • Fabius
    In the end I gave up on doing it that way, and instead set up a new Subdomain media.example.org
    for serving the media files, from a directory at ~/media.example.org/
    . I then put this in my Django settings file: MEDIA_ROOT = "/home/USERNAME/media.example.org/" MEDIA_URL = "https://media.example.org/"
    I added a .htaccess file in that directory containing this: Header set Access-Control-Allow-Origin "https://www.example.org"
    0
  • cPRex Jurassic Moderator
    I'm glad you were able to come up with a good workaround. cPanel support is very limited on the help we can provide for these type of applications, as outlined in the top of the documentation here: How to Install a Python WSGI Application | cPanel & WHM Documentation but I'm glad you found something that works for you!
    0
  • MrAli
    you can use: whitenoise ( serve its own static files locally ) or Amazon S3
  • Azure Storage
  • Dropbox
  • Google Cloud Storage
  • 0

Please sign in to leave a comment.