I have downloaded here some templates for django-registration.
Can somebody explain to me how resetting the password works ?
In password_reset_confirm.html, I don't understand where the validlink
comes from :
{% extends "base.html" %}
{% block content %}
{% if validlink %}
<form method="post" action=".">
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>
{% else %}
<p>Password reset failed.</p>
{% endif %}
{% endblock %}
In password_reset_email.html, I don't understand where that block called "reset_link" comes from, because we are not extending any template :
Reset password at {{ site_name }}
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url auth_password_reset_confirm uidb36=uid, token=token %}
{% endblock %}
Furthermore shouldn't it be site.name ?
validlink
is initialised in Django's password_reset_confirm view:
The reset_link
block from is here so that you can extend this template from your project.
The views for password_reset_confirm
and password_reset_email
will be run from Django source. For example, password_reset_confirm
view will render template:
template_name='registration/password_reset_confirm.html'
Assuming you have TEMPLATE_LOADERS
in the following order in your settings.py
:
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader'
)
By placing the customised password_reset_confirm.html
in your project at:
yourproject/
templates/
registration/
password_reset_confirm.html
Django's template loader searches for password_reset_confirm.html
in your project's templates
folder first and then in Django's own registration app if the previous search is unsuccessful.
You can read more about Django's template loader.
Every django app you download from pypi is stored in your (in case of virtualenv)envname/lib/site-packages/app-installed. As you define urls in your app on local server you developed yourself same like that apps are stored with urls in site-packages. In case you need to see a ref for the app url you can look into relevant urls.py. In your case you can go to registration and see for url name assigned to it. Your input should be something like "<input class='btn btn-primary' type="submit" value="{% trans 'Reset' %}" />"
below the form. {% trans 'Reset' %} will take you to the exact url.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With