Hello everyone,

I have written a template and view to allow users to change their password.
As soon as it hits the if pForm.is_valid, I get an error that there is a 
required field (username) missing - I don't understand why it is asking 
for this field, as I have not created it, but am assigning the username 
in the view.  Could someone please explain what I am missing.

Regards,
Leslie

The View:
class PasswordForm(forms.Form):
   password = forms.CharField(max_length=20, widget=forms.PasswordInput())
   password2 = forms.CharField(max_length=20, widget=forms.PasswordInput())

@login_required
def Change_Password(request, next='/'):
   message = 'Change Password'
   pForm = PasswordForm()

   if request.method == 'POST':
       if request.POST['submit'] == 'Change':
           postDict = request.POST.copy()
           pForm = LoginForm(postDict)
           if pForm.is_valid():
           uPass1 = request.POST['password']
           uPass2 = request.POST['password1']
           if uPass1 == uPass2:
               user = get_object_or_404(Employee.objects.get(name__exact 
= request.session['uid']))
               #user = request.session['uid']
               print 'User: ' + user
               user.set_password(uPass1)
               user.save()
               return HttpResponseRedirect(next)
           else:
               message = 'Passwords dont match'
               pForm = PasswordForm()

   return render_to_response('employee/change_password.html', {
                                                 'pForm': pForm,
                                                 'message': message })

The Template:
{% extends "base_template.html" %}
{% block title %} Update Alert {% endblock %}
{% block top_menu %}
<a href="/">Home</a>
{% endblock %}
{% block content %}
<table>
<tr><th><h3>{{message}}</h3></th></tr>
<form action="" method="post">
<tr>{{ pForm }}</tr>
</table>
<input type="submit" name="submit" value="Change" />
</form>
{% endblock %}

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to