1👍
maybe something like this… (with a custom filter!)
@register.filter
def first_with_attribute(some_list, attr):
"""
Usage in template: {{ list|first_with_attribute:"cover_image" }}
"""
for thing in some_list:
if hasattr(some_list, attr):
return getattr(some_list, attr)
return ''
Source:stackexchange.com