class ImpersonateMiddleware(object):

    def process_request(self, request):
        if request.user.is_superuser and '__impersonate' in request.GET:
            pass
Django user impersonation by admin