When I try to save my inline formset it just returns an empty list and no changes are reflected in the database. I have tried doing it with no option and commit=False but they both have the same result. I know there is data because I printed the formset as a table, and I know it is valid because the property is_valid() method returns true. Here is the code:
def edit(request):
if request.method == 'POST':
print(request.POST)
form = TombstoneForm(request.POST)
print(form.is_valid())
t = form.save(commit=False)
t.edit_date = datetime.now()
t.user_editor = request.user
t.save()
print(t)
formset_construct = inlineformset_factory(Tombstone, Tank, form=TombstoneForm)
formset = formset_construct(request.POST)
print("Passed the inline formset")
print(formset.as_table())
print(formset.is_valid())
l = formset.save()
print(l)
return render(request, 'main.html')
So I believe I have found the source of my problem and a workaround. The problem was occuring in the BaseModelFormSet class in this method:
The problem was occuring in:
Where it was always hitting continue, so my solution has just been to save the individual form data instead of the formset data: