本文整理汇总了Python中forms.UserCreateForm.cleaned_data['card_no']方法的典型用法代码示例。如果您正苦于以下问题:Python UserCreateForm.cleaned_data['card_no']方法的具体用法?Python UserCreateForm.cleaned_data['card_no']怎么用?Python UserCreateForm.cleaned_data['card_no']使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.UserCreateForm
的用法示例。
在下文中一共展示了UserCreateForm.cleaned_data['card_no']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sign_up
# 需要导入模块: from forms import UserCreateForm [as 别名]
# 或者: from forms.UserCreateForm import cleaned_data['card_no'] [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})