CHeck for current shelves attr before querying for it

This commit is contained in:
Mouse Reeve 2021-09-27 11:17:53 -07:00
parent 995e2c47db
commit 35131262ff

View file

@ -70,6 +70,9 @@ def related_status(notification):
@register.simple_tag(takes_context=True)
def active_shelf(context, book):
"""check what shelf a user has a book on, if any"""
if hasattr(book, "current_shelves"):
return book.current_shelves[0]
shelf = (
models.ShelfBook.objects.filter(
shelf__user=context["request"].user,