[Django] #31972: Django AuthenticationForm.UsernameField does not change field widget according to UserModel.USERNAME_FIELD

3 views
Skip to first unread message

Django

unread,
Sep 1, 2020, 10:58:31 AM9/1/20
to django-...@googlegroups.com
#31972: Django AuthenticationForm.UsernameField does not change field widget
according to UserModel.USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: Maksudul | Owner: nobody
Haque |
Type: Bug | Status: assigned
Component: Forms | Version: 3.1
Severity: Normal | Keywords: forms,
Triage Stage: | AuthenticationForm
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
First of all,
Thank you for such an amazing Framework. You guys are doing amazing work
on Django. really appreciate it. :)

Today I was using {{{AuthenticationForm}}} to log users in but I use a
custom User model and it specifies {{{USERNAME_FIELD}}} as email.
So, when I rendered the form {{{({{ form }})}}} I saw this:

{{{
<input type="text" name="username" autofocus="" autocapitalize="none"
autocomplete="off" maxlength="254" required="" id="id_username">
}}}

It was using {{{text}}} type input field Though It should render
{{{email}}} type field.

I don't know if it is a bug or it was intentional.

If it is a bug I would like to submit a PR! :)

--
Ticket URL: <https://code.djangoproject.com/ticket/31972>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 1, 2020, 11:09:04 AM9/1/20
to django-...@googlegroups.com
#31972: Django AuthenticationForm.UsernameField does not change field widget
according to UserModel.USERNAME_FIELD
-------------------------------------+-------------------------------------
Reporter: Maksudul Haque | Owner: Maksudul

| Haque
Type: Bug | Status: assigned
Component: Forms | Version: 3.1
Severity: Normal | Resolution:

Keywords: forms, | Triage Stage:
AuthenticationForm | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Maksudul Haque):

* owner: nobody => Maksudul Haque


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

Django

unread,
Sep 1, 2020, 11:53:59 AM9/1/20
to django-...@googlegroups.com
#31972: AuthenticationForm.UsernameField does not change field widget according to
USERNAME_FIELD.

-------------------------------------+-------------------------------------
Reporter: Maksudul Haque | Owner: Maksudul
| Haque
Type: New feature | Status: closed
Component: contrib.auth | Version: 3.1
Severity: Normal | Resolution: wontfix

Keywords: forms, | Triage Stage:
AuthenticationForm | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: assigned => closed
* resolution: => wontfix
* type: Bug => New feature
* component: Forms => contrib.auth


Comment:

Yes it's intentional, this isn't worth the extra complexity.
[https://docs.djangoproject.com/en/3.1/topics/auth/customizing/#custom-
users-and-the-built-in-auth-forms The built-in auth forms] make several
assumptions about the user model. You need to create a subclass of
`AuthenticationForm` if you want to use a different widget.

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

Reply all
Reply to author
Forward
0 new messages