code from official django tutorial 1.7