D
D
Daria Belova2019-05-28 11:17:11
Django
Daria Belova, 2019-05-28 11:17:11

How in Django to filter in view for each value from the list value_list?

Hello, such a problem has appeared, it’s impossible to filter by each value from the value_list list
in the view, I do this:

# отфильтрованные объекты по ид
o_sal = OrderService.objects.all().filter(order_id=order_id)
# list ид 
o_sal_t = o_sal.values_list('orderservice_id')
#вот здесь отфильтровать по каждому ид из list
o_sal_ex = OrderServiceExecuter.objects.all().filter(order_service_id__orderservice_id__in=(o_sal_t)).values('executer_id__username')

an example of what should be displayed in the template
{% for o_sal_ex in o_sal_ex %}
{{ o_sal_ex }}
{% endfor %}

  • orderservice_id: 1 - user1, user2
  • orderservice_id: 2 - user3
  • orderservice_id: 3 - user4, user5

etc.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question