Hi,
this is native django 4.2 code:
admin/login.html
...
<form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
...
{% url 'admin_password_reset' as password_reset_url %}
{% if password_reset_url %}
<div class="password-reset-link">
<a href="{{ password_reset_url }}">{% translate 'Forgotten your password or username?' %}</a>
</div>
{% endif %}
...
</form>
...
auth/urls.py:
urlpatterns = [
...
path("password_reset/", views.PasswordResetView.as_view(), name="password_reset"),
...
]
In template is expected admin_password_reset but auth module generates password_reset!
This is my project urls.py:
urlpatterns = []
if settings.DEBUG:
urlpatterns += [
path('__debug__/', include(debug_toolbar.urls)),
*static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT),
]
urlpatterns += [
# API
path('api/ ', include('apps.management.api_urls')),
# extra pages
path('changelog/', management_views.changelog, name='changelog'),
# (due to password reset)
path('accounts/', include('django.contrib.auth.urls')),
path('accounts/password_reset/', PasswordResetView.as_view(), name='admin_password_reset'),
# modules
path('authentication/', include('apps.authentication.urls')),
path('management/', include('apps.management.urls')),
# native admin URLs
path('', admin.site.urls), # must be last if admin URL is empty!
]
Notice that I had to add the extra
path('accounts/password_reset/', PasswordResetView.as_view(), name='admin_password_reset'),
with the requiring name admin_password_reset to display the reset password link.
Another solution would be to override the admin/login.html and admin_password_reset change to password_reset:
{% url 'password_reset' as password_reset_url %}
It obviously looks as bug and when I search stackoverflow topics and other, this bug is contained in django very long time…
My expectation is just to add
path('accounts/', include('django.contrib.auth.urls')),
to url.py and the reset link should be displayed without other extra changes. Or am I wrong?
Thanks.