Retrofit fix to #18537 in stable/1.4.x as noted in pull-request #194.

Applied Kevin Schaul's fix to issue [#18537](https://code.djangoproject.com/ticket/18537), originally reported and fixed in stable/1.5.x