Opened 18 years ago

Closed 16 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)

2416.diff (737 bytes ) - added by wiz 18 years ago.
my workover for both issues

Download all attachments as: .zip

Change History (7)

by wiz, 18 years ago

Attachment: 2416.diff added

my workover for both issues

comment:1 by anonymous, 18 years ago

Summary: Auth Profile not working problemsAuth Profile issues

comment:2 by anonymous, 18 years ago

Summary: Auth Profile issues[patch] Auth Profile issues

comment:3 by Malcolm Tredinnick, 17 years ago

Summary: [patch] Auth Profile issuesAuth 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 Malcolm Tredinnick, 17 years ago

It just occurred to me that the first part of this ticket is probably the problem from #2684.

comment:5 by Chris Beaven, 17 years ago

Patch needs improvement: set
Summary: Auth Profile issuesAuth should use primary key rather than 'id' when referencing user
Triage Stage: UnreviewedAccepted

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 Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: newclosed

I'm going to claim that this is a non-bug. The first paragraph of comment 3, above, is still correct.

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