本文整理汇总了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")
示例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