Made migrations and created the admin panel

parent b8f8fd13
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)
# Generated by Django 4.1.7 on 2023-03-28 11:56
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(blank=True, max_length=100, null=True)),
('last_name', models.CharField(blank=True, max_length=100, null=True)),
('age', models.IntegerField(blank=True, null=True)),
('nationality', models.CharField(blank=True, max_length=100, null=True)),
('bio', models.TextField(blank=True, null=True)),
],
),
migrations.CreateModel(
name='Book',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(blank=True, max_length=255, null=True)),
('publisher', models.CharField(blank=True, max_length=255, null=True)),
('year_published', models.DateField(blank=True, max_length=255, null=True)),
('ISBN', models.IntegerField(blank=True, null=True)),
('blurb', models.TextField(blank=True, null=True)),
('course', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='bookshelf.author')),
],
),
]
# Generated by Django 4.1.7 on 2023-03-28 12:01
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0001_initial'),
]
operations = [
migrations.RenameModel(
old_name='Book',
new_name='Books',
),
]
......@@ -9,7 +9,7 @@ class Author(models.Model):
bio = models.TextField(blank=True, null=True)
class Book(models.Model):
class Books(models.Model):
title = models.CharField(max_length=255, blank=True, null=True)
course = models.ForeignKey(Author, on_delete=models.CASCADE, null=True)
publisher = models.CharField(max_length=255, blank=True, null=True)
......
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