Hello. I have the following classes in my models file
class HardwareNode(models.Model):
ip_address = models.CharField(max_length=15)
port = models.IntegerField()
location = models.CharField(max_length=50)
hostname = models.CharField(max_length=30)
def __unicode__(self):
return self.hostname
class Subscription(models.Model):
customer = models.ForeignKey(Customer)
package = models.ForeignKey(Package)
location = models.ForeignKey(HardwareNode)
renewal_date = models.DateTimeField('renewal date')
def __unicode__(self):
x = '%s %s' % (self.customer.hostname, str(self.package))
return x
I'd like to do a count on the number of Subscriptions on a particular HardwareNode and display that on the admin section for the HardwareNode class e.g. 10 subscriptions hosted on node 2.
I'm still learning Django and I'm not sure where I would accomplish this. Can/should I do it in the models.py or in the HTML?
Thanks,
-seth