From bd5d6a4ed1e590051128c4f7fcc523074ca7cec2 Mon Sep 17 00:00:00 2001 From: oysteini Date: Sun, 6 Mar 2011 12:37:25 +0000 Subject: [PATCH] =?UTF-8?q?Fikset=20litt=20p=C3=A5=20Book.to=5Fstring.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Det var noe unicode-trøbbel fordi man hadde kalt str istedenfor unicode. Jeg endret dessuten litt på formateringen. --- python/web/library/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/web/library/models.py b/python/web/library/models.py index 6386bbf..7b22baa 100644 --- a/python/web/library/models.py +++ b/python/web/library/models.py @@ -57,14 +57,15 @@ class Book(models.Model): for field in book_fields: try: scratch += format % (field[1],eval('self.'+field[0])) + except Id.DoesNotExist: + scratch += format % (field[1], "None") except AttributeError: scratch += format % (field[1], '') - authors = ','.join(map(lambda x: str(x),self.get_authors())) + authors = ', '.join(map(unicode, self.get_authors())) scratch += format % ('Authors', authors) # scratch += 'Authors'.ljust(15, ' ') + ':' # scratch += authors.rjust(51, ' ') - scratch += '\n' return scratch def to_dict(self):