summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/templatetags/field_values_filter.py
blob: eb483396c26e1288633032ce139f5dab79cc583f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#
# SPDX-License-Identifier: GPL-2.0-only
#

from django import template

register = template.Library()

def field_values(iterable, field):
    """
    Convert an iterable of models into a list of strings, one for each model,
    where the string for each model is the value of the field "field".
    """
    objects = []

    if field:
        for item in iterable:
            objects.append(getattr(item, field))

    return objects

register.filter('field_values', field_values)