DATABASE_URL environment variable error

I encountered this error with the current Django scaffold:
django.core.exceptions.ImproperlyConfigured: Set the DATABASE_URL environment variable

I was able to resolve this by adding this line of code in the settings.py:
environ.Env.read_env(os.path.join(BASE_DIR, ".env"))

1 Like

Thanks for the contribution, @lorence! You can make a PR for this issue directly to the Django scaffold and the team will review it and merge it!

@anand where can I locate the Django scaffold repository?

Make sure you’re running pipenv shell before running the app. pipenv will load your .env file.

@Crowdbotics_Dan Yes. Already did those previously and this line of code fixed the issue. environ.Env.read_env(os.path.join(BASE_DIR, ".env"))

@lorence we’re working on making these publicly accessible to field PRs directly! In the meantime, I’ll add you into the repo directly.