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