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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:36:32+00:00 2026-06-15T20:36:32+00:00

I believe this is trival but fairly new to Python. I am trying to

  • 0

I believe this is trival but fairly new to Python.

I am trying to create a model using google app engine.

Basically from a E/R point of view
I have 2 objects with a join table (the join table captures the point in time of the join)
Something like this

Person      | Idea     | Person_Idea
-------------------------------
person.key   idea.key    person.key
                         idea.key
                         date_of_idea

my Python code would look like

class Person (db.Model):
  #some properties here....

class Idea(db.Model):
  #some properties here....

class IdeaCreated(db.Model):
  person= db.ReferenceProperty(Person)
  idea= db.ReferenceProperty(Idea)
  created = db.DateTimeProperty(auto_now_add = True)

What I want to be able to do is have a convient way to get all ideas a person has (bypass idea created objects) -sometimes I will need the list of ideas directly.

The only way I can think to do this is to add the follow method on the User class

def allIdeas(self):
  ideas = []
  for ideacreated in self.ideacreated_set:
     ideas.append(ideacreated.idea)
  return ideas

Is this the only way to do this? I is there a nicer way that I am missing?

Also assuming I could have a GQL and bypass hydrating the ideaCreated instances (not sure the exact syntax) but putting a GQL query smells wrong to me.

  • 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-15T20:36:33+00:00Added an answer on June 15, 2026 at 8:36 pm

    you should use the person as an ancestor/parent for the idea.

    idea = Idea(parent=some_person, other_field=field_value).put()
    

    then you can query all ideas where some_person is the ancestor

    persons_ideas = Idea.all().ancestor(some_person_key).fetch(1000)
    

    the ancestor key will be included in the Idea entities key and you won’t be able to change that the ancestor once the entity is created.

    i highly suggest you to use ndb instead of db https://developers.google.com/appengine/docs/python/ndb/

    with ndb you could even use StructuredProperty or LocalStructuredProperty
    https://developers.google.com/appengine/docs/python/ndb/properties#structured

    EDIT:
    if you need a many to many relationship look in to ListProperties and store the Persons keys in that property. then you can query for all Ideas with that Key in that property.

    class Idea(db.Model):
        person = db.StringListProperty()
    
    idea = Idea(person = [str(person.key())], ....).put()
    

    add another person to the idea

    idea.person.append(str(another_person.key())).put()
    
    ideas = Idea.filter(person=str(person.key())).fetch(1000)
    

    look into https://developers.google.com/appengine/docs/python/datastore/typesandpropertyclasses#ListProperty

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe this is a fairly simple question but it is something I am
I believe task I am trying to accomplish is fairly easy, but I have
I believe this is a quite trivial query(I did search SO and Google but
I believe this question applies to any of the For Html helpers, but my
I believe this questions has been asked in some or the other way but
I believe this to be related partially to short-circuiting logic, but I couldn't find
I believe this is possible but I haven't done it before. I need to
I believe this is pretty trivial but I can't get it to work. I
I believe this is trivial, but I can't for the life of me, figure
Hi guys i believe this could turn out to be trivial but i have

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.