#30776: AuthenticationForm's username field doesn't set maxlength HTML
attribute.
------------------------------+----------------------------------------
Reporter: felixxm | Owner: Sam Reynolds
Type: Bug | Status: assigned
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Comment (by Carlton Gibson):
> Is it a good idea to change a bunch of the field properties in the
form's init?
Grrr. This is horrible... :) — It seems necessary, at least for the tests,
because `UserModel` is swappable, so when `AuthenticationForm` (and
others) are declared, `UserModel` is `auth.User`, so we can't use
`UserModel` to pass `max_length` in the class definition.
Nor, though can we add the user name field in the form `__init__()`, in
order to avoid this kind of logic, and duplicating `CharField.__init__()`:
* Other logic, e.g. correct label setting assumes the current setup,
and...
* e.g. We swap out for IntegerFields, depending on the type of the
username field.
And then, given that last, we'd need to type check before manually re-
adding the validator, at which point I come back to Mariusz' suggestion
that it's probably not worth it.
Sorry for the back and forth. This is significantly more complex than it
at first appears.
--
Ticket URL: <https://code.djangoproject.com/ticket/30776#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.cee08cdeb703fc2da57858a7a1477e98%40djangoproject.com.