Skip to content

Custom Script filter for unconnected interfaces #17556

Answered by candlerb
SRF-rueeggdo asked this question in Q&A
Discussion options

You must be logged in to vote

TL;DR: try "occupied": False

Looking in the source code, at InterfaceFilterSet which includes CabledObjectFilterSet and PathEndpointFilterSet, I see these filters:

    cabled = django_filters.BooleanFilter(
        field_name='cable',
        lookup_expr='isnull',
        exclude=True
    )
    occupied = django_filters.BooleanFilter(
        method='filter_occupied'
    )

    def filter_occupied(self, queryset, name, value):
        if value:
            return queryset.filter(Q(cable__isnull=False) | Q(mark_connected=True))
        else:
            return queryset.filter(cable__isnull=True, mark_connected=False)

...

    connected = django_filters.BooleanFilter(
        method='filte…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@zmaster7
Comment options

@candlerb
Comment options

Answer selected by SRF-rueeggdo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants