Hello - hoping someone may be able to help me - I've looked at this tread about filtering previous results
I am trying to get the result from a previous linac output testlist where both a certain dosemeter was used and a certain energy was not skipped - it seems as though even when I try and use two filters either I get an error saying I cannot define two unit test slugs, or I just get the results where one is true (but not both) or it returns no result even when there are test instances which fulfil the criteria.
I've tried using both Django Q and multple .filter() but neither seems to work
As some examples:
from qatrack.qa.models import TestInstance, Test
from django.db.models import Q
...
output_testlist = "Outputs - TrueBeam" #define output testlist series
unit_test_slug = "op_dif_6mv_general" #define which test you want the value of
try:
previous_chamber = TestInstance.objects.filter(
unit_test_info__unit__number=META["unit_number"], #go to correct linacs test lists based on current unit
test_list_instance__test_list__name=output_testlist, #go to output testlist
Q(unit_test_info__test__slug="dosemeter", #filter by dosemeter (value from selection prior in list)
string_value = dosemeter,
skipped=False) & Q(unit_test_info__test__slug="op_rdg1_6mv",
skipped=False)
).latest("work_completed") #look for the last output testlist completed (with filter)
last_chamber_tli = previous_chamber.test_list_instance #define selected testlist (with filter)
However this just give me a syntax error (I think because I am trying to define two different unit_test_info__test__slug)
I have alternatively tried
try:
previous_chamber = TestInstance.objects.filter(
unit_test_info__unit__number=META["unit_number"], #go to correct linacs test lists based on current unit
test_list_instance__test_list__name=output_testlist, #go to output testlist
work_started__lte=META['work_started'], #define time from when refence recal testlist was started
).filter(
unit_test_info__test__slug="dosemeter", #filter by dosemeter (value from selection prior in list)
string_value = dosemeter,
).filter(
unit_test_info__test__slug=unit_test_slug,
value__isnull=False,
).latest("work_completed") #look for the last output testlist completed (with filter)
last_chamber_tli = previous_chamber.test_list_instance #define selected testlist (with filter)
Which gives me a results where no test lists are found (even though there are instances which fulfil both criteria)
Any help would be appreciated, thanks
Suzie