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 7725705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:00:26+00:00 2026-06-01T05:00:26+00:00

Im using the python framework flask with sqlalchemy. My many-to-many looks like this: collections_questions

  • 0

Im using the python framework flask with sqlalchemy.

My many-to-many looks like this:

collections_questions = db.Table('collections_questions',
         db.Column('question_id',db.Integer,db.ForeignKey('question.id')),
         db.Column('collection_id',db.Integer,db.ForeignKey('collection.id'))
)
class Collection(db.Model):
    id = db.Column(db.Integer,primary_key=True)
    title = db.Column(db.String)
    lang = db.Column(db.Integer)
    questions = db.relationship('Question',secondary=collections_questions,backref=db.backref('collections'),lazy='dynamic')
    def __init__(self,title,lang=0):
      self.title = title
      self.lang = lang

class Question(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String)
    question = db.Column(db.String)
    lang = db.Column(db.Integer)
    type = db.Column(db.Integer)

    def __init__(self,title,question,lang=0,type=0):
        self.title = title
        self.question = question
        self.lang = lang
        self.type = type

Now if i do

collection = db.session.query(Collection).get(1)

collection.questions does not return a list of questions, instead it returns the following query.

SELECT question.id AS question_id, question.title AS question_title, question.question AS question_question, question.lang AS question_lang, question.type AS question_type 
FROM question, collections_questions 
WHERE :param_1 = collections_questions.collection_id AND question.id = collections_questions.question_id

Any help would be greatly apprecieted!

Thanks

  • 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-06-01T05:00:28+00:00Added an answer on June 1, 2026 at 5:00 am

    you’re using lazy=”dynamic”, so collection.questions is a Query object. You need to iterate over it to emit SQL and get the contents:

    list(collection.questions)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using flask as a python framework with sqlalchemy. The models use the query_property
I am using Flask micro-framework 0.6 and Python 2.6 I need to get the
I'm generating an HTML page via Python, using the Flask framework to receive messages
I am using the Flask micro-framework which is based on Werkzeug, which uses Python.
I'm using Pylons (a python framework) to serve a simple web application, but it
I'm using regular expressions with a python framework to pad a specific number in
I've been looking around for a good MVC framework for Python using PyGTK. I've
I'm a python newbie and starting out with using the Bottle web framework on
I want to write a simple web framework myself using WSGI, Python. I am
I'm using the mock-0.6 library from http://www.voidspace.org.uk/python/mock/mock.html to mock out a framework for testing,

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.