I'm confused with HttpRequest object in Django. I know that the AuthenticationMiddleware will add a user to request which is an instance of HttpRequest. And the code is here, but what I want to show is as follow:
request.user = SimpleLazyObject(lambda: get_user(request))
I have read the code of HttpRequest object and can not find a user attribute and its code don't have a __setattr__ method. So I'm curious about why the code do not raise an AtrributeError when access to a no existing attribute.
Thanks for giving help.
user, then you writerequest.userwill raise AttributeError.@Sayse