Rodrigue
Rodrigue

Reputation: 169

django view for password_reset_confirm.html

I am trying to implement a reset password feature in a Django Project.

I did almost everything:

This is where I stopped.

This is the form I am using in password_reset_confirm.html:

<form action="" method="post">{% csrf_token %}
{{ form.new_password1.errors }}
<p class="aligned wide"><label for="id_new_password1">{% trans 'New password:' %}</label>{{     form.new_password1 }}</p>
{{ form.new_password2.errors }}
<p class="aligned wide"><label for="id_new_password2">{% trans 'Confirm password:' %}</label>{{     form.new_password2 }}</p>
<p><input type="submit" value="{% trans 'Change my password' %}" /></p>
</form>

Where should this form submit? what should I write in action="?"? Does Django have a view for this? or should I write one myself?

Upvotes: 0

Views: 147

Answers (1)

Daniel Hepper
Daniel Hepper

Reputation: 29967

The action attribute should be empty so that the form is sent to the current URL.

This is the common pattern for form handling in Django: a URL displays a form on a GET request and processes it on a POST request.

Upvotes: 1

Related Questions