diff options
author | jayparikh111 | 2012-01-31 19:45:00 +0530 |
---|---|---|
committer | jayparikh111 | 2012-01-31 19:45:00 +0530 |
commit | e7f3f0436555251577f61c93f2e7c1a99c9028a1 (patch) | |
tree | 99fa5dd5d0ab8e28ae0a2be972cd310f055d7f19 /testapp/exam/forms.py | |
parent | 1a3ce22d9397a1fc95dcf99fc424a47f3fc660f7 (diff) | |
download | online_test-e7f3f0436555251577f61c93f2e7c1a99c9028a1.tar.gz online_test-e7f3f0436555251577f61c93f2e7c1a99c9028a1.tar.bz2 online_test-e7f3f0436555251577f61c93f2e7c1a99c9028a1.zip |
Updated forms.py to handle and exception when username or password fields are kept blank
Diffstat (limited to 'testapp/exam/forms.py')
-rw-r--r-- | testapp/exam/forms.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index a5ca26f..d99a04d 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -85,8 +85,11 @@ class UserLoginForm(forms.Form): def clean(self): super(UserLoginForm, self).clean() - u_name, pwd = self.cleaned_data["username"], self.cleaned_data["password"] - user = authenticate(username = u_name, password = pwd) + try: + u_name, pwd = self.cleaned_data["username"], self.cleaned_data["password"] + user = authenticate(username = u_name, password = pwd) + except Exception: + raise forms.ValidationError("Username and/or Password is not entered") if not user: raise forms.ValidationError("Invalid username/password") |