Add books by this author section to author detail page

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