8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-25 16:33:47 +00:00

Optimisations select_related

This commit is contained in:
Gabriel Detraz 2017-05-27 04:55:33 +02:00 committed by root
parent 0399633cef
commit f700d59e65
3 changed files with 7 additions and 7 deletions

View file

@ -625,21 +625,21 @@ def index(request):
@login_required
@permission_required('cableur')
def index_iptype(request):
iptype_list = IpType.objects.order_by('type')
iptype_list = IpType.objects.select_related('extension').order_by('type')
return render(request, 'machines/index_iptype.html', {'iptype_list':iptype_list})
@login_required
@permission_required('cableur')
def index_machinetype(request):
machinetype_list = MachineType.objects.order_by('type')
machinetype_list = MachineType.objects.select_related('ip_type').order_by('type')
return render(request, 'machines/index_machinetype.html', {'machinetype_list':machinetype_list})
@login_required
@permission_required('cableur')
def index_extension(request):
extension_list = Extension.objects.order_by('name')
mx_list = Mx.objects.order_by('zone')
ns_list = Ns.objects.order_by('zone')
mx_list = Mx.objects.order_by('zone').select_related('zone')
ns_list = Ns.objects.order_by('zone').select_related('zone')
return render(request, 'machines/index_extension.html', {'extension_list':extension_list, 'mx_list': mx_list, 'ns_list': ns_list})
@login_required

View file

@ -696,7 +696,7 @@ class NewListRightForm(ListRightForm):
self.fields['gid'].label = 'Gid, attention, cet attribut ne doit pas être modifié après création'
class DelListRightForm(ModelForm):
listrights = forms.ModelMultipleChoiceField(queryset=ListRight.objects.all(), label="Droits actuels", widget=forms.CheckboxSelectMultiple)
listrights = forms.ModelMultipleChoiceField(queryset=ListRight.objects.all().select_related('user'), label="Droits actuels", widget=forms.CheckboxSelectMultiple)
class Meta:
exclude = ['listright','gid']

View file

@ -496,7 +496,7 @@ def index(request):
@permission_required('cableur')
def index_ban(request):
""" Affiche l'ensemble des ban, need droit cableur """
ban_list = Ban.objects.order_by('date_start').reverse()
ban_list = Ban.objects.order_by('date_start').select_related('user').reverse()
paginator = Paginator(ban_list, PAGINATION_NUMBER)
page = request.GET.get('page')
try:
@ -513,7 +513,7 @@ def index_ban(request):
@permission_required('cableur')
def index_white(request):
""" Affiche l'ensemble des whitelist, need droit cableur """
white_list = Whitelist.objects.order_by('date_start')
white_list = Whitelist.objects.select_related('user').order_by('date_start')
return render(
request,
'users/index_whitelist.html',