Thanks tome for the suggestion and patch. Backport of 3587991ba8 from master
3587991ba8
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13446 bcc190cf-cafb-0310-a4f2-bffc1f526a37