Patched function error in layers/views.py