Commit bee958d7 authored by John Riz Daniel Ramos's avatar John Riz Daniel Ramos

Added models in bookshelf and created superuser

In bookshelf app:
+ model: Author
+ model: Books

Created superuser
Migrated models
parent 6a3c34e8
...@@ -4,5 +4,4 @@ ...@@ -4,5 +4,4 @@
#ignores midtermenv virtual env #ignores midtermenv virtual env
midtermenv/ midtermenv/
.DS_Store .DS_Store
.pyc
*.pyc *.pyc
from django.contrib import admin from django.contrib import admin
from .models import Author, Books
# Register your models here.
class AuthorAdmin(admin.ModelAdmin):
model = Author
list_display = ('first_name', 'last_name', 'age', 'nationality', 'bio')
class BooksAdmin(admin.ModelAdmin):
model = Books
list_display = ('title', 'author','publisher','year_published', 'ISBN', 'blurb')
admin.site.register(Author, AuthorAdmin)
admin.site.register(Books, BooksAdmin)
\ No newline at end of file
# Generated by Django 4.1.7 on 2023-03-27 14:16
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=100)),
('last_name', models.CharField(max_length=100)),
('age', models.IntegerField()),
('nationality', models.CharField(max_length=50)),
('bio', models.TextField(max_length=700)),
],
),
migrations.CreateModel(
name='WidgetUser',
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(max_length=4)),
('ISBN', models.IntegerField(max_length=13)),
('blurb', models.TextField(max_length=200)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bookshelf.author')),
],
),
]
# Generated by Django 4.1.7 on 2023-03-27 14:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='ISBN',
field=models.IntegerField(),
),
migrations.AlterField(
model_name='widgetuser',
name='year_published',
field=models.IntegerField(),
),
]
# Generated by Django 4.1.7 on 2023-03-27 14:24
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0002_alter_widgetuser_isbn_and_more'),
]
operations = [
migrations.RenameModel(
old_name='WidgetUser',
new_name='Books',
),
]
from django.db import models from django.db import models
# Create your models here.
class Author(models.Model):
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
age = models.IntegerField()
nationality = models.CharField(max_length=50)
bio = models.TextField(max_length=700)
def __str__(self):
return '{} {}'.format(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.IntegerField()
blurb = models.TextField(max_length=200)
\ 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