本文整理汇总了Python中accounts.forms.UserRegistrationForm.non_field_errors方法的典型用法代码示例。如果您正苦于以下问题:Python UserRegistrationForm.non_field_errors方法的具体用法?Python UserRegistrationForm.non_field_errors怎么用?Python UserRegistrationForm.non_field_errors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.forms.UserRegistrationForm
的用法示例。
在下文中一共展示了UserRegistrationForm.non_field_errors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: from accounts.forms import UserRegistrationForm [as 别名]
# 或者: from accounts.forms.UserRegistrationForm import non_field_errors [as 别名]
def register(request):
data = wrap_data_accounts(request)
data.update(csrf(request))
success = False
if request.method == 'POST':
reg_form = UserRegistrationForm(request.POST)
if reg_form.is_valid():
domain = request.get_host()
new_user = reg_form.save(domain)
#username = user.username
#password = reg_form.cleaned_data.get('password1') # user.password is a hashed value
#auth_user = authenticate(username=username, password=password)
#login(request, auth_user)
success = True
else:
for error in reg_form.non_field_errors():
data['errors'].append(error)
else:
reg_form = UserRegistrationForm()
data['reg_form'] = reg_form
destination = None
if success:
destination = redirect(reverse('account_register_done'))
else:
destination = _r('account/register.html', data)
return destination