本文整理汇总了Python中models.Tag.text方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.text方法的具体用法?Python Tag.text怎么用?Python Tag.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Tag
的用法示例。
在下文中一共展示了Tag.text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: newEvent
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import text [as 别名]
def newEvent(request):
# some printout crap
for param, val in request.POST.items():
print param, val
print "articles:", request.POST.getlist('articles')
# start doing actual work
e = NewsEvent.objects.get(pk=request.POST['pk'])
print e.id
e.articles.clear()
if 'articles' in request.POST:
for articleId in request.POST.getlist('articles'):
e.articles.add(articleId)
if 'title' in request.POST:
e.title = request.POST['title']
if 'eventTag' in request.POST:
e.eventTag = request.POST['eventTag']
# handle TimelineEntries
if 'timelineEntry_add' in request.POST:
for timelineEntry in request.POST.getlist('timelineEntry_add'):
newTLEntry = TimelineEntry()
newTLEntry.text = timelineEntry
newTLEntry.event_id = request.POST['pk']
newTLEntry.save()
for param, val in request.POST.items():
index = param.find('timelineEntry_')
if index > -1 and param != 'timelineEntry_add':
tlEntryId = param[index+len('timelineEntry_'):]
tlEntry = TimelineEntry.objects.get(pk=tlEntryId)
tlEntry.text = val
tlEntry.save()
# Editors
e.editors.clear()
if 'editors' in request.POST:
print "handling editors..."
for editorId in request.POST.getlist('editors'):
print editorId
e.editors.add(editorId)
# tags
e.tag_set.clear()
if 'tags' in request.POST:
for tagVal in request.POST.getlist('tags'):
try:
tagVal = int(tagVal)
e.tag_set.add(tagVal)
except ValueError:
newTag = Tag()
newTag.text = tagVal
newTag.save()
e.tag_set.add(newTag.id)
e.save()
# return HttpResponseRedirect("/edit_event/" + request.POST['pk'])
return HttpResponseRedirect("/event/" + request.POST['pk'])