From e887b6442fe256e26f75b5137bfc202f4a1853c5 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 28 May 2017 18:29:54 +0200 Subject: [PATCH] Optimise le chargement des machines --- machines/views.py | 2 +- users/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/machines/views.py b/machines/views.py index c9a269c1..b9cbbc5a 100644 --- a/machines/views.py +++ b/machines/views.py @@ -609,7 +609,7 @@ def del_alias(request, interfaceid): @login_required @permission_required('cableur') def index(request): - machines_list = Machine.objects.select_related('user').prefetch_related('interface_set__domain__extension').prefetch_related('interface_set__ipv4__ip_type__extension').prefetch_related('interface_set__type').order_by('pk') + machines_list = Machine.objects.select_related('user').prefetch_related('interface_set__domain__extension').prefetch_related('interface_set__ipv4__ip_type__extension').prefetch_related('interface_set__type').prefetch_related('interface_set__domain__related_domain__extension').order_by('pk') paginator = Paginator(machines_list, PAGINATION_LARGE_NUMBER) page = request.GET.get('page') try: diff --git a/users/views.py b/users/views.py index 83f6bbd0..aab2826c 100644 --- a/users/views.py +++ b/users/views.py @@ -614,7 +614,7 @@ def profil(request, userid): if not request.user.has_perms(('cableur',)) and users != request.user: messages.error(request, "Vous ne pouvez pas afficher un autre user que vous sans droit cableur") return redirect("/users/profil/" + str(request.user.id)) - machines = Machine.objects.filter(user__pseudo=users) + machines = Machine.objects.filter(user__pseudo=users).select_related('user').prefetch_related('interface_set__domain__extension').prefetch_related('interface_set__ipv4__ip_type__extension').prefetch_related('interface_set__type').prefetch_related('interface_set__domain__related_domain__extension') factures = Facture.objects.filter(user__pseudo=users) bans = Ban.objects.filter(user__pseudo=users) whitelists = Whitelist.objects.filter(user__pseudo=users)