Reputation: 4937
Is there a way to get a list of a specific attribute from a list of model objects, {{ object_list }}
using the Django Template Language?
Similar to this in Python?
[o.my_attr for o in object_list]
Upvotes: 0
Views: 94
Reputation: 747
You can't really do list comprehensions inside Django templates. You should do this in your view and pass the list in your context to the template.
Upvotes: 1