Rituparna Das
Rituparna Das

Reputation: 37

How to remove first brackets from list in django?

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']

Upvotes: 1

Views: 141

Answers (1)

willeM_ Van Onsem
willeM_ Van Onsem

Reputation: 476594

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.

Upvotes: 1

Related Questions