Browse Source

Prefetch projects in profile admin.

pull/217/head
Pēteris Caune 6 years ago
parent
commit
886643db84
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      hc/accounts/admin.py

+ 2
- 1
hc/accounts/admin.py View File

@ -46,12 +46,13 @@ class ProfileAdmin(admin.ModelAdmin):
"projects", "invited", "sms", "reports_allowed")
search_fields = ["id", "user__email"]
list_filter = ("user__date_joined", "user__last_login",
"team_limit", "reports_allowed", "check_limit")
"reports_allowed", "check_limit")
fieldsets = (ProfileFieldset.tuple(), TeamFieldset.tuple())
def get_queryset(self, request):
qs = super(ProfileAdmin, self).get_queryset(request)
qs = qs.prefetch_related("user__project_set")
qs = qs.annotate(num_members=Count("user__project__member", distinct=True))
qs = qs.annotate(num_checks=Count("user__project__check", distinct=True))
qs = qs.annotate(num_channels=Count("user__project__channel", distinct=True))


Loading…
Cancel
Save