Commit a6c0c722 authored by Gabriel G. Garrero's avatar Gabriel G. Garrero

Created admin panel for bookshelf app

parent 50641422
Pipeline #2979 canceled with stages
from django.contrib import admin
# Register your models here.
from .models import Author, Books
class AuthorAdmin(admin.ModelAdmin):
model = Author
list_display = ('first_name', 'last_name', 'age', 'nationality', 'bio',)
search_fields = ('first_name', 'last_name',)
list_filter = ('first_name', 'last_name', 'age',)
class BooksAdmin(admin.ModelAdmin):
model = Books
list_display = ('title', 'author', 'publisher', 'year_published', 'ISBN', 'blurb',)
search_fields = ('title', 'author', 'publisher', 'year_published', 'ISBN',)
list_filter = ('title', 'author', 'publisher', 'year_published', 'ISBN',)
def get_author(self, obj):
return obj.books.author
get_author.short_description = 'name'
admin.site.register(Author, AuthorAdmin)
admin.site.register(Books, BooksAdmin)
\ No newline at end of file
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