backport to django 1.2