django-all-auth: Admin can create user without email despite it being required

Viewed 840

I'm using Django 1.8 with django-allauth 0.23.0. My custom user model requires an email and allauth is also setup to require it. At least I think so.

settings.py

AUTH_USER_MODEL = 'accounts.MyUser'
ACCOUNT_USER_MODEL_EMAIL_FIELD = 'email'
ACCOUNT_EMAIL_REQUIRED = True

class MyUser(AbstractBaseUser, PermissionsMixin):

    ...

    email = models.EmailField(_('email address'), blank=False)

    USERNAME_FIELD = 'username'
    REQUIRED_FIELDS = ['email']

My program logic depends on all users having an email address which collides with allauth's 2-step form process. When I add a new user via django admin I see a form with 3 inputs: username, password, password confirmation. I can create a user and then add an email, but I don't have to.

How can I add the email field to the admin-user-add-form?

I can setup model clean to not let it through but without an email field on the template, the user won't be able to add it in the first place.

0 Answers
Related