Commit 4669fb24 authored by KaoruSawade's avatar KaoruSawade

Built Author and Books models in bookshelf app

parent 626d9388
from django.db import models
# Create your models here.
class Author(models.Model):
first_name = models.CharField(max_length=300, default="")
last_name = models.CharField(max_length=300, default="")
age = models.IntegerField(default="")
nationality = models.CharField(max_length=300, default="")
bio = models.CharField(max_length=700, default="")
def __str__(self):
return '{} {}'.format(self.first_name, self.last_name)
class Books(models.Model):
title = models.CharField(max_length=300, default="")
author = models.ForeignKey(Author, on_delete=models.CASCADE)
publisher = models.CharField(max_length=300, default="")
year_published = models.DateField(null=True, default="")
ISBN = models.IntegerField(max_length=13, unique=True, null=True, default="")
blurb = models.TextField()
def __str__(self):
return "\'{}\' by {}, {}".format(self.title, self.author.last_name, self.author.first_name)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment