mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-27 01:13:46 +00:00
Fix et optimisation select_related
This commit is contained in:
parent
b635553132
commit
37870265f4
3 changed files with 7 additions and 2 deletions
|
@ -533,7 +533,8 @@ def control(request):
|
|||
facture_list = paginator.page(1)
|
||||
except EmptyPage:
|
||||
facture_list = paginator.page(paginator.num.pages)
|
||||
page_query = Facture.objects.order_by('date').reverse().filter(
|
||||
page_query = Facture.objects.order_by('date').select_related('user')\
|
||||
.select_related('paiement').reverse().filter(
|
||||
id__in=[facture.id for facture in facture_list]
|
||||
)
|
||||
controlform = controlform_set(request.POST or None, queryset=page_query)
|
||||
|
|
|
@ -380,6 +380,8 @@ class ServiceForm(ModelForm):
|
|||
def __init__(self, *args, **kwargs):
|
||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||
super(ServiceForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||
self.fields['servers'].queryset = Interface.objects.all()\
|
||||
.select_related('domain__extension')
|
||||
|
||||
def save(self, commit=True):
|
||||
instance = super(ServiceForm, self).save(commit=False)
|
||||
|
|
|
@ -1056,7 +1056,9 @@ def history(request, object, id):
|
|||
@login_required
|
||||
@permission_required('cableur')
|
||||
def index_portlist(request):
|
||||
port_list = OuverturePortList.objects.prefetch_related('ouvertureport_set').prefetch_related('interface_set__domain__extension').prefetch_related('interface_set__machine__user').order_by('name')
|
||||
port_list = OuverturePortList.objects.prefetch_related('ouvertureport_set')\
|
||||
.prefetch_related('interface_set__domain__extension')\
|
||||
.prefetch_related('interface_set__machine__user').order_by('name')
|
||||
return render(request, "machines/index_portlist.html", {'port_list':port_list})
|
||||
|
||||
@login_required
|
||||
|
|
Loading…
Reference in a new issue