3
I have it in my template:
{% for j in jobs %}
<tbody>
{% if j.background.all.0.active == False %}
...
Hence I need to filter the view similar to this.
I tried to
jobs = jobs.filter(background__first__active=False)
But I know it’s completely wrong.
The background is a Manytomany that contains a field called active, but I just want to get the first item.
How do I make this filter?
One of the options that exist besides Meumodel.objects.all() and Meumodel.objects.filter(), is Meumodel.objects.first(). If you want the first element of a queryset, you can use it in the template {{ j.background.first }}. Only this takes the first item of a queryset, I did not understand exactly the usefulness of this filter that you made.
– Puam Dias