My models are as follows (the fields in floor and board are inconsequential and omitted)
class floor(models.Model):
class board(models.Model):
class run(models.Model):
floor = models.ForeignKey(Floor)
boards = models.ManyToManyField(Board)
I have a query as follows:
runs = Run.objects.filter(floor=1)
that returns 2 run objects. Each run has a selection of boards.
runs[0].boards
returns a list of related boards. If i make a comprehension as follows:
[run.boards.all() for run in runs]
I get a list of lists like this:
[[1,2,3,4,5], [6,7,8,9,10]]
What is an effective and efficient way to massage the above list into the list below?
[1,2,3,4,5,6,7,8,9,10]
I am hoping for a 1 line solution. Is this possible using methods of the django query set, or is this best accomplished using python?
Simple: