Answer the question
In order to leave comments, you need to log in
Split Django QS result into separate lists?
There is a Django QS like this:
<QuerySet [<Seats: 1 - 1>, <Seats: 1 - 2>, <Seats: 1 - 3>, <Seats: 1 - 4>, <Seats: 1 - 5>, <Seats: 1 - 6>, <Seats: 1 - 7>, <Seats: 1 - 8>, <Seats: 2 -
1>, <Seats: 2 - 2>]>
filtered_list =
row = models.IntegerField()
seat = models.IntegerField()
Answer the question
In order to leave comments, you need to log in
Well the first that comes to mind - to use a cycle. Something like
from collections import defaultdict
res = defaultdict(list)
for q in qs:
res[q.row].append(q)
res = res.values()
CODEIGNITER
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question