本文整理汇总了Python中models.Page.redirect方法的典型用法代码示例。如果您正苦于以下问题:Python Page.redirect方法的具体用法?Python Page.redirect怎么用?Python Page.redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Page
的用法示例。
在下文中一共展示了Page.redirect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit
# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import redirect [as 别名]
def edit(request, talk):
c = {}
pagetitle = request.path[1:]
pagetitle = pagetitle.rsplit('/')[0]
pagedata = getlatestdata(pagetitle)
if not pagedata:
oldcontents = ""
elif talk:
oldcontents = pagedata.talkcontents
else:
oldcontents = pagedata.contents
blankform = PageForm({'pagecontent': oldcontents})
if request.method == "POST":
form = PageForm(request.POST)
if form.is_valid():
if form.cleaned_data['redirect']:
if not Page.objects.filter(title=form.cleaned_data['pagecontent']).exists():
return render_to_response('edit.html', {'title' : 'Editting '+pagetitle, 'form' : blankform, 'oldcontents': oldcontents})
newrev = Page(title=pagetitle)
newestrev = Page.objects.filter(title=pagetitle).count()
newrev.redirect = form.cleaned_data['redirect']
if pagedata:
talkorno = (form.cleaned_data['pagecontent'], pagedata.contents, pagedata.talkcontents)
else:
talkorno = (form.cleaned_data['pagecontent'], "", "")
if talk:
newrev.talkcontents = talkorno[0]
newrev.contents = talkorno[1]
else:
newrev.contents = talkorno[0]
newrev.talkcontents = talkorno[2]
newrev.revision = newestrev + 1
newrev.save()
return render_to_response('base.html', {'title': 'XQZ Programming Wiki'})
c.update({'title' : "Editting "+pagetitle, 'form' : blankform, 'oldcontents': oldcontents})
return render_to_response('edit.html', c, context_instance=RequestContext(request))