From 2c0d236b1caaaeaa45771f6392dc07f80ab14ff3 Mon Sep 17 00:00:00 2001 From: Sanj Date: Tue, 15 Nov 2011 15:12:50 +0530 Subject: [PATCH] fix for missing field --- printaform/formaprint/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/printaform/formaprint/models.py b/printaform/formaprint/models.py index 1904bad..f376e82 100755 --- a/printaform/formaprint/models.py +++ b/printaform/formaprint/models.py @@ -29,7 +29,10 @@ class Item(models.Model): d = json.loads(self.json) for f in fields: short_name = f['short_name'] - f['value'] = d[short_name] + if d.has_key(short_name): + f['value'] = d[short_name] + else: + f['value'] = '' return fields def render(self): @@ -38,6 +41,7 @@ class Item(models.Model): context = Context(json.loads(self.json)) return t.render(context) + class ItemType(models.Model): name = models.CharField(max_length=100, unique=True) description = models.TextField(blank=True)