本文整理汇总了Python中models.Question.count_for方法的典型用法代码示例。如果您正苦于以下问题:Python Question.count_for方法的具体用法?Python Question.count_for怎么用?Python Question.count_for使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Question
的用法示例。
在下文中一共展示了Question.count_for方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: user_profile
# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import count_for [as 别名]
def user_profile():
"""Displays the user profile page"""
user = users.get_current_user()
question_count = Question.count_for(user)
answer_count = Answer.count_for(user)
form = ProspectiveUserForm()
all_prospective_users = ProspectiveUser.get_for(user)
prospective_user = all_prospective_users.get()
if request.method == 'POST':
if prospective_user is None:
prospective_user = ProspectiveUser (
login = user,
origin_location = get_location(form.origin_location.data),
notification_radius_in_km = form.notification_radius_in_km.data,
screen_name = form.screen_name.data
)
else:
prospective_user.origin_location = get_location(form.origin_location.data)
prospective_user.notification_radius_in_km = form.notification_radius_in_km.data
prospective_user.screen_name = form.screen_name.data
try:
prospective_user.put()
subscribe_user_for_nearby_questions(prospective_user.key.id())
flash(u'Home location successfully saved.', 'success')
return redirect(url_for('user_profile'))
except CapabilityDisabledError:
flash(u'App Engine Datastore is currently in read-only mode.', 'info')
return redirect(url_for('user_profile'))
return render_template('user_profile.html', user=user, prospective_user=prospective_user,
question_count=question_count, answer_count=answer_count, form=form)