Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
gothack329 committed Mar 7, 2018
1 parent 6872930 commit ae85cab
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
Binary file modified userpage/__pycache__/views.cpython-36.pyc
Binary file not shown.
25 changes: 24 additions & 1 deletion userpage/templates/userpage/change.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,36 @@
<form class="form-inline " method="post" action="" novalidate>{% csrf_token %}
<a href="/">物志</a> › 修改密码
<hr>
{{form.as_p}}
{{change_form.as_p}}
<p style="text-align:center">
<button class="btn btn-primary" type="submit" >确认修改</button>
</p>
</form>
</div>

{% if change_form.errors %}
{% for field in change_form %}
{{field}}
{% for error in field.errors %}
<script type="text/javascript">
$.notify({
// options
message: '{{ error|escape }}',
},{
// settings
type: 'danger',
delay: 5000,
timer: 1000,
animate: {
enter: 'animated flipInY',
exit: 'animated flipOutX'
},
},);
</script>
{% endfor %}
{% endfor %}
{% endif %}



{% if messages %}
Expand Down
9 changes: 5 additions & 4 deletions userpage/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,14 @@ def password_change(request):
if form.is_valid():
form.save()
update_session_auth_hash(request, form.user)
print(dir(form))
messages.success(request,'密码修改成功!')
else:
messages.error(request,form.errors)
print(dir(messages))
#print(form.errors.as_data())
messages.error(request,form.errors.as_json())
#print(dir(messages))
pass
return redirect('.')
else:
form = PasswordChangeForm(user=request.user)
return render(request,'userpage/change.html',{'form':form})
return render(request,'userpage/change.html',{'change_form':form})

0 comments on commit ae85cab

Please sign in to comment.