[Django] #35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD

29 views
Skip to first unread message

Django

unread,
Sep 8, 2024, 4:29:19 AM9/8/24
to django-...@googlegroups.com
#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.

Django

unread,
Sep 8, 2024, 4:45:30 AM9/8/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner: (none)
Type: New feature | Status: new
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage:
add_form_template | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by antoliny0919):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:1>

Django

unread,
Sep 8, 2024, 7:25:11 AM9/8/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner: (none)
Type: New feature | Status: new
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage:
add_form_template | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by antoliny0919:

Old description:
New description:
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.

--
--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:2>

Django

unread,
Sep 8, 2024, 9:13:05 AM9/8/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* needs_tests: 0 => 1
* stage: Unreviewed => Accepted
* type: New feature => Cleanup/optimization

Comment:

Hello @antoliny0919!

Thank you for submitting this ticket and the accompanying PR.

I am accepting the ticket as this seems to be a legitimate accessibility
issue when USERNAME_FIELD
has been renamed, and I haven't found another issue that deals with that
specifically.

To be clear: This is about how the prompt text on the user creation form
does not respect the USERNAME_FIELD
and always says `First, enter a username and password. Then, you’ll be
able to edit more user options.` with no
way to change that.
--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:3>

Django

unread,
Sep 8, 2024, 9:27:31 AM9/8/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Clifford Gama):

https://code.djangoproject.com/ticket/19368 is related.
--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:4>

Django

unread,
Sep 8, 2024, 12:16:12 PM9/8/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:5>

Django

unread,
Sep 8, 2024, 12:30:51 PM9/8/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Clifford Gama):

* owner: (none) => antoliny0919
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:6>

Django

unread,
Sep 9, 2024, 12:00:50 AM9/9/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by antoliny0919):

Replying to [comment:3 Clifford Gama]:
> Hello @antoliny0919!
>
> Thank you for submitting this ticket and the accompanying PR.
>
> I am accepting the ticket as this seems to be a legitimate accessibility
issue when USERNAME_FIELD
> has been renamed, and I haven't found another ticket that deals with
that specifically.
>
> To be clear: This is about how the prompt text on the user creation form
does not respect the USERNAME_FIELD
> and always says `First, enter a username and password. Then, you’ll be
able to edit more user options.` with no
> way to change that.

Replying to [comment:5 Clifford Gama]:
Thank you so much @Clifford Gama
I checked the advice you gave me in PR.
I also agree with the parts you advised and have revised the source code.
--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:7>

Django

unread,
Sep 10, 2024, 2:00:44 AM9/10/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by antoliny0919):

PR -> [https://github.com/django/django/pull/18552]
--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:8>

Django

unread,
Sep 12, 2024, 6:28:04 AM9/12/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage:
add_form_template | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by antoliny0919):

* stage: Accepted => Unreviewed

--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:9>

Django

unread,
Sep 12, 2024, 7:52:39 AM9/12/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* stage: Unreviewed => Accepted

Comment:

Hey antoliny, thank you for your work!

Please note that the Triage Stage should not be changed to unreviewed
because that means that the ticket (as a report) needs triaging. If,
instead, what needs review is your PR, you need to unset the relevant
ticket flags (needs improvement, needs tests, needs docs, etc). The
contributing docs provides details about this workflow:
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code
/submitting-patches/#patch-style
--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:10>

Django

unread,
Sep 12, 2024, 8:20:23 AM9/12/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Natalia Bidart):

I've been doing some more investigation for this ticket, and while I agree
this should be improved, I think there are a few more places where we need
to fix the usage of the literal "username". These are:

* Password reset link on the admin login page, when password reset is
enabled. Currently shows "Forgotten your password or username?"
* (Unsure) The password reset email shows "Your username, in case you’ve
forgotten:". I guess this should say "your account identifier" or similar?

The PR is on the right path but needs tests for sure.
--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:11>

Django

unread,
Sep 12, 2024, 10:59:33 PM9/12/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by antoliny0919):

First of all, I'm sorry for the change in the Triage Stage. I was
wondering what Django members thought about this ticket.
As you advised, I will look for more parts that need to be fixed with
USERNAME_FIELD and commit again.
--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:12>

Django

unread,
Sep 13, 2024, 11:05:59 PM9/13/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by antoliny0919):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:13>

Django

unread,
Sep 14, 2024, 5:58:47 PM9/14/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by antoliny0919):

I have updated all the .po files so that the username template variable
can be translated.
Only the part that was previously used as 'username' was changed to
%(username)s, but some languages were unable to change the 'username' part
because it was difficult to distinguish exactly.
What should I do about these parts?
--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:14>

Django

unread,
Sep 15, 2024, 8:02:11 AM9/15/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Claude Paroz):

.po files should never be touched by non-translators except for cases
where tests are affected. Translation updates follow their own workflow
(generally during the last weeks before a new major release).
--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:15>

Django

unread,
Sep 16, 2024, 9:02:35 AM9/16/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:16>

Django

unread,
Sep 16, 2024, 10:17:53 PM9/16/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by antoliny0919):

I updated the test code and document!!
I'd appreciate it if you could review my code.
--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:17>

Django

unread,
Sep 17, 2024, 6:05:24 AM9/17/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by antoliny0919):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:18>

Django

unread,
Sep 19, 2024, 5:25:51 AM9/19/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:19>

Django

unread,
Sep 20, 2024, 12:37:57 AM9/20/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by antoliny0919):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:20>

Django

unread,
Sep 25, 2024, 9:31:22 PM9/25/24
to django-...@googlegroups.com
#35742: Apply UserAdmin add_form_template according to User model USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: antoliny0919 | Owner:
Type: | antoliny0919
Cleanup/optimization | Status: assigned
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: UserAdmin, | Triage Stage: Accepted
add_form_template |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by antoliny0919):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35742#comment:21>
Reply all
Reply to author
Forward
0 new messages