From 8015b27baaeb22e59f06b63dffafbaee9cd9337c Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Wed, 31 Jan 2018 02:46:48 +0100 Subject: [PATCH] Optimisation chargement de la page gestion droits --- users/forms.py | 2 +- users/views.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/users/forms.py b/users/forms.py index e52c79fb..72094d22 100644 --- a/users/forms.py +++ b/users/forms.py @@ -441,7 +441,7 @@ class ListRightForm(ModelForm): """Edition, d'un groupe , équivalent à un droit Ne peremet pas d'editer le gid, car il sert de primary key""" permissions = forms.ModelMultipleChoiceField( - Permission.objects.all(), + Permission.objects.all().select_related('content_type'), widget=forms.CheckboxSelectMultiple, required=False ) diff --git a/users/views.py b/users/views.py index 5981d4b1..11da6843 100644 --- a/users/views.py +++ b/users/views.py @@ -710,7 +710,8 @@ def index_school(request): @can_view_all(ListRight) def index_listright(request): """ Affiche l'ensemble des droits , need droit cableur """ - listright_list = ListRight.objects.order_by('unix_name') + listright_list = ListRight.objects.order_by('unix_name')\ + .prefetch_related('permissions').prefetch_related('user_set') return render( request, 'users/index_listright.html',