本文整理汇总了Python中books.models.Book.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Book.get_by_id方法的具体用法?Python Book.get_by_id怎么用?Python Book.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类books.models.Book
的用法示例。
在下文中一共展示了Book.get_by_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_borrowed_books
# 需要导入模块: from books.models import Book [as 别名]
# 或者: from books.models.Book import get_by_id [as 别名]
def get_borrowed_books():
cur_user = current_user()
borrowedBooks = []
for bookcopy in cur_user.get_borrowed_books():
book = Book.get_by_id(bookcopy.book.id())
owner = UserAccount.get_by_id(bookcopy.owner.id())
bookInfo = dict()
bookInfo["title"] = book.title
bookInfo["author"] = book.author
bookInfo["copyID"] = bookcopy.key.id()
bookInfo["ownerId"] = bookcopy.owner.id()
bookInfo["owner"] = owner.name
bookInfo["due_date"] = str(bookcopy.due_date)
borrowedBooks.append(bookInfo)
return jsonify({"borrowedBooks":borrowedBooks})