SectorLabs / django-postgres-extra

Bringing all of PostgreSQL's awesomeness to Django.
MIT License
695 stars 96 forks source link

ImproperlyConfigured: Could not locate the 'psqlextra.backend' #225

Open hitesh-scanova opened 11 months ago

hitesh-scanova commented 11 months ago

We are using django-postgres-extra and loading database settings through .env file and default database is sqllite3

DEFAULT_DATABASE = {
    'ENGINE': 'django.db.backends.sqlite3',
    'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}

DATABASES = {
    'default': eval(os.environ.get('DATABASE_MAIN', str(DEFAULT_DATABASE))),
}

The database is passed using environment specific .env file

DATABASE_MAIN{'ENGINE':'psqlextra.backend','NAME':'name','USER':'user','PASSWORD':'password','HOST':'host','PORT':'5432'}

We have setup Github actions to extract translation files. Since, there is no database defined in the actions(CI), the following command gives error - python src/manage.py makemessages -l en

Error - django.core.exceptions.ImproperlyConfigured: Could not locate the 'psqlextra.backend'. django-postgres-extra cannot function without the 'psqlextra.backend'. Set DATABASES.ENGINE.

It checks for database settings and do not find psqlextra.backend as DATABASE ENGINE name and throws this error.

Is there any way to skip the checking of database settings during the translation or pass the default database with psqlextra.backend as engine name.

Photonios commented 10 months ago

Could you perphaps have multiple databases configured? Are you sure the eval is working correctly?