diff options
| author | Jon Janzen <jon@jonjanzen.com> | 2023-02-13 18:24:35 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-03-07 13:11:22 +0100 |
| commit | e846c5e7246a0ffbe5dcf07a2b6c7c2a47537eb3 (patch) | |
| tree | d86cad38a58734387b5142b6d5d90d0b90d2f7f2 /docs/ref/request-response.txt | |
| parent | e83a88566a71a2353cebc35992c110be0f8628af (diff) | |
Fixed #31920 -- Made AuthenticationMiddleware add request.auser().
Diffstat (limited to 'docs/ref/request-response.txt')
| -rw-r--r-- | docs/ref/request-response.txt | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt index 9b0ed76e4d..9b71adfdf9 100644 --- a/docs/ref/request-response.txt +++ b/docs/ref/request-response.txt @@ -281,9 +281,23 @@ middleware class is listed in :setting:`MIDDLEWARE`. else: ... # Do something for anonymous users. + The :meth:`auser` method does the same thing but can be used from async + contexts. + Methods ------- +.. method:: HttpRequest.auser() + + .. versionadded:: 5.0 + + From the :class:`~django.contrib.auth.middleware.AuthenticationMiddleware`: + Coroutine. Returns an instance of :setting:`AUTH_USER_MODEL` representing + the currently logged-in user. If the user isn't currently logged in, + ``auser`` will return an instance of + :class:`~django.contrib.auth.models.AnonymousUser`. This is similar to the + :attr:`user` attribute but it works in async contexts. + .. method:: HttpRequest.get_host() Returns the originating host of the request using information from the |
