Lightweight Django Thumbnails

I needed a good thumbnail solution for a recent Django project but didn’t want the overhead of using sorl – I just needed a simple template tag that would let me generate the correct size of thumbnail from the main picture.

I found a solution on but it needed a little tweeking to suit my needs.

The filter is applied directly to an image field using a template tag such as

{{ object.image|make_thumbnail:'100x200' }}

and supposing the image filename is “image.jpg”, it checks if there is a file called “image_100x200.jpg”, if the file isn’t there, it resizes and saves the original image, finally it returns the proper url to the resized image.

The updated filter is given below (you will need PIL installed):
Read the rest of this entry…

Nginx & Django on Webfaction – Part 3

Now that we have a stable and resilient environment (See Part 1a, Part 1b, and Part 2) I’m going to show you how we can hand off some of the work of file uploads to nginx and even get a nice upload progress bar into the bargain :)
Take a deep breath as this is quite a long one…. :)
Read the rest of this entry…

Django on Snow Leopard

Having just been given an new MacBook Pro as an early birthday present, it didn’t take me long to try and install Django on it. Rather than use the MacPorts solution I decided to use the native python 2.6 and build the rest, apart from MySQL (use the Mac OS X 10.5 (x86_64) package from here)

Before proceeding make sure that you have installed XCode (It’s on the Snow Leopard install disc) as we need it to install libjpeg and PIL (all of my Django projects use this!)

Download libjpeg then:

tar -xzf jpegsrc-1.v7.tar
cd jpegsrc-1.v7
ln -s `which glibtool` ./libtool
./configure --enable-shared && make && sudo make install

Now we can download the source and build PIL

tar -xzf Imaging-1.1.6.tar.gz
cd Imaging-1.1.6
sudo python install

Last thing to do before we install Django is to install the MySqlDb connector – you will need to do add the following to your .bash_profile



sudo easy_install mysql-python

Now we can easy_install Django:

sudo easy_install django

and we are all set to go :)

Thanks to these guys for the help in figuring this out:

Tags: , , , , ,