Commit 9cf58a33 authored by Javi Ng's avatar Javi Ng

migrated, added some entries to database

parent 63bb6761
......@@ -18,8 +18,9 @@ class BookAdmin(admin.ModelAdmin):
list_display = ("title", "get_author", "year_published", "ISBN")
list_filter = ("year_published", "publisher",)
# display author name
def get_author(self, obj):
return obj.author.title
return obj.author
# title of column for get_author
get_author.short_description = "Author"
......
......@@ -10,6 +10,10 @@ class Author (models.Model):
bio = models.TextField(max_length = 700)
# when referred to, use firstname lastname
def __str__(self):
return self.first_name + " " + self.last_name
class Book (models.Model):
title = models.CharField(max_length = 50)
author = models.ForeignKey(Author, on_delete = models.CASCADE)
......
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