From eb7430371c94ef1f5dca3acba1caa4b4bf9ece8d Mon Sep 17 00:00:00 2001 From: oysteini Date: Sat, 5 Mar 2011 17:35:37 +0000 Subject: [PATCH] =?UTF-8?q?Forandret=20p=C3=A5=20koblingen=20mellom=20Book?= =?UTF-8?q?=20og=20Reference.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/web/library/models.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/python/web/library/models.py b/python/web/library/models.py index 7183f0f..91904a9 100644 --- a/python/web/library/models.py +++ b/python/web/library/models.py @@ -27,13 +27,6 @@ class ReferenceType(models.Model): 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) @@ -48,7 +41,7 @@ class Book(models.Model): description = models.CharField(max_length=1023, null=True, blank=True) picture = models.ImageField(upload_to='%Y/%m/%d/pictures', null=True, blank=True) thumbnail = models.ImageField(upload_to='%Y/%m/%d/thumbnails', null=True, blank=True) - references = models.ManyToManyField(Reference, related_name='books',null=True, blank=True) +# references = models.ManyToManyField(Reference, related_name='books',null=True, blank=True) #Generate a string from book info def to_string(self, commit=False): @@ -124,6 +117,14 @@ class Book(models.Model): # class Meta: # unique_together=(("isbn","id"),) +class Reference(models.Model): + book = models.ForeignKey(Book, related_name='references') + reference_type = models.ForeignKey(ReferenceType) + text = models.CharField(max_length=1023) + + def __unicode__(self): + return self.text + class Id(models.Model): id = models.CharField(max_length=511, primary_key=True) book = models.OneToOneField(Book)