예제 #1
0
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")
예제 #2
0
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')