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


Python Answer.get_by_id方法代码示例

本文整理汇总了Python中models.Answer.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Answer.get_by_id方法的具体用法?Python Answer.get_by_id怎么用?Python Answer.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Answer的用法示例。


在下文中一共展示了Answer.get_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_user_choice

# 需要导入模块: from models import Answer [as 别名]
# 或者: from models.Answer import get_by_id [as 别名]
def save_user_choice(request):
    question = get_question()
    
    post = request.POST
    if post:
        answer_ids = map(int, post.getlist('chooses'))
        username = post['username'] if 'username' in post else None 
        answers = Answer.get_by_id(answer_ids)
        user = users.get_current_user()
        if user:
            user_choose = Choose.gql("WHERE user = :1", user).get()
            if not user_choose:
                user_choose = Choose(user=user)
        else:
            user_choose = Choose(username=username)
        user_choose.question=question

        user_choose.answers = [a.key() for a in answers]
        user_choose.save()

    return redirect("polls.views.thank_you")
开发者ID:soswow,项目名称:yet-another-one-poll-on-app-engine,代码行数:23,代码来源:views.py

示例2: _get_answer_by_id

# 需要导入模块: from models import Answer [as 别名]
# 或者: from models.Answer import get_by_id [as 别名]
def _get_answer_by_id(answer_id):
    answer = Answer.get_by_id(int(answer_id))
    return answer
开发者ID:soswow,项目名称:yet-another-one-poll-on-app-engine,代码行数:5,代码来源:views.py


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