S
S
sergey-sh2016-09-13 14:50:19
Django
sergey-sh, 2016-09-13 14:50:19

Django, how to select three models?

class Empl(models.Model):
    pass

class Order(models.Model):
    empl = models.ForeignKey(Empl)

class Pay(models.Model):
    emply = model.ForeignKey(Empl)

It is necessary to select all payments (Pay) of this employee (Empl) for this order (Order)
order = Order.objects.filter(order=order)[0]
order.empl.pay_set.all() - selects from all orders, but you need only for this

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Klimenko, 2016-09-13
@aklim007

Something like:
distinct - since feedback is used and there may be duplicates.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question