Commit ba0b14df authored by Migs Atienza's avatar Migs Atienza

Finished linking books to author_details.html

parent 4cb6eeac
...@@ -15,6 +15,10 @@ class Author(models.Model): ...@@ -15,6 +15,10 @@ class Author(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse('bookshelf:authors_details', kwargs={'pk': self.pk}) return reverse('bookshelf:authors_details', kwargs={'pk': self.pk})
def get_author_books(self):
author_books = Book.objects.filter(author=self)
return author_books
class Book(models.Model): class Book(models.Model):
title = models.CharField(max_length=100) title = models.CharField(max_length=100)
......
...@@ -20,7 +20,13 @@ ...@@ -20,7 +20,13 @@
Books by {{ object.first_name }} {{ object.last_name}} I Love:<br/> Books by {{ object.first_name }} {{ object.last_name}} I Love:<br/>
</h2> </h2>
<ul> <ul>
{% for object in object.get_author_books %}
<li>
<a href="{{ object.get_absolute_url }}">
{{ object.title }}
</a>
</li>
{% endfor %}
</ul> </ul>
{% endblock %} {% endblock %}
{% block links %} {% block links %}
......
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