Commit 9c7e633d authored by Jose Gabriel L. Salas's avatar Jose Gabriel L. Salas

set up admin.py

parent 6d751dff
from django.contrib import admin
from .models import Books, Author
# Register your models here.
class AuthorAdmin(admin.ModelAdmin):
model = Author
search_fields = ('first_name', 'last_name', 'nationality', )
list_display = (
'first_name', 'last_name', 'age',
'nationality', 'bio',
)
list_filter = ('nationality', 'last_name', 'first_name', )
fieldsets = [
('Author', {
'fields': [
('first_name', 'last_name', ),
'age', 'nationality', 'bio'
]
}),
]
class BooksAdmin(admin.ModelAdmin):
model = Books
search_fields = ('title', 'author', 'ISBN', )
list_display = (
'title', 'author', 'publisher',
'year_published', 'ISBN', 'blurb',
)
list_filter = ('title', 'author', 'ISBN', )
fieldsets = [
('Books', {
'fields': [
('title', 'author', ),
('publisher', 'year_published', ), 'ISBN',
'blurb'
]
}),
]
admin.site.register(Author, AuthorAdmin)
admin.site.register(Books, BooksAdmin)
......@@ -25,5 +25,5 @@ class Books(models.Model):
blurb = models.TextField()
def __str__(self):
return '{}: {}'.format(self.title, self.author)
return '{} by {}'.format(self.title, self.author)
......@@ -58,7 +58,7 @@ ROOT_URLCONF = 'gab_salas_reading.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
......
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