backport for compatibility with django 1.3