Fixed for Django version 1.4 and higher