Projects/worblehat-old
Projects
/
worblehat-old
Archived
12
0
Fork 0

Forandret på koblingen mellom Book og Reference.

This commit is contained in:
Øystein Ingmar Skartsæterhagen 2011-03-05 17:35:37 +00:00
parent 4624c8f4a8
commit eb7430371c
1 changed files with 9 additions and 8 deletions

View File

@ -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)