Add automatic category sorting
This commit is contained in:
parent
ea9d871e25
commit
c91994d041
4 changed files with 56 additions and 4 deletions
|
@ -9,14 +9,14 @@ from .models import Transaction, TransactionForm, Invoice, InvoiceForm, Category
|
|||
@login_required
|
||||
def index(request):
|
||||
_transactions = Transaction.objects.order_by("-date")[:5]
|
||||
_categories = Category.objects.filter(parent=None).order_by("name")
|
||||
_categories = Category.objects.filter(parent=None)
|
||||
|
||||
def _cat_list(cat):
|
||||
children = []
|
||||
for child in Category.objects.filter(parent=cat):
|
||||
children += _cat_list(child)
|
||||
if len(children) == 0: return cat,
|
||||
return cat, children
|
||||
if len(children) == 0: return cat.name,
|
||||
return cat.name, children
|
||||
|
||||
_cats = []
|
||||
for cat in _categories:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue