Hi, all ,
CODE:
view.py
-----------------------------------------------------------------
def user_login(request):
if request.method == 'POST':
form = UserLoginForm(request.POST) # get the form from POST
if form.cleaned_name(): # call the check
method
return HttpResponseRedirect('/')
else :
return render_to_response('user/login_failed.html')
else:
form = UserLoginForm()
return
render_to_response('user/login.html',RequestContext(request,
{'form': form}))
form.py
------------------------------------------------------------------
class UserLoginForm(forms.Form):
name= forms.CharField(label='Username',max_length=30)
password= forms.CharField(label='Password', widget=forms.PasswordInput
())
def cleaned_name(self):
username = self.cleaned_data['name'] # ERROR LINE , I tried to
get
the name value Posted by User
thePassword = self.cleaned_data['name']
theUser = User.objects.get(name=self.cleaned_data['username'])
if theUser.password == thePassword:
return ture
else:
return false
ERROR:
'UserLoginForm' object has no attribute 'cleaned_data'
Any comment or help I would be highly appreciated.
BestRegard
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---