Opened 4 years ago

Closed 4 years ago

#31972 closed New feature (wontfix)

AuthenticationForm.UsernameField does not change field widget according to USERNAME_FIELD.

Reported by: Maksudul Haque Owned by: Maksudul Haque
Component: contrib.auth Version: 3.1
Severity: Normal Keywords: forms, AuthenticationForm
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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! :)

Change History (2)

comment:1 by Maksudul Haque, 4 years ago

Owner: changed from nobody to Maksudul Haque

comment:2 by Mariusz Felisiak, 4 years ago

Component: Formscontrib.auth
Resolution: wontfix
Status: assignedclosed
Summary: Django AuthenticationForm.UsernameField does not change field widget according to UserModel.USERNAME_FIELDAuthenticationForm.UsernameField does not change field widget according to USERNAME_FIELD.
Type: BugNew feature

Yes it's intentional, this isn't worth the extra complexity. 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.

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