Issue with ACCOUNT_EMAIL_VERIFICATION_BY_CODE_ENABLED: Mandatory verification error despite correct settings

Hi everyone,

I am trying to implement a headless flow in django-allauth using email verification with a code (instead of a link). However, I’m running into a configuration error that I can’t seem to bypass.

Despite having my settings configured as requested by the documentation, I receive the following error during startup/validation:

allauth.account.errors.ImproperlyConfigured: ACCOUNT_EMAIL_VERIFICATION_BY_CODE_ENABLED requires ACCOUNT_EMAIL_VERIFICATION = 'mandatory'

In my settings.py, I have defined the following:

# Allauth settings
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_EMAIL_VERIFICATION_BY_CODE_ENABLED = True

ALLAUTH_HEADLESS_ONLY = True

I’ve tried:

  1. Double-checking for typos in the variable names.

  2. Moving the settings higher/lower in the settings.py file to ensure no overrides are happening.

  3. Verifying that I am using the latest version of django-allauth.

It seems like the validation logic is not “seeing” the mandatory string correctly, or perhaps there is a specific interaction with the headless setup that I’m missing.

1 Like