def delete_expense(request, pk): expense = Expenses.objects.get(pk=pk) if request.method == "GET": context = { "expense": expense, "form": DeleteExpenseForm(instance=expense), } return render(request, "expense-delete.html", context) else: expense.delete() return redirect("index")
def delete_expense(request, pk): expense = Expense.objects.get(pk=pk) if request.method == 'GET': context = { 'expense': expense, 'form': DeleteExpenseForm(instance=expense), } return render(request, 'expense-delete.html', context) else: expense.delete() return redirect('index')