diff --git a/python/web/library/models.py b/python/web/library/models.py index e9f64e5..2e646f9 100644 --- a/python/web/library/models.py +++ b/python/web/library/models.py @@ -68,11 +68,20 @@ class Book(models.Model): def to_dict(self): dict = {} dict['action'] = 'edit-book' - for field in book_fields: - try: - dict[field[0]] = eval('self.'+field[0]) - except AttributeError: - dict[field[0]] = ' ' + + dict['isbn'] = self.isbn + dict['title'] = self.title + dict['category'] = self.category.id + dict['subtitle'] = self.subtitle + dict['publisher'] = self.publisher + dict['published_year'] = self.published_year + dict['edition'] = self.edition + dict['num_pages'] = self.num_pages + if self.series: + dict['series'] = self.series.id + else: + dict['series'] = '' + dict['description'] = self.description people = self.persons.all() dict['persons'] = {}