Update layermapping.py

apply https://code.djangoproject.com/attachment/ticket/17018/django-17018.2.diff