done html templates, CBV, with links and urls implemented

parent cbe6b943
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.title }}{% endblock %}
{% block heading %} {{ object.title }} {% endblock %}
{% block content%}
<p>{{ object.first_name }} {{ object.last_name }}</p>
<p>{{ object.age }}</p>
<p>{{ object.nationality }}</p>
<p>{{ object.bio }}</p>
<h4>Books by {{ object.first_name }} {{ object.last_name }} I love:</h4>
{% for books in object.books_set.all %}
<li><a href="http://localhost:8000/books/{{ books.pk }}/details">{{ books.title }}</a></li>
{% endfor %}
{%endblock%}
{% block pagelinks %}
<pre>
<a href="http://localhost:8000/home/">Home</a> <a href="http://localhost:8000/books/">Books</a> <a href="http://localhost:8000/authors/">Authors</a>
</pre>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} My Favorite Authors {% endblock %}
{% block heading %} Tenten's Favorite Authors:{% endblock %}
{% block content%}
{% for object in object_list %}
<li><a href="http://localhost:8000/authors/{{ object.pk }}/details">{{ object.first_name }} {{ object.last_name }}</a></li>
{% endfor %}
{%endblock%}
{% block pagelinks %}
<pre>
<a href="http://localhost:8000/home/">Home</a> <a href="http://localhost:8000/books/">Books</a>
</pre>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.title }}{% endblock %}
{% block heading %} {{ object.title }} {% endblock %}
{% block content%}
<p><a href="http://localhost:8000/authors/{{ object.pk }}/details">{{ object.author }}</a></p>
<p>{{ object.publisher }}</p>
<p>{{ object.year_published }}</p>
<p>{{ object.ISBN }}</p>
<p>{{ object.blurb }}</p>
{%endblock%}
{% block pagelinks %}
<pre>
<a href="http://localhost:8000/home/">Home</a> <a href="http://localhost:8000/books/">Books</a> <a href="http://localhost:8000/authors/">Authors</a>
</pre>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} My Favorite Books {% endblock %}
{% block heading %} Tenten's Favorite Books:{% endblock %}
{% block content%}
{% for object in object_list %}
<li><a href="http://localhost:8000/books/{{ object.pk }}/details">{{ object.title }}</a></li>
{% endfor %}
{%endblock%}
{% block pagelinks %}
<pre>
<a href="http://localhost:8000/home/">Home</a> <a href="http://localhost:8000/authors/">Authors</a>
</pre>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} My Favorite Books & Authors {% endblock %}
{% block heading %} Welcome to Tenten's Database of Favorite Books and Authors!{% endblock %}
{% block content%}
<p>
My taste in books leans more towards Young Adult Fiction and Queer Romance or coming-of-age stories.
Signifincant authors in my early bookworm days are Rick Riordan, Adam Silvera, Rainbow Rowell, etc.
</p>
{%endblock%}
{% block pagelinks %}
<pre>
<a href="http://localhost:8000/books/">Books</a> <a href="http://localhost:8000/authors/">Authors</a>
</pre>
{% endblock %}
\ No newline at end of file
from django.urls import path
from . import views
from .views import BooksPageView, BooksDetailView, AuthorsPageView, AuthorsDetailView
urlpatterns = [
path('home/', views.Homepage, name = "home"),
path('books/', BooksPageView.as_view(), name = "books" ),
path('books/<int:pk>/details', BooksDetailView.as_view(), name = "books_details"),
path('authors/', AuthorsPageView.as_view(), name = "authors"),
path('authors/<int:pk>/details', AuthorsDetailView.as_view(), name = "author_details"),
]
\ No newline at end of file
from django.shortcuts import render
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from .models import Books, Author
# Create your views here.
def Homepage(request):
return render(request, 'bookshelf/home.html')
class BooksPageView(ListView):
model = Books
class BooksDetailView(DetailView):
model = Books
class AuthorsPageView(ListView):
model = Author
class AuthorsDetailView(DetailView):
model = Author
\ No newline at end of file
<html>
<head>
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<div id="page heading">
<h1>{% block heading %}{% endblock %}</h1>
</div>
<div id="content">
{% block content %}{% endblock %}
</div>
<div id="page links">
{% block pagelinks %}{% endblock %}
</div>
</body>
</html>
\ No newline at end of file
......@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/3.2/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
......@@ -55,7 +56,7 @@ ROOT_URLCONF = 'tentenchidrome_reading.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
......
......@@ -14,8 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import include, path
urlpatterns = [
path('', include("bookshelf.urls")),
path('admin/', admin.site.urls),
]
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