Skip to content
Advertisement

Django Traverse Foreign Keys

I have 3 models and I am trying to create a dashboard with a list of Trials that spans all Client Sessions for a specific client chosen via a filter.

Here are the models:

JavaScript

Here is the view that im trying to create

JavaScript

Advertisement

Answer

You have an error filter query you used Filter data. Expected is queryset.

Change, trial_list = Trial.objects.filter(client_session__client=client) into

JavaScript

trial_list = Trial.objects.filter(client_session__client__in= list(client_pks)).distinct() distinct() method is used to remove duplicated but it not work some databases

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement