Serving django media files from the same host as the passenger app server


WARNING: Please read before continuing ▼

Difficulty: Easy
Time: ~5 Minutes
Last Updated: 20rd September 2010
Applies to: *NIX

The recommended configuration for django is to have any static files, such as script, CSS or images uploaded onto a CDN network. While this is the best configuration for a large site, for toy applications it is overkill.

Also, you may wish to run your development environment using passenger, rather than using manage.py runserver.

To start, we need to make a media directory in your passenger app root, and then create a symbolic link to the admin media files located on your system.

1
2
3
cd /var/www
mkdir media #the directory where our media files will be stored
ln -s /usr/lib/pymodules/python2.6/django/contrib/admin/media/ admin_media

Next, we need to disable passenger on the directories/symlinks we have created, as per the previous article on the blog.

Once this is done, edit settings.py in your django app, specifying the new addresses for your media.

Finally, restart apache, and you should now be able to access the media files you need.

, , , , , ,

  1. No comments yet.
(will not be published)


Technical Procedures is Digg proof thanks to caching by WP Super Cache