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 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

I current have an app that uses ALAsssetsLibrary to fetch the photos. I have
I have a current Android app that uses i18n via resources. res/values-es/strings.xml and so
I am developing an Android app which uses the current user location for result.
I have a web app that current uses an external directory to host static
My app uses badge to count the number of smoked cigarettes in the current
I have been using Asynctask most of time, but in the current app the
My current iPhone app uses UIKit. Now I want some small effects in the
I am writing a small app that uses the GAE. I have parts of
my current app uses week numbers (as in week x of 52). The business
I have an app that uses a SQLite database. When the app updates at

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.