La til funksjon Book.get_persons.
This commit is contained in:
parent
136d1dd7c3
commit
7716c61965
|
@ -123,6 +123,11 @@ class Book(models.Model):
|
|||
authors.append(person.person)
|
||||
return authors
|
||||
|
||||
def get_persons(self, relation):
|
||||
return map(lambda bp: bp.person,
|
||||
filter(lambda bp: bp.relation.name == relation,
|
||||
self.persons.all()))
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title
|
||||
|
||||
|
|
Reference in New Issue