Opened 6 years ago
Closed 6 years ago
#31364 closed Bug (invalid)
django.contrib.auth.forms.AuthenticationForm assumes 'username' as the USERNAME_FIELD
| Reported by: | Jihoon Park | Owned by: | nobody |
|---|---|---|---|
| Component: | Forms | Version: | 3.0 |
| Severity: | Normal | Keywords: | AuthenticationForm username |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
https://github.com/django/django/blob/3.0.4/django/contrib/auth/forms.py#L214 reads:
self.user_cache = authenticate(self.request, username=username, password=password)
However, USERNAME_FIELD may not be 'username'. This can be fixed very easily:
credentials = {UserModel.USERNAME_FIELD: username, 'password': password}
self.user_cache = authenticate(self.request, **credentials)
Note:
See TracTickets
for help on using tickets.
nvm