KeyError: 'DATABASE_URL' (maybe a 0.4.2 regression?)
See original GitHub issueThanks for your work on django-environ.
My project works fine with 0.4.1, but breaks in 0.4.2, released this morning.
I’m using Python 3.4.2 on Debian 8 and Django 1.10 in a virtualenv. I checked in a couple of ways that yes, my DATABASE_URL variable was being loaded properly. In particular, I added a line in my settings file, print(os.environ['DATABASE_URL'])
, immediately prior to my env.db()
call, and it printed my setting as I expected.
If this is not a regression, then perhaps some upgrade docs would be in order so I know what I need to change in my project to use the latest django-environ.
Thanks!
(env3) ipmetadataretention@host:~$ manage.py shell
Traceback (most recent call last):
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/environ/environ.py", line 265, in get_value
value = self.ENVIRON[var]
KeyError: 'DATABASE_URL'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/core/management/base.py", line 305, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/core/management/base.py", line 348, in execute
saved_locale = translation.get_language()
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/utils/translation/__init__.py", line 190, in get_language
return _trans.get_language()
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/utils/translation/__init__.py", line 57, in __getattr__
if settings.USE_I18N:
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/conf/__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/usr/share/ip-metadata-retention/django/ipmetadataretention/settings/production.py", line 2, in <module>
from .common import * # noqa: F401, F403
File "/usr/share/ip-metadata-retention/django/ipmetadataretention/settings/common.py", line 87, in <module>
'default': env.db(),
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/environ/environ.py", line 196, in db_url
return self.db_url_config(self.get_value(var, default=default), engine=engine)
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/environ/environ.py", line 269, in get_value
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: Set the DATABASE_URL environment variable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/environ/environ.py", line 265, in get_value
value = self.ENVIRON[var]
KeyError: 'DATABASE_URL'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/share/ip-metadata-retention/django/manage.py", line 23, in <module>
execute_from_command_line(sys.argv)
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/core/management/base.py", line 317, in run_from_argv
connections.close_all()
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/db/utils.py", line 229, in close_all
for alias in self:
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/db/utils.py", line 223, in __iter__
return iter(self.databases)
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/db/utils.py", line 156, in databases
self._databases = settings.DATABASES
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/django/conf/__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/usr/share/ip-metadata-retention/django/ipmetadataretention/settings/production.py", line 2, in <module>
from .common import * # noqa: F401, F403
File "/usr/share/ip-metadata-retention/django/ipmetadataretention/settings/common.py", line 87, in <module>
'default': env.db(),
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/environ/environ.py", line 196, in db_url
return self.db_url_config(self.get_value(var, default=default), engine=engine)
File "/var/lib/ipmetadataretention/env3/lib/python3.4/site-packages/environ/environ.py", line 269, in get_value
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: Set the DATABASE_URL environment variable
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top Results From Across the Web
KeyError: 'databaseURL' while Firebase Authentication in ...
As the error said. The databaseURL property is missing from your configuration. Since now the Realtime Database is not automatically be ...
Read more >Pyrebase KeyError : ''databaseURL' Fix - Firebase
If you are getting a KeyError: 'databaseURL' when accessing pyrebase, all you need to do is add a dummy key and value to...
Read more >Alembic Documentation
Alembic is currently in beta status and is expected to be fairly stable. Users should take care to report bugs and missing.
Read more >CHANGELOG.md - ory/hydra - Sourcegraph
This patch resolves a regression where, in a certain condition, an accepted consent ... Environment variable DATABASE_URL has been deprecated (8023d2a).
Read more >Squashed 'import-layers/yocto-poky/'; (Ia3d47aab)
... Handle performance regression" 31cef0d lib/oeqa/decorators: handle broken ... 0.9.13 fc1ac79 libxkbcommon: Update to 0.4.2 d2e1238 x264: Update SRCREV ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m looking for a solution, but probably I’ve to revert on #105.
Reverted and released.
I was trying to convert the
Env.ENVIRON
variable into a set of dictionaries, with os.environ as first item as default, in order to allow to use a cascade dicts intoEnv.get_value
.But I postpone this feature for 0.5
If anyone is interested to discuss about that… we can met on freenode#python