From a5e895f9adca21a5937d6f0af13e06edcfce402a Mon Sep 17 00:00:00 2001 From: Alexander Hosking Date: Fri, 3 Dec 2021 12:09:01 -0500 Subject: [PATCH] Add verbose names to bills Update admin view with filters Add list data Add Search --- api/bills/admin.py | 6 +++++- api/bills/models.py | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/api/bills/admin.py b/api/bills/admin.py index cbf1328..ddc1521 100644 --- a/api/bills/admin.py +++ b/api/bills/admin.py @@ -2,4 +2,8 @@ from django.contrib import admin from .models import Bill -admin.site.register(Bill) \ No newline at end of file +@admin.register(Bill) +class BillAdmin(admin.ModelAdmin): + list_display = ['name', 'due', 'amount'] + list_filter = ('name', 'type', 'is_paid', 'is_overdue', 'is_missed') + search_fields = ['name', 'type', 'amount'] \ No newline at end of file diff --git a/api/bills/models.py b/api/bills/models.py index 170c79d..6649c3b 100644 --- a/api/bills/models.py +++ b/api/bills/models.py @@ -2,14 +2,14 @@ from django.db import models # Create your models here. class Bill(models.Model): - name = models.CharField(max_length=64) - type = models.CharField(max_length=64) + name = models.CharField(max_length=64, verbose_name='Name') + type = models.CharField(max_length=64, verbose_name="Type") due = models.DateField('due_date') amount = models.FloatField(default='00.00') - is_paid = models.BooleanField(default=False) + is_paid = models.BooleanField(default=False, verbose_name="Paid") paid_date = models.DateField('paid_date',null=True, blank=True) - is_overdue = models.BooleanField(default=False) - is_missed = models.BooleanField(default=False) + is_overdue = models.BooleanField(default=False, verbose_name="Overdue") + is_missed = models.BooleanField(default=False, verbose_name='Missed Payment') def overdue(self): return self.is_overdue