Commit 809f8544 authored by Mavrick Jordan Lee's avatar Mavrick Jordan Lee

Created admin of bookshelf. Fixed book model in bookshelf and migrated.

parent 4783430e
from django.contrib import admin
from .models import Author, Book
# Register your models here.
class AuthorAdmin(admin.ModelAdmin):
model = Author
list_display = ('first_name', 'last_name', 'age', 'nationality', 'bio')
search_fields = ('first_name', 'last_name', 'age', 'nationality')
list_filter = ('first_name', 'last_name', 'age', 'nationality')
class BookAdmin(admin.ModelAdmin):
model = Book
list_display = ('title', 'author', 'publisher', 'year_published', 'ISBN', 'blurb')
search_fields = ('title', 'author', 'publisher', 'year_published', 'ISBN')
list_filter = ('title', 'author', 'publisher', 'year_published', 'ISBN')
admin.site.register(Author, AuthorAdmin)
admin.site.register(Book, BookAdmin)
\ No newline at end of file
# Generated by Django 3.2 on 2023-03-27 11:57
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0001_initial'),
]
operations = [
migrations.RenameModel(
old_name='Books',
new_name='Book',
),
]
......@@ -12,10 +12,13 @@ class Author(models.Model):
def __str__(self):
return self.first_name + " " + self.last_name
class Books(models.Model):
class Book(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
blurb = models.TextField(max_length=200)
def __str__(self):
return self.title
\ 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