I’ve got a dictionary that has a structure similar to:
<code>{
'id': 16,
'name': 'something',
'client': 'client1',
},
{
'id': 17,
'name': 'something',
'client': 'client2',
},
{
'id': 18,
'name': 'something-else',
'client': 'client3',
}
</code>
<code>{
'id': 16,
'name': 'something',
'client': 'client1',
},
{
'id': 17,
'name': 'something',
'client': 'client2',
},
{
'id': 18,
'name': 'something-else',
'client': 'client3',
}
</code>
{
'id': 16,
'name': 'something',
'client': 'client1',
},
{
'id': 17,
'name': 'something',
'client': 'client2',
},
{
'id': 18,
'name': 'something-else',
'client': 'client3',
}
I can iterate through my dicts in my templates but I’m trying to get the unique values of name
in this case. I’ve tried a couple different options such as:
{% for name in data | unique %}
or {% for name in data.name | unique %}
but none of it returns me a list of unique names.
What’s the best way to do this? I’ve thought about creating a custom filter, but wondering if there is a better way to do it.