diff --git a/apps/common/db/fields.py b/apps/common/db/fields.py index 3e1b1ac98..b1cdc76d6 100644 --- a/apps/common/db/fields.py +++ b/apps/common/db/fields.py @@ -295,7 +295,7 @@ class RelatedManager: self.instance.__dict__[self.field.name] = value @classmethod - def _get_filter_q(cls, value, to_model): + def get_to_filter_q(cls, value, to_model): """ 这个是 instance 去查找 to_model 的 queryset 的 Q :param value: @@ -320,7 +320,7 @@ class RelatedManager: queryset = to_model.get_queryset() else: queryset = to_model.objects.all() - q = cls._get_filter_q(value, to_model) + q = cls.get_to_filter_q(value, to_model) return queryset.filter(q).distinct() @staticmethod diff --git a/apps/common/drf/filters.py b/apps/common/drf/filters.py index cfdff0a6e..bac14190e 100644 --- a/apps/common/drf/filters.py +++ b/apps/common/drf/filters.py @@ -214,5 +214,5 @@ class AttrRulesFilterBackend(filters.BaseFilterBackend): raise ValidationError({'attr_rules': 'attr_rules should be json'}) logging.debug('attr_rules: %s', attr_rules) - q = RelatedManager.get_filter_q(attr_rules, queryset.model) + q = RelatedManager.get_to_filter_q(attr_rules, queryset.model) return queryset.filter(q).distinct()