From f76e01a641e9611fddb06ae909feb6681b3b380a Mon Sep 17 00:00:00 2001 From: almelid Date: Fri, 4 Mar 2011 15:35:33 +0000 Subject: [PATCH] =?UTF-8?q?la=20til=20unicode-metoder=20p=C3=A5=20alle=20m?= =?UTF-8?q?odellene?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/web/library/models.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/python/web/library/models.py b/python/web/library/models.py index 1340ab3..d6e2258 100644 --- a/python/web/library/models.py +++ b/python/web/library/models.py @@ -9,17 +9,29 @@ class Category(models.Model): id = models.CharField(max_length=255, primary_key=True) name = models.CharField(max_length=255) + def __unicode__(self): + return self.name + class BookSeries(models.Model): id = models.CharField(max_length=20, primary_key=True) title = models.CharField(max_length=511) + def __unicode__(self): + return self.title + class ReferenceType(models.Model): name = models.CharField(max_length=31) + def __unicode__(self): + return self.name + class Reference(models.Model): reference_type = models.ForeignKey(ReferenceType) text = models.CharField(max_length=1023) + def __unicode__(self): + return self.text + class Book(models.Model): isbn = models.CharField(max_length=13, primary_key=True) # id = models.CharField(max_length=255) @@ -77,14 +89,21 @@ class Id(models.Model): id = models.CharField(max_length=511, primary_key=True) book = models.OneToOneField(Book) + def __unicode__(self): + return self.id + class AlternativeTitle(models.Model): book = models.ForeignKey(Book, related_name='alt_titles') alt_title = models.CharField(max_length=511) + def __unicode__(self): + return self.book.title+"="+self.alt_title class Copy(models.Model): book = models.ForeignKey(Book, related_name='copies') number = models.IntegerField() owner = models.CharField(max_length=9) + def __unicode__(self): + return self.book.title+" "+str(self.number)+" "+self.owner class Person(models.Model): id = models.CharField(max_length=255, primary_key=True) @@ -112,3 +131,6 @@ class BookPerson(models.Model): class Placement(models.Model): category = models.ForeignKey(Category) shelf = models.CharField(max_length=10) + + def __unicode__(self): + return self.category.name+" at "+self.shelf