Commit 4d0e0d0e authored by Joei Yucoco's avatar Joei Yucoco

partially populated admin panel and created base/initial templates

- Very bare bones templates; will edit
parent 0fce4ae9
No preview for this file type
......@@ -4,9 +4,19 @@ from .models import Author, Books
class AuthorAdmin(admin.ModelAdmin):
model = Author
search_fields = ('first_name', 'last_name',)
list_display = ('first_name', 'last_name','bio',)
list_filter = ('first_name', 'last_name',)
class BooksAdmin(admin.ModelAdmin):
model = Books
search_fields = ('title', 'author',)
list_display = ('title', 'author','year_published',)
list_filter = ('title', 'author',)
admin.site.register(Author, AuthorAdmin)
admin.site.register(Books, BooksAdmin)
......
# Generated by Django 3.2 on 2023-03-27 08:30
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='books',
name='blurb',
field=models.TextField(default=0, max_length=700),
preserve_default=False,
),
]
......@@ -16,5 +16,6 @@ class Books(models.Model):
publisher = models.CharField(max_length=100)
year_published = models.IntegerField()
ISBN = models.CharField(max_length=13)
blurb = models.TextField(max_length=700)
# Create your models here.
<!DOCTYPE html>
{% extends 'base.html' %}
{% block title %}This is the page title{% endblock %}
{% block content %}
<h1>Hello World. This is the content</h1>
{% endblock %}
from django.urls import path
from .views import index
from .views import index, HomeView
urlpatterns = [
path('', index, name='index'),
path('home', HomeView.as_view(), name='home'),
]
# This might be needed, depending on your Django version
app_name = "bookshelf"
from django.shortcuts import render
from django.http import HttpResponse
from django.views import View
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from .models import Author, Books
def index(request):
return HttpResponse('Hello World!')
class HomeView(View):
def get(self, request):
return render(request, 'bookshelf/home.html', {})
# Create your views here.
......@@ -58,7 +58,7 @@ ROOT_URLCONF = 'joeiyucoco_reading.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
......
......@@ -15,8 +15,10 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import include, path
from bookshelf.views import HomeView
urlpatterns = [
path('home/', HomeView.as_view(), name='home'),
path('bookshelf/', include('bookshelf.urls', namespace="bookshelf")),
path('admin/', admin.site.urls),
]
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}My amazing site{% endblock %}</title>
{% block styles %}{% endblock %}
</head>
<body>
<div id="content">
{% block content %}{% endblock %}
</div>
{% block scripts %}{% endblock %}
</body>
</html>
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