Django. Core. Exceptions. Improperlyconfigured: Set the Redis_Url Environment Variable

I used Django-Cookiecutter to boost start my Django development. Now after building the website and wanting to host it, my choice was python anywhere and that's because I have already hosted a website there but that website wasn't built using Django-Cookiecutter. To host It on python anywhere am currently following the Django-Cookiecutter Official docs to host on pythonanywhere I have completed the first steps till it's time to run python manage.py migrate which results in the following error:

django.core.exceptions.ImproperlyConfigured: Set the REDIS_URL environment variable

In Full The Error Msg is :

Traceback (most recent call last):
File "/home/someone/.virtualenvs/smt/lib/python3.8/site-packages/environ/environ.py", line 273, in get_value
value = self.ENVIRON[var]
File "/home/someone/.virtualenvs/smt/lib/python3.8/os.py", line 673, in __getitem__
raise KeyError(key) from None
KeyError: 'REDIS_URL'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 35, in <module>
execute_from_command_line(sys.argv)
File "/home/someone/.virtualenvs/smt/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/someone/.virtualenvs/smt/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/someone/.virtualenvs/smt/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/someone/.virtualenvs/smt/lib/python3.8/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/home/someone/.virtualenvs/smt/lib/python3.8/site-packages/django/core/management/base.py", line 82, in wrapped
saved_locale = translation.get_language()
File "/home/someone/.virtualenvs/smt/lib/python3.8/site-packages/django/utils/translation/__init__.py", line 252, in get_language
return _trans.get_language()
File "/home/someone/.virtualenvs/smt/lib/python3.8/site-packages/django/utils/translation/__init__.py", line 57, in __getattr__
if settings.USE_I18N:
File "/home/someone/.virtualenvs/smt/lib/python3.8/site-packages/django/conf/__init__.py", line 83, in __getattr__
self._setup(name)
File "/home/someone/.virtualenvs/smt/lib/python3.8/site-packages/django/conf/__init__.py", line 70, in _setup
self._wrapped = Settings(settings_module)
File "/home/someone/.virtualenvs/smt/lib/python3.8/site-packages/django/conf/__init__.py", line 177, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/home/someone/.virtualenvs/smt/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/someone/proj/config/settings/production.py", line 26, in <module>
"LOCATION": env("REDIS_URL"),
File "/home/someone/.virtualenvs/smt/lib/python3.8/site-packages/environ/environ.py", line 123, in __call__
return self.get_value(var, cast=cast, default=default, parse_default=parse_default)
File "/home/someone/.virtualenvs/smt/lib/python3.8/site-packages/environ/environ.py", line 277, in get_value
raise ImproperlyConfigured(error_msg)

django.core.exceptions.ImproperlyConfigured: Set the REDIS_URL environment variable

When I tried other manage.py commands like python manage.py collectstatic they resulted with the same error msg.

1 Answer

By default it seems that Django-Cookiecutter expects a redis instance in production for caching (). If you do not have redis set up, update the CACHES setting to use a different cache backend and remove the sentry RedisIntegration.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest