Use list view
This commit is contained in:
parent
69c55f0cce
commit
fbff835598
3 changed files with 10 additions and 7 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue