当前位置: 首页>>代码示例>>Python>>正文


Python Answer.answers_for方法代码示例

本文整理汇总了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)
开发者ID:ahbuntu,项目名称:ece1779,代码行数:19,代码来源:views.py


注:本文中的models.Answer.answers_for方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。