@@ -438,14 +438,13 @@ def _create_collection(self, model):
438
438
auto_encryption_opts = getattr (client ._options , "auto_encryption_opts" , None )
439
439
if not auto_encryption_opts :
440
440
raise ImproperlyConfigured (
441
- "Encrypted fields found but "
442
- f"DATABASES[{ self .connection .alias } ]['OPTIONS'] is missing "
443
- f"Encrypted fields found but DATABASES['{ self .connection .alias } ']['OPTIONS'] is missing auto_encryption_opts."
441
+ f"Encrypted fields found but DATABASES['{ self .connection .alias } ']['OPTIONS'] "
442
+ "is missing auto_encryption_opts."
444
443
)
445
444
encrypted_fields_map = getattr (auto_encryption_opts , "_encrypted_fields_map" , None )
446
445
if not encrypted_fields_map :
447
446
encrypted_fields_map = self ._get_encrypted_fields_map (
448
- model , client , auto_encryption_opts
447
+ model , client , create_data_keys = True
449
448
)
450
449
else :
451
450
# If the encrypted fields map is provided, get the map for the
@@ -486,7 +485,8 @@ def _get_encrypted_fields_map(self, model, client, create_data_keys=False):
486
485
if not key_doc :
487
486
raise ValueError (
488
487
f"No key found in keyvault for keyAltName={ key_alt_name } . "
489
- "You may need to run the management command with '--create-data-keys' to create missing keys."
488
+ "You may need to run the management command with "
489
+ "'--create-data-keys' to create missing keys."
490
490
)
491
491
data_key = key_doc ["_id" ]
492
492
field_dict = {
0 commit comments