From 9fcecad007ee7acf3f9b5fe3b0a43bb575c04b2e Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Sun, 1 Oct 2017 23:13:10 +0200 Subject: [PATCH] Ne permet pas de sauvegarder de liste de ports vides. --- machines/views.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/machines/views.py b/machines/views.py index 36db72cd..54828999 100644 --- a/machines/views.py +++ b/machines/views.py @@ -932,7 +932,9 @@ def edit_portlist(request, pk): Port, fields=('begin','end','protocole','io'), extra=0, - can_delete=True + can_delete=True, + min_num=1, + validate_min=True, )(request.POST or None, queryset=port_list_instance.port_set.all()) if port_list.is_valid() and port_formset.is_valid(): pl = port_list.save() @@ -968,8 +970,10 @@ def add_portlist(request): port_formset = modelformset_factory( Port, fields=('begin','end','protocole','io'), - extra=1, - can_delete=True + extra=0, + can_delete=True, + min_num=1, + validate_min=True, )(request.POST or None, queryset=Port.objects.none()) if port_list.is_valid() and port_formset.is_valid(): pl = port_list.save()