Redirect on valid form input

This commit is contained in:
Edgar P. Burkhart 2022-12-21 15:49:27 +01:00
parent 6d0fb174eb
commit d8b00d91e8
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -64,6 +64,7 @@ def transaction(request, uuid=None):
_form = TransactionForm(request.POST, instance=_transaction) _form = TransactionForm(request.POST, instance=_transaction)
if _form.is_valid(): if _form.is_valid():
_form.save() _form.save()
return redirect(transaction, uuid=uuid)
_inv_form = InvoiceForm(instance=Invoice(transaction=_transaction)) _inv_form = InvoiceForm(instance=Invoice(transaction=_transaction))
elif request.POST["form"] == "invoice": elif request.POST["form"] == "invoice":
_transaction = get_object_or_404(Transaction, id=uuid) _transaction = get_object_or_404(Transaction, id=uuid)
@ -71,6 +72,7 @@ def transaction(request, uuid=None):
_inv_form = InvoiceForm(request.POST, request.FILES, instance=_invoice) _inv_form = InvoiceForm(request.POST, request.FILES, instance=_invoice)
if _inv_form.is_valid(): if _inv_form.is_valid():
_inv_form.save() _inv_form.save()
return redirect(transaction, uuid=uuid)
return render( return render(
request, request,
@ -118,6 +120,7 @@ def category(request, uuid=None):
_form = CategoryForm(request.POST, instance=_category) _form = CategoryForm(request.POST, instance=_category)
if _form.is_valid(): if _form.is_valid():
_form.save() _form.save()
return redirect(category, uuid=uuid)
return render( return render(
request, request,