Commit a04ee101 authored by justin's avatar justin

Added new blurb field for Books

parent 08ab2928
......@@ -31,6 +31,7 @@ class BooksAdmin(admin.ModelAdmin):
"publisher",
"year_published",
"isbn",
"shortened_blurb",
)
search_fields = (
"title",
......@@ -43,6 +44,11 @@ class BooksAdmin(admin.ModelAdmin):
"author",
)
def shortened_blurb(self, obj):
return obj.blurb[:50] + "..."
shortened_blurb.short_description = "Blurb"
class BooksInline(admin.StackedInline):
model = Books
......
# Generated by Django 4.1.7 on 2023-03-27 07:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0002_alter_books_isbn'),
]
operations = [
migrations.AddField(
model_name='books',
name='blurb',
field=models.TextField(blank=True),
),
]
......@@ -27,6 +27,7 @@ class Books(models.Model):
)
year_published = models.IntegerField(default=0)
isbn = models.PositiveBigIntegerField(validators=[validate_isbn])
blurb = models.TextField(blank=True)
def __str__(self):
return self.title
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