From e67df25d70ba4f6f606e35e12795065b746fc3da Mon Sep 17 00:00:00 2001 From: Sanj Date: Thu, 6 Oct 2011 17:03:38 +0530 Subject: [PATCH] handle stories with 0 images --- itf/bestpractices/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/itf/bestpractices/models.py b/itf/bestpractices/models.py index f589a0c..467c530 100644 --- a/itf/bestpractices/models.py +++ b/itf/bestpractices/models.py @@ -47,7 +47,11 @@ class BestPractice(ItfModel): } def main_image(self): - return self.get_images()[0] + imgs = self.get_images() + if len(imgs) > 0: + return imgs[0] + else: + return None def list_dict(self): return {