Commit d6139f53 authored by Alliyah Marcelo's avatar Alliyah Marcelo

Finalized admin panel for bookshelf app.

parent 9e42561c
Pipeline #3084 canceled with stages
from django.contrib import admin 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', 'nationality',)
search_fields = ('first_name', 'last_name', 'nationality',)
list_filter = ('first_name', 'last_name', 'nationality',)
fieldsets = [
('Author Data', {
'fields':[
('first_name', 'last_name', 'age', 'nationality'), 'bio'
]
}),
]
class BooksAdmin(admin.ModelAdmin):
model = Books
list_display = ('title', 'year_published', 'ISBN', 'author', 'publisher',)
search_fields = ('title', 'ISBN', 'author', 'publisher',)
list_filter = ('title', 'ISBN', 'author', 'publisher',)
fieldsets = [
('Book Data', {
'fields':[
('title', 'year_published', 'ISBN', 'publisher'), 'author', 'blurb'
]
}),
]
admin.site.register(Author, AuthorAdmin)
admin.site.register(Books, BooksAdmin)
\ No newline at end of file
...@@ -25,4 +25,4 @@ class Books(models.Model): ...@@ -25,4 +25,4 @@ class Books(models.Model):
blurb = models.TextField() blurb = models.TextField()
def __str__(self): def __str__(self):
return '{} ({})'.format(self.title, self.author) return '{} ({}) by {}'.format(self.title, self.year_published, self.author)
from django.urls import path from django.urls import path
from .views import index from .views import index
......
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