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