Reputation: 54
I'm using django 2.2.3, I'm overriding django-allauth templates and on password_reset_from_key template I came across a NoReverseMatch Exception,
Reverse for 'account_reset_password_from_key' with no arguments not found. 1 pattern(s) tried: ['accounts/password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$']
So it expects argument and probably that argument is the key that is generated during resetting password. From the URL pattern, 'key' is the variable's name
I tried to pass it with 'key'.
<form method="POST" action="{% url 'account_reset_password_from_key' key %}">
...
</form>
but it did not work. What is wrong?
Upvotes: 0
Views: 1746
Reputation: 31
For anyone encountering issues with overriding password_change_from_key.html:
For this demonstration I'm using Django 4.2.11 and django-allauth for this 65.0.2 demonstration
so all you need to do is load the allauth tag
{% load allauth %}
and then on form action put variable action_url like this
<form method="post" action="{{action_url}}">
Here is my full Example
{% extends "base.html" %}
{% load i18n %}
{% load allauth %}
{% block content %}
<div class="container d-flex justify-content-center align-items-center" style="height: 100vh;">
<div class="col-md-4">
<h3 class="text-center mb-4">{% trans "Enter New Password" %}</h3>
<form method="post" action="{{action_url}}">
{% csrf_token %}
<div class="form-floating mb-3">
<input type="password" class="form-control" name="password1" id="password1" placeholder="{% trans 'New Password' %}" required>
<label for="password1">{% trans "New Password" %}</label>
</div>
<div class="form-floating mb-3">
<input type="password" class="form-control" name="password2" id="password2" placeholder="{% trans 'Confirm Password' %}" required>
<label for="password2">{% trans "Confirm New Password" %}</label>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary btn-block">{% trans "Reset Password" %}</button>
</div>
</form>
</div>
</div>
{% endblock %}
Upvotes: 1
Reputation: 20702
If you're not overriding the allauth view, then use action_url
:
<form method="POST" action="{{ action_url }}">
that's what the view passes to the template.
Upvotes: 5
Reputation: 55369
You didn't supply where that error is coming from, but if I look for where that url name is used in the code, it's not being used in a template.
My guess is you're calling this url name and not passing the parameters to it?
url(r"^password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$",
views.password_reset_from_key,
name="account_reset_password_from_key"),
PS:
As a general rule when overriding django app templates I'd suggest starting with the original template (eg copy the file allauth/templates/account/password_reset.html
or whatever to your templates
dir (creating all the subdirectories)), and then change the pieces you need - that way if something goes wrong it's easy to roll back and figure out why.
I know from experience that allauth templates are fairly complex and it's easy to break functionality in them if you don't fully understand how they work.
Upvotes: 0