Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #model Book
- class Book(models.Model):
- #book types and placed
- BIOGRAPHY = 1
- FANTASY = 2
- HISTORICAL = 3
- HORROR = 4
- CLASSIC = 5
- YOUTH_LITHERATURE = 6
- NON_FICTION = 7
- MODERN_LITERATURE = 8
- POETRY = 9
- ADVENTURE = 10
- ESSAYS = 11
- ROMANCE = 12
- SATIRE = 13
- THRILLER = 14
- DRAMA = 15
- NONE = 0
- B00K_CHOICES = (
- (BIOGRAPHY,'Biography'),
- (FANTASY, 'Fantasy/Sci-Fi'),
- (HISTORICAL, 'Historical'),
- (HORROR, 'Horror'),
- (CLASSIC, 'Classic'),
- (YOUTH_LITHERATURE, 'Youth Litherature'),
- (NON_FICTION, 'Non-Fiction'),
- (MODERN_LITERATURE, 'Modern Literature'),
- (POETRY, 'Poetry'),
- (ADVENTURE, 'Adventure'),
- (ESSAYS, 'Essays'),
- (ROMANCE, 'Romance'),
- (SATIRE, 'Satire'),
- (THRILLER, 'Thriller'),
- (DRAMA, 'Drama'),
- (NONE, 'No Information'),
- )
- book_image = models.ImageField(upload_to='book_image', blank=True, null=True)
- book_name = models.CharField(max_length=255, unique=True)
- book_author = models.ForeignKey(Author, on_delete=models.CASCADE)
- book_types = models.IntegerField(choices=B00K_CHOICES, default= NONE)
- book_description = models.TextField(null=True, blank=True)
- book_pages = models.PositiveIntegerField(null=True, blank=True)
- book_published = models.DateField(null=True, blank=True)
- book_ratings = GenericRelation(Rating, related_query_name='book', default=NONE)
- def __str__(self):
- return '{}'.format(self.book_name)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement