It work's! :)

Thank You!!

 now I have:

def password_change_dom(request):
        if request.method == 'POST':
            form = FormularzPasswordChange(request.POST)
            if form.is_valid():
                request.user.set_password(form.cleaned_data['password2'])
                request.user.save()
                template = loader.get_template(
"registration/change_password.html")
                variables = RequestContext(request,{'user':request.user})
                output = template.render(variables)
                return HttpResponseRedirect("/")
        else:
                form = FormularzPasswordChange()
                return render(request, 'registration/change_password.html', 
{'form': form})



W dniu wtorek, 7 października 2014 20:37:49 UTC+2 użytkownik Dariusz Mysior 
napisał:
>
> I have form to change password like below, and when I try to display it I 
> have an bug:
>
> ValueError at /password_change/
>   
>
> The view dom.views.password_change_dom didn't return an HttpResponse object.
>
>
>   
>
>     
>       
>       
>     
>     
>       
>       
>     
>
>     
>       
>       
>     
>
>     
>        
>       Request Method:GETRequest URL:
> http://darmys.pythonanywhere.com/password_change/Django 
> Version:1.6.5Exception 
> Type:ValueErrorException Value:
>
> The view dom.views.password_change_dom didn't return an HttpResponse object.
>
>
> My forms.py is:
> class FormularzPasswordChange(forms.Form):
>     password1 = forms.CharField(label="Hasło:",widget=forms.PasswordInput
> ())
>     password2 = forms.CharField(label="Powtórz hasło:",widget=forms.
> PasswordInput())
>
>     def clean_password2(self):
>         password1 = self.cleaned_data['password1']
>         password2 = self.cleaned_data['password2']
>         if password1 == password2:
>                 return password2
>         else:
>                 raise forms.ValidationError("Hasła się różnią")
>
>
>
> urls.py
>
> url(r'^password_change/$', views.password_change_dom, name=
> 'change_password')
>
> change_password.html
>
> {% extends "base_site_dom.html" %}
>
> {% block title %} - zmiana hasła {% endblock %}
>
> {% block content %}
>
> <center>
>     <h2>Zmiana hasła na nowe.</h2>
>     Wpisz nowe hasło 2 razy.
>     <p>
>         <div style="margin-left:35%; margin-right:35%;">
>             <fieldset>
>                 <form method="post" action=".">{% csrf_token %}
>                 {{ form.as_p }}
>                 <input type="submit" value="Zmień"> <input type="reset" 
> value="Wartoci początkowe">
>                 </form>
>             </fieldset>
>         </div>
>     </center>
>     {% endblock %}
>     {% block footer %}
>     <p>
>     <div style="text-align:center;"><a href="/">Strona głóna</a></div>
>     </p>
>     {% endblock %}
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/596fb0ed-e644-4911-afdb-9f42a9061e47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to