I
I
Igor Che2017-03-15 13:56:30
Django
Igor Che, 2017-03-15 13:56:30

How to extend queryset in Django with fields from associated model?

I get the main queryset like this:

panel_list = dir_service_subtype.objects.filter(id=39).first().client_bind_set.first().csstate_set.all()

And I'm trying to expand it with this:
user = CsState.objects.first().client_bind.client_bind_post_set.filter(
    is_active=1,
    planned_begin_date__lte=datetime.now(),
    planned_end_date__gte=datetime.now())\
    .first()

Is it possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Larisa .•º, 2017-03-15
@barolina

obj = Model.filter(params).first()
if obj is None:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question