By giuliacta
Connected Tutorial(This question is a follow-up to this tutorial):
How To Deploy a Django App on App PlatformHello,
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.
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, then Database. 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.
This comment has been deleted
I am having the same issue. I added the component when creating the app and mirrored the settings I have in another working app, yet I get the same error.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
