Commit 4783430e authored by Mavrick Jordan Lee's avatar Mavrick Jordan Lee

Added Author and Books models in bookshelf App. Included bookshelf in...

Added Author and Books models in bookshelf App. Included bookshelf in installed_apps of settings. Migrated models of bookshelf.
parent e124792a
# Generated by Django 3.2 on 2023-03-27 11:40
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Author',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('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.TextField(max_length=700)),
],
),
migrations.CreateModel(
name='Books',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=50)),
('publisher', models.CharField(max_length=50)),
('year_published', models.IntegerField()),
('ISBN', models.CharField(max_length=13)),
('blurb', models.TextField(max_length=200)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bookshelf.author')),
],
),
]
from django.db import models from django.db import models
# Create your models here. # 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.TextField(max_length=700)
def __str__(self):
return self.first_name + " " + self.last_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(max_length=200)
\ No newline at end of file
...@@ -31,6 +31,7 @@ ALLOWED_HOSTS = [] ...@@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'bookshelf.apps.BookshelfConfig',
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
......
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