Skip to content

Commit 270727c

Browse files
committed
Fix kms_provider condition to check fields
1 parent eea4b10 commit 270727c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

django_mongodb_backend/routers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from django.core.exceptions import ImproperlyConfigured
33
from django.db.utils import ConnectionRouter
44

5+
from .fields import has_encrypted_fields
6+
57

68
class MongoRouter:
79
def allow_migrate(self, db, app_label, model_name=None, **hints):
@@ -28,7 +30,7 @@ def kms_provider(self, model, *args, **kwargs):
2830
result = func(model, *args, **kwargs)
2931
if result is not None:
3032
return result
31-
if getattr(model, "encrypted", False):
33+
if has_encrypted_fields(model):
3234
raise ImproperlyConfigured("No kms_provider found in database router.")
3335
return None
3436

0 commit comments

Comments
 (0)