我已经向管理员用户模型添加了一个字段
types=(
(0,'Super Admin'),
(1,'Headoffice Admin'),
(2,'Regionoffice Admin'),
(3,'Store Admin'),
)
User.add_to_class('admin_type', models.IntegerField(max_length=2,
choices=types,
default=3))
我想将此字段用作登录选择选项,登录的是哪种用户类型的用户?
我试过这个
在forms.py ..
from django.contrib.auth.forms import AuthenticationForm
class MyAuthenticationForm(AuthenticationForm):
password = forms.CharField(label="Passwordddd", widget=forms.PasswordInput)
username = forms.CharField(label="Usernameeee", max_length=30)
admin_type = forms.BooleanField(label="User Type",)
在 urls.py admin.site.login_form = MyAuthenticationForm
自定义更改仅反映在用户字段中??和 admin_type 没有显示??