Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#16635 closed Bug (wontfix)

Wording in documentation for contrib.auth could be improved on is_anonymous()

Reported by: cyclops Owned by: nobody
Component: contrib.auth Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


starts with the text:

"Always returns False."

A better wording might be:

"Returns False if the user has not been authenticated, i.e., entered a valid login and password."

Change History (2)

comment:1 Changed 5 years ago by anonymous

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: wontfix
Status: newclosed

The referenced doc is describing the methods implemented in the auth User class:

It's accurate as-is. The suggested re-wording implies you might have an auth User instance that would sometimes return True for is_anonymous, which is not the case. If you have a User, not an AnonymouseUser, it will always return False for is_anonymous. (The determination of whether the "requesting user" is authenticated or not is not done by the User class code but rather by other code that then constructs either a User or an AnonymousUser instance that is attached to a request object.)

is_anonymous (and is_authenticated) are there as convenience methods to allow you to call the same method on different types of user instances and get correct answers for each. They don't actually do any checking of anything, and to put in the docs anything other than that a User instance will return False for is_anonymous would be misleading, in my opinion.

comment:2 Changed 5 years ago by Karen Tracey

(That was me with the wontfix close.)

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