Commit a04ee101 authored by justin's avatar justin

Added new blurb field for Books

parent 08ab2928
...@@ -31,6 +31,7 @@ class BooksAdmin(admin.ModelAdmin): ...@@ -31,6 +31,7 @@ class BooksAdmin(admin.ModelAdmin):
"publisher", "publisher",
"year_published", "year_published",
"isbn", "isbn",
"shortened_blurb",
) )
search_fields = ( search_fields = (
"title", "title",
...@@ -43,6 +44,11 @@ class BooksAdmin(admin.ModelAdmin): ...@@ -43,6 +44,11 @@ class BooksAdmin(admin.ModelAdmin):
"author", "author",
) )
def shortened_blurb(self, obj):
return obj.blurb[:50] + "..."
shortened_blurb.short_description = "Blurb"
class BooksInline(admin.StackedInline): class BooksInline(admin.StackedInline):
model = Books 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): ...@@ -27,6 +27,7 @@ class Books(models.Model):
) )
year_published = models.IntegerField(default=0) year_published = models.IntegerField(default=0)
isbn = models.PositiveBigIntegerField(validators=[validate_isbn]) isbn = models.PositiveBigIntegerField(validators=[validate_isbn])
blurb = models.TextField(blank=True)
def __str__(self): def __str__(self):
return self.title 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