From 53253bcc83120d7502c433f6620ad31ad97bffed Mon Sep 17 00:00:00 2001 From: JKuijperM Date: Thu, 11 Jun 2026 13:14:21 +0200 Subject: [PATCH] Created table in the dashboard with the last expenses --- .../templates/expenses/dashboard.html | 28 +++++++++++++++++++ expenses_manager/expenses/views.py | 4 +++ 2 files changed, 32 insertions(+) diff --git a/expenses_manager/expenses/templates/expenses/dashboard.html b/expenses_manager/expenses/templates/expenses/dashboard.html index 4e896ac..d31dad1 100644 --- a/expenses_manager/expenses/templates/expenses/dashboard.html +++ b/expenses_manager/expenses/templates/expenses/dashboard.html @@ -179,6 +179,34 @@ + +
+

Gastos Recientes

+ + + + + + + + + + + + {% for exp in recent_expenses %} + + + + + + + + {% empty %} + + {% endfor %} + +
FechacuentaCategoríaConceptoImporte
{{ exp.date|date:"d/m/Y" }}{{ exp.account.name }}{{ exp.category.name }}{{ exp.description|default:"-" }}{{ exp.amount|floatformat:2 }}
No hay gastos recientes registrados
+
diff --git a/expenses_manager/expenses/views.py b/expenses_manager/expenses/views.py index 936c437..9194952 100644 --- a/expenses_manager/expenses/views.py +++ b/expenses_manager/expenses/views.py @@ -460,6 +460,9 @@ def dashboard(request): # Goals goals = Goal.objects.filter(owner=request.user) + # Recent expenses + recent_expenses = Expense.objects.filter(owner=request.user).order_by('-date', '-id')[:7] + # Send the data to the dashboard return render( request, @@ -491,6 +494,7 @@ def dashboard(request): "accounts_charts": accounts_charts, "period": period, "goals": goals, + "recent_expenses": recent_expenses, }, )