存在ManyToMany关系的FilterSet

时间:2019-05-13 07:13:25

标签: django-filter

基本型号:

class ModelA(Model):
    name = CharField(...)


class ModelB(Model):
    model_a = ManyToManyField(ModelA, blank=True)
class ModelBFilter(filters.FilterSet):
    unassigned = BooleanFilter(field_name='model_a', lookup_expr='isnull')

    class Meta:
        model = ModelB
        fields = ['unassigned']

如何过滤(django-filter )来查找没有相应相关模型的ModelB

0 个答案:

没有答案