from django utils _threading_local import local _locals local class Th

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from django.utils._threading_local import local
_locals = local()
class ThreadLocals(object):
def process_request(self, request):
_locals.user = request.user
def get_current_user():
return getattr(_locals, 'user', None)