Commit 06c05f6e authored by Joaquin Hermosisima's avatar Joaquin Hermosisima

edited models.py

parent 2c59b819
from django.db import models from django.db import models
from django.urls import reverse
# Create your models here. # Create your models here.
class Author(models.Model):
def __str__(self) -> str:
return self.first_name+' '+self.last_name
def get_absolute_url(self):
return reverse('bookshelf:authoritem', kwargs={'pk':self.pk})
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
age = models.IntegerField(default=0)
nationality = models.CharField(max_length=50)
bio = models.CharField(max_length=700)
class Book(models.Model):
def __str__(self) -> str:
return self.title
def get_absolute_url(self):
return reverse('bookshelf:bookitem', kwargs={'pk': self.pk})
title = models.CharField(max_length=50)
author = models.ForeignKey(Author, on_delete=models.CASCADE)
publisher = models.CharField(max_length=50)
year_published = models.CharField(max_length=50)
ISBN = models.IntegerField(default=0)
blurb = models.TextField()
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