我有以下表单类和相应的清理方法......
class SOFIATMUserLogin(forms.Form):
Username=forms.CharField(label='Username')
Password=forms.CharField(label='Password', widget=forms.PasswordInput)
def clean_Username(self):
user=self.cleaned_data['Username']
try:
SOFIALogin.objects.get(UserName=user)
except Exception:
raise forms.ValidationError('Username invalid...')
def clean_Password(self):
upass=self.cleaned_data['Password']
在clean_Password方法中,我想检查为有效用户名输入的密码是否正确...所以我需要获取用户名值...如何在clean_Password方法中访问此...请协助!! !!
答案 0 :(得分:0)
如果我理解你的问题,你只需要:self.cleaned_data ['Username']