From 6be359350b7858c0d5c06cbd6905a8f3e59ba4a1 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Thu, 26 Oct 2017 11:05:27 +0200 Subject: [PATCH] =?UTF-8?q?Optimisation=20des=20requ=C3=AAtes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- topologie/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/topologie/views.py b/topologie/views.py index 35e62ce3..023ed254 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -422,11 +422,12 @@ def create_ports(request, switch_id): messages.error(request, u"Switch inexistant") return redirect("/topologie/") - ports = switch.ports.order_by('port') s_begin = s_end = 0 - if len(ports) > 0: + nb_ports = switch.ports.count() + if nb_ports > 0: + ports = switch.ports.order_by('port') s_begin = ports[0].port - s_end = ports[len(ports)-1].port + s_end = ports.last().port port_form = CreatePortsForm( request.POST or None,