Make it work with Django versions < 1.5

Added the missing if-else - now it works with both Django <1.5 and >=1.5