本文整理汇总了Python中forms.GroupForm._errors['group']方法的典型用法代码示例。如果您正苦于以下问题:Python GroupForm._errors['group']方法的具体用法?Python GroupForm._errors['group']怎么用?Python GroupForm._errors['group']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.GroupForm
的用法示例。
在下文中一共展示了GroupForm._errors['group']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: submit_group
# 需要导入模块: from forms import GroupForm [as 别名]
# 或者: from forms.GroupForm import _errors['group'] [as 别名]
def submit_group(request, group_name="none"):
if request.user.is_authenticated():
top_groups = helper_func.calc_top_groups()
saved_groups = helper_func.find_saved_groups(request.user)
if request.method == "POST":
form = GroupForm(request.POST)
if form.is_valid():
if " " in request.POST['group']:
form._errors['group'] = ErrorList([u"Spaces are not allowed"])
return render_to_response('submitgroup.html', {'form': form, 'user': request.user, 'top_groups': top_groups, 'saved_groups': saved_groups, 'group_name': group_name}, context_instance=RequestContext(request))
group= Groups(groupname= request.POST['group'], privacy= request.POST['privacy'])
group.save()
groupname = request.POST['group']
return HttpResponseRedirect('/success/'+ str(groupname))
else:
data = {'group': group_name, 'privacy': 0}
if group_name == "none":
form = GroupForm()
else:
form = GroupForm(data)
return render_to_response('submitgroup.html', {'form': form, 'user': request.user, 'top_groups': top_groups, 'saved_groups': saved_groups, 'group_name': group_name}, context_instance=RequestContext(request))
else:
return HttpResponseRedirect('/accounts/login/?next=/submitgroup/')