[Django]-How to append values to python list instead of replacing the values with latest value

4👍

jobs = []
values = Record.objects.filter(record_id__in=[1,2,3], is_main_record=True, status='open', set__in=['sasi', 'kuttu','vava'])
if values.exists():
   all_item = ['sasi', 'kuttu','vava']
   for mask in all_item:
       for x in values:
           data = {'item' : x.item, 'device': x.device, 'log': x.log}
           jobs.append(data)

print jobs # <--- print here, then you see the whole list

your code is fine, you were just printing inside a loop step which gives you just the momentum value and not the whole list

I have updated the queries, which makes less db queries.

Leave a comment