本文整理汇总了Python中blog.forms.CommentForm.initial['email']方法的典型用法代码示例。如果您正苦于以下问题:Python CommentForm.initial['email']方法的具体用法?Python CommentForm.initial['email']怎么用?Python CommentForm.initial['email']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.forms.CommentForm
的用法示例。
在下文中一共展示了CommentForm.initial['email']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: entry
# 需要导入模块: from blog.forms import CommentForm [as 别名]
# 或者: from blog.forms.CommentForm import initial['email'] [as 别名]
def entry(request,year,month,day,slug):
post = get_object_or_404(Entry,
publish_date__year=year,
publish_date__month=month,
publish_date__day=day,
slug=slug)
if request.user.is_anonymous():
post.view += 1
post.save(update_fields=["view"])
form = CommentForm(request.POST or None)
if form.is_valid():
comment = form.save(commit=False)
comment.entry = post
comment.save()
request.session["name"] = comment.name
request.session["email"] = comment.email
request.session["website"] = comment.website
return redirect(request.path)
form.initial['name'] = request.session.get('name')
form.initial['email'] = request.session.get('email')
form.initial['website'] = request.session.get('website')
return render(request, 'blog/entry.html', {'post': post, 'form': form})