diff --git a/django/db/backends/base/operations.py b/django/db/backends/base/operations.py index 4e6a67685f..12f37e3404 100644 --- a/django/db/backends/base/operations.py +++ b/django/db/backends/base/operations.py @@ -754,6 +754,10 @@ class BaseDatabaseOperations: msg = "%s is not a recognized format." % normalized_format if supported_formats: msg += " Allowed formats: %s" % ", ".join(sorted(supported_formats)) + else: + msg += ( + f" {self.connection.display_name} does not support any formats." + ) raise ValueError(msg) if options: raise ValueError("Unknown options: %s" % ", ".join(sorted(options.keys()))) diff --git a/tests/queries/test_explain.py b/tests/queries/test_explain.py index 1d17ef8191..f61fe01e9d 100644 --- a/tests/queries/test_explain.py +++ b/tests/queries/test_explain.py @@ -74,6 +74,8 @@ class ExplainTests(TestCase): msg += " Allowed formats: %s" % ", ".join( sorted(connection.features.supported_explain_formats) ) + else: + msg += f" {connection.display_name} does not support any formats." with self.assertRaisesMessage(ValueError, msg): Tag.objects.explain(format="does not exist")