Add books by this author section to author detail page

parent 5b284520
......@@ -10,6 +10,13 @@
<li> <b>Nationality:</b> {{object.nationality}} </li>
<li> <b>Bio:</b> {{object.bio}} </li>
</ul>
<br>
<h3> Books by {{object}} I love: </h3>
<ul>
{% for book in object.books.all %}
<li> <a href="{{book.get_absolute_url}}">{{book}}</a> </li>
{% endfor %}
</ul>
<br><hr><br><br>
<a href="../../../home/">Home</a> &nbsp; <a href="../../../authors/">Authors</a> &nbsp; <a href="../../../books/">Books</a>
{% endblock %}
\ No newline at end of file
......@@ -14,6 +14,7 @@ class AuthorListView(ListView):
class AuthorDetailView(DetailView):
model = Author
books_list = Books.objects.all()
class BooksListView(ListView):
model = Books
......
......@@ -18,8 +18,8 @@ from django.urls import include, path
from bookshelf import views
urlpatterns = [
path('bookshelf/', include('bookshelf.urls', namespace="bookshelf")),
path('admin/', admin.site.urls),
path('', include('bookshelf.urls', namespace="bookshelf")),
path('home/', views.HomeView, name='home'),
path('authors/', views.AuthorListView.as_view(), name='authors-list'),
......
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