2 from django
.db
import models
5 class Author(models
.Model
):
6 name
= models
.CharField(max_length
=100)
7 age
= models
.IntegerField()
8 friends
= models
.ManyToManyField('self', blank
=True)
10 def __unicode__(self
):
13 class Publisher(models
.Model
):
14 name
= models
.CharField(max_length
=255)
15 num_awards
= models
.IntegerField()
17 def __unicode__(self
):
20 class Book(models
.Model
):
21 isbn
= models
.CharField(max_length
=9)
22 name
= models
.CharField(max_length
=255)
23 pages
= models
.IntegerField()
24 rating
= models
.FloatField()
25 price
= models
.DecimalField(decimal_places
=2, max_digits
=6)
26 authors
= models
.ManyToManyField(Author
)
27 contact
= models
.ForeignKey(Author
, related_name
='book_contact_set')
28 publisher
= models
.ForeignKey(Publisher
)
29 pubdate
= models
.DateField()
31 def __unicode__(self
):
34 class Store(models
.Model
):
35 name
= models
.CharField(max_length
=255)
36 books
= models
.ManyToManyField(Book
)
37 original_opening
= models
.DateTimeField()
38 friday_night_closing
= models
.TimeField()
40 def __unicode__(self
):