Fix battery count display - show total quantity instead of record count
This commit is contained in:
@@ -44,6 +44,10 @@ class UPSHost(models.Model):
|
||||
created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
|
||||
updated_at = models.DateTimeField(auto_now=True, verbose_name='更新时间')
|
||||
|
||||
@property
|
||||
def total_battery_count(self):
|
||||
return sum(battery.quantity for battery in self.battery_set.all())
|
||||
|
||||
def __str__(self):
|
||||
if self.ip_address and not self.ip_address.startswith('-'):
|
||||
return f'{self.brand} {self.model} - {self.ip_address}'
|
||||
|
||||
Reference in New Issue
Block a user