""" template filters """ from django import template register = template.Library() @register.filter(name="book_description") def get_book_description(book): """use the work's text if the book doesn't have it""" return book.description or book.parent_work.description @register.simple_tag(takes_context=False) def get_book_file_links(book): """links for a book""" return book.file_links.filter(domain__status="approved")