Fixed compatibility issues with django < 1.5