Opened 11 years ago
Closed 11 years ago
#21310 closed Bug (worksforme)
Admin recent actions section doesn't show content with settings.AUTH_USER_MODEL
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | 1.4 |
Severity: | Normal | Keywords: | admin event log |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
If a custom model is specified in settings (AUTH_USER_MODEL), then the query for recent activity always returns no events.
On some digging I have found the problem to be with the select related in the AdminLogNode like;
context[self.varname] = LogEntry.objects.filter(useridexact=user_id).select_related('content_type', 'user')[:self.limit]
Changing this to settings.AUTH_USER_MODEL as
context[self.varname] = LogEntry.objects.filter(useridexact=user_id).select_related('content_type', settings.AUTH_USER_MODEL)[:self.limit]
Actually I believe from the documentation this should be get_user_model() but I haven't tested that.
thanks
Steve
I'm unable to reproduce using this example custom user package here: https://github.com/jonathanchu/django-custom-user-example
I added a Group in the admin and then was able to see that listed under "Recent Actions" on /admin/.
The code looks correct as it is -- you specify the name of a foreign key to follow when using
select_related
. The FK attribute onLogEntry
is nameduser
.Please reopen if you can provide more details with steps to reproduce.