Opened 2 years ago

Closed 2 years ago

#21310 closed Bug (worksforme)

Admin recent actions section doesn't show content with settings.AUTH_USER_MODEL

Reported by: franklin.steve02@… 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


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.



Change History (1)

comment:1 Changed 2 years ago by timo

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

I'm unable to reproduce using this example custom user package here:

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 on LogEntry is named user.

Please reopen if you can provide more details with steps to reproduce.

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