fix for https://code.djangoproject.com/ticket/12728