Fixed #23555 -- Avoided suppressing IndexError in QuerySet.first() and .last()