def METHOD_NAME(self, obj):
    # Use filter_accessor to obtain a queryset of related objects
    if callable(self.filter_accessor):
        queryset = self.filter_accessor(obj)
    else:
        # treat filter_accessor as a method/property name of obj
        queryset = getattr(obj, self.filter_accessor)
        if isinstance(queryset, models.Manager):
            queryset = queryset.all()
        elif callable(queryset):
            queryset = queryset()
    # Turn this queryset into a list of IDs that will become the 'data-filter-value' used to
    # filter this listing
    return queryset.values_list("pk", flat=True)