问题描述
我正在编写登录表单,在该表单下需要重新输入密码以进行验证。 当我输入正确的信息时,它正在工作,而当我输入空白表单键错误时,django 返回键错误。 有了正确的信息,它的工作就不会明白出了什么问题。
代码如下
library(tidyverse)
set.seed(1234)
n <- 20
tibble(partyname = sample(c("blue","red","green"),size = n,replace = T),x = rnorm(n)) %>%
group_by(partyname) %>%
mutate(n = n()) %>%
filter(n > 4)
#> # A tibble: 16 x 3
#> # Groups: partyname [2]
#> partyname x n
#> <chr> <dbl> <int>
#> 1 red 0.0183 11
#> 2 red 0.705 11
#> 3 green 0.868 5
#> 4 red 0.00501 11
#> 5 red -0.0376 11
#> 6 green 0.724 5
#> 7 red -0.497 11
#> 8 red 0.0114 11
#> 9 red 0.00986 11
#> 10 green 0.678 5
#> 11 red 1.03 11
#> 12 red -1.73 11
#> 13 red -2.20 11
#> 14 red 0.543 11
#> 15 green 0.163 5
#> 16 green 1.24 5
视图.py
forms.py
class Login(forms.Form):
name = forms.CharField()
email = forms.EmailField()
passwrd = forms.CharField(label='Password',widget=forms.PasswordInput)
rpasswrd = forms.CharField(label='Re-enter Password',widget=forms.PasswordInput)
def clean(self):
cleaned_data = super().clean()
valpwd = cleaned_data['passwrd']
valrpwd = cleaned_data['rpasswrd']
valname = self.cleaned_data['name']
if valpwd != valrpwd:
raise forms.ValidationError('Password does not match')
if len(valname) < 4:
raise forms.ValidationError('Enter More than 4 words')
elif len(valname) > 20:
raise forms.ValidationError('Enter less than 20 words')
elif valname.isdigit():
raise forms.ValidationError('No Number Allowed in Name')
登录.html
def signup(request):
if request.method == 'POST':
log = Login(request.POST)
if log.is_valid():
print('Form Validated')
name = log.cleaned_data['name']
email = log.cleaned_data['email']
passwrd = log.cleaned_data['passwrd']
rpasswrd = log.cleaned_data['rpasswrd']
print('Name :',name)
print('Email:',email)
print('Password:',passwrd)
print('Re-Password:',rpasswrd)
return HttpResponseRedirect('/rk03/success/')
else:
log = Login()
print('This is a GET request')
return render(request,'rk03/login.html',{'form': log})
感谢您的关注
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)