Commit 1693e22b authored by Nate Brevin A. Que's avatar Nate Brevin A. Que

Implemented the app-level templates, and configured the urls.

parent 32df5724
Pipeline #3015 canceled with stages
{% extends 'base.html' %}
{% block title %}{{ author }}{% endblock %}
{% block content %}
<h1>{{ author }}</h1>
<h3>{{ author.age }} <br>
{{ author.nationality }}<br>
{{ author.bio }} </h3><br>
<h3> Books by {{ author }} I love: </h3>
<ul>
{% for book in author.books_set.all %}
<li><a href="http://127.0.0.1:8000/{{ book.get_absolute_url }}">{{ book.title }}</a></li>
{% endfor %}
</ul>
{% endblock %}
{% block scripts %}
<a href="http://127.0.0.1:8000/home">Home</a>
<a href="http://127.0.0.1:8000/books">Books</a>
<a href="http://127.0.0.1:8000/authors">Authors</a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}My Favorite Authors{% endblock %}
{% block content %}
<h1>{{ nickname }}'s Favorite Authors</h1>
<ul><h3>
{% for author in authors %}
<li><a href="{{ author.get_absolute_url }}">{{ author }}</li>
{% endfor %}
</h3></ul>
{% endblock %}
{% block scripts %}
<a href="http://127.0.0.1:8000/home">Home</a>
<a href="http://127.0.0.1:8000/books">Books</a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}{{ book.title }}{% endblock %}
{% block content %}
<h1>{{ book.title }}</h1>
<h3><a href="{{ book.author.get_absolute_url }}">{{ book.author }}</a><br>
{{ book.publisher }} <br>
{{ book.year_published }} <br>
{{ book.ISBN }} <br>
{{ book.blurb }} </h3>
{% endblock %}
{% block scripts %}
<a href="http://127.0.0.1:8000/home">Home</a>
<a href="http://127.0.0.1:8000/books">Books</a>
<a href="http://127.0.0.1:8000/authors">Authors</a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}My Favorite Books{% endblock %}
{% block content %}
<h1>{{ nickname }}'s Favorite Books</h1>
<ul><h3>
{% for book in books %}
<li><a href="{{ book.get_absolute_url }}">{{ book }}</li>
{% endfor %}
</h3></ul>
{% endblock %}
{% block scripts %}
<a href="http://127.0.0.1:8000/home">Home</a>
<a href="http://127.0.0.1:8000/authors">Authors</a>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}My Favorite Books & Authors{% endblock %}
{% block content %}
<h1> Welcome to {{ nickname }}'s Database of <br>
Favorite Books and Authors! </h1><br><br>
<h3>Not much of a book reader myself, but I do read <br>
and enjoy some books involving fantasy (i.e the <br>
books from the Percy Jackson and Harry Potter <br>
series, written by Rick Riordan and J.K. Rowling<br>
respectively). Other books in this database are <br>
some of the books I got introduced to when I was<br>
a kid, either through movies or school. </h3><br><br>
{% endblock %}
{% block scripts %}
<a href="http://127.0.0.1:8000/books">Books</a>
<a href="http://127.0.0.1:8000/authors">Authors</a>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import homepage_view, BooksListView, BooksDetailView, AuthorListView, AuthorDetailView
urlpatterns = [
path('home/', homepage_view, name='home'),
path('books/', BooksListView.as_view(), name='books-list'),
path('books/<int:pk>/details', BooksDetailView.as_view(), name='book-details'),
path('authors/', AuthorListView.as_view(), name='authors-list'),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name='author-details'),
]
app_name = "bookshelf"
\ 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
# Create your views here.
from .models import Books, Author
def homepage_view(request):
return render(request, 'bookshelf/home.html', {'nickname': "Brevin"})
class BooksListView(ListView):
model = Books
def get(self, request):
return render(request, 'bookshelf/books.html', {'nickname': "Brevin", 'books': self.model.objects.all()})
class BooksDetailView(DetailView):
model = Books
def get(self, request, pk):
return render(request, 'bookshelf/book_details.html', {'book': self.model.objects.get(pk=pk)})
class AuthorListView(ListView):
model = Author
def get(self, request):
return render(request, 'bookshelf/authors.html', {'nickname': "Brevin", 'authors': self.model.objects.all()})
class AuthorDetailView(DetailView):
model = Author
def get(self, request, pk):
return render(request, 'bookshelf/author_details.html', {'author': self.model.objects.get(pk=pk)})
\ No newline at end of file
......@@ -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 path, include
urlpatterns = [
path('', include('bookshelf.urls', namespace="bookshelf")),
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