Commit 4b2ebb81 authored by justin's avatar justin

Initialized HTML for list of books and base template

parent 8392e27c
{% extends 'base.html' %} {% block content %}
<h1>Justin' Favorite Books</h1>
<ul>
{% for book in bookList %}
<a><li>{{book.title}}</li></a>
{% endfor %}
</ul>
{% endblock %}
......@@ -5,9 +5,5 @@
recommendations made to me by different people, especially my girlfriend. I
love reading horror, biographies, and more. Thanks!
</p>
<ul>
<li><a href="/books">Books</a></li>
<li><a href="/authors">Authors</a></li>
</ul>
{% endblock %}
from django.urls import path
from .views import index
from .views import *
urlpatterns = [
path("", index, name="home"),
path("home/", index, name="home"),
path("books/", books, name="books"),
path("books/<int:pk>/detail", BookDetailView.as_view(), name="book-detail"),
]
from django.shortcuts import render
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):
......@@ -9,6 +12,27 @@ def index(request):
)
def books(request):
bookList = Books.objects.all()
context = {"bookList": bookList}
return render(
request,
"bookshelf/books.html",
context,
)
class BookDetailView(View):
model = Books
# class BooksView(View):
# def get(self, request):
# books = Books.objects.all()
# context = {"books": books}
# return render(request, "bookshelf/books.html", context)
# class HomePageView(View):
# def get(self, request):
# return (render, "bookshelf/home.html")
......@@ -18,5 +18,5 @@ from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path("home/", include("bookshelf.urls")),
path("", include("bookshelf.urls")),
]
......@@ -10,5 +10,9 @@
<body>
<div id="content">{% block content %}{% endblock %}</div>
{% block scripts %}{% endblock %}
<ul>
<li><a href="/books">Books</a></li>
<li><a href="/authors">Authors</a></li>
</ul>
</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