本文整理汇总了Python中models.Answer.answers_for方法的典型用法代码示例。如果您正苦于以下问题:Python Answer.answers_for方法的具体用法?Python Answer.answers_for怎么用?Python Answer.answers_for使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Answer
的用法示例。
在下文中一共展示了Answer.answers_for方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: answers_for_question
# 需要导入模块: from models import Answer [as 别名]
# 或者: from models.Answer import answers_for [as 别名]
def answers_for_question(question_id):
"""Provides a listing of the question and all of its associated answers."""
question = Question.get_by_id(question_id)
user = users.get_current_user()
answerform = AnswerForm()
answers = Answer.answers_for(question)
accepted_answer = None
if question.accepted_answer_key:
accepted_answer = question.accepted_answer_key.get()
# If the user owns the question then register for Channel notifications
channel_token = None
if (question.added_by == user):
channel_id = question_answers_channel_id(user, question)
channel_token = safe_channel_create(channel_id)
return render_template('answers_for_question.html', answers=answers, question=question, user=user, form=answerform, channel_token=channel_token, accepted_answer=accepted_answer)