#32035 closed Bug (needsinfo)
AbstractUser.clean assumes default manager is named objects
Reported by: | Ben Brooks | Owned by: | nobody |
---|---|---|---|
Component: | contrib.auth | Version: | 3.1 |
Severity: | Normal | Keywords: | |
Cc: | ben@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
From Managers documentation (https://docs.djangoproject.com/en/3.1/topics/db/managers/), "If you’re writing some code that must handle an unknown model, for example, in a third-party app that implements a generic view, use this manager (or _base_manager) rather than assuming the model has an objects manager."
Our third-party app implements a generic view (with objects = None) and set the default manager to be something else. When making calls to inherited methods, we run into NoneType errors due to normalize_email() implementation. The associated PR replaces objects with _default_manager to allow for the generic view implementation.
Change History (7)
comment:1 by , 4 years ago
Description: | modified (diff) |
---|
comment:2 by , 4 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
comment:4 by , 4 years ago
Oh sorry, I had the ticket open already and didn't see that you closed it Carlton. Unsure how to proceed now.
I think the problem is just that the clean()
method assumes that the default user manager is called objects
, and it shouldn't do that.
comment:5 by , 4 years ago
Component: | Uncategorized → contrib.auth |
---|---|
Triage Stage: | Accepted → Unreviewed |
We should wait for a clarification requested by Carlton.
comment:6 by , 4 years ago
On second thought I agree with closing the issue; the AbstractUser
definition contains objects = UserManager()
therefore the code can and should expect that the manager is called objects
.
If people want a different name for the default manager they should extend AbstractBaseUser
instead.
comment:7 by , 4 years ago
If people want a different name for the default manager they should extend AbstractBaseUser instead.
So that was my thought yeah...
(Specifying a custom user model says to use AbstractBaseUser
from django.contrib.auth.base_user
)
Hi Ben,
I'm struggling to understand whether this is a valid report or not.
So either...
AbstractBaseUser
here.Can I ask you to clarify?
Either way, it doesn't look like a valid report
User
and (by extension)AbstractUser
don't really satisfy the "an unknown model" part of the docs you link.Thanks.