mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
Optimisation sur les select related
This commit is contained in:
parent
147cb78e9e
commit
7057eafa49
2 changed files with 8 additions and 8 deletions
|
@ -857,13 +857,13 @@ def index(request):
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('cableur')
|
@permission_required('cableur')
|
||||||
def index_iptype(request):
|
def index_iptype(request):
|
||||||
iptype_list = IpType.objects.select_related('extension').order_by('type')
|
iptype_list = IpType.objects.select_related('extension').select_related('vlan').order_by('type')
|
||||||
return render(request, 'machines/index_iptype.html', {'iptype_list':iptype_list})
|
return render(request, 'machines/index_iptype.html', {'iptype_list':iptype_list})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('cableur')
|
@permission_required('cableur')
|
||||||
def index_vlan(request):
|
def index_vlan(request):
|
||||||
vlan_list = Vlan.objects.order_by('vlan_id')
|
vlan_list = Vlan.objects.prefetch_related('iptype_set').order_by('vlan_id')
|
||||||
return render(request, 'machines/index_vlan.html', {'vlan_list':vlan_list})
|
return render(request, 'machines/index_vlan.html', {'vlan_list':vlan_list})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -875,7 +875,7 @@ def index_machinetype(request):
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('cableur')
|
@permission_required('cableur')
|
||||||
def index_nas(request):
|
def index_nas(request):
|
||||||
nas_list = Nas.objects.select_related('machine_type').order_by('name')
|
nas_list = Nas.objects.select_related('machine_type').select_related('nas_type').order_by('name')
|
||||||
return render(request, 'machines/index_nas.html', {'nas_list':nas_list})
|
return render(request, 'machines/index_nas.html', {'nas_list':nas_list})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -903,8 +903,8 @@ def index_alias(request, interfaceid):
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('cableur')
|
@permission_required('cableur')
|
||||||
def index_service(request):
|
def index_service(request):
|
||||||
service_list = Service.objects.all()
|
service_list = Service.objects.prefetch_related('service_link_set__server__domain__extension').all()
|
||||||
servers_list = Service_link.objects.all()
|
servers_list = Service_link.objects.select_related('server__domain__extension').select_related('service').all()
|
||||||
return render(request, 'machines/index_service.html', {'service_list':service_list, 'servers_list':servers_list})
|
return render(request, 'machines/index_service.html', {'service_list':service_list, 'servers_list':servers_list})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -1012,7 +1012,7 @@ def history(request, object, id):
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('cableur')
|
@permission_required('cableur')
|
||||||
def index_portlist(request):
|
def index_portlist(request):
|
||||||
port_list = OuverturePortList.objects.all().order_by('name')
|
port_list = OuverturePortList.objects.prefetch_related('ouvertureport_set').prefetch_related('interface_set').order_by('name')
|
||||||
return render(request, "machines/index_portlist.html", {'port_list':port_list})
|
return render(request, "machines/index_portlist.html", {'port_list':port_list})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
|
|
@ -45,7 +45,7 @@ from preferences.models import AssoOption, GeneralOption
|
||||||
@permission_required('cableur')
|
@permission_required('cableur')
|
||||||
def index(request):
|
def index(request):
|
||||||
""" Vue d'affichage de tous les swicthes"""
|
""" Vue d'affichage de tous les swicthes"""
|
||||||
switch_list = Switch.objects.order_by('stack','stack_member_id','location').select_related('switch_interface__domain__extension').select_related('switch_interface__ipv4').select_related('switch_interface__domain')
|
switch_list = Switch.objects.order_by('stack','stack_member_id','location').select_related('switch_interface__domain__extension').select_related('switch_interface__ipv4').select_related('switch_interface__domain').select_related('stack')
|
||||||
return render(request, 'topologie/index.html', {'switch_list': switch_list})
|
return render(request, 'topologie/index.html', {'switch_list': switch_list})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -128,7 +128,7 @@ def index_room(request):
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('infra')
|
@permission_required('infra')
|
||||||
def index_stack(request):
|
def index_stack(request):
|
||||||
stack_list = Stack.objects.order_by('name')
|
stack_list = Stack.objects.order_by('name').prefetch_related('switch_set__switch_interface__domain__extension')
|
||||||
return render(request, 'topologie/index_stack.html', {'stack_list': stack_list})
|
return render(request, 'topologie/index_stack.html', {'stack_list': stack_list})
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue