我添加了一个自定义后端,以允许用户使用用户名或电子邮件以及密码登录。它工作正常,除非电子邮件超过 30 个字符。我得到的表单错误是:
"Ensure this value has at most 30 characters (it has 35)."
在我的应用程序的 urls.py 文件中,我覆盖了用户名字段的 max_length,如下所示:
from django.contrib.auth.forms import AuthenticationForm
AuthenticationForm.base_fields['username'].max_length = 75
我什至尝试过这里描述的 class_prepared 信号技术:
http://stackoverflow.com/questions/2610088/can-djangos-auth-user-username-be-varchar75-how-could-that-be-done/2613385#2613385
我不确定我在哪里出错了,我很感激你的帮助。