Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#20673 closed Cleanup/optimization (fixed)

Clarify that HttpRequest.user uses AUTH_USER_MODEL

Reported by: littlepig Owned by: susan
Component: Documentation Version: 1.5
Severity: Normal Keywords:
Cc: littlepig Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.user it is said

A django.contrib.auth.models.User object representing the currently logged-in user.

But apparently (http://stackoverflow.com/questions/17355275), it returns the AUTH_USER_MODEL if it is defined.

I think this should be clarified in the documentation.

Change History (9)

comment:1 Changed 2 years ago by bmispelon

  • Easy pickings set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Good catch, thanks.

It looks like the docstring for contrib.auth.backends.ModelBackend [1] is incorrect too.

[1] https://github.com/django/django/blob/master/django/contrib/auth/backends.py#L8

comment:2 Changed 2 years ago by susan

  • Owner changed from nobody to susan
  • Status changed from new to assigned

comment:3 Changed 2 years ago by susan

To be honest, I'm not entirely sure what the docstring needs to be in "contrib.auth.backends.ModelBackend". Can someone point me in the right direction?

comment:5 Changed 2 years ago by timo

  • Summary changed from Improve HttpRequest.user documentation to Clarify that HttpRequest.user uses AUTH_USER_MODEL

Susan, the problem is that the docs say that a django.contrib.auth.models.User object is returned, but with the introduction of custom user models, that may no longer be true.

comment:6 Changed 2 years ago by Chandrakant Gopalan

Let me take a shot...

Instead of:

A django.contrib.auth.models.User object representing the currently
logged-in user.

Say this:

An object representing the currently logged-in user. Will be the user object in
:setting:AUTH_USER_MODEL setting if specified, django.contrib.auth.models.User otherwise.

comment:7 Changed 2 years ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In f407f75aae242d1bd8d4ac7f19c5d4075353c65e:

Fixed #20673 -- Clarified that HttpRequest.user uses AUTH_USER_MODEL.

Thanks littlepig for the report.

comment:8 Changed 2 years ago by Tim Graham <timograham@…>

In 82a6a956d50edf1008b89b886090459d2e65ac1a:

[1.5.x] Fixed #20673 -- Clarified that HttpRequest.user uses AUTH_USER_MODEL.

Thanks littlepig for the report.

Backport of f407f75aae from master.

comment:9 Changed 2 years ago by Tim Graham <timograham@…>

In 23748c483b128773edb5f5e8ee509bf12732595c:

[1.6.x] Fixed #20673 -- Clarified that HttpRequest.user uses AUTH_USER_MODEL.

Thanks littlepig for the report.

Backport of f407f75aae from master.

Note: See TracTickets for help on using tickets.
Back to Top