Commit 32b47a92 authored by Star Neptune R. Sy's avatar Star Neptune R. Sy

authors.html is done, author details otw

parent cc0412ae
{% extends 'base.html' %}
{% block title %} My favorite authors {% endblock %}
{% block additional %} Neptune's favorite authors {% endblock %}
{% block content %}
<ul>
{% for author in object_list %}
<li><a href="{{author.get_absolute_url}}/details/"> {{ author.first_name }}{{ author.last_name }}
{% endfor %}
</ul>
<div>
<a href="/home">Home</a>
<a href="/books">Books</a>
</div>
{% endblock %}
{% extends 'base.html' %}
{% block title %} {{object.first_name}} {{object.last_name}} {% endblock %}
{% block additional %} {{object.first_name}} {{object.last_name}} {% endblock %}
{% block content%}
<ul>
<li> {{object.age}}
<li> {{object.nationality}}
<li> {{object.bio}}
</ul>
<div>
<p> Books by {{object.first_name}} {{object.last_name}} I love </p>
<ul>
{% for book in object_set.all %}
<li> <a href="/book/{{book.get_absolute_url}}/details/"> {{book.title}}
{% endfor %}
</ul>
<div>
<a href="/home">Home</a>
<a href="/books">Books</a>
<a href="/authors">Authors</a>\
</div>
</div>
{% endblock %}
{% extends 'base.html' %} {% extends 'base.html' %}
{% block title%} My favorite books {% endblock %} {% block title%} My favorite books {% endblock %}
{% block additional %} <h1> Neptune's favorite books</h1> {% endblock %} {% block additional %} Neptune's favorite books {% endblock %}
{% block content %} {% block content %}
<ol> <ul>
{% for obj in object_list %} {% for obj in object_list %}
<li><a href="{{obj.get_absolute_url}}/details/">{{ obj.title }}</a></li> <li><a href="{{obj.get_absolute_url}}/details/">{{ obj.title }}</a></li>
{% endfor %} {% endfor %}
</ol> </ul>
<div> <div>
<a href="/home">Home</a> <a href="/home">Home</a>
......
# bookshelf/urls.py # bookshelf/urls.py
from django.urls import path from django.urls import path
from .views import (homeView, BooksView, BooksDetail) from .views import (homeView, BooksView, BooksDetail, AuthorView, AuthorDetail)
urlpatterns = [ urlpatterns = [
path('home/', homeView, name='home'), path('home/', homeView, name='home'),
path('books/', BooksView.as_view(), name="books"), path('books/', BooksView.as_view(), name="books"),
path('books/<int:pk>/details/', BooksDetail.as_view(), name="book_details") path('books/<int:pk>/details/', BooksDetail.as_view(), name="book_details"),
path('authors/', AuthorView.as_view(), name="authors"),
path('authors/<int:pk>/details/', AuthorDetail.as_view(), name="author_details"),
] ]
# This might be needed, depending on your Django version # This might be needed, depending on your Django version
......
...@@ -15,3 +15,13 @@ class BooksView(ListView): ...@@ -15,3 +15,13 @@ class BooksView(ListView):
class BooksDetail(DetailView): class BooksDetail(DetailView):
model = Book model = Book
template_name = "bookshelf/book_detais.html" template_name = "bookshelf/book_detais.html"
class AuthorView(ListView):
model=Author
template_name = "bookshelf/authors.html"
class AuthorDetail(DetailView):
model=Author
template_name = "bookshelf/authors_details.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