Skip to content

Commit 6dc9766

Browse files
committed
Improve error message for misconfigured connection
If there's no encrypted router the previous error message stated "missing auto_encryption_opts" which is correct but not helpful. Also fix printing of database connection alias. We could potentially go a step further and say "Check your router config!"
1 parent e1ad85b commit 6dc9766

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

django_mongodb_backend/schema.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,9 @@ def _create_collection(self, model):
468468
auto_encryption_opts = getattr(client._options, "auto_encryption_opts", None)
469469
if not auto_encryption_opts:
470470
raise ImproperlyConfigured(
471-
f"Encrypted fields found but DATABASES['{self.connection.alias}']['OPTIONS'] "
472-
"is missing auto_encryption_opts."
471+
"Encrypted fields found, but `auto_encryption_opts` "
472+
"setting not found in `OPTIONS` setting for "
473+
f"'{self.connection.alias}' database connection."
473474
)
474475
encrypted_fields = self._get_encrypted_fields(model)
475476
db.create_collection(db_table, encryptedFields=encrypted_fields)

0 commit comments

Comments
 (0)