Single layer of categories
This commit is contained in:
parent
36be624f5c
commit
e38b781ff9
7 changed files with 69 additions and 80 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue