Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db import models
- class Library(models.Model):
- LIBRARY_NAME_MAX_LEN = 30
- library_name = models.CharField(
- max_length=LIBRARY_NAME_MAX_LEN,
- null=False,
- blank=False,
- verbose_name="Library Name"
- )
- def __str__(self):
- return self.library_name
- class Meta:
- verbose_name_plural = 'Library'
- class Book(models.Model):
- TITLE_MAX_LEN = 30
- AUTHOR_MAX_LEN = 30
- DESCRIPTION_LEN = 300
- title = models.CharField(
- max_length=TITLE_MAX_LEN,
- null=False,
- blank=False,
- )
- pages = models.PositiveIntegerField(
- null=False,
- blank=False,
- )
- description = models.TextField(
- max_length=DESCRIPTION_LEN,
- null=False,
- blank=False,
- )
- author = models.CharField(
- max_length=AUTHOR_MAX_LEN,
- null=False,
- blank=False
- )
- library = models.ForeignKey(
- Library,
- on_delete=models.CASCADE,
- null=True,
- blank=True
- )
- def __str__(self):
- return self.title
- class Meta:
- verbose_name_plural = 'Book'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement