#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Type: New
| feature
Status: new | Component:
| contrib.admin
Version: 5.1 | Severity: Normal
Keywords: UserAdmin, | Triage Stage:
add_form_template | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
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 manager 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.
--
Ticket URL: <
https://code.djangoproject.com/ticket/35742>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.