Exclude the object from your query instead. If you cannot do that in the DB query directly then get an array instead of a query and apply custom array filter logic to the elements in the array before rendering it in the list.
If your filter is on a related object you may have to cache the related objects before trying to access them in the array.filter function. Similar to this post on custom sorting