diff --git a/src/authentic2/compat.py b/src/authentic2/compat.py index dca5dcbc3..4e36de6da 100644 --- a/src/authentic2/compat.py +++ b/src/authentic2/compat.py @@ -4,6 +4,8 @@ import inspect import django from django.conf import settings from django.db import connection +from django.db.utils import OperationalError +from django.core.exceptions import ImproperlyConfigured from django.contrib.auth.tokens import PasswordResetTokenGenerator @@ -25,9 +27,11 @@ default_token_generator = PasswordResetTokenGenerator() def has_postgresql_support(): - if not settings.DATABASES['default'].get('NAME'): + try: + return connection.vendor == 'postgresql' and connection.pg_version > 90400 + except (ImproperlyConfigured, OperationalError): + # database is not initialized, be conservative return False - return connection.vendor == 'postgresql' and connection.pg_version > 90400 def use_django_native_field():