In a Django template, how do I return the first element of a list that matches a condition? The list could be empty. I want to know if there is a filter that finds the first element in an iterable to match a particular condition, then stops checking, similar to Python's next (https://stackoverflow.com/a/2364277/1337422).
>>> lis = ['a', 1, 40, 'three', 5]
>>> next(x for x in lis if x == 1)
1