Answer the question
In order to leave comments, you need to log in
What is the right way to write a for loop in my case?
class Order(models.Model):
work = models.ManyToManyField(Work, verbose_name='Виды работ')
class Master(models.Model):
work = models.ManyToManyField(Work, verbose_name='Виды работ')
order = Order.objects.get(id='1')
master_list = []
for item in Master.objects.all():
if item.work == order.work:
master_list.append(item)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question