Now I try change this part of code in views.py
On
urls.py
This change
On this
And I have message on first site :/
W dniu wtorek, 7 października 2014 20:37:49 UTC+2 użytkownik Dariusz Mysior napisał:
-- #request.user.set_password(form.cleaned_data['password2'])
#request.user.save()
#return render(request, 'registration/change_password_success.html', {'user': request.user})
On
from django.contrib.auth import logout,login,authenticate,password_change
.
.
.
password_change(request,'registration/change_password_success.html',post_change_redirect=None,
password_change_form=FormularzPasswordChange, current_app=None, extra_context=None)
urls.py
This change
#url(r'^password_change/$', views.password_change_dom, name='change_password'),
On this
url(r'^password_change/$', 'django.contrib.auth.views.change_password'),
And I have message on first site :/
ImportError at /
cannot import name password_change
Request Method: GET Request URL: http://darmys.pythonanywhere.com/ Django Version: 1.6.5 Exception Type: ImportError Exception Value: cannot import name password_changeException Location: /home/darmys/dom/dom/views.py in <module>, line 7
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: GET Request URL: http://darmys.pythonanywhere. com/password_change/ Django Version: 1.6.5 Exception Type: ValueError Exception 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+unsubscribe@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/e0eb0d5e-151b-492c-b9d8-07096e2a5dc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment