forked from DGNum/gestioCOF
Fewer requests on accounts groups.
- Saves two queries. (4 prefetch where done, replaced by 2 prefetchs (whose 1 with 2 selected_related))
This commit is contained in:
parent
afdb08b424
commit
2731d4630f
1 changed files with 13 additions and 4 deletions
|
@ -518,13 +518,22 @@ def account_update(request, trigramme):
|
||||||
'pwd_form': pwd_form,
|
'pwd_form': pwd_form,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@permission_required('kfet.manage_perms')
|
@permission_required('kfet.manage_perms')
|
||||||
def account_group(request):
|
def account_group(request):
|
||||||
groups = (Group.objects
|
user_pre = Prefetch(
|
||||||
.filter(name__icontains='K-Fêt')
|
'user_set',
|
||||||
.prefetch_related('permissions', 'user_set__profile__account_kfet')
|
queryset=User.objects.select_related('profile__account_kfet'),
|
||||||
)
|
)
|
||||||
return render(request, 'kfet/account_group.html', { 'groups': groups })
|
groups = (
|
||||||
|
Group.objects
|
||||||
|
.filter(name__icontains='K-Fêt')
|
||||||
|
.prefetch_related('permissions', user_pre)
|
||||||
|
)
|
||||||
|
return render(request, 'kfet/account_group.html', {
|
||||||
|
'groups': groups,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
class AccountGroupCreate(SuccessMessageMixin, CreateView):
|
class AccountGroupCreate(SuccessMessageMixin, CreateView):
|
||||||
model = Group
|
model = Group
|
||||||
|
|
Loading…
Reference in a new issue