From ca4ca01bf92fe6ea055abea8fb59fb406447defa Mon Sep 17 00:00:00 2001 From: oysteini Date: Sat, 5 Mar 2011 18:40:17 +0000 Subject: [PATCH] =?UTF-8?q?Fikset=20noen=20sm=C3=A5feil=20i=20Book.to=5Fdi?= =?UTF-8?q?ct.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/web/library/models.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/python/web/library/models.py b/python/web/library/models.py index 9e0c477..be0ece3 100644 --- a/python/web/library/models.py +++ b/python/web/library/models.py @@ -76,15 +76,16 @@ class Book(models.Model): people = self.persons.all() dict['persons'] = {} - for person in people: - if person.relation.name in dict['persons']: - dict['persons'][person.relation.name].append(person.id) + for bookperson in people: + person = bookperson.person + if bookperson.relation.name in dict['persons']: + dict['persons'][bookperson.relation.name].append(person.id) else: - dict['persons'][person.relation.name] = [person.id] + dict['persons'][bookperson.relation.name] = [person.id] dict['references'] = {} for reference in self.references.all(): - if person.relation.name in dict['references']: + if reference.reference_type.name in dict['references']: dict['references'][reference.reference_type.name].append(reference.text) else: dict['references'][reference.reference_type.name] = [reference.text]