Opened 2 months ago
Last modified 4 weeks ago
#35742 closed Cleanup/optimization
Apply UserAdmin add_form_template according to User model USERNAME_FIELD — at Version 2
Reported by: | antoliny0919 | Owned by: | |
---|---|---|---|
Component: | contrib.auth | Version: | 5.1 |
Severity: | Normal | Keywords: | UserAdmin, USERNAME_FIELD |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Hello!! I made a ticket because there was something ambiguous on the Add page of the UserAdmin model.
The UserAdmin model customizes the ModelAdmin Add page with add_form_template variable.
And the template used as the value for that variable is admin/auth/user/add_form.html.
I felt this part was ambiguous in the add_form template.
... {% block form_top %} {% if not is_popup %} <p>{% translate 'First, enter a username and password. Then, you’ll be able to edit more user options.' %}</p> {% else %} <p>{% translate "Enter a username and password." %}</p> {% endif %} {% endblock %} ...
In the UserAdmin model, when a user uses a custom user model, USERNAME_FIELD allows a field other than username to be used.
However, in the above template, <p>{%translate 'First, enter a username and password. Then, you'll be able to edit more user options.'%}</p> This part is target at the default user provided by Django, so it is awkward because "username" is also seen when customizing USERNAME_FIELD using custom users.
Is this part using a static value because it is a ModelAdmin based on the User model provided by Django?
I added the method to the UserAdmin model and modified add_form.html to show the tag using the USERNAME_FIELD value.
I respect the great code from the Django maintainer and contributors. But I made a ticket out of my personal opinion that the code would be more curious and in a better way.
Thank you for reading it.