Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 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

Description

https://docs.djangoproject.com/en/1.3/topics/auth/#django.contrib.auth.models.User.is_anonymous

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."

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

The referenced doc is describing the methods implemented in the auth User class: https://code.djangoproject.com/browser/django/trunk/django/contrib/auth/models.py#L209

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 3 years ago by kmtracey

(That was me with the wontfix close.)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.