Override default django username validators for AbstractUser model

后端 未结 2 1137
死守一世寂寞
死守一世寂寞 2021-01-19 22:59

I am using the AbstractUser model to create a custom auth model.

The problem is that i was unable to override the default form field validators for the username fie

2条回答
  •  隐瞒了意图╮
    2021-01-19 23:39

    You can explicitly define a field on the form. That way, you have full control over the field, including its validators:

    class RegularUserForm(forms.ModelForm):
        username = forms.CharField(max_length=30)
    
        class Meta:
            model = User
    

提交回复
热议问题