#34677 closed Cleanup/optimization (fixed)

Django Admin built-in password reset feature has UI issues

Reported by: Yaniv Toledano Owned by: Priyank Panchal
Component: contrib.admin Version: 4.2
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes

Description

The documentation refers to adding password reset features to the admin site here: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-a-password-reset-feature.

The resulting pages are, however, visually inconsistent with the rest of the admin.

Some examples:

  1. Spacing is off.
  2. No use of a class="submit-row" css class which makes the button look off.
  3. Header is hardcoded to "Django administration" even though the rest of the admin has a different branding (e.g., when set under admin.site.site_header, admin.site.site_title, etc.).
  4. The issues can be resolved here https://github.com/django/django/tree/650ce967825aa192222391bfe3003c8d97e6f1d0/django/contrib/admin/templates/registration (specifically only the password_reset_ templates).

Attachments (2)

Screenshot 2023-06-24 at 22.48.18.png (142.0 KB ) - added by Yaniv Toledano 17 months ago.
Screenshot 2023-06-24 at 22.47.02.png (71.2 KB ) - added by Yaniv Toledano 17 months ago.

Download all attachments as: .zip

Change History (17)

by Yaniv Toledano, 17 months ago

by Yaniv Toledano, 17 months ago

comment:1 by Yaniv Toledano, 17 months ago

Component: Uncategorizedcontrib.admin

comment:2 by Andrew Northall, 17 months ago

The header issues are due to the fact that the view providing the password reset functionality is not actually part of the admin site, so the site_header context variable is never inserted and reverts to the default.

This does seem like behaviour which should at least be mentioned in the documentation. An 'easy' solution to this particular problem would be to update the documentation to give the following example code, which will ensure the correct site header is used in the views:

from django.contrib import admin

admin.site.site_header = "My Admin Site"

urlpatterns = [
    path(
        "admin/password_reset/",
        auth_views.PasswordResetView.as_view(
            extra_context={"site_header": admin.site.site_header}
        ),
        name="admin_password_reset",
    ),
    path(
        "admin/password_reset/done/",
        auth_views.PasswordResetDoneView.as_view(
            extra_context={"site_header": admin.site.site_header}
        ),
        name="password_reset_done",
    ),
    path(
        "reset/<uidb64>/<token>/",
        auth_views.PasswordResetConfirmView.as_view(
            extra_context={"site_header": admin.site.site_header}
        ),
        name="password_reset_confirm",
    ),
    path(
        "reset/done/",
        auth_views.PasswordResetCompleteView.as_view(
            extra_context={"site_header": admin.site.site_header}
        ),
        name="password_reset_complete",
    ),
    path("admin/", admin.site.urls),
]

The alternative solutions to the header issue (refactoring class based views or the admin site) seem overly complex.

I'd be happy to work on this documentation based solution (and the CSS) if there is consensus on it.

Last edited 17 months ago by Andrew Northall (previous) (diff)

comment:3 by Priyank Panchal, 17 months ago

Owner: changed from nobody to Priyank Panchal
Status: newassigned

comment:4 by Natalia Bidart, 17 months ago

Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

Accepting considering I have reproduced the issue about lack of consistency for admin site header/title and button CSS. I think the solution for the former should be to update the docs, but do note that we should provide a code snippet that sets all the relevant variables.

comment:5 by Natalia Bidart, 17 months ago

Is worth noting that the lack of class="submit-row" affects more than one template, so all password reset related templates should be audited/fixed.

in reply to:  5 comment:6 by Yaniv Toledano, 17 months ago

Replying to Natalia Bidart:

Is worth noting that the lack of class="submit-row" affects more than one template, so all password reset related templates should be audited/fixed.

Agree with this point. I believe the email input field is malformed as well in comparison to the normal admin layouts.

comment:7 by Bhuvnesh, 17 months ago

Has patch: set
Patch needs improvement: set

comment:8 by priyank-panchal-inferenz, 17 months ago

Patch needs improvement: unset

I'm happy for any guidance on what needs to be improved.

comment:9 by Mariusz Felisiak, 16 months ago

Needs documentation: set
Needs tests: set
Patch needs improvement: set

Priyank, please check comments.

comment:10 by Howard Qiu, 16 months ago

The link to the Django document and the version is dev, but the ticket's version is 4.2. Which is the right version?

comment:11 by Priyank Panchal, 16 months ago

Needs documentation: unset

comment:12 by Mariusz Felisiak, 16 months ago

Needs tests: unset

comment:13 by Priyank Panchal, 16 months ago

Patch needs improvement: unset

comment:14 by Mariusz Felisiak, 16 months ago

Triage Stage: AcceptedReady for checkin

comment:15 by Mariusz Felisiak <felisiak.mariusz@…>, 16 months ago

Resolution: fixed
Status: assignedclosed

In 0016a429:

Fixed #34677 -- Made admin password reset templates more consistent.

Note: See TracTickets for help on using tickets.
Back to Top