fix for missing field

This commit is contained in:
Sanj 2011-11-15 15:12:50 +05:30
parent 851cb8b264
commit 2c0d236b1c

View File

@ -29,7 +29,10 @@ class Item(models.Model):
d = json.loads(self.json) d = json.loads(self.json)
for f in fields: for f in fields:
short_name = f['short_name'] 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 return fields
def render(self): def render(self):
@ -38,6 +41,7 @@ class Item(models.Model):
context = Context(json.loads(self.json)) context = Context(json.loads(self.json))
return t.render(context) return t.render(context)
class ItemType(models.Model): class ItemType(models.Model):
name = models.CharField(max_length=100, unique=True) name = models.CharField(max_length=100, unique=True)
description = models.TextField(blank=True) description = models.TextField(blank=True)