Add encapsulation function to workaround Django issue 15791
Cleanup