docker icon indicating copy to clipboard operation
docker copied to clipboard

email error

Open deboy69 opened this issue 2 years ago • 7 comments

wger | Traceback (most recent call last): wger | File "/usr/local/lib/python3.10/dist-packages/environ/environ.py", line 403, in get_value wger | value = self.ENVIRON[var_name] wger | File "/usr/lib/python3.10/os.py", line 679, in getitem wger | raise KeyError(key) from None wger | KeyError: 'FROM_EMAIL' wger | wger | The above exception was the direct cause of the following exception: wger | wger | Traceback (most recent call last): wger | File "/usr/local/bin/invoke", line 8, in wger | sys.exit(program.run()) wger | File "/usr/local/lib/python3.10/dist-packages/invoke/program.py", line 384, in run wger | self.execute() wger | File "/usr/local/lib/python3.10/dist-packages/invoke/program.py", line 569, in execute wger | executor.execute(*self.tasks) wger | File "/usr/local/lib/python3.10/dist-packages/invoke/executor.py", line 129, in execute wger | result = call.task(*args, **call.kwargs) wger | File "/usr/local/lib/python3.10/dist-packages/invoke/tasks.py", line 127, in call wger | result = self.body(*args, **kwargs) wger | File "/home/wger/src/wger/tasks.py", line 91, in bootstrap wger | setup_django_environment(settings_path) wger | File "/home/wger/src/wger/tasks.py", line 345, in setup_django_environment wger | django.setup() wger | File "/usr/local/lib/python3.10/dist-packages/django/init.py", line 19, in setup wger | configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) wger | File "/usr/local/lib/python3.10/dist-packages/django/conf/init.py", line 82, in getattr wger | self._setup(name) wger | File "/usr/local/lib/python3.10/dist-packages/django/conf/init.py", line 69, in _setup wger | self._wrapped = Settings(settings_module) wger | File "/usr/local/lib/python3.10/dist-packages/django/conf/init.py", line 170, in init wger | mod = importlib.import_module(self.SETTINGS_MODULE) wger | File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module wger | return _bootstrap._gcd_import(name[level:], package, level) wger | File "", line 1050, in _gcd_import wger | File "", line 1027, in _find_and_load wger | File "", line 1006, in _find_and_load_unlocked wger | File "", line 688, in _load_unlocked wger | File "", line 883, in exec_module wger | File "", line 241, in _call_with_frames_removed wger | File "/home/wger/src/settings.py", line 90, in wger | WGER_SETTINGS['EMAIL_FROM'] = f'wger Workout Manager <{env.str("FROM_EMAIL")}>' wger | File "/usr/local/lib/python3.10/dist-packages/environ/environ.py", line 213, in str wger | value = self.get_value(var, cast=str, default=default) wger | File "/usr/local/lib/python3.10/dist-packages/environ/environ.py", line 407, in get_value wger | raise ImproperlyConfigured(error_msg) from exc wger | django.core.exceptions.ImproperlyConfigured: Set the FROM_EMAIL environment variable

deboy69 avatar Nov 04 '22 17:11 deboy69

There was another issue about the EMAIL_FROM key not being used, this is probably something related to that

rolandgeider avatar Nov 06 '22 11:11 rolandgeider

wger | WGER_SETTINGS['EMAIL_FROM'] = **f'**wger Workout Manager <{env.str("FROM_EMAIL")}>'

removed f in the settings.py. However it wont start to get into the container so I needed to turn on Django debug to get past the error. Not sure if it was a new container pull that had the fix in it or this actually fixed it. But got it up and running with two nginx containers. (main nginx and wger nginx)

deboy69 avatar Nov 17 '22 22:11 deboy69

mhhhh, this works fine here

rolandgeider avatar Dec 15 '22 14:12 rolandgeider

Exact same error here : django.core.exceptions.ImproperlyConfigured: Set the FROM_EMAIL environment variable

My prod.env:


# Django's secret key, change to a 50 character random string if you are running
# this instance publicly. For an online generator, see e.g. https://djecrety.ir/
SECRET_KEY=xxxxxxxxxxxxx

# Signing key used for JWT, use something different than the secret key
SIGNING_KEY=xxxxxxxxxxxx

# The 'from' address used when sending emails
[email protected]

# The server's timezone, for a list of possible names:
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TIME_ZONE=Europe/Paris


#
# Consult the deployment section in the readme if you are running this behind a
# reverse proxy with HTTPS enabled
#

CSRF_TRUSTED_ORIGINS=https://wger.xxxx.fr
X_FORWARDED_PROTO_HEADER_SET=True


#
# These settings usually don't need changing
#


#
# Application
ALLOW_REGISTRATION=True
ALLOW_GUEST_USERS=True
ALLOW_UPLOAD_VIDEOS=True
# Users won't be able to contribute to exercises if their account age is
# lower than this amount in days.
MIN_ACCOUNT_AGE_TO_TRUST=21
# Note that setting these to true will always perform a sync during startup,
# even if the data is already current and will take some time. Usually you don't
# need to perform these steps so often and a manual trigger (see README) is
# usually enough.
SYNC_EXERCISES_ON_STARTUP=False
DOWNLOAD_EXERCISE_IMAGES_ON_STARTUP=False


#
# Database
DJANGO_DB_ENGINE=django.db.backends.postgresql
DJANGO_DB_DATABASE=wger
DJANGO_DB_USER=wger
DJANGO_DB_PASSWORD=wger
DJANGO_DB_HOST=db
DJANGO_DB_PORT=5432
# Perform any new database migrations on startup
DJANGO_PERFORM_MIGRATIONS=True


#
# Cache
DJANGO_CACHE_BACKEND=django_redis.cache.RedisCache
DJANGO_CACHE_LOCATION=redis://cache:6379/1
# 60*60*24*15, 15 Days
DJANGO_CACHE_TIMEOUT=12
DJANGO_CACHE_CLIENT_CLASS=django_redis.client.DefaultClient

#
# Brute force login attacks
# https://django-axes.readthedocs.io/en/latest/index.html
AXES_ENABLED=True
AXES_FAILURE_LIMIT=10
# in minutes
AXES_COOLOFF_TIME=30
AXES_HANDLER=axes.handlers.cache.AxesCacheHandler

#
# Others
DJANGO_DEBUG=False
WGER_USE_GUNICORN=True
EXERCISE_CACHE_TTL=10
SITE_URL=http://localhost

#
# JWT auth
# The lifetime duration of the access token, in minutes
ACCESS_TOKEN_LIFETIME=10
# The lifetime duration of the refresh token, in hours
REFRESH_TOKEN_LIFETIME=24


#
# Other possible settings

# RECAPTCHA_PUBLIC_KEY
# RECAPTCHA_PRIVATE_KEY
# NOCAPTCHA

# https://docs.djangoproject.com/en/4.1/topics/email/#smtp-backend
# ENABLE_EMAIL
# EMAIL_HOST
# EMAIL_PORT
# EMAIL_HOST_USER
# EMAIL_HOST_PASSWORD
# EMAIL_USE_TLS
# EMAIL_USE_SSL

# DJANGO_MEDIA_ROOT
# DJANGO_STATIC_ROOT

Elu43 avatar Jan 13 '23 19:01 Elu43

I will try to see if I can get this to fail on my machine

rolandgeider avatar Jan 16 '23 13:01 rolandgeider

I did a workaround by giving up on the prod.env and putting all the environment variables directly in my docker compose.

Elu43 avatar Jan 16 '23 13:01 Elu43

but that shouldn't make any difference, it's just more convenient to use the file 🤔

rolandgeider avatar Jan 16 '23 13:01 rolandgeider