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

  • Home
  • SEARCH
  • 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 3855234
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:44:41+00:00 2026-05-19T17:44:41+00:00

my current App uses a db.ListProperty(db.Key) for a many to many relation for a

  • 0

my current App uses a db.ListProperty(db.Key) for a many to many relation for a friendlist.

We have the following scheme:

# previous models
class User(db.Model):
    name = db.StringProperty()
    nickname = db.StringProperty()
    join_date = db.DateProperty(auto_now_add=True)
    party = db.ReferenceProperty(PartyEntry, collection_name='participants')
    def by_name(self, string):
        return self.gql("WHERE name = :name", name=string).get()
    def key_by_name(self, string):
        return self.by_name(string).key()

class FriendList(db.Model):
    owner = db.ReferenceProperty(User)
    friends = db.ListProperty(db.Key)

And a handler that fetches a users friendlist, processes it and displays it:

class Profile_FriendList(WebBase):
    def get(self):
        user = self._auth()
        if user:
            usr_key = User().key_by_name(user.nickname())
            friend_list = friend_lists = FriendList.all().filter('owner', usr_key).fetch(10)
            self.renderskeleton( { 'friendlist': friend_list } ,'friends.html')

I populated a test friendlist with two db.Key() list entries in FriendList.friends.
The s.c. SDK Console (>Interactive Datastorageviewer) diplays me those items:

key1,key2

But if I call this entity FriendList by its key and
print frlst.friends
output: []
Same problem in the handler.
I get no data I can work with.
BUT the data exist.

Fixed: FriendList problem, the called friendlist object wasn’t a query it simply was a new FriendList() object.
Updated code.

Fixed: Complete question solved

usr_key = User().key_by_name(user.nickname())
logging.info(user.nickname())
logging.info(usr_key)
friend_list = FriendList().all().filter("owner", usr_key).fetch(20)
logging.info(friend_list)
logging.info(friend_list[0].friends)
friends = User.get(friend_list[0].friends)
logging.info(friends)
self.renderskeleton( { 'friends': friends } , 'friends.html')

I selected a list of GqlQuery results instead of the “one” I want, what I had to do from there was simply putting the friends’ key list into an User.get() and voilà I had all necessary data.

  • 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-19T17:44:41+00:00Added an answer on May 19, 2026 at 5:44 pm

    friend_list = FriendList(owner=usr_key) is not a query, it is creating a new instance of FriendList.

    You want: friend_lists = FriendList.all().filter('owner', usr_key).fetch(10).

    Other comments:

    1. The two methods on User your using for queries should really be class methods:

      @classmethod
      def by_name(cls, string):
          return cls.gql("WHERE name = :name", name=string).get()
      
      @classmethod
      def key_by_name(cls, string):
          return cls.by_name(string).key()
      
      # to call:
      user = User.key_by_name('their name')
      
    2. Have you considered using the user’s id with get_by_key_name()? It would be faster than a query.

    3. Also use the user’s id as the key_name for the friend-list, then instead of a query you can do friend_list = FriendList.get_by_key_name(str(user.user_id())). You’ll need a way to handle case where one FriendList is not enough, but those will probably be rare — and it is not that difficult to solve (add a sequence number to the key_name and store a (non-indexed) count of the sequences on the User kind, then you can easily generate the key_names).

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

Sidebar

Related Questions

My current app needs to store address information for a user. I'm currently debating
I have an app that display's the current time when a page opens. I
I have a requirement on my current project (a Flex app which will be
I have Windows Vista MCML app, and I need to figure out the current
I need to integrate a email client in my current python web app. Anything
How do you get the current directory where your app is running?
in my app i am trying to show the current location in a map.
I have a WPF app with a listview control. The application basically loads a
I just need to get the name of the current user so I can
I'm writing a Facebook app. When a user adds the application i insert a

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.