Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4230748
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T01:53:51+00:00 2026-05-21T01:53:51+00:00

My models are as follows (the fields in floor and board are inconsequential and

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T01:53:52+00:00Added an answer on May 21, 2026 at 1:53 am

    Simple:

    board.objects.filter(run__floor=1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Model as follows: class TankJournal(models.Model): user = models.ForeignKey(User) tank = models.ForeignKey(TankProfile)
I have two models in Django like follows(in pseudo code) class Medicine(db.Model): field_1 =
I have 3 url fields defined in my model as follows: image_1 = models.URLField(max_length=100,
I have a CharField type with a choices field as follows: class Thing(models.Model): def
Imagine a model structure as follows: models/cross_sell_promotion.rb class CrossSellPromotion < Promotion has_and_belongs_to_many :afflicted_products, :join_table
I have a django app with models as follows: A Question model An Answer
I have an accounts model as follows (simplified): class Account < ActiveRecord::Base attr_accessible :account_number,
If I have a drop down list as follows <div class=editor-label> <%= Html.DropDownListFor(model =>
suppose we have a model in django defined as follows: class Literal: name =
I have three models defined as follows: class Comic < ActiveRecord::Base has_many :feeds end

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.