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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
This comment has been deleted
It looks like your DATABASE_URL env variable isn’t populated. App Platform will automatically set DATABASE_URL when you add a database component. You can add the component by going to the
Components
tab of your app, and then clicking+ Create Component
, thenDatabase
. You should be able to add either a new development database or an existing managed database. If you’re using a database not provided through DigitalOcean’s managed databases, you’ll have to set the DATABASE_URL manually.If you’re still seeing problems, please reach out to support.