Opened 18 years ago
Closed 17 years ago
#2416 closed enhancement (fixed)
Auth should use primary key rather than 'id' when referencing user
Reported by: | wiz | Owned by: | nobody |
---|---|---|---|
Component: | Contrib apps | Version: | dev |
Severity: | normal | Keywords: | |
Cc: | aenor.realm@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Got two problems on using profile system:
1) user.get_profile() fails with "AttributeError: NoneType has no _default_manager"
when using shell in
/usr/local/src/django_trunk/django/contrib/auth:
self._profile_cache = model._default_manager.get(useridexact=self.id)
Error is gone after execution of models.get_models()
2) i have profile class with no 'id' field, but 'user_idnr' as primary key.
But useridexact is hardcoded in the same line above.
Attachments (1)
Change History (7)
by , 18 years ago
comment:1 by , 18 years ago
Summary: | Auth Profile not working problems → Auth Profile issues |
---|
comment:2 by , 18 years ago
Summary: | Auth Profile issues → [patch] Auth Profile issues |
---|
comment:3 by , 18 years ago
Summary: | [patch] Auth Profile issues → Auth Profile issues |
---|
The second part of this patch is not correct. That queryset is referring to the User model, not the Profile model, so user__id__exact
is correct (it is finding the profile that belongs to the given user id).
For the first part of the problem, I don't really understand what you are doing to see the problem. Can you paste a few commands I can run to replicate it, please? I want to make sure we are fixing the real problem, not just covering up the cause.
Removing the patch keyword for now, since it can't be applied as is.
comment:4 by , 18 years ago
It just occurred to me that the first part of this ticket is probably the problem from #2684.
comment:5 by , 18 years ago
Patch needs improvement: | set |
---|---|
Summary: | Auth Profile issues → Auth should use primary key rather than 'id' when referencing user |
Triage Stage: | Unreviewed → Accepted |
I'll change the summary to reference the second part of this ticket since it does look like #2684 handles part 1.
I think that this would solve it, but haven't tested it:
self._profile_cache = model._default_manager.get(user=self)
comment:6 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I'm going to claim that this is a non-bug. The first paragraph of comment 3, above, is still correct.
my workover for both issues