[Django]-Serve media files with Django on production server

6👍

Here’s what I ended up doing. I just added the below to my apache2.conf file and it worked great:

Alias /media/ /home/Mysite/mediaroot/

<Directory /home/Mysite/media>
Order deny,allow
Allow from all
</Directory>

Apache serves my media now 🙂

5👍

There is no quick and dirty way. There is only the way to actually do it: point Apache to the media folder and set STATIC_URL to the URL that Apache is using.

1👍

I think I’m confused,

Normally in a production environment I set my static url and media_url to the designated folders on my server.

Then my templates reference,

<img src="{{ MEDIA_URL }}images/image1.jpg" />

My settings file would look like this,

MEDIA_URL = "http://www.noobmovies.com/static/"

and it serves CSS, JavaScript etc…

I’m not sure there is anything dirty or inappropriate about it.

Leave a comment