Skip to content

Commit e938b8f

Browse files
committed
feat: do not prefetch excluded fields
1 parent 352db82 commit e938b8f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

easy/domain/orm.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.db.models.query import QuerySet
77
from ninja_extra.shortcuts import get_object_or_none
88

9+
from easy.controller.meta_conf import ModelMetaConfig
910
from easy.exception import BaseAPIException
1011

1112
logger = logging.getLogger(__name__)
@@ -47,10 +48,15 @@ def crud_filter_exclude(self, **kwargs: Any) -> QuerySet:
4748
class DjangoOrmModel(CrudModel):
4849
def __init__(self, model: Type[models.Model]):
4950
self.model = model
51+
config = ModelMetaConfig()
52+
exclude_list = config.get_final_excluded_list(self.model())
5053
self.m2m_fields_list: List = list(
5154
_field
5255
for _field in self.model._meta.get_fields(include_hidden=True)
53-
if isinstance(_field, models.ManyToManyField)
56+
if (
57+
isinstance(_field, models.ManyToManyField)
58+
and ((_field not in exclude_list) if exclude_list else True)
59+
)
5460
)
5561
super().__init__(model)
5662

0 commit comments

Comments
 (0)