I am trying to make admin login field more than 30 characters, because I use my own email authentication server, which really does not care about how long the username field will be.
I wanted to create an application monkey_patchthat would apply the change to all admin sites.
from django.contrib.auth.forms import AuthenticationForm
AuthenticationForm.base_fields['username'].max_length = 150
This does not work, and I do not understand why not.
Print statements in ...
django.contrib.admin.forms.AdminAuthenticationFormdjango.contrib.auth.views.logindjango.contrib.auth.views.login.form # instance of the form
... shows the correct, changed number when I put out the login page through /myadmin/anywhere/.
Even an instance of the form in the final render function shows the correct number.
# django.contrib.auth.views.login
...
print form.fields['username'].max_length # this is an instantiated form!
return render_to_response(template_name, context ...)
What am I missing?
, 30 ? , render_to_response.
AuthenticationForm, .
class LongerAuthenticationForm(AuthenticationForm):
username = forms.CharField(max_length=150)
class MyAdmin(AdminSite):
login_form = LongerAuthenticationForm
, , , , CharField max_length=150.