Corrected model name from 'Books' to 'Book' and made migrations

parent 1c50cdd8
from django.contrib import admin from django.contrib import admin
from .models import Author, Books from .models import Author, Book
class AuthorAdmin(admin.ModelAdmin): class AuthorAdmin(admin.ModelAdmin):
model = Author model = Author
class BooksAdmin(admin.ModelAdmin): class BookAdmin(admin.ModelAdmin):
model = Books model = Book
admin.site.register(Author, AuthorAdmin) admin.site.register(Author, AuthorAdmin)
admin.site.register(Books, BooksAdmin) admin.site.register(Book, BookAdmin)
\ No newline at end of file \ No newline at end of file
# Generated by Django 4.1.6 on 2023-03-28 14:13
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0002_alter_books_isbn'),
]
operations = [
migrations.RenameModel(
old_name='Books',
new_name='Book',
),
]
...@@ -7,7 +7,7 @@ class Author(models.Model): ...@@ -7,7 +7,7 @@ class Author(models.Model):
nationality = models.CharField(max_length=50) nationality = models.CharField(max_length=50)
bio = models.TextField(max_length=700) bio = models.TextField(max_length=700)
class Books(models.Model): class Book(models.Model):
title = models.CharField(max_length=180) title = models.CharField(max_length=180)
author = models.ForeignKey(Author, on_delete=models.CASCADE) author = models.ForeignKey(Author, on_delete=models.CASCADE)
publisher = models.CharField(max_length=80) publisher = models.CharField(max_length=80)
......
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