本文整理汇总了Python中tags.models.Tag.put方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.put方法的具体用法?Python Tag.put怎么用?Python Tag.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tags.models.Tag
的用法示例。
在下文中一共展示了Tag.put方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: submit_suggestion
# 需要导入模块: from tags.models import Tag [as 别名]
# 或者: from tags.models.Tag import put [as 别名]
def submit_suggestion(request, suggestion_form):
"""
Save a new suggestion in the database.
"""
slug = suggestion_form.cleaned_data['slug']
tag_list = suggestion_form.cleaned_data['tags'].split()
for tag_name in tag_list:
tag = Tag.get_by_key_name(tag_name)
if tag is None:
tag = Tag(key_name=tag_name, count=0)
tag.suggestions.append(slug)
tag.count += 1
tag.put()
suggestion = Reminder(
key_name=slug,
title=suggestion_form.cleaned_data['title'],
days=suggestion_form.cleaned_data['days'],
months=suggestion_form.cleaned_data['months'],
years=suggestion_form.cleaned_data['years'],
miles=suggestion_form.cleaned_data['miles'],
kilometers=suggestion_form.cleaned_data['kilometers'],
tags=tag_list)
logging.debug(suggestion)
suggestion.put()
return HttpResponseRedirect(suggestion.get_absolute_url())