Commit 63bb6761 authored by Javi Ng's avatar Javi Ng

made bookshelf migrations

parent 890a7d8a
......@@ -9,14 +9,14 @@ class BookInline(admin.TabularInline):
class AuthorAdmin(admin.ModelAdmin):
model = Author
list_display = ("first_name", "last_name", "age", "nationality")
search_fields = ("first_name", "last_name")
list_filter = ("nationality")
search_fields = ("first_name", "last_name",)
list_filter = ("nationality",)
inlines = [BookInline]
class BookAdmin(admin.ModelAdmin):
list_display = ("title", "get_author", "year_published", "ISBN")
list_filter = ("get_author", "publisher")
list_filter = ("year_published", "publisher",)
def get_author(self, obj):
return obj.author.title
......
# Generated by Django 3.2 on 2023-03-27 05:32
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=50)),
('last_name', models.CharField(max_length=30)),
('age', models.IntegerField(default=10)),
('nationality', models.CharField(max_length=50)),
('bio', models.TextField(max_length=700)),
],
),
migrations.CreateModel(
name='Book',
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=100)),
('year_published', models.IntegerField(default=1984)),
('ISBN', models.IntegerField()),
('blurb', models.TextField(max_length=200)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bookshelf.author')),
],
),
]
......@@ -17,8 +17,5 @@ class Book (models.Model):
publisher = models.CharField(max_length = 100)
year_published = models.IntegerField(default = 1984)
ISBN = models.IntegerField(
max_value = 9999999999999,
min_value = 1000000000000
)
blurb = models.TextField(min_length = 100, max_length = 200)
\ No newline at end of file
ISBN = models.IntegerField()
blurb = models.TextField(max_length = 200)
\ No newline at end of file
......@@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'bookshelf.apps.BookshelfConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
......
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