Password reset link is not displayed by default

78 views
Skip to first unread message

Marty

unread,
Jul 23, 2023, 9:40:25 AM7/23/23
to Django developers (Contributions to Django itself)
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'),
to display the reset password link. Is this on purpose in django or is this bug that should be fixed?


Thanks.

Adam Johnson

unread,
Jul 24, 2023, 8:00:44 AM7/24/23
to django-d...@googlegroups.com
Hi!

You've found the wrong mailing list for this post. This mailing list is for discussing the development of Django itself, not for support using Django. This means the discussions of bugs and features in Django itself, rather than in your code using it. People on this list are unlikely to answer your support query with their limited time and energy.

For support, please follow the "Getting Help" page: https://docs.djangoproject.com/en/stable/faq/help/ . This will help you find people who are willing to support you, and to ask your question in a way that makes it easy for them to answer.

That said, in response to your question: Django's default admin setup does not come with a password reset view. It only has a "change password" view for logged in users. If you want to support not-logged-in users to reset their passwords, you need to add a URL as you have done.

Thanks,

Adam

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/24afc193-c22a-4be8-9f3b-14315b2b7a8bn%40googlegroups.com.

Marty

unread,
Aug 14, 2023, 8:22:59 PM8/14/23
to Django developers (Contributions to Django itself)
Hi,

ah, I see. Okay, thanks for info and link.

Marty

Reply all
Reply to author
Forward
0 new messages