I noticed that when we enter Django, we are no longer AnonymousUser (in models.py), but rather become AbstractBaseUser (in models.py).
How does django handle this change?
It is mainly located inside AuthenticationMiddleware django / contrib / auth / middleware.py : request.user = SimpleLazyObject(lambda: get_user(request))
AuthenticationMiddleware
request.user = SimpleLazyObject(lambda: get_user(request))
which calls get_user from the same module:
get_user
def get_user(request): if not hasattr(request, '_cached_user'): request._cached_user = auth.get_user(request) return request._cached_user
and finally get_user from django / contrib / auth / __ init __. py , which returns return user or AnonymousUser() . Most likely, you are interested in the latter.
return user or AnonymousUser()
Source: https://habr.com/ru/post/1211604/More articles:sudo open -e ~ / .bash_profile Permission denied mac - pathWhy for loops is faster than numpy for multiplying a 2D array - pythonHow to minimize spaces around Baidu e-cards - javascriptAndroid - Sugar ORM Save Crash - androidIs it possible to read HTTPONLY cookies using jQuery? - jqueryLaravel 4 Holding loads - eloquentTrial tests and control tests of androids on Jenkins (Gradle) - androidAsynchronous call in synchronous function - c #Facebook Graph API & ColdFusion: "The no_story parameter must be logical" - coldfusionTwo-way scroll view (diagonal), as in the Google Sheets Android app - performanceAll Articles