Single layer of categories

This commit is contained in:
Edgar P. Burkhart 2022-05-20 14:39:00 +02:00
parent 36be624f5c
commit e38b781ff9
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
7 changed files with 69 additions and 80 deletions

View file

@ -1,17 +1,18 @@
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, Category
from .models import Transaction, TransactionForm, Invoice, InvoiceForm
def index(request):
_transactions = Transaction.objects.order_by("-date")[:5]
_categories = Category.objects.order_by("name")
class IndexView(generic.ListView):
template_name = "main/index.html"
context_object_name = "transactions"
def get_queryset(self):
return Transaction.objects.order_by("-date")[:5]
context = {
"transactions": _transactions,
"categories": _categories,
}
return render(request, "main/index.html", context)
def transaction(request, uuid=None):