Use list view

This commit is contained in:
Edgar P. Burkhart 2022-05-19 21:47:02 +02:00
parent 69c55f0cce
commit fbff835598
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
3 changed files with 10 additions and 7 deletions

View file

@ -1,15 +1,17 @@
from django.shortcuts import render, get_object_or_404, redirect
from django.http import HttpResponse
from django.views import generic
from .models import Transaction, TransactionForm, Invoice, InvoiceForm
def index(request):
_transactions = Transaction.objects.order_by("-date")[:5]
context = {
"transactions": _transactions,
}
return render(request, "main/index.html", context)
class IndexView(generic.ListView):
template_name = "main/index.html"
context_object_name = "transactions"
def get_queryset(self):
return Transaction.objects.order_by("-date")[:5]
def transaction(request, uuid=None):