Scenario: Form that give values to filter some records. I have 4 models A, B, C and D.
A Have OneToOne relationship with B
B Have ManyToOne relationship with C
C Have ManyToOne relationship with D
Form value given is a field in model D, and the record that I'll retrieve is in model A
I've Tried:
records= A.objects.filter(
a_field = "form_given_value_1",
B__b_field = C.objects.filter(
c_field = D.objects.filter(
d_field=form_given_value_2
)
)
)
I got that error:
SyntaxError: keyword argument repeated
then after some search I tried given answer here:
records = A.objects.filter(
a_field = "form_given_value_1",
B__b_field__c_field__d_field = form_given_value_2
)
It doesn't give me errors but it doesn't give records also!..
how to achieve that approach ?