Update layermapping.py

apply patch from https://code.djangoproject.com/ticket/17018#comment:3