Im getting this error after trying import DATABASE_URL information from the .env

File "D:\HAZEL\GITHUB\GOLDEN PROJECT\GOLDEN-DJANGO\virtual\Lib\site-packages\environ\environ.py", line 392, in get_value raise ImproperlyConfigured(error_msg) from exc django.core.exceptions.ImproperlyConfigured: Set the DATABASE_URL environment variable

This is my settings.py

import os
import dj_database_url
import environ

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
env = environ.Env()
environ.Env.read_env(os.path.join(BASE_DIR, '.env'))

DATABASES = {
      'default': dj_database_url.parse(env('DATABASE_URL'))
      }

additionally on importing environ and dj_database_url they are underlined and show Import "dj_database_url" could not be resolved error when i hover over it... im kindly requesting for help...

Check if your os.path.join(BASE_DIR, '.env') is resolving correctly. My guess is it's not reading the .env file correctly or not loading it.

Вернуться на верх