本文整理匯總了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())