Get all books for tag

This commit is contained in:
Mouse Reeve
2020-02-21 09:15:20 -08:00
parent 375ff9365f
commit cb6b98992c
3 changed files with 8 additions and 4 deletions

View File

@ -243,11 +243,11 @@ def author_page(request, author_identifier):
def tag_page(request, tag_id):
''' books related to a tag '''
tag = models.Tag.objects.filter(identifier=tag_id).first()
books = models.Book.objects.filter(tag=tag).all()
tag_obj = models.Tag.objects.filter(identifier=tag_id).first()
books = models.Book.objects.filter(tag__identifier=tag_id)
data = {
'books': books,
'tag': tag,
'tag': tag_obj,
}
return TemplateResponse(request, 'tag.html', data)