Commit ed15c686 authored by Washington99's avatar Washington99

Model Creation

Created the Author and Books models as well as linked them to the admin file for populating later.
parent bb05f268
from django.contrib import admin
from .models import Author, Books
# Register your models here.
class AuthorAdmin(admin.ModelAdmin):
model = Author
class BooksAdmin(admin.ModelAdmin):
model = Books
admin.site.register(Author, AuthorAdmin)
admin.site.register(Books, BooksAdmin)
\ No newline at end of file
from django.db import models
# Create your models here.
class Author(models.Model):
first_name = models.CharField(max_length = 50)
last_name = models.CharField(max_length = 50)
age = models.IntegerField()
nationality = models.CharField(max_length = 50)
bio = models.CharField(max_length = 700)
def __str__(self):
return "{}, {}".format(self.last_name, self.first_name)
class Books(models.Model):
title = models.CharField(max_length = 50)
author = models.ForeignKey(Author, on_delete = models.CASCADE)
publisher = models.CharField(max_length = 50)
year_published = models.IntegerField()
ISBN = models.CharField(max_length = 13)
blurb = models.TextField()
\ No newline at end of file
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