{{{
<form action="/admin/" method="post" id="login-form">
<input type="hidden" name="csrfmiddlewaretoken" value="">
<div class="form-row">
<label class="required" for="id_username">Username:</label>
<input autofocus="" id="id_username" maxlength="254" name="username"
type="text" required="">
}}}
`maxlength="150"` is Right,
--
Ticket URL: <https://code.djangoproject.com/ticket/27515>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => assigned
* owner: nobody => Ramin Farajpour Cami
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:1>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:2>
* Attachment "fix.patch" added.
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:3>
Comment (by Tim Graham):
The suggestion doesn't account for custom user models and undoes #19130
(you might try using `git blame` to 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
[https://github.com/django/django/commit/bfcda778#commitcomment-2001360 as
Claude suggested] .
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:4>
Comment (by Ramin Farajpour Cami):
User model use max_length=150,also in add user form set 150,
What your means "value setting the max length based on the custom user
model"?
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:5>
* status: assigned => closed
* component: Forms => contrib.auth
* has_patch: 1 => 0
* resolution: => invalid
* stage: Unreviewed => Accepted
Comment:
[https://docs.djangoproject.com/en/stable/topics/auth/customizing/#specifying-a
-custom-user-model Custom user models] may have a username with length
other than 150, that's why using that value isn't appropriate. We might be
able to use that with something like this:
`self.fields['username'].max_length =
UserModel._meta.get_field(UserModel.USERNAME_FIELD).max_length`.
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:6>
* status: closed => new
* resolution: invalid =>
Old description:
> Hi,
>
> http://127.0.0.1:8000/admin/
>
> {{{
> <form action="/admin/" method="post" id="login-form">
> <input type="hidden" name="csrfmiddlewaretoken" value="">
> <div class="form-row">
> <label class="required" for="id_username">Username:</label>
> <input autofocus="" id="id_username" maxlength="254" name="username"
> type="text" required="">
> }}}
>
> `maxlength="150"` is Right,
New description:
`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__()`.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:7>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/7592 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:8>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:9>
Comment (by Andrey Kuzminov):
Can I take this ticket or is it still Ramin's?
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:10>
Comment (by Ramin Farajpour Cami):
Yes, please assign to you
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:11>
* owner: Ramin Farajpour Cami => Andrey Kuzminov
* status: new => assigned
* cc: Andrey Kuzminov (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:12>
* owner: Andrey Kuzminov => Lucas Connors
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:13>
* needs_better_patch: 1 => 0
* has_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:14>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:15>
Comment (by Lucas Connors):
Sorry for the spam. I thought unchecking and rechecking would
automatically find the PR on Github. This is it here:
https://github.com/django/django/pull/8925
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:16>
* version: 1.10 => master
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:17>
* needs_better_patch: 0 => 1
* stage: Ready for checkin => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:18>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:19>
Comment (by Tim Graham <timograham@…>):
In [changeset:"d2333912085fc3bd827295f2bc8253d6723c242b" d2333912]:
{{{
#!CommitTicketReference repository=""
revision="d2333912085fc3bd827295f2bc8253d6723c242b"
Refs #19130 -- Added a test for AuthenticationForm.username max_length.
This will be a more useful regression test after refs #27515.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:20>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"5ceaf14686ce626404afb6a5fbd3d8286410bf13" 5ceaf146]:
{{{
#!CommitTicketReference repository=""
revision="5ceaf14686ce626404afb6a5fbd3d8286410bf13"
Fixed #27515 -- Made AuthenticationForm's username field use the
max_length from the model field.
Thanks Ramin Farajpour Cami for the report.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27515#comment:21>