Question
How to solve dj_database_url error
Hello,
I have been following the ‘How to Deploy a Django App on App Platform’ tutorial and I keep getting the following error during deploy:
File "/workspace/.heroku/python/lib/python3.8/site-packages/dj_database_url.py", line 103, in parse
engine = SCHEMES[url.scheme] if engine is None else engine
KeyError: ''
[11] [INFO] Worker exiting (pid: 11)
[1] [INFO] Shutting down: Master
[INFO] Reason: Worker failed to boot.
The configuration regarding the database in settings.py is identical to the one used in the tutorial:
DEVELOPMENT_MODE = os.getenv("DEVELOPMENT_MODE", "False") == "True"
if DEVELOPMENT_MODE is True:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
}
elif len(sys.argv) > 0 and sys.argv[1] != 'collectstatic':
if os.getenv("DATABASE_URL", None) is None:
raise Exception("DATABASE_URL environment variable not defined")
DATABASES = {
"default": dj_database_url.parse(os.environ.get("DATABASE_URL")),
}
Any clue on this?
Thanks a lot.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×