Issue
I write a query to get the list like this:
tStartEnd = APIHistory.objects.values('status_start','status_end')
codereview = list(tStartEnd)
expected output is: ['start', 'end'] but I'm getting : [('START', 'END')]
using django query how get the output like this
['start', 'end']
Solution
You need to concatenate the items in the tuple:
tStartEnd = APIHistory.objects.values_list('status_start','status_end')
codereview = [item for q in tStartEnd for item in q]
This will thus enumerate over the records q
in the queryset, and over the items in the tuple that 1
presents.
Answered By - Willem Van Onsem
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.