In the django.contrib.auth middleware I see the code:
class AuthenticationMiddleware(object):
def process_request(self, request):
assert hasattr(request, 'session'), "requires session middleware"
request.__class__.user = LazyUser()
return None
Please avdise me why such a form request._ class _.user = LazyUser() used? Why not just request.user = LazyUser() ?
I know what _ class _ attribute means, but as I undersand direct assignment to instance variable will be better. Where I'm wrong?