From 42f2c79fa797adf22796db20eb13d85af4209dde Mon Sep 17 00:00:00 2001 From: Nikolai R Kristiansen Date: Mon, 29 Dec 2014 17:39:15 +0100 Subject: [PATCH] Domain: Count host records --- mdb/models.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mdb/models.py b/mdb/models.py index b765da9..cec5bf9 100644 --- a/mdb/models.py +++ b/mdb/models.py @@ -46,11 +46,13 @@ class Domain(models.Model): return self.domain_name def num_records(self): - size = {} - size["cname"] = self.domaincnamerecord_set.count() - size["srv"] = self.domainsrvrecord_set.count() - size["txt"] = self.domaintxtrecord_set.count() - size["a"] = self.domainarecord_set.count() + host_a_records = Host.objects.filter(interface__domain=self).count() + size = { + "cname": self.domaincnamerecord_set.count(), + "srv": self.domainsrvrecord_set.count(), + "txt": self.domaintxtrecord_set.count(), + "a": self.domainarecord_set.count() + host_a_records + } return size num_records.short_description = "Num Records"