For my application, the email field in the Django User model
should be required, but by default it's optional.
I searched this question but most answers I found were talking about making the email field required in the customised UserCreationForm
for example:
class CustomUserForm(UserCreationForm):
"""Provide a view for creating users with only the requisite fields."""
class Meta:
model = User
# Note that password is taken care of for us by auth's UserCreationForm.
fields = ('username', 'email')
def __init__(self, *args, **kwargs):
super(CustomUserForm, self).__init__(*args, **kwargs)
self.fields['email'].required = True
but I want to make the email mandatory in the User
model as well because I was thinking maybe ModelForm
are a frontend thing and the required condition maybe be turned off by the user by using the chrome dev tools, am I wrong? Will making the email required in ModelForm
is same as making it required in the user model
as well, or can I override the user model to make the email required?