Make AuthenticationForm use the username length from the user model
AuthenticationForm has a hardcoded max_length=254 (#19130). It might be able to use the max length from the user model with something like: self.fields['username'].max_length = UserModel._meta.get_field(UserModel.USERNAME_FIELD).max_length in AuthenticationForm.__init__().
Change History
(22)
| Owner: |
changed from nobody to Ramin Farajpour Cami
|
| Status: |
new → assigned
|
| Summary: |
admin login action is maxlength 254 rether thet 150 characters → admin login action is maxlength 254 rather than 150 characters
|
| Component: |
Forms → contrib.auth
|
| Has patch: |
unset
|
| Resolution: |
→ invalid
|
| Status: |
assigned → closed
|
| Summary: |
admin login action is maxlength 254 rather than 150 characters → Make AuthenticationForm use the username length from the user model
|
| Triage Stage: |
Unreviewed → Accepted
|
| Description: |
modified (diff)
|
| Resolution: |
invalid
|
| Status: |
closed → new
|
| Patch needs improvement: |
set
|
| Cc: |
Andrey Kuzminov added
|
| Owner: |
changed from Ramin Farajpour Cami to Andrey Kuzminov
|
| Status: |
new → assigned
|
| Owner: |
changed from Andrey Kuzminov to Lucas Connors
|
| Has patch: |
unset
|
| Patch needs improvement: |
unset
|
| Triage Stage: |
Accepted → Ready for checkin
|
| Version: |
1.10 → master
|
| Patch needs improvement: |
set
|
| Triage Stage: |
Ready for checkin → Accepted
|
| Patch needs improvement: |
unset
|
| Resolution: |
→ fixed
|
| Status: |
assigned → closed
|
The suggestion doesn't account for custom user models and undoes #19130 (you might try using
git blameto investigate history next time).If the current situation is problematic for you, perhaps there would be some value in setting the max length based on the custom user model as Claude suggested .