本文整理汇总了Python中forms.UserCreateForm.clean_password2方法的典型用法代码示例。如果您正苦于以下问题:Python UserCreateForm.clean_password2方法的具体用法?Python UserCreateForm.clean_password2怎么用?Python UserCreateForm.clean_password2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.UserCreateForm
的用法示例。
在下文中一共展示了UserCreateForm.clean_password2方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_user
# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import clean_password2 [as 别名]
def register_user(request):
template_name = 'kitchen/crispy.html'
if request.method == 'POST':
user_form = UserCreateForm(request.POST)
if user_form.is_valid():
username = user_form.clean_username()
password = user_form.clean_password2()
user_form.save()
user = authenticate(username=username,
password=password)
if user:
# save extra parameters - email
user.email = user_form.data['email']
user.save()
#ASK - may be we should init it only in one place - on login?
initUser(user)
login(request, user)
return redirect('account-list')
return render(request,
template_name,
{ 'form' : user_form })
args = {}
args.update(csrf(request))
args['form'] = UserCreateForm()
print args
return render(request, template_name, args)
示例2: signup
# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import clean_password2 [as 别名]
def signup(request):
user_form = UserCreateForm(data=request.POST)
if request.method == 'POST':
if user_form.is_valid():
username = user_form.clean_username()
password = user_form.clean_password2()
user_form.save()
user = authenticate(username=username, password=password)
login(request, user)
return redirect('/')
else:
return index(request, user_form=user_form)
return redirect('/')
示例3: register
# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import clean_password2 [as 别名]
def register(request):
if request.method == 'GET':
form = UserCreateForm()
return render_to_response("register.html", RequestContext(request, {"form": form, }))
else:
form = UserCreateForm(request.POST)
if form.is_valid():
username = form.clean_username()
password = form.clean_password2()
form.save()
user = authenticate(username=username, password=password)
login(request, user)
return HttpResponseRedirect("/")
else:
return render_to_response("register.html", RequestContext(request, {"form": form, "account_error": True }))
示例4: sign_up
# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import clean_password2 [as 别名]
def sign_up(request, user_form=None, incomplete_form=None):
if request.method == 'POST' and incomplete_form is None:
user_form = UserCreateForm(data=request.POST)
if user_form.is_valid():
max_username = User.objects.all().aggregate(Max('username'))['username__max']
if(max_username!=None and max_username!='admin'):
temp='ID00'+str(int(max_username[2:])+1)
else:
temp='ID001001'
user_form.cleaned_data['card_no']=temp
user_form.cleaned_data['username']=temp
password = user_form.clean_password2()
user_form.save()
user = authenticate(username=temp, password=password)
login(request, user)
return redirect('/')
else:
messages.error(request, "Form invalid")
return sign_up(request, user_form=user_form, incomplete_form=True)
if incomplete_form is None or not incomplete_form:
user_form = UserCreateForm()
return render(request, 'sign_up.html', {'user_form': user_form})