From f9584b4c829a47586366d1f541cb87dfd896eff5 Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 23 Aug 2018 09:06:31 +0200 Subject: [PATCH] Fix a bug when vm_template is None --- hosting/models.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hosting/models.py b/hosting/models.py index e9fcdc7e..601568c5 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -53,9 +53,11 @@ class OrderDetail(AssignPermissionsMixin, models.Model): ssd_size = models.IntegerField(default=0) def __str__(self): - return "%s - %s, %s cores, %s GB RAM, %s GB SSD" % ( - self.vm_template.name, self.vm_template.vm_type, self.cores, - self.memory, self.ssd_size + return "Not available" if self.vm_template is None else ( + "%s - %s, %s cores, %s GB RAM, %s GB SSD" % ( + self.vm_template.name, self.vm_template.vm_type, self.cores, + self.memory, self.ssd_size + ) )