Apprunner Django getting error ValueError: None is not a valid AppSettings.EmailVerificationMethod

0

Hi, I'm new to Django. I'm trying to deploy my application using app runner, but I'm getting the error "ValueError: None is not a valid AppSettings.EmailVerificationMethod" in the application log.

08-09-2024 04:37:41 PM Traceback (most recent call last):
08-09-2024 04:37:41 PM   File "/app/manage.py", line 21, in <module>
08-09-2024 04:37:41 PM     main()
08-09-2024 04:37:41 PM   File "/app/manage.py", line 17, in main
08-09-2024 04:37:41 PM     execute_from_command_line(sys.argv)
08-09-2024 04:37:41 PM   File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
08-09-2024 04:37:41 PM     utility.execute()
08-09-2024 04:37:41 PM   File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 416, in execute
08-09-2024 04:37:41 PM     django.setup()
08-09-2024 04:37:41 PM   File "/usr/local/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
08-09-2024 04:37:41 PM     apps.populate(settings.INSTALLED_APPS)
08-09-2024 04:37:41 PM   File "/usr/local/lib/python3.11/site-packages/django/apps/registry.py", line 116, in populate
08-09-2024 04:37:41 PM     app_config.import_models()
08-09-2024 04:37:41 PM   File "/usr/local/lib/python3.11/site-packages/django/apps/config.py", line 269, in import_models
08-09-2024 04:37:41 PM     self.models_module = import_module(models_module_name)
08-09-2024 04:37:41 PM                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
08-09-2024 04:37:41 PM   File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
08-09-2024 04:37:41 PM     return _bootstrap._gcd_import(name[level:], package, level)
08-09-2024 04:37:41 PM            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
08-09-2024 04:37:41 PM   File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
08-09-2024 04:37:41 PM   File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
08-09-2024 04:37:41 PM   File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
08-09-2024 04:37:41 PM   File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
08-09-2024 04:37:41 PM   File "<frozen importlib._bootstrap_external>", line 940, in exec_module
08-09-2024 04:37:41 PM   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
08-09-2024 04:37:41 PM   File "/usr/local/lib/python3.11/site-packages/allauth/account/models.py", line 13, in <module>
08-09-2024 04:37:41 PM     from allauth.account import app_settings, signals
08-09-2024 04:37:41 PM   File "/usr/local/lib/python3.11/site-packages/allauth/account/app_settings.py", line 433, in <module>
08-09-2024 04:37:41 PM     _app_settings = AppSettings("ACCOUNT_")
08-09-2024 04:37:41 PM                     ^^^^^^^^^^^^^^^^^^^^^^^
08-09-2024 04:37:41 PM   File "/usr/local/lib/python3.11/site-packages/allauth/account/app_settings.py", line 36, in __init__
08-09-2024 04:37:41 PM     self.EMAIL_VERIFICATION != self.EmailVerificationMethod.MANDATORY
08-09-2024 04:37:41 PM     ^^^^^^^^^^^^^^^^^^^^^^^
08-09-2024 04:37:41 PM   File "/usr/local/lib/python3.11/site-packages/allauth/account/app_settings.py", line 127, in EMAIL_VERIFICATION
08-09-2024 04:37:41 PM     return self.EmailVerificationMethod(ret)
08-09-2024 04:37:41 PM            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
08-09-2024 04:37:41 PM   File "/usr/local/lib/python3.11/enum.py", line 714, in __call__
08-09-2024 04:37:41 PM     return cls.__new__(cls, value)
08-09-2024 04:37:41 PM            ^^^^^^^^^^^^^^^^^^^^^^^
08-09-2024 04:37:41 PM   File "/usr/local/lib/python3.11/enum.py", line 1137, in __new__
08-09-2024 04:37:41 PM     raise ve_exc
08-09-2024 04:37:41 PM ValueError: None is not a valid AppSettings.EmailVerificationMethod

Please let me know if you need more information.

Here is app runner config :

version: 1.0
runtime: python311
build:
  commands:
    build:
      - python3.11 -m ensurepip --upgrade
      - pip3 install Django
run:
  runtime-version: 3.11
  pre-run:
    - pip3 install gunicorn
    - pip3 install whitenoise
    - pip3 install -r requirements.txt
    - which gunicorn
  command: sh startup.sh
  network:
    port: 8000

Thank you in Advanced.

Hd
asked a month ago189 views
3 Answers
2
Accepted Answer

Try changing "ACCOUNT_EMAIL_VERIFICATION" to "none" instead of "None".
https://docs.allauth.org/en/latest/account/configuration.html

ACCOUNT_EMAIL_VERIFICATION (default: "optional") Determines the email verification method during signup – choose one of "mandatory", "optional", or "none".

ACCOUNT_EMAIL_VERIFICATION = 'none'
profile picture
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago
profile picture
EXPERT
reviewed a month ago
  • Thank you, Riku. It's working fine now.

1

Hello.

Judging from the error message, I think the problem is with Django settings, not AppRunner settings.
I think this is probably an error caused by a misconfiguration of django-allauth.
What settings are in "settings.py"?
https://github.com/pennersr/django-allauth/tree/main

profile picture
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago
0

Here i setting.py

"""
Django settings for main project.

Generated by 'django-admin startproject' using Django 2.2.1.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '****'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = ['*']
CSRF_TRUSTED_ORIGINS=['https://*.awsapprunner.com']

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'chat',
    'crispy_forms',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'django.contrib.sites',
    'health_check', 
    
]

SITE_ID = 1

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'allauth.account.middleware.AccountMiddleware',
    "whitenoise.middleware.WhiteNoiseMiddleware",
]

ROOT_URLCONF = 'main.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

AUTHENTICATION_BACKENDS = (
    # Needed to login by username in Django admin, regardless of `allauth`
    'django.contrib.auth.backends.ModelBackend',

    # `allauth` specific authentication methods, such as login by e-mail
    'allauth.account.auth_backends.AuthenticationBackend',
)

WSGI_APPLICATION = 'main.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static_cdn/")
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'


MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

SITE_ID = 1

LOGIN_REDIRECT_URL = '/'

CRISPY_TEMPLATE_PACK = 'bootstrap3'

ACCOUNT_EMAIL_VERIFICATION = None

try:
    from .local_settings import *
except ImportError:
    pass
Hd
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions