diff options
-rw-r--r-- | archaeological_operations/views.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py index d6ebd940c..da46d9e17 100644 --- a/archaeological_operations/views.py +++ b/archaeological_operations/views.py @@ -421,9 +421,17 @@ def operation_modify_parcels(request, pk): if request.method == 'POST': #TODO print(request.POST) - formset = formset_class(request.POST or None, request.FILES or None) + # formset = formset_class(request.POST or None, request.FILES or None) if formset.is_valid(): print(formset.cleaned_data) + post_data = request.POST.copy() + + for key in post_data.keys(): + if key.endswith("-DELETE"): + post_data.pop(key) + + request.POST = post_data + formset_class(request.POST).save() else: formset = formset_class() else: @@ -443,6 +451,8 @@ def operation_modify_parcels(request, pk): 'TOWNS': available_towns, 'form-TOTAL_FORMS': len(initial), 'form-INITIAL_FORMS': 0, + 'form-MIN_NUM_FORMS': 0, + 'form-MAX_NUM_FORMS': 100, } formset = formset_class(initial=initial, data=data) |