diff --git a/core/__pycache__/admin.cpython-311.pyc b/core/__pycache__/admin.cpython-311.pyc index cd6f855..eb1affd 100644 Binary files a/core/__pycache__/admin.cpython-311.pyc and b/core/__pycache__/admin.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index 9aa598b..60a1227 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 1f807fa..42da972 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 6867ddf..0581aad 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/admin.py b/core/admin.py index 8c38f3f..dbd4267 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,3 +1,4 @@ from django.contrib import admin +from .models import Book -# Register your models here. +admin.site.register(Book) diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py new file mode 100644 index 0000000..0855af4 --- /dev/null +++ b/core/migrations/0001_initial.py @@ -0,0 +1,25 @@ +# Generated by Django 5.2.7 on 2025-10-25 14:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Book', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200)), + ('author', models.CharField(max_length=200)), + ('isbn', models.CharField(max_length=13, unique=True)), + ('total_copies', models.PositiveIntegerField(default=1)), + ('available_copies', models.PositiveIntegerField(default=1)), + ], + ), + ] diff --git a/core/migrations/0002_preload_books.py b/core/migrations/0002_preload_books.py new file mode 100644 index 0000000..904d22f --- /dev/null +++ b/core/migrations/0002_preload_books.py @@ -0,0 +1,36 @@ +# Generated by Django 5.0.7 on 2025-10-25 14:30 + +from django.db import migrations + +def preload_books(apps, schema_editor): + Book = apps.get_model('core', 'Book') + books = [ + ('The Great Gatsby', 'F. Scott Fitzgerald', '9780743273565', 5, 5), + ('To Kill a Mockingbird', 'Harper Lee', '9780061120084', 3, 3), + ('1984', 'George Orwell', '9780451524935', 7, 7), + ('The Catcher in the Rye', 'J.D. Salinger', '9780316769488', 4, 4), + ('The Lord of the Rings', 'J.R.R. Tolkien', '9780618640157', 2, 2), + ('Pride and Prejudice', 'Jane Austen', '9780141439518', 6, 6), + ('The Hobbit', 'J.R.R. Tolkien', '9780618260300', 8, 8), + ('Brave New World', 'Aldous Huxley', '9780060850524', 5, 5), + ('Moby Dick', 'Herman Melville', '9781503280786', 3, 3), + ('War and Peace', 'Leo Tolstoy', '9781400079988', 2, 2), + ] + for title, author, isbn, total_copies, available_copies in books: + Book.objects.create( + title=title, + author=author, + isbn=isbn, + total_copies=total_copies, + available_copies=available_copies + ) + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0001_initial'), + ] + + operations = [ + migrations.RunPython(preload_books), + ] \ No newline at end of file diff --git a/core/migrations/__pycache__/0001_initial.cpython-311.pyc b/core/migrations/__pycache__/0001_initial.cpython-311.pyc new file mode 100644 index 0000000..27fafec Binary files /dev/null and b/core/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/core/migrations/__pycache__/0002_preload_books.cpython-311.pyc b/core/migrations/__pycache__/0002_preload_books.cpython-311.pyc new file mode 100644 index 0000000..f0d3260 Binary files /dev/null and b/core/migrations/__pycache__/0002_preload_books.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 71a8362..e6c3602 100644 --- a/core/models.py +++ b/core/models.py @@ -1,3 +1,11 @@ from django.db import models -# Create your models here. +class Book(models.Model): + title = models.CharField(max_length=200) + author = models.CharField(max_length=200) + isbn = models.CharField(max_length=13, unique=True) + total_copies = models.PositiveIntegerField(default=1) + available_copies = models.PositiveIntegerField(default=1) + + def __str__(self): + return self.title \ No newline at end of file diff --git a/core/templates/base.html b/core/templates/base.html index 788576e..31e2b18 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -1,11 +1,23 @@ -
+ -